UbixOS V2 2.0

api_msg.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_API_MSG_H
38 #define LWIP_HDR_API_MSG_H
39
40 #include "net/opt.h"
41
42 #if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
43 /* Note: Netconn API is always available when sockets are enabled -
44 * sockets are implemented on top of them */
45
46 #include "net/arch.h"
47 #include "net/ip_addr.h"
48 #include "net/err.h"
49 #include "net/sys.h"
50 #include "net/igmp.h"
51 #include "net/api.h"
52 #include "net/priv/tcpip_priv.h"
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #if LWIP_MPU_COMPATIBLE
59 #if LWIP_NETCONN_SEM_PER_THREAD
60 #define API_MSG_M_DEF_SEM(m) *m
61 #else
62 #define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
63 #endif
64 #else /* LWIP_MPU_COMPATIBLE */
65 #define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
66 #endif /* LWIP_MPU_COMPATIBLE */
67
68 /* For the netconn API, these values are use as a bitmask! */
69 #define NETCONN_SHUT_RD 1
70 #define NETCONN_SHUT_WR 2
71 #define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
72
73 /* IP addresses and port numbers are expected to be in
74 * the same byte order as in the corresponding pcb.
75 */
79 struct api_msg {
82 struct netconn *conn;
84 err_t err;
86 union {
88 struct netbuf *b;
90 struct {
91 u8_t proto;
92 } n;
94 struct {
95 API_MSG_M_DEF_C(ip_addr_t, ipaddr);
96 u16_t port;
97 } bc;
99 struct {
100 ip_addr_t API_MSG_M_DEF(ipaddr);
101 u16_t API_MSG_M_DEF(port);
102 u8_t local;
103 } ad;
105 struct {
106 const void *dataptr;
107 size_t len;
108 u8_t apiflags;
109 #if LWIP_SO_SNDTIMEO
110 u32_t time_started;
111 #endif /* LWIP_SO_SNDTIMEO */
112 } w;
114 struct {
115 u32_t len;
116 } r;
117 #if LWIP_TCP
118
119 struct {
120 u8_t shut;
121 #if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
122 u32_t time_started;
123 #else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
124 u8_t polls_left;
125 #endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
126 } sd;
127 #endif /* LWIP_TCP */
128 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
129
130 struct {
131 API_MSG_M_DEF_C(ip_addr_t, multiaddr);
132 API_MSG_M_DEF_C(ip_addr_t, netif_addr);
133 enum netconn_igmp join_or_leave;
134 } jl;
135 #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
136 #if TCP_LISTEN_BACKLOG
137 struct {
138 u8_t backlog;
139 } lb;
140 #endif /* TCP_LISTEN_BACKLOG */
141 } msg;
142 #if LWIP_NETCONN_SEM_PER_THREAD
143 sys_sem_t* op_completed_sem;
144 #endif /* LWIP_NETCONN_SEM_PER_THREAD */
145 };
146
147 #if LWIP_NETCONN_SEM_PER_THREAD
148 #define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem)
149 #else /* LWIP_NETCONN_SEM_PER_THREAD */
150 #define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed)
151 #endif /* LWIP_NETCONN_SEM_PER_THREAD */
152
153
154 #if LWIP_DNS
155
159 struct dns_api_msg {
161 #if LWIP_MPU_COMPATIBLE
162 char name[DNS_MAX_NAME_LENGTH];
163 #else /* LWIP_MPU_COMPATIBLE */
164 const char *name;
165 #endif /* LWIP_MPU_COMPATIBLE */
166
167 ip_addr_t API_MSG_M_DEF(addr);
168 #if LWIP_IPV4 && LWIP_IPV6
169
170 u8_t dns_addrtype;
171 #endif /* LWIP_IPV4 && LWIP_IPV6 */
172
174 sys_sem_t API_MSG_M_DEF_SEM(sem);
176 err_t API_MSG_M_DEF(err);
177 };
178 #endif /* LWIP_DNS */
179
180 #if LWIP_TCP
181 extern u8_t netconn_aborted;
182 #endif /* LWIP_TCP */
183
184 void lwip_netconn_do_newconn (void *m);
185 void lwip_netconn_do_delconn (void *m);
186 void lwip_netconn_do_bind (void *m);
187 void lwip_netconn_do_connect (void *m);
188 void lwip_netconn_do_disconnect (void *m);
189 void lwip_netconn_do_listen (void *m);
190 void lwip_netconn_do_send (void *m);
191 void lwip_netconn_do_recv (void *m);
192 #if TCP_LISTEN_BACKLOG
193 void lwip_netconn_do_accepted (void *m);
194 #endif /* TCP_LISTEN_BACKLOG */
195 void lwip_netconn_do_write (void *m);
196 void lwip_netconn_do_getaddr (void *m);
197 void lwip_netconn_do_close (void *m);
198 void lwip_netconn_do_shutdown (void *m);
199 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
200 void lwip_netconn_do_join_leave_group(void *m);
201 #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
202
203 #if LWIP_DNS
204 void lwip_netconn_do_gethostbyname(void *arg);
205 #endif /* LWIP_DNS */
206
207 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
208 void netconn_free(struct netconn *conn);
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214 #endif /* LWIP_NETCONN || LWIP_SOCKET */
215
216 #endif /* LWIP_HDR_API_MSG_H */
API_MSG_M_DEF
#define API_MSG_M_DEF(m)
Definition: tcpip_priv.h:91
tcpip_priv.h
sys.h
opt.h
DNS_MAX_NAME_LENGTH
#define DNS_MAX_NAME_LENGTH
Definition: lwipopts.h:159
u16_t
uint16_t u16_t
Definition: arch.h:124
igmp.h
u32_t
uint32_t u32_t
Definition: arch.h:126
sys_sem
Definition: sem.h:36
arch.h
u8_t
uint8_t u8_t
Definition: arch.h:122
err.h
ip_addr_t
ip6_addr_t ip_addr_t
Definition: ip_addr.h:290
err_t
s8_t err_t
Definition: err.h:57
name
const char * name
Definition: pci.c:37
ip_addr.h
api.h
API_MSG_M_DEF_C
#define API_MSG_M_DEF_C(t, m)
Definition: tcpip_priv.h:92