Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/

Embed: (wiki syntax)

« Back to documentation index

tcpip.c File Reference

tcpip.c File Reference

Sequential API Main thread module. More...

Go to the source code of this file.

Functions

static void tcpip_thread (void *arg)
 The main lwIP thread.
err_t tcpip_input (struct pbuf *p, struct netif *inp)
 Pass a received packet to tcpip_thread for input processing.
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.
err_t tcpip_timeout (u32_t msecs, sys_timeout_handler h, void *arg)
 call sys_timeout in tcpip_thread
err_t tcpip_untimeout (sys_timeout_handler h, void *arg)
 call sys_untimeout in tcpip_thread
err_t tcpip_apimsg (struct api_msg *apimsg)
 Call the lower part of a netconn_* function This function is then running in the thread context of tcpip_thread and has exclusive access to lwIP core code.
err_t tcpip_apimsg_lock (struct api_msg *apimsg)
 Call the lower part of a netconn_* function This function has exclusive access to lwIP core code by locking it before the function is called.
err_t tcpip_netifapi (struct netifapi_msg *netifapimsg)
 Much like tcpip_apimsg, but calls the lower part of a netifapi_* function.
err_t tcpip_netifapi_lock (struct netifapi_msg *netifapimsg)
 Call the lower part of a netifapi_* function This function has exclusive access to lwIP core code by locking it before the function is called.
void tcpip_init (tcpip_init_done_fn initfunc, void *arg)
 Initialize this module:

  • initialize all sub modules
  • start the tcpip_thread.

static void pbuf_free_int (void *p)
 Simple callback function used with tcpip_callback to free a pbuf (pbuf_free has a wrong signature for tcpip_callback)
err_t pbuf_free_callback (struct pbuf *p)
 A simple wrapper function that allows you to free a pbuf from interrupt context.
err_t mem_free_callback (void *m)
 A simple wrapper function that allows you to free heap memory from interrupt context.

Variables

sys_mutex_t lock_tcpip_core
 The global semaphore to lock the stack.

Detailed Description

Sequential API Main thread module.

Definition in file tcpip.c.


Function Documentation

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

Definition at line 455 of file tcpip.c.

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

Definition at line 442 of file tcpip.c.

static void pbuf_free_int ( void *  p ) [static]

Simple callback function used with tcpip_callback to free a pbuf (pbuf_free has a wrong signature for tcpip_callback)

Parameters:
pThe pbuf (chain) to be dereferenced.

Definition at line 429 of file tcpip.c.

err_t tcpip_apimsg ( struct api_msg apimsg )

Call the lower part of a netconn_* function This function is then running in the thread context of tcpip_thread and has exclusive access to lwIP core code.

Parameters:
apimsga struct containing the function to call and its parameters
Returns:
ERR_OK if the function was called, another err_t if not

Definition at line 301 of file tcpip.c.

err_t tcpip_apimsg_lock ( struct api_msg apimsg )

Call the lower part of a netconn_* function This function has exclusive access to lwIP core code by locking it before the function is called.

Parameters:
apimsga struct containing the function to call and its parameters
Returns:
ERR_OK (only for compatibility fo tcpip_apimsg())

Definition at line 329 of file tcpip.c.

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

Definition at line 206 of file tcpip.c.

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

Definition at line 404 of file tcpip.c.

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

Definition at line 156 of file tcpip.c.

err_t tcpip_netifapi ( struct netifapi_msg *  netifapimsg )

Much like tcpip_apimsg, but calls the lower part of a netifapi_* function.

Parameters:
netifapimsga struct containing the function to call and its parameters
Returns:
error code given back by the function that was called

Definition at line 355 of file tcpip.c.

err_t tcpip_netifapi_lock ( struct netifapi_msg *  netifapimsg )

Call the lower part of a netifapi_* function This function has exclusive access to lwIP core code by locking it before the function is called.

Parameters:
netifapimsga struct containing the function to call and its parameters
Returns:
ERR_OK (only for compatibility fo tcpip_netifapi())

Definition at line 385 of file tcpip.c.

static void tcpip_thread ( void *  arg ) [static]

The main lwIP thread.

This thread has exclusive access to lwIP core functions (unless access to them is not locked). Other threads communicate with this thread using message boxes.

It also starts all the timers to make sure they are running in the right thread context.

Parameters:
argunused argument

Definition at line 74 of file tcpip.c.

err_t tcpip_timeout ( u32_t  msecs,
sys_timeout_handler  h,
void *  arg 
)

call sys_timeout in tcpip_thread

Parameters:
msectime in milliseconds for timeout
hfunction to be called on timeout
argargument to pass to timeout function h
Returns:
ERR_MEM on memory error, ERR_OK otherwise

Definition at line 242 of file tcpip.c.

err_t tcpip_untimeout ( sys_timeout_handler  h,
void *  arg 
)

call sys_untimeout in tcpip_thread

Parameters:
msectime in milliseconds for timeout
hfunction to be called on timeout
argargument to pass to timeout function h
Returns:
ERR_MEM on memory error, ERR_OK otherwise

Definition at line 271 of file tcpip.c.


Variable Documentation

sys_mutex_t lock_tcpip_core

The global semaphore to lock the stack.

Definition at line 59 of file tcpip.c.