Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of F7_Ethernet by
tcpip.h
00001 /* 00002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 #ifndef __LWIP_TCPIP_H__ 00033 #define __LWIP_TCPIP_H__ 00034 00035 #include "lwip/opt.h" 00036 00037 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */ 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 /** Define this to something that triggers a watchdog. This is called from 00052 * tcpip_thread after processing a message. */ 00053 #ifndef LWIP_TCPIP_THREAD_ALIVE 00054 #define LWIP_TCPIP_THREAD_ALIVE() 00055 #endif 00056 00057 #if LWIP_TCPIP_CORE_LOCKING 00058 /** The global semaphore to lock the stack. */ 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 /* LWIP_TCPIP_CORE_LOCKING */ 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 /* LWIP_TCPIP_CORE_LOCKING */ 00074 00075 /** Function prototype for the init_done function passed to tcpip_init */ 00076 typedef void (*tcpip_init_done_fn)(void *arg); 00077 /** Function prototype for functions passed to tcpip_callback() */ 00078 typedef void (*tcpip_callback_fn)(void *ctx); 00079 00080 /* Forward declarations */ 00081 struct tcpip_callback_msg; 00082 00083 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); 00084 00085 //[MS_CHANGE] 00086 err_t tcpip_shutdown(); 00087 //[END_MS_CHANGE] 00088 00089 #if LWIP_NETCONN 00090 err_t tcpip_apimsg(struct api_msg *apimsg); 00091 #if LWIP_TCPIP_CORE_LOCKING 00092 err_t tcpip_apimsg_lock(struct api_msg *apimsg); 00093 #endif /* LWIP_TCPIP_CORE_LOCKING */ 00094 #endif /* LWIP_NETCONN */ 00095 00096 err_t tcpip_input(struct pbuf *p, struct netif *inp); 00097 00098 #if LWIP_NETIF_API 00099 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg); 00100 #if LWIP_TCPIP_CORE_LOCKING 00101 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); 00102 #endif /* LWIP_TCPIP_CORE_LOCKING */ 00103 #endif /* LWIP_NETIF_API */ 00104 00105 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); 00106 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) 00107 00108 struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx); 00109 void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg); 00110 err_t tcpip_trycallback(struct tcpip_callback_msg* msg); 00111 00112 /* free pbufs or heap memory from another context without blocking */ 00113 err_t pbuf_free_callback(struct pbuf *p); 00114 err_t mem_free_callback(void *m); 00115 00116 #if LWIP_TCPIP_TIMEOUT 00117 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); 00118 err_t tcpip_untimeout(sys_timeout_handler h, void *arg); 00119 #endif /* LWIP_TCPIP_TIMEOUT */ 00120 00121 enum tcpip_msg_type { 00122 #if LWIP_NETCONN 00123 TCPIP_MSG_API, 00124 #endif /* LWIP_NETCONN */ 00125 TCPIP_MSG_INPKT, 00126 #if LWIP_NETIF_API 00127 TCPIP_MSG_NETIFAPI, 00128 #endif /* LWIP_NETIF_API */ 00129 #if LWIP_TCPIP_TIMEOUT 00130 TCPIP_MSG_TIMEOUT, 00131 TCPIP_MSG_UNTIMEOUT, 00132 #endif /* LWIP_TCPIP_TIMEOUT */ 00133 TCPIP_MSG_CALLBACK, 00134 TCPIP_MSG_CALLBACK_STATIC, 00135 //[MS_CHANGE] 00136 TCPIP_MSG_SHUTDOWN 00137 //[END_MS_CHANGE] 00138 }; 00139 00140 struct tcpip_msg { 00141 enum tcpip_msg_type type; 00142 sys_sem_t *sem; 00143 union { 00144 #if LWIP_NETCONN 00145 struct api_msg *apimsg; 00146 #endif /* LWIP_NETCONN */ 00147 #if LWIP_NETIF_API 00148 struct netifapi_msg *netifapimsg; 00149 #endif /* LWIP_NETIF_API */ 00150 struct { 00151 struct pbuf *p; 00152 struct netif *netif; 00153 } inp; 00154 struct { 00155 tcpip_callback_fn function; 00156 void *ctx; 00157 } cb; 00158 #if LWIP_TCPIP_TIMEOUT 00159 struct { 00160 u32_t msecs; 00161 sys_timeout_handler h; 00162 void *arg; 00163 } tmo; 00164 #endif /* LWIP_TCPIP_TIMEOUT */ 00165 } msg; 00166 }; 00167 00168 #ifdef __cplusplus 00169 } 00170 #endif 00171 00172 #endif /* !NO_SYS */ 00173 00174 #endif /* __LWIP_TCPIP_H__ */
Generated on Tue Jul 12 2022 21:19:02 by
1.7.2
