The Pedigree Project 0.1
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(f, ctx)   tcpip_callback_with_block(f, ctx, 1)
 

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_shutdown (void)
 
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_callback_with_block (tcpip_callback_fn function, void *ctx, u8_t block)
 
err_t tcpip_callback_wait (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_trycallback (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

Definition in file tcpip.h.

Macro Definition Documentation

◆ LOCK_TCPIP_CORE

#define LOCK_TCPIP_CORE ( )

Definition at line 79 of file tcpip.h.

◆ tcpip_callback

#define tcpip_callback (   f,
  ctx 
)    tcpip_callback_with_block(f, ctx, 1)
See also
tcpip_callback_with_block

Definition at line 113 of file tcpip.h.

◆ UNLOCK_TCPIP_CORE

#define UNLOCK_TCPIP_CORE ( )

Definition at line 80 of file tcpip.h.

Typedef Documentation

◆ tcpip_callback_fn

typedef void(* tcpip_callback_fn) (void *ctx)

Function prototype for functions passed to tcpip_callback()

Definition at line 89 of file tcpip.h.

◆ tcpip_init_done_fn

typedef void(* tcpip_init_done_fn) (void *arg)

Function prototype for the init_done function passed to tcpip_init

Definition at line 87 of file tcpip.h.

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

Definition at line 790 of file tcpip.c.

References mem_free().

◆ 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

Definition at line 777 of file tcpip.c.

◆ tcpip_callback_wait()

err_t tcpip_callback_wait ( tcpip_callback_fn  function,
void *  ctx 
)

Runs a callback in tcpip_thread and retires it before returning.

Definition at line 365 of file tcpip.c.

References ERR_ARG, ERR_CLSD, ERR_OK, sys_arch_sem_wait(), sys_sem_free(), sys_sem_new(), and sys_thread_is_current().

Referenced by NetworkStack::deRegisterDevice(), and NetworkStack::registerDevice().

+ Here is the caller graph for this function:

◆ tcpip_callback_with_block()

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

Definition at line 334 of file tcpip.c.

◆ 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

Definition at line 612 of file tcpip.c.

References memp_free().

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

Definition at line 594 of file tcpip.c.

References memp_malloc().

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

References ERR_OK, lwip_init(), sys_mbox_new(), sys_mutex_new(), sys_thread_new(), TCPIP_MBOX_SIZE, TCPIP_THREAD_NAME, TCPIP_THREAD_PRIO, and TCPIP_THREAD_STACKSIZE.

◆ 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

Definition at line 236 of file tcpip.c.

References ERR_CLSD, ERR_MEM, ERR_OK, LWIP_DEBUGF, memp_free(), memp_malloc(), sys_mbox_trypost(), sys_mbox_valid_val, and TCPIP_DEBUG.

Referenced by tcpip_input().

+ 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

Definition at line 286 of file tcpip.c.

References netif::flags, NETIF_FLAG_ETHARP, NETIF_FLAG_ETHERNET, and tcpip_inpkt().

◆ tcpip_shutdown()

err_t tcpip_shutdown ( void  )

Stop and join tcpip_thread after all users have retired.

ERR_INPROGRESS means initialization or another shutdown owns the lifecycle; callers may retry. ERR_USE rejects shutdown from tcpip_thread itself.

Definition at line 680 of file tcpip.c.

References ERR_CLSD, ERR_IF, ERR_INPROGRESS, ERR_OK, ERR_USE, sys_mbox_free(), sys_mbox_post_and_close(), sys_mbox_set_invalid_val, sys_mbox_valid_val, sys_msleep(), sys_mutex_free(), sys_mutex_set_invalid(), sys_mutex_valid(), sys_thread_is_current(), and sys_thread_join().

◆ tcpip_trycallback()

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

Definition at line 625 of file tcpip.c.

References ERR_CLSD, sys_mbox_trypost(), and sys_mbox_valid_val.