FreeRTOS
[armadillo_firmware.git] / FreeRTOS / Common / ethernet / lwIP_130 / src / include / lwip / tcpip.h
blob782243782c2d6b57a43595b699b9ce212f6ee324
1 /*
2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
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.
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.
27 * This file is part of the lwIP TCP/IP stack.
29 * Author: Adam Dunkels <adam@sics.se>
32 #ifndef __LWIP_TCPIP_H__
33 #define __LWIP_TCPIP_H__
35 #include "lwip/opt.h"
37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
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"
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
49 #if LWIP_TCPIP_CORE_LOCKING
50 /** The global semaphore to lock the stack. */
51 extern sys_sem_t lock_tcpip_core;
52 #define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core)
53 #define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core)
54 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
55 #define TCPIP_APIMSG_ACK(m)
56 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
57 #define TCPIP_NETIFAPI_ACK(m)
58 #else
59 #define LOCK_TCPIP_CORE()
60 #define UNLOCK_TCPIP_CORE()
61 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
62 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(m->conn->op_completed)
63 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
64 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
65 #endif /* LWIP_TCPIP_CORE_LOCKING */
67 void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
69 #if LWIP_NETCONN
70 err_t tcpip_apimsg(struct api_msg *apimsg);
71 #if LWIP_TCPIP_CORE_LOCKING
72 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
73 #endif /* LWIP_TCPIP_CORE_LOCKING */
74 #endif /* LWIP_NETCONN */
76 err_t tcpip_input(struct pbuf *p, struct netif *inp);
78 #if LWIP_NETIF_API
79 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
80 #if LWIP_TCPIP_CORE_LOCKING
81 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
82 #endif /* LWIP_TCPIP_CORE_LOCKING */
83 #endif /* LWIP_NETIF_API */
85 err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
86 #define tcpip_callback(f,ctx) tcpip_callback_with_block(f,ctx,1)
88 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
89 #define tcpip_untimeout(h, arg) tcpip_timeout(0xffffffff, h, arg)
91 enum tcpip_msg_type {
92 #if LWIP_NETCONN
93 TCPIP_MSG_API,
94 #endif /* LWIP_NETCONN */
95 TCPIP_MSG_INPKT,
96 #if LWIP_NETIF_API
97 TCPIP_MSG_NETIFAPI,
98 #endif /* LWIP_NETIF_API */
99 TCPIP_MSG_CALLBACK,
100 TCPIP_MSG_TIMEOUT
103 struct tcpip_msg {
104 enum tcpip_msg_type type;
105 sys_sem_t *sem;
106 union {
107 #if LWIP_NETCONN
108 struct api_msg *apimsg;
109 #endif /* LWIP_NETCONN */
110 #if LWIP_NETIF_API
111 struct netifapi_msg *netifapimsg;
112 #endif /* LWIP_NETIF_API */
113 struct {
114 struct pbuf *p;
115 struct netif *netif;
116 } inp;
117 struct {
118 void (*f)(void *ctx);
119 void *ctx;
120 } cb;
121 struct {
122 u32_t msecs;
123 sys_timeout_handler h;
124 void *arg;
125 } tmo;
126 } msg;
129 #ifdef __cplusplus
131 #endif
133 #endif /* !NO_SYS */
135 #endif /* __LWIP_TCPIP_H__ */