The Pedigree Project 0.1
api_msg.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_API_MSG_H
57#define LWIP_HDR_API_MSG_H
58
59#include "lwip/opt.h"
60
61#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
62/* Note: Netconn API is always available when sockets are enabled -
63 * sockets are implemented on top of them */
64
65#include "lwip/arch.h"
66#include "lwip/ip_addr.h"
67#include "lwip/err.h"
68#include "lwip/sys.h"
69#include "lwip/igmp.h"
70#include "lwip/api.h"
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77#if LWIP_MPU_COMPATIBLE
78#if LWIP_NETCONN_SEM_PER_THREAD
79#define API_MSG_M_DEF_SEM(m) *m
80#else
81#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
82#endif
83#else /* LWIP_MPU_COMPATIBLE */
84#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
85#endif /* LWIP_MPU_COMPATIBLE */
86
87/* For the netconn API, these values are use as a bitmask! */
88#define NETCONN_SHUT_RD 1
89#define NETCONN_SHUT_WR 2
90#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
91
92/* IP addresses and port numbers are expected to be in
93 * the same byte order as in the corresponding pcb.
94 */
98struct api_msg {
101 struct netconn *conn;
103 err_t err;
105 union {
107 struct netbuf *b;
109 struct {
110 u8_t proto;
111 } n;
113 struct {
114 API_MSG_M_DEF_C(ip_addr_t, ipaddr);
115 u16_t port;
116 } bc;
118 struct {
119 ip_addr_t API_MSG_M_DEF(ipaddr);
120 u16_t API_MSG_M_DEF(port);
121 u8_t local;
122 } ad;
124 struct {
125 const void *dataptr;
126 size_t len;
127 u8_t apiflags;
128#if LWIP_SO_SNDTIMEO
129 u32_t time_started;
130#endif /* LWIP_SO_SNDTIMEO */
131 } w;
133 struct {
134 u32_t len;
135 } r;
136#if LWIP_TCP
138 struct {
139 u8_t shut;
140#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
141 u32_t time_started;
142#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
143 u8_t polls_left;
144#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
145 } sd;
146#endif /* LWIP_TCP */
147#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
149 struct {
150 API_MSG_M_DEF_C(ip_addr_t, multiaddr);
151 API_MSG_M_DEF_C(ip_addr_t, netif_addr);
152 enum netconn_igmp join_or_leave;
153 } jl;
154#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
155#if TCP_LISTEN_BACKLOG
156 struct {
157 u8_t backlog;
158 } lb;
159#endif /* TCP_LISTEN_BACKLOG */
160 } msg;
161#if LWIP_NETCONN_SEM_PER_THREAD
162 sys_sem_t* op_completed_sem;
163#endif /* LWIP_NETCONN_SEM_PER_THREAD */
164};
165
166#if LWIP_NETCONN_SEM_PER_THREAD
167#define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem)
168#else /* LWIP_NETCONN_SEM_PER_THREAD */
169#define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed)
170#endif /* LWIP_NETCONN_SEM_PER_THREAD */
171
172
173#if LWIP_DNS
178struct dns_api_msg {
180#if LWIP_MPU_COMPATIBLE
181 char name[DNS_MAX_NAME_LENGTH];
182#else /* LWIP_MPU_COMPATIBLE */
183 const char *name;
184#endif /* LWIP_MPU_COMPATIBLE */
186 ip_addr_t API_MSG_M_DEF(addr);
187#if LWIP_IPV4 && LWIP_IPV6
189 u8_t dns_addrtype;
190#endif /* LWIP_IPV4 && LWIP_IPV6 */
193 sys_sem_t API_MSG_M_DEF_SEM(sem);
195 err_t API_MSG_M_DEF(err);
196};
197#endif /* LWIP_DNS */
198
199#if LWIP_TCP
200extern u8_t netconn_aborted;
201#endif /* LWIP_TCP */
202
203void lwip_netconn_do_newconn (void *m);
204void lwip_netconn_do_delconn (void *m);
205void lwip_netconn_do_bind (void *m);
206void lwip_netconn_do_connect (void *m);
207void lwip_netconn_do_disconnect (void *m);
208void lwip_netconn_do_listen (void *m);
209void lwip_netconn_do_send (void *m);
210void lwip_netconn_do_recv (void *m);
211#if TCP_LISTEN_BACKLOG
212void lwip_netconn_do_accepted (void *m);
213#endif /* TCP_LISTEN_BACKLOG */
214void lwip_netconn_do_write (void *m);
215void lwip_netconn_do_getaddr (void *m);
216void lwip_netconn_do_close (void *m);
217void lwip_netconn_do_shutdown (void *m);
218#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
219void lwip_netconn_do_join_leave_group(void *m);
220#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
221
222#if LWIP_DNS
223void lwip_netconn_do_gethostbyname(void *arg);
224#endif /* LWIP_DNS */
225
226struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
227void netconn_free(struct netconn *conn);
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif /* LWIP_NETCONN || LWIP_SOCKET */
234
235#endif /* LWIP_HDR_API_MSG_H */
s8_t err_t
Definition err.h:76
#define DNS_MAX_NAME_LENGTH
Definition opt.h:1040