486dbe2003-04-23Marcus Comstedt /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. */ #ifndef PIKE_NETLIB_H #define PIKE_NETLIB_H #include <sys/types.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_H #include <netinet/in.h>
4d416e2014-09-04Per Hedbor #include <netinet/tcp.h>
486dbe2003-04-23Marcus Comstedt #endif /* HAVE_NETINET_IN_H */
12a2302003-04-30Henrik Grubbström (Grubba) #ifdef HAVE_WINSOCK2_H
521c8e2006-07-01Martin Stjernholm #include <winsock2.h>
12a2302003-04-30Henrik Grubbström (Grubba) #ifdef HAVE_WS2TCPIP_H /* Needed for IPv6 support. */
521c8e2006-07-01Martin Stjernholm #include <ws2tcpip.h>
12a2302003-04-30Henrik Grubbström (Grubba) #endif #elif defined(HAVE_WINSOCK_H) #include <winsock.h> #endif
486dbe2003-04-23Marcus Comstedt typedef union { struct sockaddr sa; struct sockaddr_in ipv4; #ifdef HAVE_STRUCT_SOCKADDR_IN6 struct sockaddr_in6 ipv6; #endif
cf77092003-04-24Marcus Comstedt } PIKE_SOCKADDR;
486dbe2003-04-23Marcus Comstedt  #define SOCKADDR_FAMILY(X) ((X).sa.sa_family) #ifdef HAVE_STRUCT_SOCKADDR_IN6 #define SOCKADDR_IN_ADDR(X) (SOCKADDR_FAMILY(X)==AF_INET? \ &(X).ipv4.sin_addr : (struct in_addr *)&(X).ipv6.sin6_addr) #else
3a1f622003-04-24Marcus Comstedt #define SOCKADDR_IN_ADDR(X) (&(X).ipv4.sin_addr)
486dbe2003-04-23Marcus Comstedt #endif #endif /* PIKE_NETLIB_H */