ReactOS 0.4.16-dev-457-g087979e
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)
 
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_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

Definition in file tcpip.h.

Macro Definition Documentation

◆ LOCK_TCPIP_CORE

#define LOCK_TCPIP_CORE ( )

Definition at line 62 of file tcpip.h.

◆ UNLOCK_TCPIP_CORE

#define UNLOCK_TCPIP_CORE ( )

Definition at line 63 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 72 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 70 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 701 of file tcpip.c.

702{
704}
#define mem_free(ptr, bsize)
Definition: types.h:124
const GLfloat * m
Definition: glext.h:10848
err_t tcpip_try_callback(tcpip_callback_fn function, void *ctx)
Definition: tcpip.c:350

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

689{
691}
GLfloat GLfloat p
Definition: glext.h:8902
static void pbuf_free_int(void *p)
Definition: tcpip.c:675

Referenced by LibTCPGetDataFromConnectionQueue().

◆ tcpip_callback_wait()

err_t tcpip_callback_wait ( tcpip_callback_fn  function,
void ctx 
)

Sends a message to TCPIP thread to call a function. Caller thread blocks until the function returns. It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or LWIP_NETCONN_SEM_PER_THREAD. If not, a semaphore is created and destroyed on every call which is usually an expensive/slow operation.

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

Definition at line 610 of file tcpip.c.

611{
612#if LWIP_TCPIP_CORE_LOCKING
614 function(ctx);
616 return ERR_OK;
617#else /* LWIP_TCPIP_CORE_LOCKING */
618 err_t err;
620 struct tcpip_msg msg;
621
622 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
623
624 err = sys_sem_new(&sem, 0);
625 if (err != ERR_OK) {
626 return err;
627 }
628
630 msg.msg.cb_wait.function = function;
631 msg.msg.cb_wait.ctx = ctx;
632 msg.msg.cb_wait.sem = &sem;
636 return ERR_OK;
637#endif /* LWIP_TCPIP_CORE_LOCKING */
638}
#define msg(x)
Definition: auth_time.c:54
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
#define LOCK_TCPIP_CORE()
Definition: tcpip.h:62
#define UNLOCK_TCPIP_CORE()
Definition: tcpip.h:63
s8_t err_t
Definition: err.h:96
@ ERR_OK
Definition: err.h:55
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:160
void sys_sem_free(sys_sem_t *sem)
Definition: sys_arch.c:72
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Definition: sys_arch.c:86
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
Definition: sys_arch.c:46
static HANDLE sem
Definition: sync.c:674
#define err(...)
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_STATIC_WAIT
Definition: tcpip_priv.h:127

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

246{
247#if LWIP_TCPIP_CORE_LOCKING_INPUT
248 err_t ret;
249 LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_inpkt: PACKET %p/%p\n", (void *)p, (void *)inp));
251 ret = input_fn(p, inp);
253 return ret;
254#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
255 struct tcpip_msg *msg;
256
257 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
258
259 msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT);
260 if (msg == NULL) {
261 return ERR_MEM;
262 }
263
264 msg->type = TCPIP_MSG_INPKT;
265 msg->msg.inp.p = p;
266 msg->msg.inp.netif = inp;
267 msg->msg.inp.input_fn = input_fn;
269 memp_free(MEMP_TCPIP_MSG_INPKT, msg);
270 return ERR_MEM;
271 }
272 return ERR_OK;
273#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */
274}
#define NULL
Definition: types.h:112
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:158
#define ERR_MEM
Definition: fontsub.h:52
#define TCPIP_DEBUG
Definition: opt.h:3512
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:247
void * memp_malloc(memp_t type)
Definition: memp.c:337
void memp_free(memp_t type, void *mem)
Definition: memp.c:420
struct tcpip_msg::@1056::@1060 inp
netif_input_fn input_fn
Definition: tcpip_priv.h:153
@ TCPIP_MSG_INPKT
Definition: tcpip_priv.h:119
int ret

Referenced by tcpip_input().