libosmocore 1.13.1.12-8e6ea
Osmocom core library
socket_compat.h
Go to the documentation of this file.
1#define __LIBOSMOCORE_HAVE_SYS_SOCKET_H 1
2#define __LIBOSMOCORE_HAVE_NETINET_IN_H 1
3
4#if __LIBOSMOCORE_HAVE_SYS_SOCKET_H
5 #include <sys/socket.h>
6#else
7/* Minimal netinet/in.h as per POSIX https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html */
8#include <stdint.h>
9typedef uint32_t socklen_t;
10typedef unsigned short sa_family_t;
11
12struct sockaddr {
13 sa_family_t sa_family;
14 char sa_data[14];
15};
16
17struct sockaddr_storage {
18 sa_family_t ss_family;
19 char __data[128 - sizeof(sa_family_t)];
20};
21#endif /* if __LIBOSMOCORE_HAVE_SYS_SOCKET_H */
22
23#if __LIBOSMOCORE_HAVE_NETINET_IN_H
24 #include <netinet/in.h>
25#else
26/* Minimal netinet/in.h as per POSIX https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html */
27#include <stdint.h>
28
29typedef uint32_t in_addr_t;
30struct in_addr {
31 in_addr_t s_addr;
32};
33
34typedef uint16_t in_port_t;
35
36struct in6_addr {
37 union {
38 uint8_t __u6_addr8[16];
39 uint16_t __u6_addr16[8];
40 uint32_t __u6_addr32[4];
41 } __in6_u;
42 #define s6_addr __in6_u.__u6_addr8
43 #define s6_addr16 __in6_u.__u6_addr16
44 #define s6_addr32 __in6_u.__u6_addr32
45};
46
47#define INET_ADDRSTRLEN 16
48#define INET6_ADDRSTRLEN 46
49
50struct sockaddr_in {
51 sa_family_t sin_family;
52 in_port_t sin_port;
53 struct in_addr sin_addr;
54 unsigned char sin_zero[sizeof (struct sockaddr)
55 - sizeof (sa_family_t)
56 - sizeof (in_port_t)
57 - sizeof (struct in_addr)];
58};
59
60struct sockaddr_in6 {
61 sa_family_t sin6_family;
62 in_port_t sin6_port;
63 uint32_t sin6_flowinfo;
64 struct in6_addr sin6_addr;
65 uint32_t sin6_scope_id;
66};
67
68#endif /* if __LIBOSMOCORE_HAVE_NETINET_IN_H */