UbixOS V2 2.0

tcpip_priv.h
Go to the documentation of this file.
1
6 /*
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Adam Dunkels <adam@sics.se>
35 *
36 */
37 #ifndef LWIP_HDR_TCPIP_PRIV_H
38 #define LWIP_HDR_TCPIP_PRIV_H
39
40 #include "net/opt.h"
41
42 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
43
44 #include "net/tcpip.h"
45 #include "net/sys.h"
46 #include "net/timeouts.h"
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 struct pbuf;
53 struct netif;
54
55 #if LWIP_MPU_COMPATIBLE
56 #define API_VAR_REF(name) (*(name))
57 #define API_VAR_DECLARE(type, name) type * name
58 #define API_VAR_ALLOC(type, pool, name, errorval) do { \
59 name = (type *)memp_malloc(pool); \
60 if (name == NULL) { \
61 return errorval; \
62 } \
63 } while(0)
64 #define API_VAR_ALLOC_POOL(type, pool, name, errorval) do { \
65 name = (type *)LWIP_MEMPOOL_ALLOC(pool); \
66 if (name == NULL) { \
67 return errorval; \
68 } \
69 } while(0)
70 #define API_VAR_FREE(pool, name) memp_free(pool, name)
71 #define API_VAR_FREE_POOL(pool, name) LWIP_MEMPOOL_FREE(pool, name)
72 #define API_EXPR_REF(expr) (&(expr))
73 #if LWIP_NETCONN_SEM_PER_THREAD
74 #define API_EXPR_REF_SEM(expr) (expr)
75 #else
76 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
77 #endif
78 #define API_EXPR_DEREF(expr) expr
79 #define API_MSG_M_DEF(m) m
80 #define API_MSG_M_DEF_C(t, m) t m
81 #else /* LWIP_MPU_COMPATIBLE */
82 #define API_VAR_REF(name) name
83 #define API_VAR_DECLARE(type, name) type name
84 #define API_VAR_ALLOC(type, pool, name, errorval)
85 #define API_VAR_ALLOC_POOL(type, pool, name, errorval)
86 #define API_VAR_FREE(pool, name)
87 #define API_VAR_FREE_POOL(pool, name)
88 #define API_EXPR_REF(expr) expr
89 #define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
90 #define API_EXPR_DEREF(expr) (*(expr))
91 #define API_MSG_M_DEF(m) *m
92 #define API_MSG_M_DEF_C(t, m) const t * m
93 #endif /* LWIP_MPU_COMPATIBLE */
94
95 err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
96
97 struct tcpip_api_call_data
98 {
99 #if !LWIP_TCPIP_CORE_LOCKING
100 err_t err;
101 #if !LWIP_NETCONN_SEM_PER_THREAD
102 sys_sem_t sem;
103 #endif /* LWIP_NETCONN_SEM_PER_THREAD */
104 #else /* !LWIP_TCPIP_CORE_LOCKING */
105 u8_t dummy; /* avoid empty struct :-( */
106 #endif /* !LWIP_TCPIP_CORE_LOCKING */
107 };
108 typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call_data* call);
109 err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call);
110
111 enum tcpip_msg_type {
112 TCPIP_MSG_API,
113 TCPIP_MSG_API_CALL,
114 TCPIP_MSG_INPKT,
115 #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
116 TCPIP_MSG_TIMEOUT,
117 TCPIP_MSG_UNTIMEOUT,
118 #endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
119 TCPIP_MSG_CALLBACK,
120 TCPIP_MSG_CALLBACK_STATIC
121 };
122
123 struct tcpip_msg {
124 enum tcpip_msg_type type;
125 union {
126 struct {
127 tcpip_callback_fn function;
128 void* msg;
129 } api_msg;
130 struct {
131 tcpip_api_call_fn function;
132 struct tcpip_api_call_data *arg;
133 sys_sem_t *sem;
134 } api_call;
135 struct {
136 struct pbuf *p;
137 struct netif *netif;
138 netif_input_fn input_fn;
139 } inp;
140 struct {
141 tcpip_callback_fn function;
142 void *ctx;
143 } cb;
144 #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
145 struct {
146 u32_t msecs;
147 sys_timeout_handler h;
148 void *arg;
149 } tmo;
150 #endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
151 } msg;
152 };
153
154 #ifdef __cplusplus
155 }
156 #endif
157
158 #endif /* !NO_SYS */
159
160 #endif /* LWIP_HDR_TCPIP_PRIV_H */
sys.h
tcpip_msg::sem
sys_sem_t * sem
Definition: tcpip_priv.h:133
opt.h
tcpip.h
TCPIP_MSG_INPKT
Definition: tcpip_priv.h:114
tcpip_api_call_data
Definition: tcpip_priv.h:97
tcpip_api_call
err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call)
Definition: tcpip.c:356
tcpip_msg_type
tcpip_msg_type
Definition: tcpip_priv.h:111
tcpip_msg::api_msg
struct tcpip_msg::@3::@4 api_msg
tcpip_api_call_data::err
err_t err
Definition: tcpip_priv.h:100
u32_t
uint32_t u32_t
Definition: arch.h:126
netif_input_fn
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition: netif.h:170
sys_sem
Definition: sem.h:36
tcpip_msg::msg
void * msg
Definition: tcpip_priv.h:128
tcpip_api_call_data::sem
sys_sem_t sem
Definition: tcpip_priv.h:102
tcpip_msg::cb
struct tcpip_msg::@3::@7 cb
u8_t
uint8_t u8_t
Definition: arch.h:122
tcpip_msg::inp
struct tcpip_msg::@3::@6 inp
netif
Definition: netif.h:233
tcpip_msg::input_fn
netif_input_fn input_fn
Definition: tcpip_priv.h:138
tcpip_msg::type
enum tcpip_msg_type type
Definition: tcpip_priv.h:124
TCPIP_MSG_CALLBACK_STATIC
Definition: tcpip_priv.h:120
tcpip_msg
Definition: tcpip_priv.h:123
err_t
s8_t err_t
Definition: err.h:57
tcpip_send_msg_wait_sem
err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t *sem)
Definition: tcpip.c:322
TCPIP_MSG_API
Definition: tcpip_priv.h:112
tcpip_msg::netif
struct netif * netif
Definition: tcpip_priv.h:137
TCPIP_MSG_API_CALL
Definition: tcpip_priv.h:113
tcpip_msg::ctx
void * ctx
Definition: tcpip_priv.h:142
tcpip_callback_fn
void(* tcpip_callback_fn)(void *ctx)
Definition: tcpip.h:70
tcpip_msg::p
struct pbuf * p
Definition: tcpip_priv.h:136
timeouts.h
pbuf
Definition: pbuf.h:142
TCPIP_MSG_CALLBACK
Definition: tcpip_priv.h:119
tcpip_msg::arg
struct tcpip_api_call_data * arg
Definition: tcpip_priv.h:132
tcpip_msg::api_call
struct tcpip_msg::@3::@5 api_call
tcpip_api_call_fn
err_t(* tcpip_api_call_fn)(struct tcpip_api_call_data *call)
Definition: tcpip_priv.h:108