summaryrefslogtreecommitdiff
path: root/ACE/ace/os_include/sys/os_socket.h
blob: dbdba632729eb52430ea91bc58083737f0a04827 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// -*- C++ -*-

//=============================================================================
/**
 *  @file    os_socket.h
 *
 *  main sockets header
 *
 *  @author Don Hinton <dhinton@dresystems.com>
 *  @author This code was originally in various places including ace/OS.h.
 */
//=============================================================================

#ifndef ACE_OS_INCLUDE_SYS_OS_SOCKET_H
#define ACE_OS_INCLUDE_SYS_OS_SOCKET_H

#include /**/ "ace/pre.h"

#include /**/ "ace/config-lite.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/os_include/sys/os_uio.h"

#if !defined (ACE_LACKS_SYS_SOCKET_H)
#  include /**/ <sys/socket.h>
#endif /* !ACE_LACKS_SYS_SOCKET_H */

#if defined (ACE_USES_SOCKET_H)
#  include /**/ <socket.h>
#endif /* ACE_USES_SOCKET_H */

#if defined (ACE_USES_SOCKLIB_H)
#  include /**/ <sockLib.h>
#endif /* ACE_USES_SOCKLIB_H */

// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

#if !defined (ACE_HAS_MSG)
   struct msghdr {};
#endif /* ACE_HAS_MSG */

#if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
#  if !defined (msg_accrights)
#    undef msg_control
#    define msg_accrights msg_control
#  endif /* ! msg_accrights */

#  if !defined (msg_accrightslen)
#    undef msg_controllen
#    define msg_accrightslen msg_controllen
#  endif /* ! msg_accrightslen */
#endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */

# if defined (ACE_LACKS_SOCKADDR)
    struct sockaddr {
            u_char  sa_len;                 /* total length */
            u_char  sa_family;              /* address family */
            char    sa_data[14];            /* actually longer; address value */
    };
# endif /* ACE_LACKS_SOCKADDR */

# if defined (ACE_LACKS_LINGER)
    struct  linger {
          int     l_onoff;                /* option on/off */
          int     l_linger;               /* linger time */
    };
# endif /* ACE_LACKS_LINGER */

#if defined (ACE_WIN32)
   struct msghdr
   {
     /// Optional address
     sockaddr * msg_name;

     /// Size of address
     int msg_namelen;

     /// Scatter/gather array
     iovec *msg_iov;

     /// # elements in msg_iov
     int msg_iovlen;

     /// Access rights sent/received
     caddr_t msg_accrights;

     int msg_accrightslen;
   };
#endif /* ACE_WIN32 */

#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
   // Control message size to pass a file descriptor.
#  define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */

// Increase the range of "address families".  Please note that this
// must appear _after_ the include of sys/socket.h, for the AF_FILE
// definition on Linux/glibc2.
#if !defined (AF_ANY)
#  define AF_ANY (-1)
#endif /* AF_ANY */

#if !defined (AF_UNSPEC)
#  define AF_UNSPEC 0
#endif /* AF_UNSPEC */

#if !defined (AF_LOCAL)
#  define AF_LOCAL 1
#endif /* AF_LOCAL */

#if !defined (AF_UNIX)
#  define AF_UNIX AF_LOCAL
#endif /* AF_UNIX */

#if !defined (AF_INET)
#  define AF_INET 2
#endif /* AF_INET */

#if !defined (PF_INET)
#  define PF_INET AF_INET
#endif /* PF_INET */

#if !defined (PF_LOCAL)
#  define PF_LOCAL AF_LOCAL
#endif /* PF_LOCAL */

#if !defined (PF_UNIX)
#  define PF_UNIX PF_LOCAL
#endif /* PF_UNIX */

#if !defined (AF_MAX)
#  define AF_MAX 29
#endif /* AF_MAX */

#if !defined (PF_UNSPEC)
#  define PF_UNSPEC 0
#endif /* PF_UNSPEC */

#define AF_SPIPE (AF_MAX + 1)
#if !defined (AF_FILE)
#  define AF_FILE (AF_MAX + 2)
#endif /* ! AF_FILE */
#define AF_DEV (AF_MAX + 3)
#define AF_UPIPE (AF_SPIPE)

#if !defined (MSG_OOB)
#  define MSG_OOB 0x1
#endif /* MSG_OOB */

#if !defined (MSG_PEEK)
#  define MSG_PEEK 0x2
#endif /* MSG_PEEK */

#if !defined (SOCK_STREAM)
#  define SOCK_STREAM 1
#endif /* SOCK_STREAM */

