(file) Return to Network.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 martin 1.22 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.23 //
  3 martin 1.22 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.23 //
 10 martin 1.22 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.23 //
 17 martin 1.22 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.23 //
 20 martin 1.22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.23 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.23 //
 28 martin 1.22 //////////////////////////////////////////////////////////////////////////
 29 mike   1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_Network_h
 33             #define Pegasus_Network_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36             
 37             //==============================================================================
 38             //
 39             // Network.h
 40             //
 41             //     This file includes network-related system-header files. Please include
 42             //     this file directly rather than including system headers directly. If
 43             //     special inclusions are necessary for any platform, please add them to
 44 kumpf  1.8  //     this file rather than other files. The reason for this file is to limit
 45             //     platform-specific conditional compilation expressions to only a few
 46 mike   1.1  //     well-known header files.
 47 kumpf  1.8  //
 48 mike   1.1  //==============================================================================
 49             
 50             //------------------------------------------------------------------------------
 51             //
 52             // PEGASUS_OS_TYPE_WINDOWS network system header files
 53             //
 54             //------------------------------------------------------------------------------
 55             
 56             #ifdef PEGASUS_OS_TYPE_WINDOWS
 57             #   ifdef FD_SETSIZE
 58 mateus.baur 1.11 #       ifndef PEGASUS_WMIMAPPER
 59                  #           error "<Pegasus/Common/Network.h>: FD_SETSIZE is already defined. \
 60                               This file must be included prior to any header file that defines \
 61                               FD_SETSIZE, such as <windows.h>, <winsock.h>, or <winsock2.h>."
 62                  #       else
 63                  #           undef FD_SETSIZE
 64 kumpf       1.12 #       endif
 65 mike        1.1  #   endif
 66                  #   define FD_SETSIZE 1024
 67                  #   include <windows.h>
 68                  #   ifndef _WINSOCKAPI_
 69                  #       include <winsock2.h>
 70                  #   endif
 71                  #   include <wincrypt.h>
 72 dave.sudlik 1.13 #   include <ws2tcpip.h>
 73 mike        1.1  #endif
 74                  
 75 venkat.puvvada 1.19 #    ifdef PEGASUS_HAS_GETIFADDRS
 76 venkat.puvvada 1.18 #       include <ifaddrs.h>
 77                     #    endif
 78                     
 79 mike           1.1  //------------------------------------------------------------------------------
 80                     //
 81 carson.hovey   1.4  // PEGASUS_OS_TYPE_UNIX or PEGASUS_OS_VMS network system header files.
 82 mike           1.1  //
 83                     //------------------------------------------------------------------------------
 84                     
 85 carson.hovey   1.4  #if defined(PEGASUS_OS_TYPE_UNIX) || defined (PEGASUS_OS_VMS)
 86 venkat.puvvada 1.18 
 87 mike           1.1  #   include <errno.h>
 88                     #   include <sys/types.h>
 89                     #   include <fcntl.h>
 90                     #   include <netdb.h>
 91                     #   include <netinet/in.h>
 92                     #   include <arpa/inet.h>
 93                     #   include <sys/socket.h>
 94                     #   include <sys/time.h>
 95 thilo.boehm    1.6  #   include <sys/ioctl.h>
 96 mike           1.1  #   ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 97                     #       include <unistd.h>
 98                     #       include <sys/un.h>
 99                     #   endif
