ConOpSys V2970  P004.07
ANVILEX control operating system
Macros | Typedefs | Functions
tcpip.h File Reference
#include "lwip/opt.h"
#include "lwip/err.h"
#include "lwip/timeouts.h"
#include "lwip/netif.h"
Include dependency graph for tcpip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOCK_TCPIP_CORE()
 
#define UNLOCK_TCPIP_CORE()
 
#define tcpip_callback_with_block(function, ctx, block)   ((block != 0)? tcpip_callback(function, ctx) : tcpip_try_callback(function, ctx))
 

Typedefs

typedef void(* tcpip_init_done_fn) (void *arg)
 
typedef void(* tcpip_callback_fn) (void *ctx)
 

Functions

void tcpip_init (tcpip_init_done_fn tcpip_init_done, void *arg)
 
err_t tcpip_inpkt (struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
 
err_t tcpip_input (struct pbuf *p, struct netif *inp)
 
err_t tcpip_try_callback (tcpip_callback_fn function, void *ctx)
 
err_t tcpip_callback (tcpip_callback_fn function, void *ctx)
 
struct tcpip_callback_msg * tcpip_callbackmsg_new (tcpip_callback_fn function, void *ctx)
 
void tcpip_callbackmsg_delete (struct tcpip_callback_msg *msg)
 
err_t tcpip_callbackmsg_trycallback (struct tcpip_callback_msg *msg)
 
err_t tcpip_callbackmsg_trycallback_fromisr (struct tcpip_callback_msg *msg)
 
err_t pbuf_free_callback (struct pbuf *p)
 
err_t mem_free_callback (void *m)
 

Detailed Description

Functions to sync with TCPIP thread

Macro Definition Documentation

◆ LOCK_TCPIP_CORE

#define LOCK_TCPIP_CORE ( )

◆ tcpip_callback_with_block

#define tcpip_callback_with_block (   function,
  ctx,
  block 
)    ((block != 0)? tcpip_callback(function, ctx) : tcpip_try_callback(function, ctx))

◆ UNLOCK_TCPIP_CORE

#define UNLOCK_TCPIP_CORE ( )

Typedef Documentation

◆ tcpip_callback_fn

typedef void(* tcpip_callback_fn) (void *ctx)

Function prototype for functions passed to tcpip_callback()

◆ tcpip_init_done_fn

typedef void(* tcpip_init_done_fn) (void *arg)

Function prototype for the init_done function passed to tcpip_init

Function Documentation

◆ mem_free_callback()

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

Here is the call graph for this function:

◆ pbuf_free_callback()

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

Here is the call graph for this function:

◆ tcpip_callback()

err_t tcpip_callback ( tcpip_callback_fn  function,
void *  ctx 
)

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. Blocks until the request is posted. Must not be called from interrupt context!

Parameters
functionthe function to call
ctxparameter passed to f
Returns
ERR_OK if the function was called, another err_t if not
See also
tcpip_try_callback

References tcpip_msg::ctx, ERR_MEM, ERR_OK, LWIP_ASSERT, memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_post(), sys_mbox_valid_val, tcpip_mbox, and TCPIP_MSG_CALLBACK.

Here is the call graph for this function:

◆ tcpip_callbackmsg_delete()

void tcpip_callbackmsg_delete ( struct tcpip_callback_msg *  msg)

Free a callback message allocated by tcpip_callbackmsg_new().

Parameters
msgthe message to free
See also
tcpip_callbackmsg_new()

References memp_free(), and tcpip_msg::msg.

Here is the call graph for this function:

◆ tcpip_callbackmsg_new()

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

Allocate a structure for a static callback message and initialise it. The message has a special type such that lwIP never frees it. This is intended to be used to send "static" messages from interrupt context, e.g. the message is allocated once and posted several times from an IRQ using tcpip_callbackmsg_trycallback(). Example usage: Trigger execution of an ethernet IRQ DPC routine in lwIP thread context.

