Microchip® Advanced Software Framework

dev/src/include/lwip/tcpip.h File Reference
#include "lwip/opt.h"
#include "lwip/api_msg.h"
#include "lwip/netifapi.h"
#include "lwip/pppapi.h"
#include "lwip/pbuf.h"
#include "lwip/api.h"
#include "lwip/sys.h"
#include "lwip/timers.h"
#include "lwip/netif.h"

Data Structures

struct  tcpip_msg
 

Macros

#define API_EXPR_DEREF(expr)   *(expr)
 
#define API_EXPR_REF(expr)   expr
 
#define API_VAR_ALLOC(type, pool, name)
 
#define API_VAR_ALLOC_DONTFAIL(type, pool, name)
 
#define API_VAR_DECLARE(type, name)   type name
 
#define API_VAR_FREE(pool, name)
 
#define API_VAR_REF(name)   name
 
#define LOCK_TCPIP_CORE()
 
#define LWIP_TCPIP_THREAD_ALIVE()
 Define this to something that triggers a watchdog. More...
 
#define TCPIP_APIMSG(m, f, e)   do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0)
 
#define TCPIP_APIMSG_ACK(m)   sys_sem_signal(LWIP_API_MSG_SEM(m))
 
#define TCPIP_APIMSG_NOERR(m, f)   do { (m)->function = f; tcpip_apimsg(m); } while(0)
 
#define tcpip_callback(f, ctx)   tcpip_callback_with_block(f, ctx, 1)
 
#define TCPIP_NETIFAPI(m)   tcpip_netifapi(m)
 
#define TCPIP_NETIFAPI_ACK(m)   sys_sem_signal(&m->sem)
 
#define TCPIP_PPPAPI(m)   tcpip_pppapi(m)
 
#define TCPIP_PPPAPI_ACK(m)   sys_sem_signal(&m->sem)
 
#define UNLOCK_TCPIP_CORE()
 

Typedefs

typedef void(* tcpip_callback_fn )(void *ctx)
 Function prototype for functions passed to tcpip_callback() More...
 
typedef void(* tcpip_init_done_fn )(void *arg)
 Function prototype for the init_done function passed to tcpip_init. More...
 

Enumerations

enum  tcpip_msg_type {
  TCPIP_MSG_INPKT,
  TCPIP_MSG_CALLBACK,
  TCPIP_MSG_CALLBACK_STATIC,
  TCPIP_MSG_INPKT,
  TCPIP_MSG_CALLBACK,
  TCPIP_MSG_CALLBACK_STATIC
}
 

Functions

err_t mem_free_callback (void *m)
 A simple wrapper function that allows you to free heap memory from interrupt context. More...
 
err_t pbuf_free_callback (struct pbuf *p)
 A simple wrapper function that allows you to free a pbuf from interrupt context. More...
 
err_t tcpip_callback_with_block (tcpip_callback_fn function, void *ctx, u8_t block)
 Call a specific function in the thread context of tcpip_thread for easy access synchronization. More...
 
void tcpip_callbackmsg_delete (struct tcpip_callback_msg *msg)
 Free a callback message allocated by tcpip_callbackmsg_new(). More...
 
struct tcpip_callback_msg * tcpip_callbackmsg_new (tcpip_callback_fn function, void *ctx)
 Allocate a structure for a static callback message and initialize it. More...
 
void tcpip_init (tcpip_init_done_fn tcpip_init_done, void *arg)
 Initialize this module: More...
 
err_t tcpip_input (struct pbuf *p, struct netif *inp)
 Pass a received packet to tcpip_thread for input processing. More...
 
err_t tcpip_trycallback (struct tcpip_callback_msg *msg)
 Try to post a callback-message to the tcpip_thread mbox This is intended to be used to send "static" messages from interrupt context. More...
 

#define API_EXPR_DEREF (   expr)    *(expr)
#define API_EXPR_REF (   expr)    expr
#define API_VAR_ALLOC (   type,
  pool,
  name 
)
#define API_VAR_ALLOC_DONTFAIL (   type,
  pool,
  name 
)
#define API_VAR_DECLARE (   type,
  name 
)    type name
#define API_VAR_FREE (   pool,
  name 
)
#define API_VAR_REF (   name)    name
#define LOCK_TCPIP_CORE ( )
#define LWIP_TCPIP_THREAD_ALIVE ( )

Define this to something that triggers a watchdog.

This is called from tcpip_thread after processing a message.

#define TCPIP_APIMSG (   m,
  f,
 
)    do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0)
#define TCPIP_APIMSG_ACK (   m)    sys_sem_signal(LWIP_API_MSG_SEM(m))
#define TCPIP_APIMSG_NOERR (   m,
 
)    do { (m)->function = f; tcpip_apimsg(m); } while(0)
#define tcpip_callback (   f,
  ctx 
)    tcpip_callback_with_block(f, ctx, 1)
#define TCPIP_NETIFAPI (   m)    tcpip_netifapi(m)
#define TCPIP_NETIFAPI_ACK (   m)    sys_sem_signal(&m->sem)
#define TCPIP_PPPAPI (   m)    tcpip_pppapi(m)
#define TCPIP_PPPAPI_ACK (   m)    sys_sem_signal(&m->sem)
#define UNLOCK_TCPIP_CORE ( )