100 ouyang.jian    1.10 #   include <unistd.h>
101 r.kieninger    1.21 #   ifdef PEGASUS_OS_ZOS
102 mike           1.1  #       ifndef TCP_NODELAY
103                     #           define TCP_NODELAY 1
104                     #       endif
105                     #   else
106                     #       include <netinet/tcp.h>
107                     #   endif
108 rohini.deshpande 1.27 //------------------------------------------------------------------------------
109                       // 
110                       // if_nametoindex() in libC on HP_UX does not support name mangling.
111                       // Therefore, have "C" linkage for if.h on HP-UX.
112                       // 
113                       //------------------------------------------------------------------------------
114                       #   ifdef PEGASUS_OS_HPUX
115                       extern "C"
116                       {
117                       #       include <net/if.h>
118                       }
119                       #   else
120                       #       include <net/if.h>
121                       #   endif
122 mike             1.1  #endif
123                       
124                       //------------------------------------------------------------------------------
125                       //
126 kumpf            1.17 // PEGASUS_RETRY_SYSTEM_CALL()
127                       //
128                       //     This macro repeats the given system call until it returns something
129                       //     other than EINTR.
130                       //
131                       //------------------------------------------------------------------------------
132                       
133                       #ifdef PEGASUS_OS_TYPE_WINDOWS
134                       #   define PEGASUS_RETRY_SYSTEM_CALL(EXPR, RESULT) RESULT = EXPR
135                       #else
136                       #   define PEGASUS_RETRY_SYSTEM_CALL(EXPR, RESULT) \
137                               while (((RESULT = (EXPR)) == -1) && (errno == EINTR))
138                       #endif
139                       
140                       //------------------------------------------------------------------------------
141                       //
142 mike             1.1  // PEGASUS_SOCKET_ERROR
143                       //
144                       //------------------------------------------------------------------------------
145                       
146                       #ifdef PEGASUS_OS_TYPE_WINDOWS
147                       #   define PEGASUS_SOCKET_ERROR SOCKET_ERROR
148                       #else
149                       #   define PEGASUS_SOCKET_ERROR (-1)
150                       #endif
151                       
152 thilo.boehm      1.6  //------------------------------------------------------------------------------
153                       //
154                       // PEGASUS_NETWORK_TCPIP_STOPPED
155 kumpf            1.8  //
156                       // This return code indicates that the transpor layer is
157 thilo.boehm      1.6  // stopped and the socket is invalid. The socket must created again.
158                       //
159                       //------------------------------------------------------------------------------
160                       
161                       #ifdef PEGASUS_OS_ZOS
162                       #   define PEGASUS_NETWORK_TCPIP_STOPPED EIO
163                       #else
164                       #   define PEGASUS_NETWORK_TCPIP_STOPPED 0
165                       #endif
166                       
167                       //------------------------------------------------------------------------------
168                       //
169                       // PEGASUS_NETWORK_TRYAGAIN
170 kumpf            1.8  //
171                       // This return code indicates that the network function
172 thilo.boehm      1.6  // should be tried again by the program.
173                       //
174                       //------------------------------------------------------------------------------
175                       
176                       #if !defined(PEGASUS_OS_TYPE_WINDOWS)
177                       #   define PEGASUS_NETWORK_TRYAGAIN EAGAIN
178                       #else
179                       #   define PEGASUS_NETWORK_TRYAGAIN 0
180                       #endif
181                       
182 kumpf            1.17 //------------------------------------------------------------------------------
183                       //
184                       // PEGASUS_NETWORK_EINPROGRESS
185                       //
186                       // This return code indicates that the network function
187                       // is in progress. The application should try select or poll and
188                       // check for successful completion.
189                       //
190                       //------------------------------------------------------------------------------
191                       
192                       #if !defined(PEGASUS_OS_TYPE_WINDOWS)
193                       #   define PEGASUS_NETWORK_EINPROGRESS EINPROGRESS
194                       #else
195                       #   define PEGASUS_NETWORK_EINPROGRESS WSAEWOULDBLOCK
196                       #endif
197                       
198 kumpf            1.3  ////////////////////////////////////////////////////////////////////////////////
199                       //
200                       // getSocketError()
201                       //
202                       ////////////////////////////////////////////////////////////////////////////////
203                       
204                       static inline int getSocketError()
205                       {
206                       #ifdef PEGASUS_OS_TYPE_WINDOWS
207                           return WSAGetLastError();
208                       #else
209                           return errno;
210                       #endif
211                       }
212                       
213 mike             1.1  //------------------------------------------------------------------------------
214                       //
215                       // PEGASUS_INVALID_SOCKET
216                       //
217                       //------------------------------------------------------------------------------
218                       
219                       #ifdef PEGASUS_OS_TYPE_WINDOWS
220                       #   define PEGASUS_INVALID_SOCKET INVALID_SOCKET
221                       #else
222                       #   define PEGASUS_INVALID_SOCKET (-1)
223                       #endif
224                       
225                       //------------------------------------------------------------------------------
226                       //
227 venkat.puvvada   1.15 //
228                       // PEGASUS_INVALID_ADDRESS_FAMILY
229                       //
230                       //------------------------------------------------------------------------------
231                       
232                       #   ifdef PEGASUS_OS_TYPE_WINDOWS
233                       #      define PEGASUS_INVALID_ADDRESS_FAMILY WSAEAFNOSUPPORT
234 mateus.baur      1.16 #   elif defined(PEGASUS_OS_HPUX)
235                       #      define PEGASUS_INVALID_ADDRESS_FAMILY EPROTONOSUPPORT
236 venkat.puvvada   1.15 #   else
237                       #      define PEGASUS_INVALID_ADDRESS_FAMILY EAFNOSUPPORT
238                       #   endif
239                       
240                       //------------------------------------------------------------------------------
241                       //
242 mike             1.1  // SocketHandle
243                       //
244                       //------------------------------------------------------------------------------
245                       
246                       #ifdef PEGASUS_OS_TYPE_WINDOWS
247                       typedef SOCKET SocketHandle;
248                       #else
249                       typedef int SocketHandle;
250                       #endif
251                       
252                       //------------------------------------------------------------------------------
253                       //
254 mike             1.2  // SocketLength
255 mike             1.1  //
256                       //------------------------------------------------------------------------------
257                       
258 karl             1.20 #if defined(PEGASUS_OS_SOLARIS) || \
259 mike             1.1      defined(PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX) || \
260 a.dunfey         1.9      defined(PEGASUS_PLATFORM_WIN64_IA64_MSVC) || \
261                           defined(PEGASUS_PLATFORM_WIN64_X86_64_MSVC) || \
262 mike             1.1      defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
263 mike             1.2      typedef int SocketLength;
264                       #elif defined(PEGASUS_PLATFORM_VMS_ALPHA_DECCXX) || \
265 r.kieninger      1.21     defined(PEGASUS_PLATFORM_VMS_IA64_DECCXX)
266 mike             1.2      typedef size_t SocketLength;
267 r.kieninger      1.21 #elif defined(PEGASUS_OS_ZOS)
268                           typedef socklen_t SocketLength;
269 mike             1.2  #elif defined(PEGASUS_PLATFORM_HPUX_IA64_ACC) && \
270 mike             1.1      !defined(_XOPEN_SOURCE_EXTENDED)
271 mike             1.2      typedef int SocketLength;
272 nagaraj.gr       1.28 #elif defined(PEGASUS_PLATFORM_HPUX_IA64_GNU) && \
273                           !defined(_XOPEN_SOURCE_EXTENDED)
274                           typedef int SocketLength;
275 mike             1.2  #elif defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) && \
276 mike             1.1      !defined(_XOPEN_SOURCE_EXTENDED)
277 mike             1.2      typedef int SocketLength;
278 nagaraj.gr       1.28 #elif defined(PEGASUS_PLATFORM_HPUX_PARISC_GNU) && \
279                           !defined(_XOPEN_SOURCE_EXTENDED)
280                           typedef int SocketLength;
281 mike             1.2  #else
282                           typedef socklen_t SocketLength;
283 mike             1.1  #endif
284                       
285                       #endif  /* Pegasus_Network_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2