-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
100 lines (81 loc) · 2.13 KB
/
types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** types.h - types needed in sendip and not defined everywhere
* Created by Mike Ricketts <mike@earth.li>
*/
#ifndef _SENDIP_TYPES_H
#define _SENDIP_TYPES_H
#include <sys/types.h>
/* C99+ feature */
#include <stdbool.h>
#ifndef FALSE
#define TRUE true
#define FALSE false
#endif
/* Solaris doesn't define these */
#ifdef __sun
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint8_t u_int8_t;
/* disable ipv6 on solaris */
#define gethostbyname2(x,y) gethostbyname(x)
#endif /* __sun */
/* for things that *really* don't know about ipv6, ... */
#ifndef AF_INET6
#define AF_INET6 10
#define IPPROTO_ICMPV6 58
#define IPPROTO_NONE 59
#define IPPROTO_DSTOPTS 60
#endif /* !AF_INET6 */
#ifndef s6_addr
struct in6_addr {
union {
u_int8_t u6_addr8[16];
u_int16_t u6_addr16[8];
u_int32_t u6_addr32[4];
} in6_u;
#define s6_addr in6_u.u6_addr8
#define s6_add16 in6_u.u6_addr16
#define s6_add32 in6_u.u6_addr32
};
extern const struct in6_addr in6addr_any; /* :: */
extern const struct in6_addr in6addr_loopback; /* ::1 */
struct sockaddr_in6 {
u_int16_t sin6_family;
u_int16_t sin6_port;
u_int32_t sin6_flowinfo;
struct in6_addr sin6_addr;
u_int32_t sin6_scope_id;
};
extern int inet_pton (int af, const char *cp, void *buf);
#endif /* !s6_addr */
/* Convert _BIG_ENDIAN/_LITTLE_ENDIAN to __BYTE_ORDER */
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
#ifndef __BYTE_ORDER
/* Not linux-style, maybe FreeBSD-style */
#ifdef BYTE_ORDER
#undef __LITTLE_ENDIAN
#undef __BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BIG_ENDIAN BIG_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#else
/* Not FreeBSD-style, try solaris style */
#ifdef _BIG_ENDIAN
#define __BYTE_ORDER __BIG_ENDIAN
#else /* not _BIG_ENDIAN */
#ifdef _LITTLE_ENDIAN
#define __BYTE_ORDER __LITTLE_ENDIAN
#else /* not _LITTLE_ENDIAN */
/* Not solaris style. Give up. */
#error Could not guess your byte order
#endif /* not _LITTLE_ENDIAN */
#endif /* not _BIG_ENDIAN */
#endif /* not BYTE_ORDER */
#endif /* not __BYTE_ORDER */
#endif /* _SENDIP_TYPES_H */
/* vim: ts=4 sw=4 filetype=c
*/