Sequential API External module.
#include "lwip/opt.h"
#include "lwip/api.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#include "lwip/ip.h"
#include "lwip/raw.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include <string.h>
Macros | |
#define | API_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name) |
#define | API_MSG_VAR_ALLOC_DONTFAIL(name) API_VAR_ALLOC_DONTFAIL(struct api_msg, MEMP_API_MSG, name) |
#define | API_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct api_msg, name) |
#define | API_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_API_MSG, name) |
#define | API_MSG_VAR_REF(name) API_VAR_REF(name) |
Functions | |
err_t | netconn_accept (struct netconn *conn, struct netconn **new_conn) |
Accept a new connection on a TCP listening netconn. More... | |
err_t | netconn_bind (struct netconn *conn, ip_addr_t *addr, u16_t port) |
Bind a netconn to a specific local IP address and port. More... | |
err_t | netconn_close (struct netconn *conn) |
Close a TCP netconn (doesn't delete it). More... | |
static err_t | netconn_close_shutdown (struct netconn *conn, u8_t how) |
Close or shutdown a TCP netconn (doesn't delete it). More... | |
err_t | netconn_connect (struct netconn *conn, ip_addr_t *addr, u16_t port) |
Connect a netconn to a specific remote IP address and port. More... | |
err_t | netconn_delete (struct netconn *conn) |
Close a netconn 'connection' and free its resources. More... | |
err_t | netconn_disconnect (struct netconn *conn) |
Disconnect a netconn from its current peer (only valid for UDP netconns). More... | |
err_t | netconn_getaddr (struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) |
Get the local or remote IP address and port of a netconn. More... | |
err_t | netconn_gethostbyname (const char *name, ip_addr_t *addr) |
Execute a DNS query, only one IP address is returned. More... | |
err_t | netconn_join_leave_group (struct netconn *conn, ip_addr_t *multiaddr, ip_addr_t *netif_addr, enum netconn_igmp join_or_leave) |
Join multicast groups for UDP netconns. More... | |
err_t | netconn_listen_with_backlog (struct netconn *conn, u8_t backlog) |
Set a TCP netconn into listen mode. More... | |
struct netconn * | netconn_new_with_proto_and_callback (enum netconn_type t, u8_t proto, netconn_callback callback) |
Create a new netconn (of a specific type) that has a callback function. More... | |
err_t | netconn_recv (struct netconn *conn, struct netbuf **new_buf) |
Receive data (in form of a netbuf containing a packet buffer) from a netconn. More... | |
static err_t | netconn_recv_data (struct netconn *conn, void **new_buf) |
Receive data: actual implementation that doesn't care whether pbuf or netbuf is received. More... | |
err_t | netconn_recv_tcp_pbuf (struct netconn *conn, struct pbuf **new_buf) |
Receive data (in form of a pbuf) from a TCP netconn. More... | |
void | netconn_recved (struct netconn *conn, u32_t length) |
TCP: update the receive window: by calling this, the application tells the stack that it has processed data and is able to accept new data. More... | |
err_t | netconn_send (struct netconn *conn, struct netbuf *buf) |
Send data over a UDP or RAW netconn (that is already connected). More... | |
err_t | netconn_sendto (struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port) |
Send data (in form of a netbuf) to a specific remote IP address and port. More... | |
err_t | netconn_shutdown (struct netconn *conn, u8_t shut_rx, u8_t shut_tx) |
Shut down one or both sides of a TCP netconn (doesn't delete it). More... | |
err_t | netconn_write_partly (struct netconn *conn, const void *dataptr, size_t size, u8_t apiflags, size_t *bytes_written) |
Send data over a TCP netconn. More... | |
#define API_MSG_VAR_ALLOC | ( | name | ) | API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name) |
#define API_MSG_VAR_ALLOC_DONTFAIL | ( | name | ) | API_VAR_ALLOC_DONTFAIL(struct api_msg, MEMP_API_MSG, name) |
Referenced by netconn_accept(), netconn_new_with_proto_and_callback(), netconn_recv_data(), and netconn_recved().
#define API_MSG_VAR_DECLARE | ( | name | ) | API_VAR_DECLARE(struct api_msg, name) |
Referenced by netconn_accept(), netconn_bind(), netconn_close_shutdown(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_getaddr(), netconn_join_leave_group(), netconn_listen_with_backlog(), netconn_new_with_proto_and_callback(), netconn_recv_data(), netconn_recved(), netconn_send(), and netconn_write_partly().
#define API_MSG_VAR_FREE | ( | name | ) | API_VAR_FREE(MEMP_API_MSG, name) |
Referenced by netconn_accept(), netconn_bind(), netconn_close_shutdown(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_getaddr(), netconn_join_leave_group(), netconn_listen_with_backlog(), netconn_new_with_proto_and_callback(), netconn_recv_data(), netconn_recved(), netconn_send(), and netconn_write_partly().
#define API_MSG_VAR_REF | ( | name | ) | API_VAR_REF(name) |
Referenced by netconn_accept(), netconn_bind(), netconn_close_shutdown(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_getaddr(), netconn_join_leave_group(), netconn_listen_with_backlog(), netconn_new_with_proto_and_callback(), netconn_recv_data(), netconn_recved(), netconn_send(), and netconn_write_partly().
Accept a new connection on a TCP listening netconn.
conn | the TCP listen netconn |
new_conn | pointer where the new connection is stored |
References netconn::acceptmbox, API_EVENT, API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ABRT, ERR_ARG, ERR_IS_FATAL, ERR_OK, ERR_TIMEOUT, netconn::last_err, LWIP_ERROR(), lwip_netconn_do_recv(), NETCONN_EVT_RCVMINUS, NETCONN_SET_SAFE_ERR, NULL, sys_arch_mbox_fetch(), SYS_ARCH_TIMEOUT, sys_mbox_valid(), and TCPIP_APIMSG_NOERR.
Referenced by ap_task().
Bind a netconn to a specific local IP address and port.
Binding one netconn twice might not always be checked correctly!
conn | the netconn to bind |
addr | the local IP address to bind the netconn to (use IP_ADDR_ANY to bind to all addresses) |
port | the local port to bind the netconn to (not used for RAW) |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_bind(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.
Referenced by ap_task(), and sta_task().
Close a TCP netconn (doesn't delete it).
conn | the TCP netconn to close |
References netconn_close_shutdown(), and NETCONN_SHUT_RDWR.
Referenced by http_request(), and sta_task().
Close or shutdown a TCP netconn (doesn't delete it).
conn | the TCP netconn to close or shutdown |
how | fully close or only shutdown one side? |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_ERROR(), lwip_netconn_do_close(), NETCONN_SET_SAFE_ERR, NULL, and tcpip_apimsg().
Referenced by netconn_close(), and netconn_shutdown().
Connect a netconn to a specific remote IP address and port.
conn | the netconn to connect |
addr | the remote IP address to connect to |
port | the remote port to connect to (no used for RAW) |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_connect(), NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, TCPIP_APIMSG, tcpip_apimsg(), and netconn::type.
Referenced by sta_task().
Close a netconn 'connection' and free its resources.
UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.
conn | the netconn to delete |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_OK, lwip_netconn_do_delconn(), netconn_free(), NULL, and tcpip_apimsg().
Referenced by http_request(), and sta_task().
Disconnect a netconn from its current peer (only valid for UDP netconns).
conn | the netconn to disconnect |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_ERROR(), lwip_netconn_do_disconnect(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.
Get the local or remote IP address and port of a netconn.
For RAW netconns, this returns the protocol instead of a port!
conn | the netconn to query |
addr | a pointer to which to save the IP address |
port | a pointer to which to save the port (or protocol for RAW) |
local | 1 to get the local IP address, 0 to get the remote one |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ip_2_ipX, ipX_2_ip, LWIP_ERROR(), lwip_netconn_do_getaddr(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.
Execute a DNS query, only one IP address is returned.
name | a string representation of the DNS host name to query |
addr | a preallocated ip_addr_t where to store the resolved IP address |
References API_EXPR_REF, API_VAR_ALLOC, API_VAR_DECLARE, API_VAR_FREE, API_VAR_REF, ERR_ARG, ERR_OK, LWIP_ERROR(), lwip_netconn_do_gethostbyname(), NULL, sys_sem_free(), sys_sem_new(), sys_sem_wait, and tcpip_callback.
err_t netconn_join_leave_group | ( | struct netconn * | conn, |
ip_addr_t * | multiaddr, | ||
ip_addr_t * | netif_addr, | ||
enum netconn_igmp | join_or_leave | ||
) |
Join multicast groups for UDP netconns.
conn | the UDP netconn for which to change multicast addresses |
multiaddr | IP address of the multicast group to join or leave |
netif_addr | the IP address of the network interface on which to send the igmp message |
join_or_leave | flag whether to send a join- or leave-message |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ip_2_ipX, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_join_leave_group(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.
Set a TCP netconn into listen mode.
conn | the tcp netconn to set to listen mode |
backlog | the listen backlog, only used if TCP_LISTEN_BACKLOG==1 |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_ERROR(), lwip_netconn_do_listen(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.
struct netconn* netconn_new_with_proto_and_callback | ( | enum netconn_type | t, |
u8_t | proto, | ||
netconn_callback | callback | ||
) |
Create a new netconn (of a specific type) that has a callback function.
The corresponding pcb is also 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, API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_OK, LWIP_ASSERT, lwip_netconn_do_newconn(), memp_free(), netconn_alloc(), NULL, netconn::op_completed, netconn::pcb, netconn::recvmbox, sys_mbox_free(), sys_mbox_valid(), sys_sem_free(), sys_sem_valid(), netconn::tcp, and TCPIP_APIMSG.
Receive data (in form of a netbuf containing a packet buffer) from a netconn.
conn | the netconn from which to receive data |
new_buf | pointer where a new netbuf is stored when received data |
References ERR_ARG, ERR_CONN, ERR_MEM, ERR_OK, ipX_addr_set_any, LWIP_ASSERT, LWIP_ERROR(), LWIP_IPV6, memp_free(), memp_malloc(), netconn_recv_data(), NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, netconn::recvmbox, sys_mbox_valid(), and netconn::type.
Referenced by http_request(), and sta_task().
Receive data: actual implementation that doesn't care whether pbuf or netbuf is received.
conn | the netconn from which to receive data |
new_buf | pointer where a new pbuf/netbuf is stored when received data |
References API_EVENT, API_LIB_DEBUG, API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ERR_CLSD, ERR_CONN, ERR_IS_FATAL, ERR_OK, ERR_TIMEOUT, netconn::last_err, LWIP_ASSERT, LWIP_DEBUGF, LWIP_ERROR(), lwip_netconn_do_recv(), NETCONN_EVT_RCVMINUS, netconn_get_noautorecved, NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, netconn::recvmbox, SYS_ARCH_DEC, sys_arch_mbox_fetch(), SYS_ARCH_TIMEOUT, sys_mbox_valid(), TCPIP_APIMSG_NOERR, netconn::type, and U16_F.
Referenced by netconn_recv(), and netconn_recv_tcp_pbuf().
Receive data (in form of a pbuf) from a TCP netconn.
conn | the netconn from which to receive data |
new_buf | pointer where a new pbuf is stored when received data |
References ERR_ARG, LWIP_ERROR(), netconn_recv_data(), NETCONN_TCP, NETCONNTYPE_GROUP, and NULL.
TCP: update the receive window: by calling this, the application tells the stack that it has processed data and is able to accept new data.
ATTENTION: use with care, this is mainly used for sockets! Can only be used when calling netconn_set_noautorecved(conn, 1) before.
conn | the netconn for which to update the receive window |
length | amount of data processed (ATTENTION: this must be accurate!) |
References API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, lwip_netconn_do_recv(), netconn_get_noautorecved, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, TCPIP_APIMSG_NOERR, and netconn::type.
Send data over a UDP or RAW netconn (that is already connected).
conn | the UDP or RAW netconn over which to send data |
buf | a netbuf containing the data to send |
References API_LIB_DEBUG, API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_DEBUGF, LWIP_ERROR(), lwip_netconn_do_send(), NETCONN_SET_SAFE_ERR, NULL, TCPIP_APIMSG, and U16_F.
Referenced by netconn_sendto().
Send data (in form of a netbuf) to a specific remote IP address and port.
Only to be used for UDP and RAW netconns (not TCP).
conn | the netconn over which to send data |
buf | a netbuf containing the data to send |
addr | the remote IP address to which to send the data |
port | the remote port to which to send the data |
References ERR_VAL, netconn::ip, ipX_addr_set_ipaddr, netconn_send(), NULL, netconn::pcb, and PCB_ISIPV6.
Shut down one or both sides of a TCP netconn (doesn't delete it).
conn | the TCP netconn to shut down |
References netconn_close_shutdown(), NETCONN_SHUT_RD, and NETCONN_SHUT_WR.
err_t netconn_write_partly | ( | struct netconn * | conn, |
const void * | dataptr, | ||
size_t | size, | ||
u8_t | apiflags, | ||
size_t * | bytes_written | ||
) |
Send data over a TCP netconn.
conn | the TCP netconn over which to send data |
dataptr | pointer to the application buffer that contains the data to send |
size | size of the application data to send |
apiflags | combination of following flags :
|
bytes_written | pointer to a location that receives the number of written bytes |
References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ERR_OK, ERR_VAL, LWIP_ERROR(), lwip_netconn_do_write(), NETCONN_DONTBLOCK, netconn_is_nonblocking, NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, sys_now(), TCPIP_APIMSG, and netconn::type.