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