mptcpd
Multipath TCP Daemon
sockaddr.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
10 #ifndef MPTCPD_PRIVATE_SOCKADDR_H
11 #define MPTCPD_PRIVATE_SOCKADDR_H
12 
13 #include <stdbool.h>
14 #include <endian.h>
15 #include <byteswap.h>
16 
17 #include <netinet/in.h> // For in_addr_t.
18 
19 #include <mptcpd/export.h>
20 
28 #if __BYTE_ORDER == __LITTLE_ENDIAN
29 # define MPTCPD_CONSTANT_HTONS(hs) __bswap_constant_16(hs)
30 # define MPTCPD_CONSTANT_HTONL(hl) __bswap_constant_32(hl)
31 #else
32 // No need to swap bytes on big endian platforms.
33 // host byte order == network byte order
34 # define MPTCPD_CONSTANT_HTONS(hs) hs
35 # define MPTCPD_CONSTANT_HTONL(hl) hl
36 #endif // __BYTE_ORDER == __LITTLE_ENDIAN
38 
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 struct in6_addr;
45 struct sockaddr_storage;
46 
61 MPTCPD_API bool
62 mptcpd_sockaddr_storage_init(in_addr_t const *addr4,
63  struct in6_addr const *addr6,
64  in_port_t port,
65  struct sockaddr_storage *addr);
66 
80 MPTCPD_API struct sockaddr *
81 mptcpd_sockaddr_copy(struct sockaddr const *sa);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 
88 #endif /* MPTCPD_PRIVATE_SOCKADDR_H */
89 
90 
91 /*
92  Local Variables:
93  c-file-style: "linux"
94  End:
95 */
mptcpd shared library symbol export/import macros.
MPTCPD_API struct sockaddr * mptcpd_sockaddr_copy(struct sockaddr const *sa)
Deep copy a sockaddr.
Definition: sockaddr.c:50
MPTCPD_API bool mptcpd_sockaddr_storage_init(in_addr_t const *addr4, struct in6_addr const *addr6, in_port_t port, struct sockaddr_storage *addr)
Initialize sockaddr_storage instance.
Definition: sockaddr.c:22