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/timers.h"
00045 #include "lwip/netif.h"
00046
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050
00051
00052
00053 #ifndef LWIP_TCPIP_THREAD_ALIVE
00054 #define LWIP_TCPIP_THREAD_ALIVE()
00055 #endif
00056
00057 #if LWIP_TCPIP_CORE_LOCKING
00058
00059 extern sys_mutex_t lock_tcpip_core;
00060 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
00061 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
00062 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
00063 #define TCPIP_APIMSG_ACK(m)
00064 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
00065 #define TCPIP_NETIFAPI_ACK(m)
00066 #else
00067 #define LOCK_TCPIP_CORE()
00068 #define UNLOCK_TCPIP_CORE()
00069 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
00070 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
00071 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
00072 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
00073 #endif
00074
00075
00076 typedef void (*tcpip_init_done_fn)(void *arg);
00077
00078 typedef void (*tcpip_callback_fn)(void *ctx);
00079
00080
00081 struct tcpip_callback_msg;
00082
00083 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
00084
00085 #if LWIP_NETCONN
00086 err_t tcpip_apimsg(struct api_msg *apimsg);
00087 #if LWIP_TCPIP_CORE_LOCKING
00088 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
00089 #endif
00090 #endif
00091
00092 err_t tcpip_input(struct pbuf *p, struct netif *inp);
00093
00094 #if LWIP_NETIF_API
00095 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
00096 #if LWIP_TCPIP_CORE_LOCKING
00097 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
00098 #endif
00099 #endif
00100
00101 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
00102 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
00103
00104 struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx);
00105 void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg);
00106 err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
00107
00108
00109 err_t pbuf_free_callback(struct pbuf *p);
00110 err_t mem_free_callback(void *m);
00111
00112 #if LWIP_TCPIP_TIMEOUT
00113 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
00114 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
00115 #endif
00116
00117 enum tcpip_msg_type {
00118 #if LWIP_NETCONN
00119 TCPIP_MSG_API,
00120 #endif
00121 TCPIP_MSG_INPKT,
00122 #if LWIP_NETIF_API
00123 TCPIP_MSG_NETIFAPI,
00124 #endif
00125 #if LWIP_TCPIP_TIMEOUT
00126 TCPIP_MSG_TIMEOUT,
00127 TCPIP_MSG_UNTIMEOUT,
00128 #endif
00129 TCPIP_MSG_CALLBACK,
00130 TCPIP_MSG_CALLBACK_STATIC
00131 };
00132
00133 struct tcpip_msg {
00134 enum tcpip_msg_type type;
00135 sys_sem_t *sem;
00136 union {
00137 #if LWIP_NETCONN
00138 struct api_msg *apimsg;
00139 #endif
00140 #if LWIP_NETIF_API
00141 struct netifapi_msg *netifapimsg;
00142 #endif
00143 struct {
00144 struct pbuf *p;
00145 struct netif *netif;
00146 } inp;
00147 struct {
00148 tcpip_callback_fn function;
00149 void *ctx;
00150 } cb;
00151 #if LWIP_TCPIP_TIMEOUT
00152 struct {
00153 u32_t msecs;
00154 sys_timeout_handler h;
00155 void *arg;
00156 } tmo;
00157 #endif
00158 } msg;
00159 };
00160
00161 #ifdef __cplusplus
00162 }
00163 #endif
00164
00165 #endif
00166
00167 #endif