#include "lwip/opt.h"
#include <stddef.h>
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include "lwip/igmp.h"
#include "lwip/api.h"
Data Structures | |
struct | api_msg |
This struct contains a function to execute in another thread context and a struct api_msg_msg that serves as an argument for this function. More... | |
struct | api_msg_msg |
This struct includes everything that is necessary to execute a function for a netconn in another thread context (mainly used to process netconns in the tcpip_thread context to be thread safe). More... | |
Macros | |
#define | NETCONN_SHUT_RD 1 |
#define | NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) |
#define | NETCONN_SHUT_WR 2 |
Functions | |
void | do_bind (struct api_msg_msg *msg) |
Bind a pcb contained in a netconn Called from netconn_bind. More... | |
void | do_close (struct api_msg_msg *msg) |
Close a TCP pcb contained in a netconn Called from netconn_close. More... | |
void | do_connect (struct api_msg_msg *msg) |
Connect a pcb contained inside a netconn Called from netconn_connect. More... | |
void | do_delconn (struct api_msg_msg *msg) |
Delete the pcb inside a netconn. More... | |
void | do_disconnect (struct api_msg_msg *msg) |
Connect a pcb contained inside a netconn Only used for UDP netconns. More... | |
void | do_getaddr (struct api_msg_msg *msg) |
Return a connection's local or remote address Called from netconn_getaddr. More... | |
void | do_listen (struct api_msg_msg *msg) |
Set a TCP pcb contained in a netconn into listen mode Called from netconn_listen. More... | |
void | do_newconn (struct api_msg_msg *msg) |
Create a new pcb of a specific type inside a netconn. More... | |
void | do_recv (struct api_msg_msg *msg) |
Indicate data has been received from a TCP pcb contained in a netconn Called from netconn_recv. More... | |
void | do_send (struct api_msg_msg *msg) |
Send some data on a RAW or UDP pcb contained in a netconn Called from netconn_send. More... | |
void | do_shutdown (struct api_msg_msg *msg) |
void | do_write (struct api_msg_msg *msg) |
Send some data on a TCP pcb contained in a netconn Called from netconn_write. More... | |
struct netconn * | netconn_alloc (enum netconn_type t, netconn_callback callback) |
Create a new netconn (of a specific type) that has a callback function. More... | |
void | netconn_free (struct netconn *conn) |
Delete a netconn and all its resources. More... | |
#define NETCONN_SHUT_RD 1 |
Referenced by do_close(), do_close_internal(), and netconn_shutdown().
#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) |
Referenced by do_close(), do_close_internal(), do_delconn(), and netconn_close().
#define NETCONN_SHUT_WR 2 |
Referenced by do_close_internal(), and netconn_shutdown().
void do_bind | ( | struct api_msg_msg * | msg | ) |
Bind a pcb contained in a netconn Called from netconn_bind.
msg | the api_msg_msg pointing to the connection and containing the IP address and port to bind to |
References api_msg_msg::bc, api_msg_msg::conn, api_msg_msg::err, ERR_IS_FATAL, ERR_VAL, netconn::last_err, api_msg_msg::msg, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, netconn::raw, netconn::tcp, tcp_bind(), TCPIP_APIMSG_ACK, netconn::type, and netconn::udp.
Referenced by netconn_bind().
void do_close | ( | struct api_msg_msg * | msg | ) |
Close a TCP pcb contained in a netconn Called from netconn_close.
msg | the api_msg_msg pointing to the connection |
References api_msg_msg::conn, netconn::current_msg, do_close_internal(), api_msg_msg::err, ERR_CONN, ERR_INPROGRESS, ERR_VAL, LWIP_ASSERT, api_msg_msg::msg, NETCONN_CLOSE, netconn_drain(), NETCONN_LISTEN, NETCONN_NONE, NETCONN_SHUT_RD, NETCONN_SHUT_RDWR, NETCONN_TCP, NULL, netconn::op_completed, netconn::pcb, api_msg_msg::sd, netconn::state, sys_sem_signal(), netconn::tcp, netconn::type, and netconn::write_offset.
Referenced by netconn_close_shutdown().
void do_connect | ( | struct api_msg_msg * | msg | ) |
Connect a pcb contained inside a netconn Called from netconn_connect.
msg | the api_msg_msg pointing to the connection and containing the IP address and port to connect to |
References api_msg_msg::bc, api_msg_msg::conn, netconn::current_msg, do_connected(), api_msg_msg::err, ERR_CLSD, ERR_INPROGRESS, ERR_ISCONN, ERR_OK, ERR_VAL, LWIP_ERROR(), api_msg_msg::msg, NETCONN_CONNECT, netconn_is_nonblocking, NETCONN_NONE, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::op_completed, netconn::pcb, netconn::raw, SET_NONBLOCKING_CONNECT, setup_tcp(), netconn::state, sys_sem_signal(), netconn::tcp, tcp_connect(), netconn::type, and netconn::udp.
Referenced by netconn_connect().
void do_delconn | ( | struct api_msg_msg * | msg | ) |
Delete the pcb inside a netconn.
Called from netconn_delete.
msg | the api_msg_msg pointing to the connection |
References API_EVENT, api_msg_msg::conn, netconn::current_msg, do_close_internal(), api_msg_msg::err, ERR_INPROGRESS, IN_NONBLOCKING_CONNECT, LWIP_ASSERT, api_msg_msg::msg, NETCONN_CLOSE, NETCONN_CONNECT, netconn_drain(), NETCONN_EVT_RCVPLUS, NETCONN_EVT_SENDPLUS, NETCONN_LISTEN, NETCONN_NONE, NETCONN_RAW, NETCONN_SHUT_RDWR, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::op_completed, netconn::pcb, netconn::raw, api_msg_msg::sd, netconn::state, sys_sem_signal(), sys_sem_valid(), netconn::tcp, netconn::type, netconn::udp, and netconn::write_offset.
Referenced by netconn_delete().
void do_disconnect | ( | struct api_msg_msg * | msg | ) |
Connect a pcb contained inside a netconn Only used for UDP netconns.
Called from netconn_disconnect.
msg | the api_msg_msg pointing to the connection to disconnect |
References api_msg_msg::conn, api_msg_msg::err, ERR_OK, ERR_VAL, NETCONN_UDP, NETCONNTYPE_GROUP, netconn::pcb, TCPIP_APIMSG_ACK, netconn::type, and netconn::udp.
Referenced by netconn_disconnect().
void do_getaddr | ( | struct api_msg_msg * | msg | ) |
Return a connection's local or remote address Called from netconn_getaddr.
msg | the api_msg_msg pointing to the connection |
References api_msg_msg::ad, api_msg_msg::conn, api_msg_msg::err, ERR_CONN, ERR_OK, netconn::ip, LWIP_ASSERT, api_msg_msg::msg, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, netconn::raw, tcp_pcb::remote_port, netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, and netconn::udp.
Referenced by netconn_getaddr().
void do_listen | ( | struct api_msg_msg * | msg | ) |
Set a TCP pcb contained in a netconn into listen mode Called from netconn_listen.
msg | the api_msg_msg pointing to the connection |
References accept_function(), netconn::acceptmbox, api_msg_msg::conn, DEFAULT_ACCEPTMBOX_SIZE, api_msg_msg::err, ERR_CONN, ERR_IS_FATAL, ERR_MEM, ERR_OK, netconn::last_err, api_msg_msg::msg, NETCONN_LISTEN, NETCONN_NONE, NETCONN_TCP, NULL, netconn::pcb, netconn::recvmbox, netconn::state, sys_mbox_free(), sys_mbox_new(), sys_mbox_set_invalid(), sys_mbox_valid(), netconn::tcp, tcp_accept(), tcp_arg(), tcp_close(), tcp_listen, tcp_listen_with_backlog(), TCPIP_APIMSG_ACK, and netconn::type.
Referenced by netconn_listen_with_backlog().
void do_newconn | ( | struct api_msg_msg * | msg | ) |
Create a new pcb of a specific type inside a netconn.
Called from netconn_new_with_proto_and_callback.
msg | the api_msg_msg describing the connection type |
References api_msg_msg::conn, api_msg_msg::err, ERR_OK, NULL, netconn::pcb, pcb_new(), netconn::tcp, and TCPIP_APIMSG_ACK.
Referenced by netconn_new_with_proto_and_callback().
void do_recv | ( | struct api_msg_msg * | msg | ) |
Indicate data has been received from a TCP pcb contained in a netconn Called from netconn_recv.
msg | the api_msg_msg pointing to the connection |
References api_msg_msg::conn, api_msg_msg::err, ERR_OK, LISTEN, api_msg_msg::msg, NETCONN_TCP, NULL, netconn::pcb, api_msg_msg::r, netconn::tcp, tcp_accepted, tcp_recved(), TCPIP_APIMSG_ACK, and netconn::type.
Referenced by netconn_accept(), netconn_recv_data(), and netconn_recved().
void do_send | ( | struct api_msg_msg * | msg | ) |
Send some data on a RAW or UDP pcb contained in a netconn Called from netconn_send.
msg | the api_msg_msg pointing to the connection |
References netbuf::addr, api_msg_msg::b, api_msg_msg::conn, api_msg_msg::err, ERR_CONN, ERR_IS_FATAL, ip_addr_isany, netconn::last_err, api_msg_msg::msg, NETBUF_FLAG_CHKSUM, NETCONN_RAW, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netbuf::p, netconn::pcb, netbuf::port, netconn::raw, netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, and netconn::udp.
Referenced by netconn_send().
void do_shutdown | ( | struct api_msg_msg * | msg | ) |
void do_write | ( | struct api_msg_msg * | msg | ) |
Send some data on a TCP pcb contained in a netconn Called from netconn_write.
msg | the api_msg_msg pointing to the connection |
References api_msg_msg::conn, netconn::current_msg, do_writemore(), api_msg_msg::err, ERR_CONN, ERR_INPROGRESS, ERR_IS_FATAL, ERR_OK, ERR_VAL, netconn::flags, netconn::last_err, LOCK_TCPIP_CORE, LWIP_ASSERT, api_msg_msg::msg, NETCONN_FLAG_WRITE_DELAYED, NETCONN_NONE, NETCONN_TCP, NETCONN_WRITE, NULL, netconn::op_completed, netconn::pcb, netconn::state, sys_arch_sem_wait(), netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, UNLOCK_TCPIP_CORE, api_msg_msg::w, and netconn::write_offset.
Referenced by netconn_write().
struct netconn* netconn_alloc | ( | enum netconn_type | t, |
netconn_callback | callback | ||
) |
Create a new netconn (of a specific type) that has a callback function.
The corresponding pcb is NOT created!
t | the type of 'connection' to create ( |
proto | the IP protocol for RAW IP pcbs |
callback | a function to call on status changes (RX available, TX'ed) |
References netconn::acceptmbox, netconn::callback, netconn::current_msg, DEFAULT_RAW_RECVMBOX_SIZE, DEFAULT_TCP_RECVMBOX_SIZE, DEFAULT_UDP_RECVMBOX_SIZE, ERR_OK, netconn::flags, netconn::last_err, LWIP_ASSERT, memp_free(), memp_malloc(), NETCONN_NONE, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::op_completed, netconn::pcb, RECV_BUFSIZE_DEFAULT, netconn::recvmbox, netconn::socket, netconn::state, sys_mbox_new(), sys_mbox_set_invalid(), sys_sem_free(), sys_sem_new(), netconn::tcp, netconn::type, and netconn::write_offset.
Referenced by accept_function(), and netconn_new_with_proto_and_callback().
Delete a netconn and all its resources.
The pcb is NOT freed (since we might not be in the right thread context do this).
conn | the netconn to free |
References netconn::acceptmbox, LWIP_ASSERT, memp_free(), NULL, netconn::op_completed, netconn::pcb, netconn::recvmbox, sys_mbox_valid(), sys_sem_free(), sys_sem_set_invalid(), and netconn::tcp.
Referenced by accept_function(), netconn_delete(), and netconn_drain().