Blame lib/replace/system/network.h

rpm-build 95f51c
#ifndef _system_network_h
rpm-build 95f51c
#define _system_network_h
rpm-build 95f51c
/* 
rpm-build 95f51c
   Unix SMB/CIFS implementation.
rpm-build 95f51c
rpm-build 95f51c
   networking system include wrappers
rpm-build 95f51c
rpm-build 95f51c
   Copyright (C) Andrew Tridgell 2004
rpm-build 95f51c
   Copyright (C) Jelmer Vernooij 2007
rpm-build 95f51c
   
rpm-build 95f51c
     ** NOTE! The following LGPL license applies to the replace
rpm-build 95f51c
     ** library. This does NOT imply that all of Samba is released
rpm-build 95f51c
     ** under the LGPL
rpm-build 95f51c
   
rpm-build 95f51c
   This library is free software; you can redistribute it and/or
rpm-build 95f51c
   modify it under the terms of the GNU Lesser General Public
rpm-build 95f51c
   License as published by the Free Software Foundation; either
rpm-build 95f51c
   version 3 of the License, or (at your option) any later version.
rpm-build 95f51c
rpm-build 95f51c
   This library is distributed in the hope that it will be useful,
rpm-build 95f51c
   but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 95f51c
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 95f51c
   Lesser General Public License for more details.
rpm-build 95f51c
rpm-build 95f51c
   You should have received a copy of the GNU Lesser General Public
rpm-build 95f51c
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
rpm-build 95f51c
rpm-build 95f51c
*/
rpm-build 95f51c
rpm-build 95f51c
#ifndef LIBREPLACE_NETWORK_CHECKS
rpm-build 95f51c
#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_UNISTD_H
rpm-build 95f51c
#include <unistd.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_SYS_SOCKET_H
rpm-build 95f51c
#include <sys/socket.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_UNIXSOCKET
rpm-build 95f51c
#include <sys/un.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETINET_IN_H
rpm-build 95f51c
#include <netinet/in.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
#ifdef HAVE_ARPA_INET_H
rpm-build 95f51c
#include <arpa/inet.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETDB_H
rpm-build 95f51c
#include <netdb.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETINET_TCP_H
rpm-build 95f51c
#include <netinet/tcp.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/*
rpm-build 95f51c
 * The next three defines are needed to access the IPTOS_* options
rpm-build 95f51c
 * on some systems.
rpm-build 95f51c
 */
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETINET_IN_SYSTM_H
rpm-build 95f51c
#include <netinet/in_systm.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETINET_IN_IP_H
rpm-build 95f51c
#include <netinet/in_ip.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NETINET_IP_H
rpm-build 95f51c
#include <netinet/ip.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_NET_IF_H
rpm-build 95f51c
#include <net/if.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_SYS_IOCTL_H
rpm-build 95f51c
#include <sys/ioctl.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_SYS_UIO_H
rpm-build 95f51c
#include <sys/uio.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_STROPTS_H
rpm-build 95f51c
#include <stropts.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_SOCKLEN_T
rpm-build 95f51c
#define HAVE_SOCKLEN_T
rpm-build 95f51c
typedef int socklen_t;
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
char *rep_inet_ntoa(struct in_addr ip);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_INET_PTON
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
int rep_inet_pton(int af, const char *src, void *dst);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_INET_NTOP
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_INET_ATON
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
int rep_inet_aton(const char *src, struct in_addr *dst);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_CONNECT
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_GETHOSTBYNAME
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
struct hostent *rep_gethostbyname(const char *name);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_IFADDRS_H
rpm-build 95f51c
#include <ifaddrs.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_STRUCT_IFADDRS
rpm-build 95f51c
struct ifaddrs {
rpm-build 95f51c
	struct ifaddrs   *ifa_next;         /* Pointer to next struct */
rpm-build 95f51c
	char             *ifa_name;         /* Interface name */
rpm-build 95f51c
	unsigned int     ifa_flags;         /* Interface flags */
rpm-build 95f51c
	struct sockaddr  *ifa_addr;         /* Interface address */
rpm-build 95f51c
	struct sockaddr  *ifa_netmask;      /* Interface netmask */
rpm-build 95f51c
#undef ifa_dstaddr
rpm-build 95f51c
	struct sockaddr  *ifa_dstaddr;      /* P2P interface destination */
rpm-build 95f51c
	void             *ifa_data;         /* Address specific data */
rpm-build 95f51c
};
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_GETIFADDRS
rpm-build 95f51c
int rep_getifaddrs(struct ifaddrs **);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_FREEIFADDRS
rpm-build 95f51c
void rep_freeifaddrs(struct ifaddrs *);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_SOCKETPAIR
rpm-build 95f51c
/* define is in "replace.h" */
rpm-build 95f51c
int rep_socketpair(int d, int type, int protocol, int sv[2]);
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/*
rpm-build 95f51c
 * Some systems have getaddrinfo but not the
rpm-build 95f51c
 * defines needed to use it.
rpm-build 95f51c
 */
