#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... | |
struct | dns_api_msg |
As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn, it has its own struct (to avoid struct api_msg getting bigger than necessary). More... | |
Macros | |
#define | API_MSG_M_DEF(m) *m |
#define | LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed) |
#define | LWIP_NETCONN_SCOPE |
#define | NETCONN_SHUT_RD 1 |
#define | NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) |
#define | NETCONN_SHUT_WR 2 |
Functions | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_bind (struct api_msg_msg *msg) |
Bind a pcb contained in a netconn Called from netconn_bind. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_close (struct api_msg_msg *msg) |
Close or half-shutdown a TCP pcb contained in a netconn Called from netconn_close In contrast to closing sockets, the netconn is not deallocated. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_connect (struct api_msg_msg *msg) |
Connect a pcb contained inside a netconn Called from netconn_connect. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_delconn (struct api_msg_msg *msg) |
Delete the pcb inside a netconn. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_disconnect (struct api_msg_msg *msg) |
Connect a pcb contained inside a netconn Only used for UDP netconns. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_getaddr (struct api_msg_msg *msg) |
Return a connection's local or remote address Called from netconn_getaddr. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_gethostbyname (void *arg) |
Execute a DNS query Called from netconn_gethostbyname. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_join_leave_group (struct api_msg_msg *msg) |
Join multicast groups for UDP netconns. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_listen (struct api_msg_msg *msg) |
Set a TCP pcb contained in a netconn into listen mode Called from netconn_listen. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_newconn (struct api_msg_msg *msg) |
Create a new pcb of a specific type inside a netconn. More... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_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... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_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... | |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_shutdown (struct api_msg_msg *msg) |
LWIP_NETCONN_SCOPE void | lwip_netconn_do_write (struct api_msg_msg *msg) |
Send some data on a TCP pcb contained in a netconn Called from netconn_write. More... | |
LWIP_NETCONN_SCOPE 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... | |
LWIP_NETCONN_SCOPE void | netconn_free (struct netconn *conn) |
Delete a netconn and all its resources. More... | |
#define API_MSG_M_DEF | ( | m | ) | *m |
#define LWIP_API_MSG_SEM | ( | msg | ) | (&(msg)->conn->op_completed) |
#define LWIP_NETCONN_SCOPE |
#define NETCONN_SHUT_RD 1 |
Referenced by lwip_netconn_do_close(), lwip_netconn_do_close_internal(), and netconn_shutdown().
#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) |
Referenced by lwip_netconn_do_close(), lwip_netconn_do_close_internal(), lwip_netconn_do_delconn(), and netconn_close().
#define NETCONN_SHUT_WR 2 |
Referenced by lwip_netconn_do_close_internal(), and netconn_shutdown().
LWIP_NETCONN_SCOPE void lwip_netconn_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_EXPR_REF, 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, raw_bind(), netconn::tcp, tcp_bind(), TCPIP_APIMSG_ACK, netconn::type, netconn::udp, and udp_bind().
Referenced by netconn_bind().
LWIP_NETCONN_SCOPE void lwip_netconn_do_close | ( | struct api_msg_msg * | msg | ) |
Close or half-shutdown a TCP pcb contained in a netconn Called from netconn_close In contrast to closing sockets, the netconn is not deallocated.
msg | the api_msg_msg pointing to the connection |
References api_msg_msg::conn, netconn::current_msg, api_msg_msg::err, ERR_CONN, ERR_INPROGRESS, LWIP_API_MSG_SEM, LWIP_ASSERT, lwip_netconn_do_close_internal(), api_msg_msg::msg, NETCONN_CLOSE, netconn_drain(), NETCONN_LISTEN, NETCONN_NONE, NETCONN_SHUT_RD, NETCONN_SHUT_RDWR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, netconn::pcb, api_msg_msg::sd, netconn::state, sys_sem_signal(), netconn::tcp, netconn::type, and netconn::write_offset.
Referenced by netconn_close_shutdown().
LWIP_NETCONN_SCOPE void lwip_netconn_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_EXPR_REF, api_msg_msg::bc, api_msg_msg::conn, netconn::current_msg, api_msg_msg::err, ERR_CLSD, ERR_INPROGRESS, ERR_ISCONN, ERR_OK, ERR_VAL, LWIP_API_MSG_SEM, LWIP_ERROR(), lwip_netconn_do_connected(), api_msg_msg::msg, NETCONN_CONNECT, netconn_is_nonblocking, NETCONN_NONE, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, netconn::raw, raw_connect(), SET_NONBLOCKING_CONNECT, setup_tcp(), netconn::state, sys_sem_signal(), netconn::tcp, tcp_connect(), TCPIP_APIMSG_ACK, netconn::type, netconn::udp, and udp_connect().
Referenced by netconn_connect().
LWIP_NETCONN_SCOPE void lwip_netconn_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, api_msg_msg::err, ERR_INPROGRESS, ERR_OK, IN_NONBLOCKING_CONNECT, LWIP_API_MSG_SEM, LWIP_ASSERT, lwip_netconn_do_close_internal(), 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::pcb, netconn::raw, raw_remove(), udp_pcb::recv_arg, api_msg_msg::sd, netconn::state, sys_sem_signal(), sys_sem_valid(), netconn::tcp, netconn::type, netconn::udp, udp_remove(), and netconn::write_offset.
Referenced by netconn_delete().
LWIP_NETCONN_SCOPE void lwip_netconn_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, netconn::udp, and udp_disconnect().
Referenced by netconn_disconnect().
LWIP_NETCONN_SCOPE void lwip_netconn_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_EXPR_DEREF, CLOSED, api_msg_msg::conn, api_msg_msg::err, ERR_CONN, ERR_OK, udp_pcb::flags, netconn::ip, ipX_addr_copy, LISTEN, udp_pcb::local_port, LWIP_ASSERT, api_msg_msg::msg, NETCONN_RAW, NETCONN_TCP, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, PCB_ISIPV6, raw_pcb::protocol, netconn::raw, udp_pcb::remote_port, tcp_pcb::remote_port, netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, netconn::udp, and UDP_FLAGS_CONNECTED.
Referenced by netconn_getaddr().
LWIP_NETCONN_SCOPE void lwip_netconn_do_gethostbyname | ( | void * | arg | ) |
Execute a DNS query Called from netconn_gethostbyname.
arg | the dns_api_msg pointing to the query |
References API_EXPR_DEREF, API_EXPR_REF, dns_gethostbyname(), ERR_INPROGRESS, lwip_netconn_do_dns_found(), dns_api_msg::name, and sys_sem_signal().
Referenced by netconn_gethostbyname().
LWIP_NETCONN_SCOPE void lwip_netconn_do_join_leave_group | ( | struct api_msg_msg * | msg | ) |
Join multicast groups for UDP netconns.
Called from netconn_join_leave_group
msg | the api_msg_msg pointing to the connection |
References API_EXPR_REF, api_msg_msg::conn, api_msg_msg::err, ERR_CONN, ERR_IS_FATAL, ERR_VAL, ipX_2_ip, ipX_2_ip6, api_msg_msg::jl, netconn::last_err, mld6_joingroup(), mld6_leavegroup(), api_msg_msg::msg, NETCONN_JOIN, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, PCB_ISIPV6, netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, and netconn::udp.
Referenced by netconn_join_leave_group().
LWIP_NETCONN_SCOPE void lwip_netconn_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, CLOSED, api_msg_msg::conn, DEFAULT_ACCEPTMBOX_SIZE, api_msg_msg::err, ERR_ARG, ERR_CONN, ERR_IS_FATAL_LISTENCONNECT, ERR_MEM, ERR_OK, ERR_VAL, netconn::flags, netconn::last_err, api_msg_msg::msg, NETCONN_FLAG_IPV6_V6ONLY, NETCONN_LISTEN, NETCONN_NONE, NETCONN_TCP, NETCONNTYPE_GROUP, 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_dual, tcp_listen_dual_with_backlog(), tcp_listen_with_backlog(), TCPIP_APIMSG_ACK, and netconn::type.
Referenced by netconn_listen_with_backlog().
LWIP_NETCONN_SCOPE void lwip_netconn_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().
LWIP_NETCONN_SCOPE void lwip_netconn_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, NETCONNTYPE_GROUP, 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().
LWIP_NETCONN_SCOPE void lwip_netconn_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 api_msg_msg::b, api_msg_msg::conn, api_msg_msg::err, ERR_CONN, ERR_IS_FATAL, netconn::ip, ipX_2_ip, ipX_addr_isany, netconn::last_err, api_msg_msg::msg, NETCONN_RAW, NETCONN_UDP, NETCONNTYPE_GROUP, NULL, netconn::pcb, PCB_ISIPV6, netconn::raw, raw_send(), raw_sendto(), netconn::tcp, TCPIP_APIMSG_ACK, netconn::type, netconn::udp, udp_send(), and udp_sendto().
Referenced by netconn_send().
LWIP_NETCONN_SCOPE void lwip_netconn_do_shutdown | ( | struct api_msg_msg * | msg | ) |
LWIP_NETCONN_SCOPE void lwip_netconn_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, api_msg_msg::err, ERR_CONN, ERR_INPROGRESS, ERR_IS_FATAL, ERR_OK, ERR_VAL, netconn::flags, netconn::last_err, LOCK_TCPIP_CORE, LWIP_API_MSG_SEM, LWIP_ASSERT, lwip_netconn_do_writemore(), api_msg_msg::msg, NETCONN_FLAG_WRITE_DELAYED, NETCONN_NONE, NETCONN_TCP, NETCONN_WRITE, NETCONNTYPE_GROUP, NULL, 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_partly().
LWIP_NETCONN_SCOPE 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, netconn::recvmbox, netconn::state, sys_mbox_free(), sys_mbox_new(), sys_mbox_set_invalid(), sys_sem_new(), netconn::tcp, netconn::type, and netconn::write_offset.
Referenced by accept_function(), and netconn_new_with_proto_and_callback().
LWIP_NETCONN_SCOPE void netconn_free | ( | struct netconn * | conn | ) |
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().