Parameters
functionthe function to call
ctxparameter passed to function
Returns
a struct pointer to pass to tcpip_callbackmsg_trycallback().
See also
tcpip_callbackmsg_trycallback()
tcpip_callbackmsg_delete()

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

Here is the call graph for this function:

◆ tcpip_callbackmsg_trycallback()

err_t tcpip_callbackmsg_trycallback ( struct tcpip_callback_msg *  msg)

Try to post a callback-message to the tcpip_thread tcpip_mbox.

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

References LWIP_ASSERT, tcpip_msg::msg, sys_mbox_trypost(), sys_mbox_valid_val, and tcpip_mbox.

Here is the call graph for this function:

◆ tcpip_callbackmsg_trycallback_fromisr()

err_t tcpip_callbackmsg_trycallback_fromisr ( struct tcpip_callback_msg *  msg)

Try to post a callback-message to the tcpip_thread mbox. Same as tcpip_callbackmsg_trycallback but calls sys_mbox_trypost_fromisr(), mainly to help FreeRTOS, where calls differ between task level and ISR level.

Parameters
msgpointer to the message to post
Returns
sys_mbox_trypost_fromisr() return code (without change, so this knowledge can be used to e.g. propagate "bool needs_scheduling")
See also
tcpip_callbackmsg_new()

References LWIP_ASSERT, tcpip_msg::msg, sys_mbox_trypost_fromisr(), sys_mbox_valid_val, and tcpip_mbox.

Here is the call graph for this function:

◆ tcpip_init()

void tcpip_init ( tcpip_init_done_fn  initfunc,
void *  arg 
)

initialise this module:

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

References tcpip_msg::arg, 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, TCPIP_MBOX_SIZE, tcpip_thread(), TCPIP_THREAD_NAME, TCPIP_THREAD_PRIO, and TCPIP_THREAD_STACKSIZE.

Here is the call graph for this function:

◆ tcpip_inpkt()

err_t tcpip_inpkt ( struct pbuf p,
struct netif inp,
netif_input_fn  input_fn 
)

Pass a received packet to tcpip_thread for input processing

Parameters
pthe received packet
inpthe network interface on which the packet was received
input_fninput function to call

References ERR_MEM, ERR_OK, tcpip_msg::inp, tcpip_msg::input_fn, LOCK_TCPIP_CORE, LWIP_ASSERT, LWIP_DEBUGF, memp_free(), memp_malloc(), tcpip_msg::msg, NULL, tcpip_msg::p, sys_mbox_trypost(), sys_mbox_valid_val, TCPIP_DEBUG, tcpip_mbox, TCPIP_MSG_INPKT, and UNLOCK_TCPIP_CORE.

Referenced by tcpip_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcpip_input()

err_t tcpip_input ( struct pbuf p,
struct netif inp 
)

Pass a received packet to tcpip_thread for input processing with ethernet_input or ip_input. Don't call directly, pass to netif_add() and call netif->input().

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 tcpip_msg::inp, NETIF_FLAG_ETHARP, NETIF_FLAG_ETHERNET, tcpip_msg::p, and tcpip_inpkt().

Referenced by netif_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcpip_try_callback()

err_t tcpip_try_callback ( tcpip_callback_fn  function,
void *  ctx 
)

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. Does NOT block when the request cannot be posted because the tcpip_mbox is full, but returns ERR_MEM instead. Can be called from interrupt context.

Parameters
functionthe function to call
ctxparameter passed to f
Returns
ERR_OK if the function was called, another err_t if not
See also
tcpip_callback

References tcpip_msg::ctx, ERR_MEM, ERR_OK, LWIP_ASSERT, memp_free(), memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_trypost(), sys_mbox_valid_val, tcpip_mbox, and TCPIP_MSG_CALLBACK.

Referenced by mem_free_callback(), and pbuf_free_callback().

Here is the call graph for this function:
Here is the caller graph for this function: