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)
147 #define SOCK_FLAGS_CONNECT_REMOTE (0x0002)
154 #define SOCK_ADDR_ANY_NETIF (0)
155 
159 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
160  .netif = SOCK_ADDR_ANY_NETIF }
161 
162 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
166 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
167  .netif = SOCK_ADDR_ANY_NETIF }
168 #endif
169 
173 #define SOCK_NO_TIMEOUT (UINT32_MAX)
174 
178 typedef struct {
184  int family;
185 
186  union {
187 #ifdef SOCK_HAS_IPV6
193  uint8_t ipv6[16];
194 #endif
195  uint8_t ipv4[4];
196  uint32_t ipv4_u32;
197  } addr;
209  uint16_t netif;
210 } sock_ip_ep_t;
211 
215 struct _sock_tl_ep {
221  int family;
222 
223  union {
224 #ifdef SOCK_HAS_IPV6
230  uint8_t ipv6[16];
231 #endif
232  uint8_t ipv4[4];
233  uint32_t ipv4_u32;
234  } addr;
246  uint16_t netif;
247  uint16_t port;
248 };
249 
253 enum {
268  SOCK_AUX_GET_LOCAL = (1LU << 0),
306  SOCK_AUX_GET_RSSI = (1LU << 2),
321  SOCK_AUX_SET_LOCAL = (1LU << 3),
322 };
323 
334 typedef uint8_t sock_aux_flags_t;
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif /* NET_SOCK_H */
uint8_t sock_aux_flags_t
Type holding the flags used to request specific auxiliary data.
Definition: sock.h:334
@ SOCK_AUX_SET_LOCAL
Flag to set the local address/endpoint.
Definition: sock.h:321
@ SOCK_AUX_GET_LOCAL
Flag to request the local address/endpoint.
Definition: sock.h:268
@ SOCK_AUX_GET_TIMESTAMP
Flag to request the time stamp of transmission / reception.
Definition: sock.h:290
@ SOCK_AUX_GET_RSSI
Flag to request the RSSI value of received frame.
Definition: sock.h:306
iolist scatter / gather IO
Common IP-based transport layer end point.
Definition: sock.h:215
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:247
union _sock_tl_ep::@357 addr
address
int family
family of sock_ip_ep_t::addr
Definition: sock.h:221
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:233
uint16_t netif
stack-specific network interface ID
Definition: sock.h:246
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:232
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:230
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:178
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:196
uint16_t netif
stack-specific network interface ID
Definition: sock.h:209
int family
family of sock_ip_ep_t::addr
Definition: sock.h:184