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 #include <stddef.h>
107 #include "iolist.h"
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
113 #if defined(DOXYGEN)
119 #define SOCK_HAS_IPV6
125 #define SOCK_HAS_ASYNC
136 #define SOCK_HAS_ASYNC_CTX
138 #endif
139 
146 #define SOCK_FLAGS_REUSE_EP (0x0001)
153 #define SOCK_ADDR_ANY_NETIF (0)
154 
158 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
159  .netif = SOCK_ADDR_ANY_NETIF }
160 
161 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
165 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
166  .netif = SOCK_ADDR_ANY_NETIF }
167 #endif
168 
172 #define SOCK_NO_TIMEOUT (UINT32_MAX)
173 
177 typedef struct {
183  int family;
184 
185  union {
186 #ifdef SOCK_HAS_IPV6
192  uint8_t ipv6[16];
193 #endif
194  uint8_t ipv4[4];
195  uint32_t ipv4_u32;
196  } addr;
208  uint16_t netif;
209 } sock_ip_ep_t;
210 
214 struct _sock_tl_ep {
220  int family;
221 
222  union {
223 #ifdef SOCK_HAS_IPV6
229  uint8_t ipv6[16];
230 #endif
231  uint8_t ipv4[4];
232  uint32_t ipv4_u32;
233  } addr;
245  uint16_t netif;
246  uint16_t port;
247 };
248 
252 enum {
267  SOCK_AUX_GET_LOCAL = (1LU << 0),
305  SOCK_AUX_GET_RSSI = (1LU << 2),
320  SOCK_AUX_SET_LOCAL = (1LU << 3),
321 };
322 
333 typedef uint8_t sock_aux_flags_t;
334 
335 #ifdef __cplusplus
336 }
337 #endif
338 
339 #endif /* NET_SOCK_H */
uint8_t sock_aux_flags_t
Type holding the flags used to request specific auxiliary data.
Definition: sock.h:333
@ SOCK_AUX_SET_LOCAL
Flag to set the local address/endpoint.
Definition: sock.h:320
@ SOCK_AUX_GET_LOCAL
Flag to request the local address/endpoint.
Definition: sock.h:267
@ SOCK_AUX_GET_TIMESTAMP
Flag to request the time stamp of transmission / reception.
Definition: sock.h:289
@ SOCK_AUX_GET_RSSI
Flag to request the RSSI value of received frame.
Definition: sock.h:305
iolist scatter / gather IO
Common IP-based transport layer end point.
Definition: sock.h:214
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:246
union _sock_tl_ep::@357 addr
address
int family
family of sock_ip_ep_t::addr
Definition: sock.h:220
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:232
uint16_t netif
stack-specific network interface ID
Definition: sock.h:245
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:231
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:229
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:177
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:195
uint16_t netif
stack-specific network interface ID
Definition: sock.h:208
int family
family of sock_ip_ep_t::addr
Definition: sock.h:183