2006-09-19 02:49:20 +04:00
# ifndef _system_network_h
# define _system_network_h
/*
Unix SMB / CIFS implementation .
networking system include wrappers
Copyright ( C ) Andrew Tridgell 2004
2007-12-16 04:39:01 +03:00
Copyright ( C ) Jelmer Vernooij 2007
2006-09-19 02:49:20 +04:00
2007-06-02 13:10:08 +04:00
* * NOTE ! The following LGPL license applies to the replace
* * library . This does NOT imply that all of Samba is released
* * under the LGPL
2006-09-19 02:49:20 +04:00
2007-06-02 13:10:08 +04:00
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation ; either
2007-07-10 05:44:42 +04:00
version 3 of the License , or ( at your option ) any later version .
2007-06-02 13:10:08 +04:00
This library is distributed in the hope that it will be useful ,
2006-09-19 02:49:20 +04:00
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2007-06-02 13:10:08 +04:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public
2007-07-10 07:42:26 +04:00
License along with this library ; if not , see < http : //www.gnu.org/licenses/>.
2007-06-02 13:10:08 +04:00
2006-09-19 02:49:20 +04:00
*/
2008-05-08 12:39:41 +04:00
# ifndef LIBREPLACE_NETWORK_CHECKS
# error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
# endif
2006-09-19 02:49:20 +04:00
# ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# endif
# ifdef HAVE_UNIXSOCKET
# include <sys/un.h>
# endif
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
# ifdef HAVE_NETDB_H
# include <netdb.h>
# endif
# ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
# endif
/*
* The next three defines are needed to access the IPTOS_ * options
* on some systems .
*/
# ifdef HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
# endif
# ifdef HAVE_NETINET_IN_IP_H
# include <netinet/in_ip.h>
# endif
# ifdef HAVE_NETINET_IP_H
# include <netinet/ip.h>
# endif
# ifdef HAVE_NET_IF_H
# include <net/if.h>
# endif
2006-09-27 18:18:08 +04:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
2006-09-27 16:43:51 +04:00
# ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
# endif
2009-03-11 10:05:11 +03:00
# ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
# endif
2007-12-17 21:44:09 +03:00
# ifdef HAVE_STROPTS_H
# include <stropts.h>
# endif
2008-02-26 13:18:51 +03:00
# ifndef HAVE_SOCKLEN_T
# define HAVE_SOCKLEN_T
typedef int socklen_t ;
# endif
2008-03-18 14:16:47 +03:00
# if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
2007-10-10 16:09:06 +04:00
/* define is in "replace.h" */
2006-09-19 02:49:20 +04:00
char * rep_inet_ntoa ( struct in_addr ip ) ;
2007-10-10 16:09:06 +04:00
# endif
# ifndef HAVE_INET_PTON
/* define is in "replace.h" */
int rep_inet_pton ( int af , const char * src , void * dst ) ;
# endif
# ifndef HAVE_INET_NTOP
/* define is in "replace.h" */
const char * rep_inet_ntop ( int af , const void * src , char * dst , socklen_t size ) ;
2006-09-19 02:49:20 +04:00
# endif
2008-03-14 10:49:34 +03:00
# ifndef HAVE_INET_ATON
/* define is in "replace.h" */
int rep_inet_aton ( const char * src , struct in_addr * dst ) ;
# endif
2008-02-26 15:24:54 +03:00
# ifndef HAVE_CONNECT
/* define is in "replace.h" */
int rep_connect ( int sockfd , const struct sockaddr * addr , socklen_t addrlen ) ;
# endif
# ifndef HAVE_GETHOSTBYNAME
/* define is in "replace.h" */
struct hostent * rep_gethostbyname ( const char * name ) ;
# endif
2007-12-16 04:39:01 +03:00
# ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
# endif
# ifndef HAVE_STRUCT_IFADDRS
struct ifaddrs {
struct ifaddrs * ifa_next ; /* Pointer to next struct */
char * ifa_name ; /* Interface name */
2007-12-16 05:22:13 +03:00
unsigned int ifa_flags ; /* Interface flags */
2007-12-16 04:39:01 +03:00
struct sockaddr * ifa_addr ; /* Interface address */
struct sockaddr * ifa_netmask ; /* Interface netmask */
2007-12-17 08:57:30 +03:00
# undef ifa_dstaddr
2007-12-16 04:39:01 +03:00
struct sockaddr * ifa_dstaddr ; /* P2P interface destination */
void * ifa_data ; /* Address specific data */
} ;
# endif
# ifndef HAVE_GETIFADDRS
int rep_getifaddrs ( struct ifaddrs * * ) ;
# endif
# ifndef HAVE_FREEIFADDRS
2007-12-17 14:27:59 +03:00
void rep_freeifaddrs ( struct ifaddrs * ) ;
2007-12-16 04:39:01 +03:00
# endif
2008-03-18 19:20:47 +03:00
# ifndef HAVE_SOCKETPAIR
/* define is in "replace.h" */
int rep_socketpair ( int d , int type , int protocol , int sv [ 2 ] ) ;
# endif
2007-10-17 02:15:23 +04:00
/*
* Some systems have getaddrinfo but not the
* defines needed to use it .
*/
/* Various macros that ought to be in <netdb.h>, but might not be */
# ifndef EAI_FAIL
# define EAI_BADFLAGS (-1)
# define EAI_NONAME (-2)
# define EAI_AGAIN (-3)
# define EAI_FAIL (-4)
# define EAI_FAMILY (-6)
# define EAI_SOCKTYPE (-7)
# define EAI_SERVICE (-8)
# define EAI_MEMORY (-10)
# define EAI_SYSTEM (-11)
# endif /* !EAI_FAIL */
# ifndef AI_PASSIVE
# define AI_PASSIVE 0x0001
# endif
# ifndef AI_CANONNAME
# define AI_CANONNAME 0x0002
# endif
# ifndef AI_NUMERICHOST
/*
* some platforms don ' t support AI_NUMERICHOST ; define as zero if using
* the system version of getaddrinfo . . .
*/
# if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
# define AI_NUMERICHOST 0
# else
# define AI_NUMERICHOST 0x0004
# endif
# endif
# ifndef AI_ADDRCONFIG
2008-02-01 16:23:56 +03:00
/*
* logic copied from AI_NUMERICHOST
*/
# if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
# define AI_ADDRCONFIG 0
# else
2007-10-17 02:15:23 +04:00
# define AI_ADDRCONFIG 0x0020
# endif
2008-02-01 16:23:56 +03:00
# endif
2007-10-17 02:15:23 +04:00
2007-10-25 13:16:11 +04:00
# ifndef AI_NUMERICSERV
/*
* logic copied from AI_NUMERICHOST
*/
# if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
# define AI_NUMERICSERV 0
# else
# define AI_NUMERICSERV 0x0400
# endif
# endif
2007-10-17 02:15:23 +04:00
# ifndef NI_NUMERICHOST
# define NI_NUMERICHOST 1
# endif
# ifndef NI_NUMERICSERV
# define NI_NUMERICSERV 2
# endif
# ifndef NI_NOFQDN
# define NI_NOFQDN 4
# endif
# ifndef NI_NAMEREQD
# define NI_NAMEREQD 8
# endif
# ifndef NI_DGRAM
# define NI_DGRAM 16
# endif
# ifndef NI_MAXHOST
# define NI_MAXHOST 1025
# endif
# ifndef NI_MAXSERV
# define NI_MAXSERV 32
# endif
2006-09-19 02:49:20 +04:00
/*
* glibc on linux doesn ' t seem to have MSG_WAITALL
* defined . I think the kernel has it though . .
*/
# ifndef MSG_WAITALL
# define MSG_WAITALL 0
# endif
# ifndef INADDR_LOOPBACK
# define INADDR_LOOPBACK 0x7f000001
# endif
# ifndef INADDR_NONE
# define INADDR_NONE 0xffffffff
# endif
2007-10-02 23:27:25 +04:00
# ifndef EAFNOSUPPORT
# define EAFNOSUPPORT EINVAL
# endif
# ifndef INET_ADDRSTRLEN
# define INET_ADDRSTRLEN 16
# endif
# ifndef INET6_ADDRSTRLEN
# define INET6_ADDRSTRLEN 46
# endif
2007-10-24 16:55:40 +04:00
# ifndef HOST_NAME_MAX
2009-01-31 11:32:14 +03:00
# define HOST_NAME_MAX 255
# endif
# ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN HOST_NAME_MAX
2007-10-24 16:55:40 +04:00
# endif
2007-10-03 00:04:14 +04:00
# ifndef HAVE_SA_FAMILY_T
2007-10-24 17:01:03 +04:00
# define HAVE_SA_FAMILY_T
2007-10-03 00:04:14 +04:00
typedef unsigned short int sa_family_t ;
# endif
2007-10-04 21:20:49 +04:00
# ifndef HAVE_STRUCT_SOCKADDR_STORAGE
2007-10-25 10:53:38 +04:00
# define HAVE_STRUCT_SOCKADDR_STORAGE
2007-10-04 21:35:12 +04:00
# ifdef HAVE_STRUCT_SOCKADDR_IN6
# define sockaddr_storage sockaddr_in6
# define ss_family sin6_family
2007-12-20 17:59:39 +03:00
# define HAVE_SS_FAMILY 1
2007-10-04 21:35:12 +04:00
# else
2007-10-04 02:01:25 +04:00
# define sockaddr_storage sockaddr_in
# define ss_family sin_family
2007-12-20 17:59:39 +03:00
# define HAVE_SS_FAMILY 1
# endif
# endif
# ifndef HAVE_SS_FAMILY
# ifdef HAVE___SS_FAMILY
# define ss_family __ss_family
# define HAVE_SS_FAMILY 1
2007-10-03 23:12:39 +04:00
# endif
2007-10-04 21:35:12 +04:00
# endif
2007-10-03 23:12:39 +04:00
2007-10-24 16:57:57 +04:00
# ifndef HAVE_STRUCT_ADDRINFO
2007-10-24 17:01:03 +04:00
# define HAVE_STRUCT_ADDRINFO
2007-10-24 16:57:57 +04:00
struct addrinfo {
int ai_flags ;
int ai_family ;
int ai_socktype ;
int ai_protocol ;
socklen_t ai_addrlen ;
struct sockaddr * ai_addr ;
char * ai_canonname ;
struct addrinfo * ai_next ;
} ;
# endif /* HAVE_STRUCT_ADDRINFO */
2007-10-25 10:53:38 +04:00
# if !defined(HAVE_GETADDRINFO)
# include "getaddrinfo.h"
# endif
2007-10-26 02:43:44 +04:00
/* Needed for some systems that don't define it (Solaris). */
# ifndef ifr_netmask
2008-02-28 20:58:05 +03:00
# define ifr_netmask ifr_addr
2007-10-26 02:43:44 +04:00
# endif
2007-10-24 16:53:34 +04:00
# ifdef SOCKET_WRAPPER
2009-02-26 12:29:55 +03:00
# ifndef SOCKET_WRAPPER_DISABLE
2007-10-24 16:53:34 +04:00
# ifndef SOCKET_WRAPPER_NOT_REPLACE
# define SOCKET_WRAPPER_REPLACE
2009-02-26 12:29:55 +03:00
# endif /* SOCKET_WRAPPER_NOT_REPLACE */
2008-09-16 18:39:45 +04:00
# include "../socket_wrapper/socket_wrapper.h"
2009-02-26 12:29:55 +03:00
# endif /* SOCKET_WRAPPER_DISABLE */
# endif /* SOCKET_WRAPPER */
2007-10-24 16:53:34 +04:00
2006-09-19 02:49:20 +04:00
# endif