rpm-build 95f51c
rpm-build 95f51c
/* Various macros that ought to be in <netdb.h>, but might not be */
rpm-build 95f51c
rpm-build 95f51c
#ifndef EAI_FAIL
rpm-build 95f51c
#define EAI_BADFLAGS	(-1)
rpm-build 95f51c
#define EAI_NONAME	(-2)
rpm-build 95f51c
#define EAI_AGAIN	(-3)
rpm-build 95f51c
#define EAI_FAIL	(-4)
rpm-build 95f51c
#define EAI_FAMILY	(-6)
rpm-build 95f51c
#define EAI_SOCKTYPE	(-7)
rpm-build 95f51c
#define EAI_SERVICE	(-8)
rpm-build 95f51c
#define EAI_MEMORY	(-10)
rpm-build 95f51c
#define EAI_SYSTEM	(-11)
rpm-build 95f51c
#endif   /* !EAI_FAIL */
rpm-build 95f51c
rpm-build 95f51c
#ifndef AI_PASSIVE
rpm-build 95f51c
#define AI_PASSIVE	0x0001
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef AI_CANONNAME
rpm-build 95f51c
#define AI_CANONNAME	0x0002
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef AI_NUMERICHOST
rpm-build 95f51c
/*
rpm-build 95f51c
 * some platforms don't support AI_NUMERICHOST; define as zero if using
rpm-build 95f51c
 * the system version of getaddrinfo...
rpm-build 95f51c
 */
rpm-build 95f51c
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
rpm-build 95f51c
#define AI_NUMERICHOST	0
rpm-build 95f51c
#else
rpm-build 95f51c
#define AI_NUMERICHOST	0x0004
rpm-build 95f51c
#endif
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/*
rpm-build 95f51c
 * Some of the functions in source3/lib/util_sock.c use AI_ADDRCONFIG. On QNX
rpm-build 95f51c
 * 6.3.0, this macro is defined but, if it's used, getaddrinfo will fail. This
rpm-build 95f51c
 * prevents smbd from opening any sockets.
rpm-build 95f51c
 *
rpm-build 95f51c
 * If I undefine AI_ADDRCONFIG on such systems and define it to be 0,
rpm-build 95f51c
 * this works around the issue.
rpm-build 95f51c
 */
rpm-build 95f51c
#ifdef __QNX__
rpm-build 95f51c
#include <sys/neutrino.h>
rpm-build 95f51c
#if _NTO_VERSION == 630
rpm-build 95f51c
#undef AI_ADDRCONFIG
rpm-build 95f51c
#endif
rpm-build 95f51c
#endif
rpm-build 95f51c
#ifndef AI_ADDRCONFIG
rpm-build 95f51c
/*
rpm-build 95f51c
 * logic copied from AI_NUMERICHOST
rpm-build 95f51c
 */
rpm-build 95f51c
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
rpm-build 95f51c
#define AI_ADDRCONFIG	0
rpm-build 95f51c
#else
rpm-build 95f51c
#define AI_ADDRCONFIG	0x0020
rpm-build 95f51c
#endif
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef AI_NUMERICSERV
rpm-build 95f51c
/*
rpm-build 95f51c
 * logic copied from AI_NUMERICHOST
rpm-build 95f51c
 */
rpm-build 95f51c
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
rpm-build 95f51c
#define AI_NUMERICSERV	0
rpm-build 95f51c
#else
rpm-build 95f51c
#define AI_NUMERICSERV	0x0400
rpm-build 95f51c
#endif
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_NUMERICHOST
rpm-build 95f51c
#define NI_NUMERICHOST	1
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_NUMERICSERV
rpm-build 95f51c
#define NI_NUMERICSERV	2
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_NOFQDN
rpm-build 95f51c
#define NI_NOFQDN	4
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_NAMEREQD
rpm-build 95f51c
#define NI_NAMEREQD 	8
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_DGRAM
rpm-build 95f51c
#define NI_DGRAM	16
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_MAXHOST
rpm-build 95f51c
#define NI_MAXHOST	1025
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef NI_MAXSERV
rpm-build 95f51c
#define NI_MAXSERV	32
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/*
rpm-build 95f51c
 * glibc on linux doesn't seem to have MSG_WAITALL
rpm-build 95f51c
 * defined. I think the kernel has it though..
rpm-build 95f51c
 */
