ReactOS 0.4.16-dev-297-gc569aee
tcpip_priv.h File Reference
#include "lwip/opt.h"
#include "lwip/tcpip.h"
#include "lwip/sys.h"
#include "lwip/timeouts.h"
Include dependency graph for tcpip_priv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tcpip_api_call_data
 
struct  tcpip_msg
 

Macros

#define API_VAR_REF(name)   name
 
#define API_VAR_DECLARE(type, name)   type name
 
#define API_VAR_ALLOC_EXT(type, pool, name, errorblock)
 
#define API_VAR_ALLOC(type, pool, name, errorval)
 
#define API_VAR_ALLOC_POOL(type, pool, name, errorval)
 
#define API_VAR_FREE(pool, name)
 
#define API_VAR_FREE_POOL(pool, name)
 
#define API_EXPR_REF(expr)   expr
 
#define API_EXPR_REF_SEM(expr)   API_EXPR_REF(expr)
 
#define API_EXPR_DEREF(expr)   (*(expr))
 
#define API_MSG_M_DEF(m)   *m
 
#define API_MSG_M_DEF_C(t, m)   const t * m
 

Typedefs

typedef err_t(* tcpip_api_call_fn) (struct tcpip_api_call_data *call)
 

Enumerations

enum  tcpip_msg_type {
  TCPIP_MSG_API , TCPIP_MSG_API_CALL , TCPIP_MSG_INPKT , TCPIP_MSG_CALLBACK ,
  TCPIP_MSG_CALLBACK_STATIC , TCPIP_MSG_CALLBACK_STATIC_WAIT
}
 

Functions

err_t tcpip_send_msg_wait_sem (tcpip_callback_fn fn, void *apimsg, sys_sem_t *sem)
 
err_t tcpip_api_call (tcpip_api_call_fn fn, struct tcpip_api_call_data *call)
 

Detailed Description

TCPIP API internal implementations (do not use in application code)

Definition in file tcpip_priv.h.

Macro Definition Documentation

◆ API_EXPR_DEREF

#define API_EXPR_DEREF (   expr)    (*(expr))

Definition at line 92 of file tcpip_priv.h.

◆ API_EXPR_REF

#define API_EXPR_REF (   expr)    expr

Definition at line 90 of file tcpip_priv.h.

◆ API_EXPR_REF_SEM

#define API_EXPR_REF_SEM (   expr)    API_EXPR_REF(expr)

Definition at line 91 of file tcpip_priv.h.

◆ API_MSG_M_DEF

#define API_MSG_M_DEF (   m)    *m

Definition at line 93 of file tcpip_priv.h.

◆ API_MSG_M_DEF_C

#define API_MSG_M_DEF_C (   t,
  m 
)    const t * m

Definition at line 94 of file tcpip_priv.h.

◆ API_VAR_ALLOC

#define API_VAR_ALLOC (   type,
  pool,
  name,
  errorval 
)

Definition at line 86 of file tcpip_priv.h.

◆ API_VAR_ALLOC_EXT

#define API_VAR_ALLOC_EXT (   type,
  pool,
  name,
  errorblock 
)

Definition at line 85 of file tcpip_priv.h.

◆ API_VAR_ALLOC_POOL

#define API_VAR_ALLOC_POOL (   type,
  pool,
  name,
  errorval 
)

Definition at line 87 of file tcpip_priv.h.

◆ API_VAR_DECLARE

#define API_VAR_DECLARE (   type,
  name 
)    type name

Definition at line 84 of file tcpip_priv.h.

◆ API_VAR_FREE

#define API_VAR_FREE (   pool,
  name 
)

Definition at line 88 of file tcpip_priv.h.

◆ API_VAR_FREE_POOL

#define API_VAR_FREE_POOL (   pool,
  name 
)

Definition at line 89 of file tcpip_priv.h.

◆ API_VAR_REF

#define API_VAR_REF (   name)    name

Definition at line 83 of file tcpip_priv.h.

Typedef Documentation

◆ tcpip_api_call_fn

typedef err_t(* tcpip_api_call_fn) (struct tcpip_api_call_data *call)

Definition at line 110 of file tcpip_priv.h.

Enumeration Type Documentation

◆ tcpip_msg_type

Enumerator
TCPIP_MSG_API 
TCPIP_MSG_API_CALL 
TCPIP_MSG_INPKT 
TCPIP_MSG_CALLBACK 
TCPIP_MSG_CALLBACK_STATIC 
TCPIP_MSG_CALLBACK_STATIC_WAIT 

Definition at line 113 of file tcpip_priv.h.