typedef void(* tcpip_callback_fn)(void *ctx)

Function prototype for functions passed to tcpip_callback()

typedef void(* tcpip_init_done_fn)(void *arg)

Function prototype for the init_done function passed to tcpip_init.

Enumerator
TCPIP_MSG_INPKT 
TCPIP_MSG_CALLBACK 
TCPIP_MSG_CALLBACK_STATIC 
TCPIP_MSG_INPKT 
TCPIP_MSG_CALLBACK 
TCPIP_MSG_CALLBACK_STATIC 

err_t mem_free_callback ( void *  m)

A simple wrapper function that allows you to free heap memory from interrupt context.

Parameters
mthe heap memory to free
Returns
ERR_OK if callback could be enqueued, an err_t if not

References mem_free(), and tcpip_callback_with_block().

err_t pbuf_free_callback ( struct pbuf p)

A simple wrapper function that allows you to free a pbuf from interrupt context.

Parameters
pThe pbuf (chain) to be dereferenced.
Returns
ERR_OK if callback could be enqueued, an err_t if not

References pbuf_free_int(), and tcpip_callback_with_block().

err_t tcpip_callback_with_block ( tcpip_callback_fn  function,
void *  ctx,
u8_t  block 
)

Call a specific function in the thread context of tcpip_thread for easy access synchronization.

A function called in that way may access lwIP core code without fearing concurrent access.

Parameters
fthe function to call
ctxparameter passed to f
block1 to block until the request is posted, 0 to non-blocking mode
Returns
ERR_OK if the function was called, another err_t if not

References tcpip_msg::cb, tcpip_msg::ctx, ERR_MEM, ERR_OK, ERR_VAL, memp_free(), memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_post(), sys_mbox_trypost(), sys_mbox_valid(), TCPIP_MSG_CALLBACK, and tcpip_msg::type.

Referenced by mem_free_callback(), and pbuf_free_callback().

void tcpip_callbackmsg_delete ( struct tcpip_callback_msg *  msg)

Free a callback message allocated by tcpip_callbackmsg_new().

Parameters
msgthe message to free

References memp_free().

struct tcpip_callback_msg* tcpip_callbackmsg_new ( tcpip_callback_fn  function,
void *  ctx 
)

Allocate a structure for a static callback message and initialize it.

This is intended to be used to send "static" messages from interrupt context.

Parameters
functionthe function to call
ctxparameter passed to function
Returns
a struct pointer to pass to tcpip_trycallback().

References tcpip_msg::cb, tcpip_msg::ctx, memp_malloc(), tcpip_msg::msg, NULL, TCPIP_MSG_CALLBACK_STATIC, and tcpip_msg::type.

void tcpip_init ( tcpip_init_done_fn  initfunc,
void *  arg 
)

Initialize this module:

  • initialize all sub modules
  • start the tcpip_thread
Parameters
initfunca function to call when tcpip_thread is running and finished initializing
argargument to pass to initfunc

References ERR_OK, LWIP_ASSERT, lwip_init(), NULL, sys_mbox_new(), sys_mutex_new(), sys_thread_new(), tcpip_init_done, tcpip_init_done_arg, TCPIP_MBOX_SIZE, tcpip_thread(), TCPIP_THREAD_NAME, TCPIP_THREAD_PRIO, and TCPIP_THREAD_STACKSIZE.

err_t tcpip_input ( struct pbuf p,
struct netif inp 
)

Pass a received packet to tcpip_thread for input processing.

Parameters
pthe received packet, p->payload pointing to the Ethernet header or to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or NETIF_FLAG_ETHERNET flags)
inpthe network interface on which the packet was received

References ERR_MEM, ERR_OK, ERR_VAL, netif::flags, tcpip_msg::inp, ip_input(), LOCK_TCPIP_CORE, LWIP_DEBUGF, memp_free(), memp_malloc(), tcpip_msg::msg, NETIF_FLAG_ETHARP, NETIF_FLAG_ETHERNET, NULL, tcpip_msg::p, sys_mbox_trypost(), sys_mbox_valid(), TCPIP_DEBUG, TCPIP_MSG_INPKT, tcpip_msg::type, and UNLOCK_TCPIP_CORE.

Referenced by netif_init().

err_t tcpip_trycallback ( struct tcpip_callback_msg *  msg)

Try to post a callback-message to the tcpip_thread mbox This is intended to be used to send "static" messages from interrupt context.

Parameters
msgpointer to the message to post
Returns
sys_mbox_trypost() return code

References ERR_VAL, sys_mbox_trypost(), and sys_mbox_valid().