sock.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Alexander Aring <aar@pengutronix.de>
3  * Freie Universit├Ąt Berlin
4  * HAW Hamburg
5  * Kaspar Schleiser <kaspar@schleiser.de>
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser
8  * General Public License v2.1. See the file LICENSE in the top level
9  * directory for more details.
10  */
11 
102 #ifndef NET_SOCK_H
103 #define NET_SOCK_H
104 
105 #include <stdint.h>
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
111 #if defined(DOXYGEN)
112 
117 #define SOCK_HAS_IPV6
123 #define SOCK_HAS_ASYNC
124 
134 #define SOCK_HAS_ASYNC_CTX
135 
136 #endif
137 
144 #define SOCK_FLAGS_REUSE_EP (0x0001)
152 #define SOCK_ADDR_ANY_NETIF (0)
153 
157 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
158  .netif = SOCK_ADDR_ANY_NETIF }
159 
160 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
161 
164 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
165  .netif = SOCK_ADDR_ANY_NETIF }
166 #endif
167 
171 #define SOCK_NO_TIMEOUT (UINT32_MAX)
172 
176 typedef struct {
182  int family;
183 
184  union {
185 #ifdef SOCK_HAS_IPV6
186 
191  uint8_t ipv6[16];
192 #endif
193  uint8_t ipv4[4];
194  uint32_t ipv4_u32;
195  } addr;
207  uint16_t netif;
208 } sock_ip_ep_t;
209 
213 struct _sock_tl_ep {
219  int family;
220 
221  union {
222 #ifdef SOCK_HAS_IPV6
223 
228  uint8_t ipv6[16];
229 #endif
230  uint8_t ipv4[4];
231  uint32_t ipv4_u32;
232  } addr;
244  uint16_t netif;
245  uint16_t port;
246 };
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 #endif /* NET_SOCK_H */
253 
uint16_t netif
stack-specific network interface ID
Definition: sock.h:207
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:230
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:231
union _sock_tl_ep::@240 addr
address
int family
family of sock_ip_ep_t::addr
Definition: sock.h:219
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:245
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:176
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:228
Common IP-based transport layer end point.
Definition: sock.h:213
int family
family of sock_ip_ep_t::addr
Definition: sock.h:182
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:194
uint16_t netif
stack-specific network interface ID
Definition: sock.h:244