diff options
Diffstat (limited to 'core/lwip/src/include/lwip/tcpip.h')
-rw-r--r-- | core/lwip/src/include/lwip/tcpip.h | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/core/lwip/src/include/lwip/tcpip.h b/core/lwip/src/include/lwip/tcpip.h index 75393ee9..995ba8ad 100644 --- a/core/lwip/src/include/lwip/tcpip.h +++ b/core/lwip/src/include/lwip/tcpip.h @@ -41,31 +41,43 @@ #include "lwip/pbuf.h" #include "lwip/api.h" #include "lwip/sys.h" +#include "lwip/timers.h" #include "lwip/netif.h" #ifdef __cplusplus extern "C" { #endif +/** Define this to something that triggers a watchdog. This is called from + * tcpip_thread after processing a message. */ +#ifndef LWIP_TCPIP_THREAD_ALIVE +#define LWIP_TCPIP_THREAD_ALIVE() +#endif + #if LWIP_TCPIP_CORE_LOCKING /** The global semaphore to lock the stack. */ -extern sys_sem_t lock_tcpip_core; -#define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core) -#define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core) +extern sys_mutex_t lock_tcpip_core; +#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) +#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m) #define TCPIP_APIMSG_ACK(m) #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m) #define TCPIP_NETIFAPI_ACK(m) -#else +#else /* LWIP_TCPIP_CORE_LOCKING */ #define LOCK_TCPIP_CORE() #define UNLOCK_TCPIP_CORE() #define TCPIP_APIMSG(m) tcpip_apimsg(m) -#define TCPIP_APIMSG_ACK(m) sys_sem_signal(m->conn->op_completed) +#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed) #define TCPIP_NETIFAPI(m) tcpip_netifapi(m) -#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem) +#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem) #endif /* LWIP_TCPIP_CORE_LOCKING */ -void tcpip_init(void (* tcpip_init_done)(void *), void *arg); +/** Function prototype for the init_done function passed to tcpip_init */ +typedef void (*tcpip_init_done_fn)(void *arg); +/** Function prototype for functions passed to tcpip_callback() */ +typedef void (*tcpip_callback_fn)(void *ctx); + +void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); #if LWIP_NETCONN err_t tcpip_apimsg(struct api_msg *apimsg); @@ -83,15 +95,17 @@ err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); #endif /* LWIP_TCPIP_CORE_LOCKING */ #endif /* LWIP_NETIF_API */ -err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block); +err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) /* free pbufs or heap memory from another context without blocking */ err_t pbuf_free_callback(struct pbuf *p); err_t mem_free_callback(void *m); +#if LWIP_TCPIP_TIMEOUT err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); err_t tcpip_untimeout(sys_timeout_handler h, void *arg); +#endif /* LWIP_TCPIP_TIMEOUT */ enum tcpip_msg_type { #if LWIP_NETCONN @@ -101,9 +115,11 @@ enum tcpip_msg_type { #if LWIP_NETIF_API TCPIP_MSG_NETIFAPI, #endif /* LWIP_NETIF_API */ - TCPIP_MSG_CALLBACK, +#if LWIP_TCPIP_TIMEOUT TCPIP_MSG_TIMEOUT, - TCPIP_MSG_UNTIMEOUT + TCPIP_MSG_UNTIMEOUT, +#endif /* LWIP_TCPIP_TIMEOUT */ + TCPIP_MSG_CALLBACK }; struct tcpip_msg { @@ -121,14 +137,16 @@ struct tcpip_msg { struct netif *netif; } inp; struct { - void (*f)(void *ctx); + tcpip_callback_fn function; void *ctx; } cb; +#if LWIP_TCPIP_TIMEOUT struct { u32_t msecs; sys_timeout_handler h; void *arg; } tmo; +#endif /* LWIP_TCPIP_TIMEOUT */ } msg; }; |