Loading...
Searching...
No Matches
sock.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Alexander Aring <aar@pengutronix.de>
3 * SPDX-FileCopyrightText: 2016 Freie Universität Berlin
4 * SPDX-FileCopyrightText: 2016 HAW Hamburg
5 * SPDX-FileCopyrightText: 2016 Kaspar Schleiser <kaspar@schleiser.de>
6 * SPDX-License-Identifier: LGPL-2.1-only
7 */
8
9#pragma once
10
100
101#include <stdint.h>
102#include <stddef.h>
103#include "iolist.h"
104
105#ifdef __cplusplus
106extern "C" {
107#endif
108
109#if defined(DOXYGEN)
115#define SOCK_HAS_IPV6
121#define SOCK_HAS_ASYNC
132#define SOCK_HAS_ASYNC_CTX
134#endif
135
142#define SOCK_FLAGS_REUSE_EP (0x0001)
143#define SOCK_FLAGS_CONNECT_REMOTE (0x0002)
145
150#define SOCK_ADDR_ANY_NETIF (0)
151
155#define SOCK_IPV4_EP_ANY { .family = AF_INET, \
156 .netif = SOCK_ADDR_ANY_NETIF }
157
158#if defined(SOCK_HAS_IPV6) || defined(DOXYGEN)
162#define SOCK_IPV6_EP_ANY { .family = AF_INET6, \
163 .netif = SOCK_ADDR_ANY_NETIF }
164#endif
165
169#define SOCK_NO_TIMEOUT (UINT32_MAX)
170
174typedef struct {
181
182 union {
183#ifdef SOCK_HAS_IPV6
189 uint8_t ipv6[16];
190#endif
191 uint8_t ipv4[4];
192 uint32_t ipv4_u32;
193 } addr;
194
205 uint16_t netif;
207
218
219 union {
220#ifdef SOCK_HAS_IPV6
226 uint8_t ipv6[16];
227#endif
228 uint8_t ipv4[4];
229 uint32_t ipv4_u32;
231
242 uint16_t netif;
243 uint16_t port;
244};
245
249enum {
264 SOCK_AUX_GET_LOCAL = (1LU << 0),
302 SOCK_AUX_GET_RSSI = (1LU << 2),
317 SOCK_AUX_SET_LOCAL = (1LU << 3),
332 SOCK_AUX_GET_TTL = (1LU << 4),
333};
334
345typedef uint8_t sock_aux_flags_t;
346
347#ifdef __cplusplus
348}
349#endif
350
uint8_t sock_aux_flags_t
Type holding the flags used to request specific auxiliary data.
Definition sock.h:345
@ SOCK_AUX_GET_TTL
Flag to request the TTL value of received frame.
Definition sock.h:332
@ SOCK_AUX_SET_LOCAL
Flag to set the local address/endpoint.
Definition sock.h:317
@ SOCK_AUX_GET_LOCAL
Flag to request the local address/endpoint.
Definition sock.h:264
@ SOCK_AUX_GET_TIMESTAMP
Flag to request the time stamp of transmission / reception.
Definition sock.h:286
@ SOCK_AUX_GET_RSSI
Flag to request the RSSI value of received frame.
Definition sock.h:302
iolist scatter / gather IO
Common IP-based transport layer end point.
Definition sock.h:211
uint16_t port
transport layer port (in host byte order)
Definition sock.h:243
int family
family of sock_ip_ep_t::addr
Definition sock.h:217
union _sock_tl_ep::@145104007015077003173063335316042002054250273140 addr
address
uint32_t ipv4_u32
IPv4 address in network byte order
Definition sock.h:229
uint16_t netif
stack-specific network interface ID
Definition sock.h:242
uint8_t ipv4[4]
IPv4 address mode.
Definition sock.h:228
uint8_t ipv6[16]
IPv6 address mode.
Definition sock.h:226
Abstract IP end point and end point for a raw IP sock object.
Definition sock.h:174
uint32_t ipv4_u32
IPv4 address in network byte order
Definition sock.h:192
uint16_t netif
stack-specific network interface ID
Definition sock.h:205
uint8_t ipv6[16]
IPv6 address mode.
Definition sock.h:189
int family
family of sock_ip_ep_t::addr
Definition sock.h:180
uint8_t ipv4[4]
IPv4 address mode.
Definition sock.h:191