Main Page | Class List | Directories | File List | Class Members | File Members

pike_netlib.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: pike_netlib.h,v 1.4 2003/04/30 10:25:42 grubba Exp $
00006 */
00007 
00008 #ifndef PIKE_NETLIB_H
00009 #define PIKE_NETLIB_H
00010 
00011 #ifdef HAVE_SYS_TYPES_H
00012 #include <sys/types.h>
00013 #endif /* HAVE_SYS_TYPES_H */
00014 #ifdef HAVE_UNISTD_H
00015 #include <unistd.h>
00016 #endif /* HAVE_UNISTD_H */
00017 #ifdef HAVE_SYS_SOCKET_H
00018 #include <sys/socket.h>
00019 #endif /* HAVE_SYS_SOCKET_H */
00020 #ifdef HAVE_NETINET_IN_H
00021 #include <netinet/in.h>
00022 #endif /* HAVE_NETINET_IN_H */
00023 
00024 #ifdef HAVE_WINSOCK2_H
00025 #include <WinSock2.h>
00026 #ifdef HAVE_WS2TCPIP_H
00027 /* Needed for IPv6 support. */
00028 #include <WS2tcpip.h>
00029 #endif
00030 #elif defined(HAVE_WINSOCK_H)
00031 #include <winsock.h>
00032 #endif
00033 
00034 typedef union {
00035   struct sockaddr sa;
00036   struct sockaddr_in ipv4;
00037 #ifdef HAVE_STRUCT_SOCKADDR_IN6
00038   struct sockaddr_in6 ipv6;
00039 #endif
00040 } PIKE_SOCKADDR;
00041 
00042 #define SOCKADDR_FAMILY(X) ((X).sa.sa_family)
00043 
00044 #ifdef HAVE_STRUCT_SOCKADDR_IN6
00045 #define SOCKADDR_IN_ADDR(X) (SOCKADDR_FAMILY(X)==AF_INET? \
00046   &(X).ipv4.sin_addr : (struct in_addr *)&(X).ipv6.sin6_addr)
00047 #else
00048 #define SOCKADDR_IN_ADDR(X) (&(X).ipv4.sin_addr)
00049 #endif
00050 
00051 #endif /* PIKE_NETLIB_H */

Generated on Fri Jul 22 23:44:26 2005 for Pike by  doxygen 1.3.9.1