acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
sockets.h
1#pragma once
2
3#define AF_UNSPEC 0
4#define AF_INET 2 // internetwork: UDP, TCP, etc.
5#define AF_INET6 23 // Internetwork Version 6
6
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12/*
13 * Basic system type definitions, taken from the BSD file sys/types.h.
14 */
15typedef ::u8 u_char;
16typedef ::u16 u_short;
17typedef ::u32 u_int;
18typedef ulong u_long;
19
20#if(_WIN32_WINNT >= 0x0501)
21typedef ::u64 u_int64;
22#endif //(_WIN32_WINNT >= 0x0501)
23
24#ifdef __cplusplus
25}
26#endif
27
28#ifndef s_addr
29/*
30 * Internet address (old style... should be updated)
31 */
32struct in_addr {
33 union {
34 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
35 struct { u_short s_w1,s_w2; } S_un_w;
36 u_long S_addr;
37 } S_un;
38#define s_addr S_un.S_addr
39 /* can be used for most tcp & ip code */
40#define s_host S_un.S_un_b.s_b2
41 /* host on imp */
42#define s_net S_un.S_un_b.s_b1
43 /* network */
44#define s_imp S_un.S_un_w.s_w2
45 /* imp */
46#define s_impno S_un.S_un_b.s_b4
47 /* imp # */
48#define s_lh S_un.S_un_b.s_b3
49 /* logical host */
50};
51#endif
52
53
54
55/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
56#ifndef USE_WS_PREFIX
57
58#undef htonl
59#undef htons
60#undef ntohl
61#undef ntohs
62
63#ifdef WORDS_BIGENDIAN
64
65#define htonl(l) ((ULONG)(l))
66#define htons(s) ((u_short)(s))
67#define ntohl(l) ((ULONG)(l))
68#define ntohs(s) ((u_short)(s))
69
70#else /* WORDS_BIGENDIAN */
71
72static inline u_short __wine_ushort_swap(u_short s)
73{
74 return (s >> 8) | (s << 8);
75}
76static inline ULONG __wine_ulong_swap(ULONG l)
77{
78 return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
79}
80#define htonl(l) __wine_ulong_swap(l)
81#define htons(s) __wine_ushort_swap(s)
82#define ntohl(l) __wine_ulong_swap(l)
83#define ntohs(s) __wine_ushort_swap(s)
84
85#endif /* WORDS_BIGENDIAN */
86
87#endif /* USE_WS_PREFIX */
88
89
90
91
92
93
94
95//
96// IPv6 Internet address (RFC 2553)
97// This is an 'on-wire' format structure.
98//
99//typedef struct in6_addr {
100// union {
101// UCHAR Byte[16];
102// USHORT Word[8];
103// } u;
104//} IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR;
105//
106//#define in_addr6 in6_addr
107//
111//#define _S6_un u
112//#define _S6_unsigned_char Byte
113//#define s6_addr _S6_un._S6_unsigned_char
114//
118//#define s6_bytes u.Byte
119//#define s6_words u.Word
120
121
122/*
123 * Structure used by kernel to store most
124 * addresses.
125 */
126//struct sockaddr {
127// u_short sa_family; /* address family */
128// ::i8 sa_data[14]; /* up to 14 bytes of direct address */
129//};
130
131/*
132 * Structure used by kernel to pass protocol
133 * information in raw sockets.
134 */
135//struct sockproto {
136// u_short sp_family; /* address family */
137// u_short sp_protocol; /* protocol */
138//};
139
140
141//
142//struct sockaddr_in
143//{
144// ::i16 sin_family;
145// ::u16 sin_port;
146// struct in_addr sin_addr;
147// ::i8 sin_zero[8];
148//};
149//
150//
151//struct sockaddr_in6
152//{
153// ::i16 sin6_family;
154// u_short sin6_port;
155// u_long sin6_flowinfo;
156// struct in6_addr sin6_addr;
157// u_long sin6_scope_id;
158//};
159//
160//
161
162//typedef struct addrinfo {
163// ::i32 ai_flags;
164// ::i32 ai_family;
165// ::i32 ai_socktype;
166// ::i32 ai_protocol;
167// size_t ai_addrlen;
168// char_pointer ai_canonname;
169// struct sockaddr *ai_addr;
170// struct addrinfo *ai_next;
171//} ADDRINFOA, *PADDRINFOA;
172
173
174
175#define AI_NUMERICHOST 0x00000004 // Nodename must be a numeric address string
176#define NI_NUMERICHOST 0x02 /* Return numeric form of the host's address */
177#define NI_NUMERICSERV 0x08 /* Return numeric form of the service (port #) */
178
179
180//typedef ::i32 SOCKET;
181
182//#define INVALID_SOCKET ((SOCKET) -1)
183
184
185
186
Definition sockets.h:32