Microchip® Advanced Software Framework

api_msg.h File Reference
#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 netconnnetconn_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
#define NETCONN_SHUT_RDWR   (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
#define NETCONN_SHUT_WR   2

void do_bind ( struct api_msg_msg msg)

Bind a pcb contained in a netconn Called from netconn_bind.

Parameters
msgthe 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, netconn::udp, and udp_bind().

Referenced by netconn_bind().

void do_disconnect ( struct api_msg_msg msg)

Connect a pcb contained inside a netconn Only used for UDP netconns.

Called from netconn_disconnect.

Parameters
msgthe 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().

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.

Parameters
msgthe 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.

Parameters
msgthe 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)
void do_shutdown ( struct api_msg_msg msg)
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!

Parameters
tthe type of 'connection' to create (
See Also
enum netconn_type)
Parameters
protothe IP protocol for RAW IP pcbs
callbacka function to call on status changes (RX available, TX'ed)
Returns
a newly allocated struct netconn or NULL on memory error

References netconn::acceptmbox, netconn::callback, netconn::current_msg, DEFAULT_RAW_RECVMBOX_SIZE, DEFAULT_TCP_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_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().

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).

Parameters
connthe 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().