Sequential API Main thread module.
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "lwip/memp.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/tcpip.h"
#include "lwip/init.h"
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
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... | |
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) More... | |
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. 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_init (tcpip_init_done_fn initfunc, 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... | |
static void | tcpip_thread (void *arg) |
The main lwIP thread. More... | |
err_t | tcpip_timeout (u32_t msecs, sys_timeout_handler h, void *arg) |
call sys_timeout in tcpip_thread More... | |
err_t | tcpip_untimeout (sys_timeout_handler h, void *arg) |
call sys_untimeout in tcpip_thread More... | |
Variables | |
static sys_mbox_t | mbox |
static tcpip_init_done_fn | tcpip_init_done |
static void * | tcpip_init_done_arg |
A simple wrapper function that allows you to free heap memory from interrupt context.
m | the heap memory to free |
References mem_free(), and tcpip_callback_with_block().
A simple wrapper function that allows you to free a pbuf from interrupt context.
p | The pbuf (chain) to be dereferenced. |
References pbuf_free_int(), and tcpip_callback_with_block().
Simple callback function used with tcpip_callback to free a pbuf (pbuf_free has a wrong signature for tcpip_callback)
p | The pbuf (chain) to be dereferenced. |
References pbuf_free().
Referenced by pbuf_free_callback().
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.
apimsg | a struct containing the function to call and its parameters |
References tcpip_msg::apimsg, api_msg_msg::conn, api_msg_msg::err, ERR_VAL, api_msg::msg, tcpip_msg::msg, netconn::op_completed, sys_arch_sem_wait(), sys_mbox_post(), sys_mbox_valid(), TCPIP_MSG_API, and tcpip_msg::type.
Referenced by netconn_close_shutdown(), netconn_connect(), and netconn_delete().
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.
f | the function to call |
ctx | parameter passed to f |
block | 1 to block until the request is posted, 0 to non-blocking mode |
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(), pbuf_free_callback(), and pbuf_pool_is_empty().
void tcpip_init | ( | tcpip_init_done_fn | initfunc, |
void * | arg | ||
) |
Initialize this module:
initfunc | a function to call when tcpip_thread is running and finished initializing |
arg | argument to pass to initfunc |
References 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_SIZE, tcpip_thread(), TCPIP_THREAD_NAME, TCPIP_THREAD_PRIO, and TCPIP_THREAD_STACKSIZE.
Referenced by prvlwIPInit().
Pass a received packet to tcpip_thread for input processing.
p | the 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) |
inp | the network interface on which the packet was received |
References ERR_MEM, ERR_OK, ERR_VAL, ethernet_input(), 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(), and prvEthernetConfigureInterface().
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.
arg | unused argument |
References tcpip_msg::apimsg, tcpip_msg::cb, ethernet_input(), api_msg::function, tcpip_msg::function, tcpip_msg::inp, ip_input(), LOCK_TCPIP_CORE, LWIP_ASSERT, LWIP_DEBUGF, LWIP_TCPIP_THREAD_ALIVE, LWIP_UNUSED_ARG, memp_free(), api_msg::msg, tcpip_msg::msg, NETIF_FLAG_ETHARP, NETIF_FLAG_ETHERNET, NULL, sys_timeout(), sys_timeouts_mbox_fetch(), sys_untimeout(), TCPIP_DEBUG, tcpip_init_done, tcpip_init_done_arg, TCPIP_MSG_API, TCPIP_MSG_CALLBACK, TCPIP_MSG_INPKT, TCPIP_MSG_TIMEOUT, TCPIP_MSG_UNTIMEOUT, tcpip_msg::tmo, tcpip_msg::type, and UNLOCK_TCPIP_CORE.
Referenced by tcpip_init().
err_t tcpip_timeout | ( | u32_t | msecs, |
sys_timeout_handler | h, | ||
void * | arg | ||
) |
call sys_timeout in tcpip_thread
msec | time in milliseconds for timeout |
h | function to be called on timeout |
arg | argument to pass to timeout function h |
References arg, ERR_MEM, ERR_OK, ERR_VAL, h, memp_malloc(), tcpip_msg::msecs, tcpip_msg::msg, NULL, sys_mbox_post(), sys_mbox_valid(), TCPIP_MSG_TIMEOUT, tcpip_msg::tmo, and tcpip_msg::type.
err_t tcpip_untimeout | ( | sys_timeout_handler | h, |
void * | arg | ||
) |
call sys_untimeout in tcpip_thread
msec | time in milliseconds for timeout |
h | function to be called on timeout |
arg | argument to pass to timeout function h |
References arg, ERR_MEM, ERR_OK, ERR_VAL, h, memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_post(), sys_mbox_valid(), TCPIP_MSG_UNTIMEOUT, tcpip_msg::tmo, and tcpip_msg::type.
|
static |
|
static |
Referenced by tcpip_init(), and tcpip_thread().
|
static |
Referenced by tcpip_init(), and tcpip_thread().