The friendly Operating System for the Internet of Things
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 
101 #ifndef NET_SOCK_H
102 #define NET_SOCK_H
103 
104 #include <stdint.h>
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109 
110 #if defined(DOXYGEN)
111 
116 #define SOCK_HAS_IPV6
118 #endif
119 
126 #define SOCK_FLAGS_REUSE_EP (0x0001)
134 #define SOCK_ADDR_ANY_NETIF (0)
135 
139 #define SOCK_IPV4_EP_ANY { .family = AF_INET, \
140  .netif = SOCK_ADDR_ANY_NETIF }
141 
142 #if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
143 
146 #define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
147  .netif = SOCK_ADDR_ANY_NETIF }
148 #endif
149 
153 #define SOCK_NO_TIMEOUT (UINT32_MAX)
154 
158 typedef struct {
164  int family;
165 
166  union {
167 #ifdef SOCK_HAS_IPV6
168 
173  uint8_t ipv6[16];
174 #endif
175  uint8_t ipv4[4];
176  uint32_t ipv4_u32;
177  } addr;
189  uint16_t netif;
190 } sock_ip_ep_t;
191 
195 struct _sock_tl_ep {
201  int family;
202 
203  union {
204 #ifdef SOCK_HAS_IPV6
205 
210  uint8_t ipv6[16];
211 #endif
212  uint8_t ipv4[4];
213  uint32_t ipv4_u32;
214  } addr;
226  uint16_t netif;
227  uint16_t port;
228 };
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif /* NET_SOCK_H */
235 
uint16_t netif
stack-specific network interface ID
Definition: sock.h:189
uint8_t ipv4[4]
IPv4 address mode.
Definition: sock.h:212
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:213
int family
family of sock_ip_ep_t::addr
Definition: sock.h:201
uint16_t port
transport layer port (in host byte order)
Definition: sock.h:227
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:158
union _sock_tl_ep::@151 addr
address
uint8_t ipv6[16]
IPv6 address mode.
Definition: sock.h:210
Common IP-based transport layer end point.
Definition: sock.h:195
int family
family of sock_ip_ep_t::addr
Definition: sock.h:164
uint32_t ipv4_u32
IPv4 address in network byte order
Definition: sock.h:176
uint16_t netif
stack-specific network interface ID
Definition: sock.h:226