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