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 OmniWheels by
tcpip_priv.h
00001 /** 00002 * @file 00003 * TCPIP API internal implementations (do not use in application code) 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_TCPIP_PRIV_H 00038 #define LWIP_HDR_TCPIP_PRIV_H 00039 00040 #include "lwip/opt.h" 00041 00042 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */ 00043 00044 #include "lwip/tcpip.h" 00045 #include "lwip/sys.h" 00046 #include "lwip/timeouts.h" 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 struct pbuf; 00053 struct netif; 00054 00055 #if LWIP_MPU_COMPATIBLE 00056 #define API_VAR_REF(name) (*(name)) 00057 #define API_VAR_DECLARE(type, name) type * name 00058 #define API_VAR_ALLOC(type, pool, name, errorval) do { \ 00059 name = (type *)memp_malloc(pool); \ 00060 if (name == NULL) { \ 00061 return errorval; \ 00062 } \ 00063 } while(0) 00064 #define API_VAR_ALLOC_POOL(type, pool, name, errorval) do { \ 00065 name = (type *)LWIP_MEMPOOL_ALLOC(pool); \ 00066 if (name == NULL) { \ 00067 return errorval; \ 00068 } \ 00069 } while(0) 00070 #define API_VAR_FREE(pool, name) memp_free(pool, name) 00071 #define API_VAR_FREE_POOL(pool, name) LWIP_MEMPOOL_FREE(pool, name) 00072 #define API_EXPR_REF(expr) (&(expr)) 00073 #if LWIP_NETCONN_SEM_PER_THREAD 00074 #define API_EXPR_REF_SEM(expr) (expr) 00075 #else 00076 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) 00077 #endif 00078 #define API_EXPR_DEREF(expr) expr 00079 #define API_MSG_M_DEF(m) m 00080 #define API_MSG_M_DEF_C(t, m) t m 00081 #else /* LWIP_MPU_COMPATIBLE */ 00082 #define API_VAR_REF(name) name 00083 #define API_VAR_DECLARE(type, name) type name 00084 #define API_VAR_ALLOC(type, pool, name, errorval) 00085 #define API_VAR_ALLOC_POOL(type, pool, name, errorval) 00086 #define API_VAR_FREE(pool, name) 00087 #define API_VAR_FREE_POOL(pool, name) 00088 #define API_EXPR_REF(expr) expr 00089 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) 00090 #define API_EXPR_DEREF(expr) (*(expr)) 00091 #define API_MSG_M_DEF(m) *m 00092 #define API_MSG_M_DEF_C(t, m) const t * m 00093 #endif /* LWIP_MPU_COMPATIBLE */ 00094 00095 err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem); 00096 00097 struct tcpip_api_call_data 00098 { 00099 #if !LWIP_TCPIP_CORE_LOCKING 00100 err_t err; 00101 #if !LWIP_NETCONN_SEM_PER_THREAD 00102 sys_sem_t sem; 00103 #endif /* LWIP_NETCONN_SEM_PER_THREAD */ 00104 #else /* !LWIP_TCPIP_CORE_LOCKING */ 00105 u8_t dummy; /* avoid empty struct :-( */ 00106 #endif /* !LWIP_TCPIP_CORE_LOCKING */ 00107 }; 00108 typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call_data* call); 00109 err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call); 00110 00111 enum tcpip_msg_type { 00112 TCPIP_MSG_API, 00113 TCPIP_MSG_API_CALL, 00114 TCPIP_MSG_INPKT, 00115 #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS 00116 TCPIP_MSG_TIMEOUT, 00117 TCPIP_MSG_UNTIMEOUT, 00118 #endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ 00119 TCPIP_MSG_CALLBACK, 00120 TCPIP_MSG_CALLBACK_STATIC 00121 }; 00122 00123 struct tcpip_msg { 00124 enum tcpip_msg_type type; 00125 union { 00126 struct { 00127 tcpip_callback_fn function; 00128 void* msg; 00129 } api_msg; 00130 struct { 00131 tcpip_api_call_fn function; 00132 struct tcpip_api_call_data *arg; 00133 sys_sem_t *sem; 00134 } api_call; 00135 struct { 00136 struct pbuf *p; 00137 struct netif *netif; 00138 netif_input_fn input_fn; 00139 } inp; 00140 struct { 00141 tcpip_callback_fn function; 00142 void *ctx; 00143 } cb; 00144 #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS 00145 struct { 00146 u32_t msecs; 00147 sys_timeout_handler h; 00148 void *arg; 00149 } tmo; 00150 #endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ 00151 } msg; 00152 }; 00153 00154 #ifdef __cplusplus 00155 } 00156 #endif 00157 00158 #endif /* !NO_SYS */ 00159 00160 #endif /* LWIP_HDR_TCPIP_PRIV_H */
Generated on Fri Jul 22 2022 04:54:02 by
 1.7.2
 1.7.2 
    