ReactOS 0.4.16-dev-257-g6aa11ac
OS mode (TCPIP thread)
Collaboration diagram for OS mode (TCPIP thread):

Macros

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

Functions

err_t tcpip_input (struct pbuf *p, struct netif *inp)
 
err_t tcpip_callback (tcpip_callback_fn function, void *ctx)
 
err_t tcpip_try_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)
 
void tcpip_init (tcpip_init_done_fn initfunc, void *arg)
 

Detailed Description

Use this mode if you run an OS on your system. It is recommended to use an RTOS that correctly handles priority inversion and to use LWIP_TCPIP_CORE_LOCKING.
Porting: implement all functions in Porting (system abstraction layer).
You can use "raw" APIs together with tcpip_callback, and all Sequential-style APIs.

Macro Definition Documentation

◆ tcpip_callback_with_block

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

Definition at line 88 of file tcpip.h.

Function Documentation

◆ 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

Definition at line 314 of file tcpip.c.

315{
316 struct tcpip_msg *msg;
317
318 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
319
320 msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
321 if (msg == NULL) {
322 return ERR_MEM;
323 }
324
325 msg->type = TCPIP_MSG_CALLBACK;
326 msg->msg.cb.function = function;
327 msg->msg.cb.ctx = ctx;
328
330 return ERR_OK;
331}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
#define ERR_MEM
Definition: fontsub.h:52
@ ERR_OK
Definition: err.h:55
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:160
void * memp_malloc(memp_t type)
Definition: memp.c:337
void * ctx
Definition: tcpip_priv.h:145
tcpip_callback_fn function
Definition: tcpip_priv.h:135
#define sys_mbox_valid_val(mbox)
Definition: sys.h:395
static sys_mbox_t tcpip_mbox
Definition: tcpip.c:61
@ TCPIP_MSG_CALLBACK
Definition: tcpip_priv.h:125

◆ 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()

Definition at line 557 of file tcpip.c.

558{
559 memp_free(MEMP_TCPIP_MSG_API, msg);
560}
void memp_free(memp_t type, void *mem)
Definition: memp.c:420

◆ 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 initialize 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()

Definition at line 536 of file tcpip.c.

537{
538 struct tcpip_msg *msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
539 if (msg == NULL) {
540 return NULL;
541 }
543 msg->msg.cb.function = function;
544 msg->msg.cb.ctx = ctx;
545 return (struct tcpip_callback_msg *)msg;
546}
@ TCPIP_MSG_CALLBACK_STATIC
Definition: tcpip_priv.h:126

◆ 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()

Definition at line 572 of file tcpip.c.

573{
574 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
576}
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:247

◆ 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()

Definition at line 591 of file tcpip.c.

592{
593 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
595}
#define sys_mbox_trypost_fromisr
Definition: sys_arch.h:31

◆ tcpip_init()

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 650 of file tcpip.c.

651{
652 lwip_init();
653
654 tcpip_init_done = initfunc;
657 LWIP_ASSERT("failed to create tcpip_thread mbox", 0);
658 }
659#if LWIP_TCPIP_CORE_LOCKING
660 if (sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
661 LWIP_ASSERT("failed to create lock_tcpip_core", 0);
662 }
663#endif /* LWIP_TCPIP_CORE_LOCKING */
664
666}
void lwip_init(void)
Definition: init.c:339
#define TCPIP_THREAD_NAME
Definition: opt.h:1807
#define TCPIP_THREAD_PRIO
Definition: opt.h:1825
#define TCPIP_MBOX_SIZE
Definition: opt.h:1834
#define TCPIP_THREAD_STACKSIZE
Definition: opt.h:1816
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
Definition: sys_arch.c:128
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
Definition: sys_arch.c:275
err_t sys_mutex_new(sys_mutex_t *mutex)
Definition: sys_arch.c:149
static void tcpip_thread(void *arg)
Definition: tcpip.c:127
static tcpip_init_done_fn tcpip_init_done
Definition: tcpip.c:59
static void * tcpip_init_done_arg
Definition: tcpip.c:60
void * arg
Definition: msvc.h:10

Referenced by LibIPInitialize(), and main().

◆ 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

Definition at line 288 of file tcpip.c.

289{
290#if LWIP_ETHERNET
292 return tcpip_inpkt(p, inp, ethernet_input);
293 } else
294#endif /* LWIP_ETHERNET */
295 return tcpip_inpkt(p, inp, ip_input);
296}
GLfloat GLfloat p
Definition: glext.h:8902
#define NETIF_FLAG_ETHERNET
Definition: netif.h:101
#define NETIF_FLAG_ETHARP
Definition: netif.h:97
u8_t flags
Definition: netif.h:354
err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
Definition: tcpip.c:245

Referenced by netif_init(), and TCPRegisterInterface().

◆ 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

Definition at line 350 of file tcpip.c.

351{
352 struct tcpip_msg *msg;
353
354 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
355
356 msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
357 if (msg == NULL) {
358 return ERR_MEM;
359 }
360
361 msg->type = TCPIP_MSG_CALLBACK;
362 msg->msg.cb.function = function;
363 msg->msg.cb.ctx = ctx;
364
366 memp_free(MEMP_TCPIP_MSG_API, msg);
367 return ERR_MEM;
368 }
369 return ERR_OK;
370}

Referenced by mem_free_callback(), and pbuf_free_callback().