#if !defined (SOCK_DGRAM)
#  define SOCK_DGRAM 2
#endif /* SOCK_DGRAM */

#if !defined (SOCK_SEQPACKET)
#  define SOCK_SEQPACKET 5
#endif /* SOCK_SEQPACKET */

#if !defined (SOL_SOCKET)
#  define SOL_SOCKET 0xffff
#endif /* SOL_SOCKET */

#if !defined (SO_REUSEADDR)
#  define SO_REUSEADDR 0x0004
#endif /* SO_REUSEADDR */

#if !defined (SO_LINGER)
#  define SO_LINGER 0x0080
#endif /* SO_LINGER */

#if !defined (SO_SNDBUF)
#  define SO_SNDBUF 0x1001
#endif /* SO_SNDBUF */

#if !defined (SO_RCVBUF)
#  define SO_RCVBUF 0x1002
#endif /* SO_RCVBUF */

#if !defined (SO_BROADCAST)
#  define SO_BROADCAST 0x0020
#endif /* SO_BROADCAST */

#if !defined (SO_ERROR)
#  define SO_ERROR 0x1007
#endif /* SO_ERROR */

#if !defined (SCM_RIGHTS)
#  define SCM_RIGHTS 0x01
#endif /* SCM_RIGHTS */

#if defined (ACE_HAS_IPV6)
#  if defined (ACE_USES_IPV4_IPV6_MIGRATION)
#    define ACE_ADDRESS_FAMILY_INET  AF_UNSPEC
#    define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
#  else
#    define ACE_ADDRESS_FAMILY_INET AF_INET6
#    define ACE_PROTOCOL_FAMILY_INET PF_INET6
#  endif /* ACE_USES_IPV4_IPV6_MIGRATION */
#else /* !ACE_HAS_IPV6 */
#  define ACE_ADDRESS_FAMILY_INET AF_INET
#  define ACE_PROTOCOL_FAMILY_INET PF_INET
#endif /* ACE_HAS_IPV6 */

#if !defined (ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
#define ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE SSIZE_MAX
#endif /* ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE */

#if !defined (ACE_SOCKET_LEN)
#if defined (ACE_HAS_SOCKLEN_T)
#  if defined (__hpux)
  /*
  ** HP-UX supplies the socklen_t type unless some feature set less than
  ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only
  ** actually uses the socklen_t type in supplied socket functions if
  ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example,
  ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE
  ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t
  ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions
  ** to use int, not socklen_t). React to this situation here...
  */
#    if defined (_XOPEN_SOURCE_EXTENDED)
typedef socklen_t ACE_SOCKET_LEN;
#    else
typedef int ACE_SOCKET_LEN;
#    endif /* _XOPEN_SOURCE_EXTENDED */
#  else
typedef socklen_t ACE_SOCKET_LEN;
#  endif /* __hpux */
#elif defined (ACE_HAS_SIZET_SOCKET_LEN)
typedef size_t ACE_SOCKET_LEN;
#else
typedef int ACE_SOCKET_LEN;
#endif /* ACE_HAS_SIZET_SOCKET_LEN */
#endif /* ACE_SOCKET_LEN */

#if defined (ACE_HAS_NETLINK)
#  include /**/ <asm/types.h>
#  include /**/ <linux/netlink.h>
#  define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK
#endif

#if defined (ACE_HAS_LKSCTP)
extern "C"
{
#include /**/ <netinet/in.h>
#include /**/ <netinet/sctp.h>
}
#endif /* ACE_HAS_LKSCTP */

# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)

  ssize_t recv_timedwait (ACE_HANDLE handle,
                          char *buf,
                          int len,
                          int flags,
                          struct timespec *timeout);

  ssize_t recvmsg_timedwait (ACE_HANDLE handle,
                             struct msghdr *msg,
                             int flags,
                             struct timespec *timeout);

  ssize_t recvfrom_timedwait (ACE_HANDLE handle,
                              char *buf,
                              int len,
                              int flags,
                              struct sockaddr *addr,
                              int *addrlen,
                              struct timespec *timeout);

  ssize_t send_timedwait (ACE_HANDLE handle,
                          const char *buf,
                          int len,
                          int flags,
                          struct timespec *timeout);

  ssize_t sendmsg_timedwait (ACE_HANDLE handle,
                             const struct msghdr *msg,
                             int flags,
                             struct timespec *timeout);

  ssize_t sendto_timedwait (ACE_HANDLE handle,
                            const char *buf,
                            int len,
                            int flags,
                            const struct sockaddr *addr,
                            int addrlen,
                            struct timespec *timeout);

# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#include /**/ "ace/post.h"
#endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */