os_socket.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    os_socket.h
00006  *
00007  *  main sockets header
00008  *
00009  *  $Id: os_socket.h 80826 2008-03-04 14:51:23Z wotte $
00010  *
00011  *  @author Don Hinton <dhinton@dresystems.com>
00012  *  @author This code was originally in various places including ace/OS.h.
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_OS_INCLUDE_SYS_OS_SOCKET_H
00017 #define ACE_OS_INCLUDE_SYS_OS_SOCKET_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "ace/config-lite.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "ace/os_include/sys/os_uio.h"
00028 
00029 #if !defined (ACE_LACKS_SYS_SOCKET_H)
00030 #  include /**/ <sys/socket.h>
00031 #endif /* !ACE_LACKS_SYS_SOCKET_H */
00032 
00033 #if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
00034 #  include /**/ <sockLib.h>
00035 #endif /* ACE_VXWORKS */
00036 
00037 // Place all additions (especially function declarations) within extern "C" {}
00038 #ifdef __cplusplus
00039 extern "C"
00040 {
00041 #endif /* __cplusplus */
00042 
00043 #if !defined (ACE_HAS_MSG) && !defined (SCO)
00044    struct msghdr {};
00045 #endif /* ACE_HAS_MSG */
00046 
00047 #if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
00048 #  if !defined (msg_accrights)
00049 #    undef msg_control
00050 #    define msg_accrights msg_control
00051 #  endif /* ! msg_accrights */
00052 
00053 #  if !defined (msg_accrightslen)
00054 #    undef msg_controllen
00055 #    define msg_accrightslen msg_controllen
00056 #  endif /* ! msg_accrightslen */
00057 #endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */
00058 
00059 # if defined (ACE_LACKS_SOCKADDR)
00060     struct sockaddr {
00061             u_char  sa_len;                 /* total length */
00062             u_char  sa_family;              /* address family */
00063             char    sa_data[14];            /* actually longer; address value */
00064     };
00065 # endif /* ACE_LACKS_SOCKADDR */
00066 
00067 # if defined (ACE_LACKS_LINGER)
00068     struct  linger {
00069           int     l_onoff;                /* option on/off */
00070           int     l_linger;               /* linger time */
00071     };
00072 # endif /* ACE_LACKS_LINGER */
00073 
00074 #if defined (ACE_WIN32)
00075    struct msghdr
00076    {
00077      /// Optional address
00078      sockaddr * msg_name;
00079 
00080      /// Size of address
00081      int msg_namelen;
00082 
00083      /// Scatter/gather array
00084      iovec *msg_iov;
00085 
00086      /// # elements in msg_iov
00087      int msg_iovlen;
00088 
00089      /// Access rights sent/received
00090      caddr_t msg_accrights;
00091 
00092      int msg_accrightslen;
00093    };
00094 #endif /* ACE_WIN32 */
00095 
00096 #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
00097    // Control message size to pass a file descriptor.
00098 #  define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
00099 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
00100 
00101 // Increase the range of "address families".  Please note that this
00102 // must appear _after_ the include of sys/socket.h, for the AF_FILE
00103 // definition on Linux/glibc2.
00104 #if !defined (AF_ANY)
00105 #  define AF_ANY (-1)
00106 #endif /* AF_ANY */
00107 
00108 #if !defined (AF_UNSPEC)
00109 #  define AF_UNSPEC 0
00110 #endif /* AF_UNSPEC */
00111 
00112 #if !defined (AF_LOCAL)
00113 #  define AF_LOCAL 1
00114 #endif /* AF_LOCAL */
00115 
00116 #if !defined (AF_UNIX)
00117 #  define AF_UNIX AF_LOCAL
00118 #endif /* AF_UNIX */
00119 
00120 #if !defined (AF_INET)
00121 #  define AF_INET 2
00122 #endif /* AF_INET */
00123 
00124 #if !defined (PF_INET)
00125 #  define PF_INET AF_INET
00126 #endif /* PF_INET */
00127 
00128 #if !defined (PF_LOCAL)
00129 #  define PF_LOCAL AF_LOCAL
00130 #endif /* PF_LOCAL */
00131 
00132 #if !defined (PF_UNIX)
00133 #  define PF_UNIX PF_LOCAL
00134 #endif /* PF_UNIX */
00135 
00136 #if !defined (AF_MAX)
00137 #  define AF_MAX 29
00138 #endif /* AF_MAX */
00139 
00140 #if !defined (PF_UNSPEC)
00141 #  define PF_UNSPEC 0
00142 #endif /* PF_UNSPEC */
00143 
00144 #define AF_SPIPE (AF_MAX + 1)
00145 #if !defined (AF_FILE)
00146 #  define AF_FILE (AF_MAX + 2)
00147 #endif /* ! AF_FILE */
00148 #define AF_DEV (AF_MAX + 3)
00149 #define AF_UPIPE (AF_SPIPE)
00150 
00151 #if !defined (MSG_OOB)
00152 #  define MSG_OOB 0x1
00153 #endif /* MSG_OOB */
00154 
00155 #if !defined (MSG_PEEK)
00156 #  define MSG_PEEK 0x2
00157 #endif /* MSG_PEEK */
00158 
00159 #if !defined (SOCK_STREAM)
00160 #  define SOCK_STREAM 1
00161 #endif /* SOCK_STREAM */
00162 
00163 #if !defined (SOCK_DGRAM)
00164 #  define SOCK_DGRAM 2
00165 #endif /* SOCK_DGRAM */
00166 
00167 #if !defined (SOCK_SEQPACKET)
00168 #  define SOCK_SEQPACKET 5
00169 #endif /* SOCK_SEQPACKET */
00170 
00171 #if !defined (SOL_SOCKET)
00172 #  define SOL_SOCKET 0xffff
00173 #endif /* SOL_SOCKET */
00174 
00175 #if !defined (SO_REUSEADDR)
00176 #  define SO_REUSEADDR 0x0004
00177 #endif /* SO_REUSEADDR */
00178 
00179 #if !defined (SO_LINGER)
00180 #  define SO_LINGER 0x0080
00181 #endif /* SO_LINGER */
00182 
00183 #if !defined (SO_SNDBUF)
00184 #  define SO_SNDBUF 0x1001
00185 #endif /* SO_SNDBUF */
00186 
00187 #if !defined (SO_RCVBUF)
00188 #  define SO_RCVBUF 0x1002
00189 #endif /* SO_RCVBUF */
00190 
00191 #if !defined (SO_BROADCAST)
00192 #  define SO_BROADCAST 0x0020
00193 #endif /* SO_BROADCAST */
00194 
00195 #if !defined (SO_ERROR)
00196 #  define SO_ERROR 0x1007
00197 #endif /* SO_ERROR */
00198 
00199 #if !defined (SCM_RIGHTS)
00200 #  define SCM_RIGHTS 0x01
00201 #endif /* SCM_RIGHTS */
00202 
00203 #if defined (ACE_HAS_IPV6)
00204 #  if defined (ACE_USES_IPV4_IPV6_MIGRATION)
00205 #    define ACE_ADDRESS_FAMILY_INET  AF_UNSPEC
00206 #    define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
00207 #  else
00208 #    define ACE_ADDRESS_FAMILY_INET AF_INET6
00209 #    define ACE_PROTOCOL_FAMILY_INET PF_INET6
00210 #  endif /* ACE_USES_IPV4_IPV6_MIGRATION */
00211 #else /* !ACE_HAS_IPV6 */
00212 #  define ACE_ADDRESS_FAMILY_INET AF_INET
00213 #  define ACE_PROTOCOL_FAMILY_INET PF_INET
00214 #endif /* ACE_HAS_IPV6 */
00215 
00216 #if !defined (ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
00217 #define ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE SSIZE_MAX
00218 #endif /* ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE */
00219 
00220 #if defined (ACE_HAS_SOCKLEN_T)
00221 #  if defined (__hpux)
00222   /*
00223   ** HP-UX supplies the socklen_t type unless some feature set less than
00224   ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only
00225   ** actually uses the socklen_t type in supplied socket functions if
00226   ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example,
00227   ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE
00228   ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t
00229   ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions
00230   ** to use int, not socklen_t). React to this situation here...
00231   */
00232 #    if defined (_XOPEN_SOURCE_EXTENDED)
00233 typedef socklen_t ACE_SOCKET_LEN;
00234 #    else
00235 typedef int ACE_SOCKET_LEN;
00236 #    endif /* _XOPEN_SOURCE_EXTENDED */
00237 #  else
00238 typedef socklen_t ACE_SOCKET_LEN;
00239 #  endif /* __hpux */
00240 #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
00241 typedef size_t ACE_SOCKET_LEN;
00242 #else
00243 typedef int ACE_SOCKET_LEN;
00244 #endif /* ACE_HAS_SIZET_SOCKET_LEN */
00245 
00246 #if defined (ACE_HAS_NETLINK)
00247 #  include /**/ <asm/types.h>
00248 #  include /**/ <linux/netlink.h>
00249 #  define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK
00250 #endif
00251 
00252 #if defined (ACE_HAS_LKSCTP)
00253 extern "C"
00254 {
00255 #include /**/ <netinet/in.h>
00256 #include /**/ <netinet/sctp.h>
00257 }
00258 #endif /* ACE_HAS_LKSCTP */
00259 
00260 # if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)
00261 
00262   ssize_t recv_timedwait (ACE_HANDLE handle,
00263                           char *buf,
00264                           int len,
00265                           int flags,
00266                           struct timespec *timeout);
00267 
00268   ssize_t recvmsg_timedwait (ACE_HANDLE handle,
00269                              struct msghdr *msg,
00270                              int flags,
00271                              struct timespec *timeout);
00272 
00273   ssize_t recvfrom_timedwait (ACE_HANDLE handle,
00274                               char *buf,
00275                               int len,
00276                               int flags,
00277                               struct sockaddr *addr,
00278                               int *addrlen,
00279                               struct timespec *timeout);
00280 
00281   ssize_t send_timedwait (ACE_HANDLE handle,
00282                           const char *buf,
00283                           int len,
00284                           int flags,
00285                           struct timespec *timeout);
00286 
00287   ssize_t sendmsg_timedwait (ACE_HANDLE handle,
00288                              const struct msghdr *msg,
00289                              int flags,
00290                              struct timespec *timeout);
00291 
00292   ssize_t sendto_timedwait (ACE_HANDLE handle,
00293                             const char *buf,
00294                             int len,
00295                             int flags,
00296                             const struct sockaddr *addr,
00297                             int addrlen,
00298                             struct timespec *timeout);
00299 
00300 # endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */
00301 
00302 #ifdef __cplusplus
00303 }
00304 #endif /* __cplusplus */
00305 
00306 #include /**/ "ace/post.h"
00307 #endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7