113 {
114#if !LWIP_TCPIP_CORE_LOCKING
117#endif /* !LWIP_TCPIP_CORE_LOCKING */
118#if !LWIP_TCPIP_CORE_LOCKING_INPUT
120#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
121#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
122 TCPIP_MSG_TIMEOUT,
123 TCPIP_MSG_UNTIMEOUT,
124#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
128};
@ TCPIP_MSG_CALLBACK_STATIC
Definition: tcpip_priv.h:126
@ TCPIP_MSG_CALLBACK
Definition: tcpip_priv.h:125
@ TCPIP_MSG_CALLBACK_STATIC_WAIT
Definition: tcpip_priv.h:127
@ TCPIP_MSG_INPKT
Definition: tcpip_priv.h:119
@ TCPIP_MSG_API
Definition: tcpip_priv.h:115
@ TCPIP_MSG_API_CALL
Definition: tcpip_priv.h:116

Function Documentation

◆ tcpip_api_call()

err_t tcpip_api_call ( tcpip_api_call_fn  fn,
struct tcpip_api_call_data call 
)

Synchronously calls function in TCPIP thread and waits for its completion. 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
fnFunction to call
callCall parameters
Returns
Return value from tcpip_api_call_fn

Definition at line 478 of file tcpip.c.

479{
480#if LWIP_TCPIP_CORE_LOCKING
481 err_t err;
483 err = fn(call);
485 return err;
486#else /* LWIP_TCPIP_CORE_LOCKING */
488
489#if !LWIP_NETCONN_SEM_PER_THREAD
490 err_t err = sys_sem_new(&call->sem, 0);
491 if (err != ERR_OK) {
492 return err;
493 }
494#endif /* LWIP_NETCONN_SEM_PER_THREAD */
495
496 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
497
500 TCPIP_MSG_VAR_REF(msg).msg.api_call.arg = call;
501 TCPIP_MSG_VAR_REF(msg).msg.api_call.function = fn;
502#if LWIP_NETCONN_SEM_PER_THREAD
504#else /* LWIP_NETCONN_SEM_PER_THREAD */
505 TCPIP_MSG_VAR_REF(msg).msg.api_call.sem = &call->sem;
506#endif /* LWIP_NETCONN_SEM_PER_THREAD */
508 sys_arch_sem_wait(TCPIP_MSG_VAR_REF(msg).msg.api_call.sem, 0);
510
511#if !LWIP_NETCONN_SEM_PER_THREAD
512 sys_sem_free(&call->sem);
513#endif /* LWIP_NETCONN_SEM_PER_THREAD */
514
515 return call->err;
516#endif /* LWIP_TCPIP_CORE_LOCKING */
517}
#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
#define LWIP_NETCONN_THREAD_SEM_GET()
Definition: sys_arch.h:74
#define err(...)
#define sys_mbox_valid_val(mbox)
Definition: sys.h:395
#define TCPIP_MSG_VAR_ALLOC(name)
Definition: tcpip.c:55
static sys_mbox_t tcpip_mbox
Definition: tcpip.c:61
#define TCPIP_MSG_VAR_FREE(name)
Definition: tcpip.c:56
#define TCPIP_MSG_VAR_REF(name)
Definition: tcpip.c:53
#define TCPIP_MSG_VAR_DECLARE(name)
Definition: tcpip.c:54
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

◆ tcpip_send_msg_wait_sem()

err_t tcpip_send_msg_wait_sem ( tcpip_callback_fn  fn,
void apimsg,
sys_sem_t sem 
)

Sends a message to TCPIP thread to call a function. Caller thread blocks on on a provided semaphore, which ist NOT automatically signalled by TCPIP thread, this has to be done by the user. It is recommended to use LWIP_TCPIP_CORE_LOCKING since this is the way with least runtime overhead.

Parameters
fnfunction to be called from TCPIP thread
apimsgargument to API function
semsemaphore to wait on
Returns
ERR_OK if the function was called, another err_t if not

Definition at line 442 of file tcpip.c.

443{
444#if LWIP_TCPIP_CORE_LOCKING
447 fn(apimsg);
449 return ERR_OK;
450#else /* LWIP_TCPIP_CORE_LOCKING */
452
453 LWIP_ASSERT("semaphore not initialized", sys_sem_valid(sem));
454 LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
455
458 TCPIP_MSG_VAR_REF(msg).msg.api_msg.function = fn;
459 TCPIP_MSG_VAR_REF(msg).msg.api_msg.msg = apimsg;
463 return ERR_OK;
464#endif /* LWIP_TCPIP_CORE_LOCKING */
465}
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:373
#define sys_sem_valid(sema)
Definition: sys_arch.h:36
static HANDLE sem
Definition: sync.c:674