00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LWIP_TCPIP_H__
00033 #define __LWIP_TCPIP_H__
00034
00035 #include "lwip/opt.h"
00036
00037 #if !NO_SYS
00038
00039 #include "lwip/api_msg.h"
00040 #include "lwip/netifapi.h"
00041 #include "lwip/pbuf.h"
00042 #include "lwip/api.h"
00043 #include "lwip/sys.h"
00044 #include "lwip/netif.h"
00045
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049
00050 #if LWIP_TCPIP_CORE_LOCKING
00051
00052 extern sys_sem_t lock_tcpip_core;
00053 #define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core)
00054 #define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core)
00055 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
00056 #define TCPIP_APIMSG_ACK(m)
00057 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
00058 #define TCPIP_NETIFAPI_ACK(m)
00059 #else
00060 #define LOCK_TCPIP_CORE()
00061 #define UNLOCK_TCPIP_CORE()
00062 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
00063 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(m->conn->op_completed)
00064 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
00065 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
00066 #endif
00067
00068 void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
00069
00070 #if LWIP_NETCONN
00071 err_t tcpip_apimsg(struct api_msg *apimsg);
00072 #if LWIP_TCPIP_CORE_LOCKING
00073 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
00074 #endif
00075 #endif
00076
00077 err_t tcpip_input(struct pbuf *p, struct netif *inp);
00078
00079 #if LWIP_NETIF_API
00080 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
00081 #if LWIP_TCPIP_CORE_LOCKING
00082 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
00083 #endif
00084 #endif
00085
00086 err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
00087 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
00088
00089
00090 err_t pbuf_free_callback(struct pbuf *p);
00091 err_t mem_free_callback(void *m);
00092
00093 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
00094 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
00095
00096 enum tcpip_msg_type {
00097 #if LWIP_NETCONN
00098 TCPIP_MSG_API,
00099 #endif
00100 TCPIP_MSG_INPKT,
00101 #if LWIP_NETIF_API
00102 TCPIP_MSG_NETIFAPI,
00103 #endif
00104 TCPIP_MSG_CALLBACK,
00105 TCPIP_MSG_TIMEOUT,
00106 TCPIP_MSG_UNTIMEOUT
00107 };
00108
00109 struct tcpip_msg {
00110 enum tcpip_msg_type type;
00111 sys_sem_t *sem;
00112 union {
00113 #if LWIP_NETCONN
00114 struct api_msg *apimsg;
00115 #endif
00116 #if LWIP_NETIF_API
00117 struct netifapi_msg *netifapimsg;
00118 #endif
00119 struct {
00120 struct pbuf *p;
00121 struct netif *netif;
00122 } inp;
00123 struct {
00124 void (*f)(void *ctx);
00125 void *ctx;
00126 } cb;
00127 struct {
00128 u32_t msecs;
00129 sys_timeout_handler h;
00130 void *arg;
00131 } tmo;
00132 } msg;
00133 };
00134
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138
00139 #endif
00140
00141 #endif