ReactOS 0.4.15-dev-8219-ge8b88cf
tcpip.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_TCPIP_H__
33#define __LWIP_TCPIP_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/api_msg.h"
40#include "lwip/netifapi.h"
41#include "lwip/pbuf.h"
42#include "lwip/api.h"
43#include "lwip/sys.h"
44#include "lwip/timers.h"
45#include "lwip/netif.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
53#ifndef LWIP_TCPIP_THREAD_ALIVE
54#define LWIP_TCPIP_THREAD_ALIVE()
55#endif
56
57#if LWIP_TCPIP_CORE_LOCKING
59extern sys_mutex_t lock_tcpip_core;
60#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
61#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
62#define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
63#define TCPIP_APIMSG_ACK(m)
64#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
65#define TCPIP_NETIFAPI_ACK(m)
66#else /* LWIP_TCPIP_CORE_LOCKING */
67#define LOCK_TCPIP_CORE()
68#define UNLOCK_TCPIP_CORE()
69#define TCPIP_APIMSG(m) tcpip_apimsg(m)
70#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
71#define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
72#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
73#endif /* LWIP_TCPIP_CORE_LOCKING */
74
76typedef void (*tcpip_init_done_fn)(void *arg);
78typedef void (*tcpip_callback_fn)(void *ctx);
79
80/* Forward declarations */
81struct tcpip_callback_msg;
82
84
85#if LWIP_NETCONN
86err_t tcpip_apimsg(struct api_msg *apimsg);
87#if LWIP_TCPIP_CORE_LOCKING
88err_t tcpip_apimsg_lock(struct api_msg *apimsg);
89#endif /* LWIP_TCPIP_CORE_LOCKING */
90#endif /* LWIP_NETCONN */
91
92err_t tcpip_input(struct pbuf *p, struct netif *inp);
93
94#if LWIP_NETIF_API
95err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
96#if LWIP_TCPIP_CORE_LOCKING
97err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
98#endif /* LWIP_TCPIP_CORE_LOCKING */
99#endif /* LWIP_NETIF_API */
100
102#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
103
104struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx);
105void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg);
106err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
107
108/* free pbufs or heap memory from another context without blocking */
111
112#if LWIP_TCPIP_TIMEOUT
113err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
114err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
115#endif /* LWIP_TCPIP_TIMEOUT */
116
118#if LWIP_NETCONN
119 TCPIP_MSG_API,
120#endif /* LWIP_NETCONN */
122#if LWIP_NETIF_API
123 TCPIP_MSG_NETIFAPI,
124#endif /* LWIP_NETIF_API */
125#if LWIP_TCPIP_TIMEOUT
126 TCPIP_MSG_TIMEOUT,
127 TCPIP_MSG_UNTIMEOUT,
128#endif /* LWIP_TCPIP_TIMEOUT */
132
133struct tcpip_msg {
136 union {
137#if LWIP_NETCONN
138 struct api_msg *apimsg;
139#endif /* LWIP_NETCONN */
140#if LWIP_NETIF_API
141 struct netifapi_msg *netifapimsg;
142#endif /* LWIP_NETIF_API */
143 struct {
144 struct pbuf *p;
145 struct netif *netif;
147 struct {
149 void *ctx;
150 } cb;
151#if LWIP_TCPIP_TIMEOUT
152 struct {
153 u32_t msecs;
155 void *arg;
156 } tmo;
157#endif /* LWIP_TCPIP_TIMEOUT */
159};
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif /* !NO_SYS */
166
167#endif /* __LWIP_TCPIP_H__ */
#define msg(x)
Definition: auth_time.c:54
unsigned long u32_t
Definition: cc.h:25
unsigned char u8_t
Definition: cc.h:23
s8_t err_t
Definition: err.h:47
struct tcpip_callback_msg * tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx)
Definition: tcpip.c:411
tcpip_msg_type
Definition: tcpip.h:117
@ TCPIP_MSG_CALLBACK_STATIC
Definition: tcpip.h:130
@ TCPIP_MSG_CALLBACK
Definition: tcpip.h:129
@ TCPIP_MSG_INPKT
Definition: tcpip.h:121
void(* tcpip_callback_fn)(void *ctx)
Definition: tcpip.h:78
err_t mem_free_callback(void *m)
Definition: tcpip.c:509
err_t pbuf_free_callback(struct pbuf *p)
Definition: tcpip.c:496
void(* tcpip_init_done_fn)(void *arg)
Definition: tcpip.h:76
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block)
Definition: tcpip.c:214
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg)
Definition: tcpip.c:458
void tcpip_callbackmsg_delete(struct tcpip_callback_msg *msg)
Definition: tcpip.c:428
err_t tcpip_trycallback(struct tcpip_callback_msg *msg)
Definition: tcpip.c:441
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition: tcpip.c:164
GLfloat GLfloat p
Definition: glext.h:8902
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
Definition: netif.h:136
Definition: pbuf.h:79
struct tcpip_msg::@1048::@1049 inp
enum tcpip_msg_type type
Definition: tcpip.h:134
sys_sem_t * sem
Definition: tcpip.h:135
struct netif * netif
Definition: tcpip.h:145
union tcpip_msg::@1048 msg
void * ctx
Definition: tcpip.h:149
struct pbuf * p
Definition: tcpip.h:144
tcpip_callback_fn function
Definition: tcpip.h:148
struct tcpip_msg::@1048::@1050 cb
static tcpip_init_done_fn tcpip_init_done
Definition: tcpip.c:56
void(* sys_timeout_handler)(void *arg)
Definition: timers.h:65
void * arg
Definition: msvc.h:10
static unsigned int block
Definition: xmlmemory.c:101