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
119 #endif
120 
127 #define SOCK_FLAGS_REUSE_EP (0x0001)
135 #define SOCK_ADDR_ANY_NETIF (0)
136 
140 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
141  .netif = SOCK_ADDR_ANY_NETIF }
142 
143 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
144 
147 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
148  .netif = SOCK_ADDR_ANY_NETIF }
149 #endif
150 
154 #define SOCK_NO_TIMEOUT (UINT32_MAX)
155 
159 typedef struct {
165  int family;
166 
167  union {
168 #ifdef SOCK_HAS_IPV6
169 
174  uint8_t ipv6[16];
175 #endif
176  uint8_t ipv4[4];
177  uint32_t ipv4_u32;
178  } addr;
190  uint16_t netif;
191 } sock_ip_ep_t;
192 
196 struct _sock_tl_ep {
202  int family;
203 
204  union {
205 #ifdef SOCK_HAS_IPV6
206 
211  uint8_t ipv6[16];
212 #endif
213  uint8_t ipv4[4];
214  uint32_t ipv4_u32;
215  } addr;
227  uint16_t netif;
228  uint16_t port;
229 };
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif /* NET_SOCK_H */
236 
uint16_t netif
stack-specific network interface ID
Definition: sock.h:190
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:213
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:214
int family
family of sock_ip_ep_t::addr
Definition: sock.h:202
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:228
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:159
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:211
Common IP-based transport layer end point.
Definition: sock.h:196
int family
family of sock_ip_ep_t::addr
Definition: sock.h:165
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:177
uint16_t netif
stack-specific network interface ID
Definition: sock.h:227
union _sock_tl_ep::@218 addr
address