rpm-build 95f51c
#ifndef MSG_WAITALL
rpm-build 95f51c
#define MSG_WAITALL 0
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef INADDR_LOOPBACK
rpm-build 95f51c
#define INADDR_LOOPBACK 0x7f000001
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef INADDR_NONE
rpm-build 95f51c
#define INADDR_NONE 0xffffffff
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef EAFNOSUPPORT
rpm-build 95f51c
#define EAFNOSUPPORT EINVAL
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef INET_ADDRSTRLEN
rpm-build 95f51c
#define INET_ADDRSTRLEN 16
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef INET6_ADDRSTRLEN
rpm-build 95f51c
#define INET6_ADDRSTRLEN 46
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HOST_NAME_MAX
rpm-build 95f51c
#define HOST_NAME_MAX 255
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef MAXHOSTNAMELEN
rpm-build 95f51c
#define MAXHOSTNAMELEN HOST_NAME_MAX
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_SA_FAMILY_T
rpm-build 95f51c
#define HAVE_SA_FAMILY_T
rpm-build 95f51c
typedef unsigned short int sa_family_t;
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
rpm-build 95f51c
#define HAVE_STRUCT_SOCKADDR_STORAGE
rpm-build 95f51c
#ifdef HAVE_STRUCT_SOCKADDR_IN6
rpm-build 95f51c
#define sockaddr_storage sockaddr_in6
rpm-build 95f51c
#define ss_family sin6_family
rpm-build 95f51c
#define HAVE_SS_FAMILY 1
rpm-build 95f51c
#else /*HAVE_STRUCT_SOCKADDR_IN6*/
rpm-build 95f51c
#define sockaddr_storage sockaddr_in
rpm-build 95f51c
#define ss_family sin_family
rpm-build 95f51c
#define HAVE_SS_FAMILY 1
rpm-build 95f51c
#endif /*HAVE_STRUCT_SOCKADDR_IN6*/
rpm-build 95f51c
#endif /*HAVE_STRUCT_SOCKADDR_STORAGE*/
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_SS_FAMILY
rpm-build 95f51c
#ifdef HAVE___SS_FAMILY
rpm-build 95f51c
#define ss_family __ss_family
rpm-build 95f51c
#define HAVE_SS_FAMILY 1
rpm-build 95f51c
#endif
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef IOV_MAX
rpm-build 95f51c
# ifdef UIO_MAXIOV
rpm-build 95f51c
#  define IOV_MAX UIO_MAXIOV
rpm-build 95f51c
# else
rpm-build 95f51c
#  ifdef __sgi
rpm-build 95f51c
    /*
rpm-build 95f51c
     * IRIX 6.5 has sysconf(_SC_IOV_MAX)
rpm-build 95f51c
     * which might return 512 or bigger
rpm-build 95f51c
     */
rpm-build 95f51c
#   define IOV_MAX 512
rpm-build 95f51c
#  endif
rpm-build 95f51c
# endif
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_STRUCT_ADDRINFO
rpm-build 95f51c
#define HAVE_STRUCT_ADDRINFO
rpm-build 95f51c
struct addrinfo {
rpm-build 95f51c
	int			ai_flags;
rpm-build 95f51c
	int			ai_family;
rpm-build 95f51c
	int			ai_socktype;
rpm-build 95f51c
	int			ai_protocol;
rpm-build 95f51c
	socklen_t		ai_addrlen;
rpm-build 95f51c
	struct sockaddr 	*ai_addr;
rpm-build 95f51c
	char			*ai_canonname;
rpm-build 95f51c
	struct addrinfo		*ai_next;
rpm-build 95f51c
};
rpm-build 95f51c
#endif   /* HAVE_STRUCT_ADDRINFO */
rpm-build 95f51c
rpm-build 95f51c
#if !defined(HAVE_GETADDRINFO)
rpm-build 95f51c
#include "getaddrinfo.h"
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/* Needed for some systems that don't define it (Solaris). */
rpm-build 95f51c
#ifndef ifr_netmask
rpm-build 95f51c
#define ifr_netmask ifr_addr
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
/* Some old Linux systems have broken header files */
rpm-build 95f51c
#ifdef HAVE_IPV6
rpm-build 95f51c
#ifdef HAVE_LINUX_IPV6_V6ONLY_26
rpm-build 95f51c
#define IPV6_V6ONLY 26
rpm-build 95f51c
#endif /* HAVE_LINUX_IPV6_V6ONLY_26 */
rpm-build 95f51c
#endif /* HAVE_IPV6 */
rpm-build 95f51c
rpm-build 95f51c
#ifndef SCOPE_DELIMITER
rpm-build 95f51c
#define SCOPE_DELIMITER '%'
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#endif