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)
117 #define SOCK_HAS_IPV6
123 #define SOCK_HAS_ASYNC
134 #define SOCK_HAS_ASYNC_CTX
136 #endif
137 
144 #define SOCK_FLAGS_REUSE_EP (0x0001)
151 #define SOCK_ADDR_ANY_NETIF (0)
152 
156 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
157  .netif = SOCK_ADDR_ANY_NETIF }
158 
159 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
163 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
164  .netif = SOCK_ADDR_ANY_NETIF }
165 #endif
166 
170 #define SOCK_NO_TIMEOUT (UINT32_MAX)
171 
175 typedef struct {
181  int family;
182 
183  union {
184 #ifdef SOCK_HAS_IPV6
190  uint8_t ipv6[16];
191 #endif
192  uint8_t ipv4[4];
193  uint32_t ipv4_u32;
194  } addr;
206  uint16_t netif;
207 } sock_ip_ep_t;
208 
212 struct _sock_tl_ep {
218  int family;
219 
220  union {
221 #ifdef SOCK_HAS_IPV6
227  uint8_t ipv6[16];
228 #endif
229  uint8_t ipv4[4];
230  uint32_t ipv4_u32;
231  } addr;
243  uint16_t netif;
244  uint16_t port;
245 };
246 
250 enum {
265  SOCK_AUX_GET_LOCAL = (1LU << 0),
303  SOCK_AUX_GET_RSSI = (1LU << 2),
304 };
305 
316 typedef uint8_t sock_aux_flags_t;
317 
318 #ifdef __cplusplus
319 }
320 #endif
321 
322 #endif /* NET_SOCK_H */
uint8_t sock_aux_flags_t
Type holding the flags used to request specific auxiliary data.
Definition: sock.h:316
@ SOCK_AUX_GET_LOCAL
Flag to request the local address/endpoint.
Definition: sock.h:265
@ SOCK_AUX_GET_TIMESTAMP
Flag to request the time stamp of transmission / reception.
Definition: sock.h:287
@ SOCK_AUX_GET_RSSI
Flag to request the RSSI value of received frame.
Definition: sock.h:303
Common IP-based transport layer end point.
Definition: sock.h:212
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:244
int family
family of sock_ip_ep_t::addr
Definition: sock.h:218
union _sock_tl_ep::@350 addr
address
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:230
uint16_t netif
stack-specific network interface ID
Definition: sock.h:243
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:229
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:227
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:175
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:193
uint16_t netif
stack-specific network interface ID
Definition: sock.h:206
int family
family of sock_ip_ep_t::addr
Definition: sock.h:181