STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
tcpip_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef LWIP_HDR_TCPIP_PRIV_H
33 #define LWIP_HDR_TCPIP_PRIV_H
34 
35 #include "lwip/opt.h"
36 
37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
38 
39 #include "lwip/tcpip.h"
40 #include "lwip/priv/api_msg.h"
41 #include "lwip/netifapi.h"
42 #include "lwip/pppapi.h"
43 #include "lwip/pbuf.h"
44 #include "lwip/api.h"
45 #include "lwip/sys.h"
46 #include "lwip/lwip_timers.h"
47 #include "lwip/netif.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
55 #ifndef LWIP_TCPIP_THREAD_ALIVE
56 #define LWIP_TCPIP_THREAD_ALIVE()
57 #endif
58 
59 #if LWIP_TCPIP_CORE_LOCKING
60 
61 extern sys_mutex_t lock_tcpip_core;
62 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
63 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
64 #ifdef LWIP_DEBUG
65 #define TCIP_APIMSG_SET_ERR(m, e) (m)->msg.err = e /* catch functions that don't set err */
66 #else
67 #define TCIP_APIMSG_SET_ERR(m, e)
68 #endif
69 #if LWIP_NETCONN_SEM_PER_THREAD
70 #define TCPIP_APIMSG_SET_SEM(m) ((m)->msg.op_completed_sem = LWIP_NETCONN_THREAD_SEM_GET())
71 #else
72 #define TCPIP_APIMSG_SET_SEM(m)
73 #endif
74 #define TCPIP_APIMSG_NOERR(m,f) do { \
75  TCIP_APIMSG_SET_ERR(m, ERR_VAL); \
76  TCPIP_APIMSG_SET_SEM(m); \
77  LOCK_TCPIP_CORE(); \
78  f(&((m)->msg)); \
79  UNLOCK_TCPIP_CORE(); \
80 } while(0)
81 #define TCPIP_APIMSG(m,f,e) do { \
82  TCPIP_APIMSG_NOERR(m,f); \
83  (e) = (m)->msg.err; \
84 } while(0)
85 #define TCPIP_APIMSG_ACK(m) NETCONN_SET_SAFE_ERR((m)->conn, (m)->err)
86 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
87 #define TCPIP_NETIFAPI_ACK(m)
88 #define TCPIP_PPPAPI(m) tcpip_pppapi_lock(m)
89 #define TCPIP_PPPAPI_ACK(m)
90 #else /* LWIP_TCPIP_CORE_LOCKING */
91 #define LOCK_TCPIP_CORE()
92 #define UNLOCK_TCPIP_CORE()
93 #define TCPIP_APIMSG_NOERR(m,f) do { (m)->function = f; tcpip_apimsg(m); } while(0)
94 #define TCPIP_APIMSG(m,f,e) do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0)
95 #define TCPIP_APIMSG_ACK(m) do { NETCONN_SET_SAFE_ERR((m)->conn, (m)->err); sys_sem_signal(LWIP_API_MSG_SEM(m)); } while(0)
96 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
97 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
98 #define TCPIP_PPPAPI(m) tcpip_pppapi(m)
99 #define TCPIP_PPPAPI_ACK(m) sys_sem_signal(&m->sem)
100 #endif /* LWIP_TCPIP_CORE_LOCKING */
101 
102 
103 #if LWIP_MPU_COMPATIBLE
104 #define API_VAR_REF(name) (*(name))
105 #define API_VAR_DECLARE(type, name) type * name
106 #define API_VAR_ALLOC(type, pool, name) do { \
107  name = (type *)memp_malloc(pool); \
108  if (name == NULL) { \
109  return ERR_MEM; \
110  } \
111  } while(0)
112 #define API_VAR_ALLOC_DONTFAIL(type, pool, name) do { \
113  name = (type *)memp_malloc(pool); \
114  LWIP_ASSERT("pool empty", name != NULL); \
115  } while(0)
116 #define API_VAR_FREE(pool, name) memp_free(pool, name)
117 #define API_EXPR_REF(expr) &(expr)
118 #if LWIP_NETCONN_SEM_PER_THREAD
119 #define API_EXPR_REF_SEM(expr) (expr)
120 #else
121 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
122 #endif
123 #define API_EXPR_DEREF(expr) expr
124 #else /* LWIP_MPU_COMPATIBLE */
125 #define API_VAR_REF(name) name
126 #define API_VAR_DECLARE(type, name) type name
127 #define API_VAR_ALLOC(type, pool, name)
128 #define API_VAR_ALLOC_DONTFAIL(type, pool, name)
129 #define API_VAR_FREE(pool, name)
130 #define API_EXPR_REF(expr) expr
131 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
132 #define API_EXPR_DEREF(expr) *(expr)
133 #endif /* LWIP_MPU_COMPATIBLE */
134 
135 
136 #if LWIP_NETCONN || LWIP_SOCKET
137 err_t tcpip_apimsg(struct api_msg *apimsg);
138 #endif /* LWIP_NETCONN || LWIP_SOCKET */
139 
140 #if PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE
141 err_t tcpip_pppos_input(struct pbuf *p, struct netif *inp);
142 #endif /* PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE */
143 
144 #if LWIP_NETIF_API
145 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
146 #if LWIP_TCPIP_CORE_LOCKING
147 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
148 #endif /* LWIP_TCPIP_CORE_LOCKING */
149 #endif /* LWIP_NETIF_API */
150 
151 #if LWIP_PPP_API
152 err_t tcpip_pppapi(struct pppapi_msg *pppapimsg);
153 #if LWIP_TCPIP_CORE_LOCKING
154 err_t tcpip_pppapi_lock(struct pppapi_msg *pppapimsg);
155 #endif /* LWIP_TCPIP_CORE_LOCKING */
156 #endif /* LWIP_PPP_API */
157 
158 
160 #if LWIP_NETCONN || LWIP_SOCKET
161  TCPIP_MSG_API,
162 #endif /* LWIP_NETCONN || LWIP_SOCKET */
164 #if PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE
165  TCPIP_MSG_INPKT_PPPOS,
166 #endif /* PPPOS_SUPPORT && !PPP_INPROC_IRQ_SAFE */
167 #if LWIP_NETIF_API
168  TCPIP_MSG_NETIFAPI,
169 #endif /* LWIP_NETIF_API */
170 #if LWIP_PPP_API
171  TCPIP_MSG_PPPAPI,
172 #endif /* LWIP_PPP_API */
173 #if LWIP_TCPIP_TIMEOUT
174  TCPIP_MSG_TIMEOUT,
175  TCPIP_MSG_UNTIMEOUT,
176 #endif /* LWIP_TCPIP_TIMEOUT */
179 };
180 
181 struct tcpip_msg {
184  union {
185 #if LWIP_NETCONN || LWIP_SOCKET
186  struct api_msg *apimsg;
187 #endif /* LWIP_NETCONN || LWIP_SOCKET */
188 #if LWIP_NETIF_API
189  struct netifapi_msg *netifapimsg;
190 #endif /* LWIP_NETIF_API */
191 #if LWIP_PPP_API
192  struct pppapi_msg *pppapimsg;
193 #endif /* LWIP_PPP_API */
194  struct {
195  struct pbuf *p;
196  struct netif *netif;
197  } inp;
198  struct {
200  void *ctx;
201  } cb;
202 #if LWIP_TCPIP_TIMEOUT
203  struct {
204  u32_t msecs;
206  void *arg;
207  } tmo;
208 #endif /* LWIP_TCPIP_TIMEOUT */
209  } msg;
210 };
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif /* !NO_SYS */
217 
218 #endif /* LWIP_HDR_TCPIP_PRIV_H */
219 
void(* tcpip_callback_fn)(void *ctx)
Definition: tcpip.h:51
struct pbuf * p
Definition: tcpip_priv.h:195
struct netif * netif
Definition: tcpip_priv.h:196
sys_sem_t * sem
Definition: tcpip_priv.h:183
unsigned long u32_t
Definition: cc.h:42
Definition: pbuf.h:108
union tcpip_msg::@48 msg
s8_t err_t
Definition: err.h:47
osSemaphoreId sys_sem_t
Definition: sys_arch.h:44
Definition: netif.h:182
void(* sys_timeout_handler)(void *arg)
Definition: lwip_timers.h:65
enum tcpip_msg_type type
Definition: tcpip_priv.h:182
struct tcpip_msg::@48::@49 inp
struct tcpip_msg::@48::@50 cb
void * ctx
Definition: tcpip_priv.h:200
tcpip_msg_type
Definition: tcpip_priv.h:159
osSemaphoreId sys_mutex_t
Definition: sys_arch.h:45