Home | History | Annotate | Line # | Download | only in include
ntp_rfc2553.h revision 1.2.2.2
      1  1.2.2.2  msaitoh /*	$NetBSD: ntp_rfc2553.h,v 1.2.2.2 2015/01/07 04:45:24 msaitoh Exp $	*/
      2  1.2.2.2  msaitoh 
      3  1.2.2.2  msaitoh /*
      4  1.2.2.2  msaitoh  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      5  1.2.2.2  msaitoh  * All rights reserved.
      6  1.2.2.2  msaitoh  *
      7  1.2.2.2  msaitoh  * Redistribution and use in source and binary forms, with or without
      8  1.2.2.2  msaitoh  * modification, are permitted provided that the following conditions
      9  1.2.2.2  msaitoh  * are met:
     10  1.2.2.2  msaitoh  * 1. Redistributions of source code must retain the above copyright
     11  1.2.2.2  msaitoh  *    notice, this list of conditions and the following disclaimer.
     12  1.2.2.2  msaitoh  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2.2.2  msaitoh  *    notice, this list of conditions and the following disclaimer in the
     14  1.2.2.2  msaitoh  *    documentation and/or other materials provided with the distribution.
     15  1.2.2.2  msaitoh  * 3. Neither the name of the project nor the names of its contributors
     16  1.2.2.2  msaitoh  *    may be used to endorse or promote products derived from this software
     17  1.2.2.2  msaitoh  *    without specific prior written permission.
     18  1.2.2.2  msaitoh  *
     19  1.2.2.2  msaitoh  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     20  1.2.2.2  msaitoh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  1.2.2.2  msaitoh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  1.2.2.2  msaitoh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     23  1.2.2.2  msaitoh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  1.2.2.2  msaitoh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  1.2.2.2  msaitoh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  1.2.2.2  msaitoh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  1.2.2.2  msaitoh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  1.2.2.2  msaitoh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  1.2.2.2  msaitoh  * SUCH DAMAGE.
     30  1.2.2.2  msaitoh  */
     31  1.2.2.2  msaitoh 
     32  1.2.2.2  msaitoh /*
     33  1.2.2.2  msaitoh  * Copyright (c) 1982, 1986, 1990, 1993
     34  1.2.2.2  msaitoh  *	The Regents of the University of California.  All rights reserved.
     35  1.2.2.2  msaitoh  *
     36  1.2.2.2  msaitoh  * Redistribution and use in source and binary forms, with or without
     37  1.2.2.2  msaitoh  * modification, are permitted provided that the following conditions
     38  1.2.2.2  msaitoh  * are met:
     39  1.2.2.2  msaitoh  * 1. Redistributions of source code must retain the above copyright
     40  1.2.2.2  msaitoh  *    notice, this list of conditions and the following disclaimer.
     41  1.2.2.2  msaitoh  * 2. Redistributions in binary form must reproduce the above copyright
     42  1.2.2.2  msaitoh  *    notice, this list of conditions and the following disclaimer in the
     43  1.2.2.2  msaitoh  *    documentation and/or other materials provided with the distribution.
     44  1.2.2.2  msaitoh  * 3. All advertising materials mentioning features or use of this software
     45  1.2.2.2  msaitoh  *    must display the following acknowledgement:
     46  1.2.2.2  msaitoh  *	This product includes software developed by the University of
     47  1.2.2.2  msaitoh  *	California, Berkeley and its contributors.
     48  1.2.2.2  msaitoh  * 4. Neither the name of the University nor the names of its contributors
     49  1.2.2.2  msaitoh  *    may be used to endorse or promote products derived from this software
     50  1.2.2.2  msaitoh  *    without specific prior written permission.
     51  1.2.2.2  msaitoh  *
     52  1.2.2.2  msaitoh  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     53  1.2.2.2  msaitoh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  1.2.2.2  msaitoh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  1.2.2.2  msaitoh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     56  1.2.2.2  msaitoh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  1.2.2.2  msaitoh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  1.2.2.2  msaitoh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  1.2.2.2  msaitoh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  1.2.2.2  msaitoh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  1.2.2.2  msaitoh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  1.2.2.2  msaitoh  * SUCH DAMAGE.
     63  1.2.2.2  msaitoh  *
     64  1.2.2.2  msaitoh  *	@(#)in.h	8.3 (Berkeley) 1/3/94
     65  1.2.2.2  msaitoh  */
     66  1.2.2.2  msaitoh 
     67  1.2.2.2  msaitoh /*
     68  1.2.2.2  msaitoh  * Compatability shims with the rfc2553 API to simplify ntp.
     69  1.2.2.2  msaitoh  */
     70  1.2.2.2  msaitoh #ifndef NTP_RFC2553_H
     71  1.2.2.2  msaitoh #define NTP_RFC2553_H
     72  1.2.2.2  msaitoh 
     73  1.2.2.2  msaitoh #include <netdb.h>
     74  1.2.2.2  msaitoh #include <isc/net.h>
     75  1.2.2.2  msaitoh 
     76  1.2.2.2  msaitoh #include "ntp_types.h"
     77  1.2.2.2  msaitoh #include "ntp_malloc.h"
     78  1.2.2.2  msaitoh 
     79  1.2.2.2  msaitoh struct addrinfo *copy_addrinfo_impl(const struct addrinfo *
     80  1.2.2.2  msaitoh #ifdef EREALLOC_CALLSITE	/* from ntp_malloc.h */
     81  1.2.2.2  msaitoh 							   ,
     82  1.2.2.2  msaitoh 				    const char *, int
     83  1.2.2.2  msaitoh #endif
     84  1.2.2.2  msaitoh 					 );
     85  1.2.2.2  msaitoh struct addrinfo *copy_addrinfo_list_impl(const struct addrinfo *
     86  1.2.2.2  msaitoh #ifdef EREALLOC_CALLSITE	/* from ntp_malloc.h */
     87  1.2.2.2  msaitoh 								,
     88  1.2.2.2  msaitoh 					 const char *, int
     89  1.2.2.2  msaitoh #endif
     90  1.2.2.2  msaitoh 					 );
     91  1.2.2.2  msaitoh #ifdef EREALLOC_CALLSITE
     92  1.2.2.2  msaitoh # define copy_addrinfo(l) \
     93  1.2.2.2  msaitoh 	 copy_addrinfo_impl((l), __FILE__, __LINE__)
     94  1.2.2.2  msaitoh # define copy_addrinfo_list(l) \
     95  1.2.2.2  msaitoh 	 copy_addrinfo_list_impl((l), __FILE__, __LINE__)
     96  1.2.2.2  msaitoh #else
     97  1.2.2.2  msaitoh # define copy_addrinfo(l)	copy_addrinfo_impl(l)
     98  1.2.2.2  msaitoh # define copy_addrinfo_list(l)	copy_addrinfo_list_impl(l)
     99  1.2.2.2  msaitoh #endif
    100  1.2.2.2  msaitoh 
    101  1.2.2.2  msaitoh /*
    102  1.2.2.2  msaitoh  * If various macros are not defined we need to define them
    103  1.2.2.2  msaitoh  */
    104  1.2.2.2  msaitoh 
    105  1.2.2.2  msaitoh #ifndef AF_INET6
    106  1.2.2.2  msaitoh # define AF_INET6	AF_MAX
    107  1.2.2.2  msaitoh # define PF_INET6	AF_INET6
    108  1.2.2.2  msaitoh #endif
    109  1.2.2.2  msaitoh 
    110  1.2.2.2  msaitoh #if !defined(_SS_MAXSIZE) && !defined(_SS_ALIGNSIZE)
    111  1.2.2.2  msaitoh 
    112  1.2.2.2  msaitoh # define	_SS_MAXSIZE	128
    113  1.2.2.2  msaitoh # define	_SS_ALIGNSIZE	(sizeof(ntp_uint64_t))
    114  1.2.2.2  msaitoh # ifdef ISC_PLATFORM_HAVESALEN
    115  1.2.2.2  msaitoh #  define	_SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t))
    116  1.2.2.2  msaitoh #  define	_SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t) - \
    117  1.2.2.2  msaitoh 				_SS_PAD1SIZE - _SS_ALIGNSIZE)
    118  1.2.2.2  msaitoh # else
    119  1.2.2.2  msaitoh #  define	_SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(short))
    120  1.2.2.2  msaitoh #  define	_SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(short) - \
    121  1.2.2.2  msaitoh 				_SS_PAD1SIZE - _SS_ALIGNSIZE)
    122  1.2.2.2  msaitoh # endif /* ISC_PLATFORM_HAVESALEN */
    123  1.2.2.2  msaitoh #endif
    124  1.2.2.2  msaitoh 
    125  1.2.2.2  msaitoh #ifndef INET6_ADDRSTRLEN
    126  1.2.2.2  msaitoh # define	INET6_ADDRSTRLEN	46	/* max len of IPv6 addr in ascii */
    127  1.2.2.2  msaitoh #endif
    128  1.2.2.2  msaitoh 
    129  1.2.2.2  msaitoh /*
    130  1.2.2.2  msaitoh  * If we don't have the sockaddr_storage structure
    131  1.2.2.2  msaitoh  * we need to define it
    132  1.2.2.2  msaitoh  */
    133  1.2.2.2  msaitoh 
    134  1.2.2.2  msaitoh #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
    135  1.2.2.2  msaitoh struct sockaddr_storage {
    136  1.2.2.2  msaitoh #ifdef ISC_PLATFORM_HAVESALEN
    137  1.2.2.2  msaitoh 	ntp_u_int8_t	ss_len;		/* address length */
    138  1.2.2.2  msaitoh 	ntp_u_int8_t	ss_family;	/* address family */
    139  1.2.2.2  msaitoh #else
    140  1.2.2.2  msaitoh 	short		ss_family;	/* address family */
    141  1.2.2.2  msaitoh #endif
    142  1.2.2.2  msaitoh 	char		__ss_pad1[_SS_PAD1SIZE];
    143  1.2.2.2  msaitoh 	ntp_uint64_t	__ss_align;	/* force desired structure storage alignment */
    144  1.2.2.2  msaitoh 	char		__ss_pad2[_SS_PAD2SIZE];
    145  1.2.2.2  msaitoh };
    146  1.2.2.2  msaitoh #endif
    147  1.2.2.2  msaitoh 
    148  1.2.2.2  msaitoh /*
    149  1.2.2.2  msaitoh  * Finally if the platform doesn't support IPv6 we need some
    150  1.2.2.2  msaitoh  * additional definitions
    151  1.2.2.2  msaitoh  */
    152  1.2.2.2  msaitoh 
    153  1.2.2.2  msaitoh /*
    154  1.2.2.2  msaitoh  * Flag values for getaddrinfo()
    155  1.2.2.2  msaitoh  */
    156  1.2.2.2  msaitoh #ifndef AI_PASSIVE
    157  1.2.2.2  msaitoh #define	AI_PASSIVE	0x00000001 /* get address to use bind() */
    158  1.2.2.2  msaitoh #define	AI_CANONNAME	0x00000002 /* fill ai_canonname */
    159  1.2.2.2  msaitoh #define	AI_NUMERICHOST	0x00000004 /* prevent name resolution */
    160  1.2.2.2  msaitoh /* valid flags for addrinfo */
    161  1.2.2.2  msaitoh #define AI_MASK \
    162  1.2.2.2  msaitoh     (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
    163  1.2.2.2  msaitoh 
    164  1.2.2.2  msaitoh #define	AI_ADDRCONFIG	0x00000400 /* only if any address is assigned */
    165  1.2.2.2  msaitoh #endif	/* !AI_PASSIVE */
    166  1.2.2.2  msaitoh 
    167  1.2.2.2  msaitoh #ifndef AI_NUMERICHOST		/* such as AIX 4.3 */
    168  1.2.2.2  msaitoh # define Z_AI_NUMERICHOST	0
    169  1.2.2.2  msaitoh #else
    170  1.2.2.2  msaitoh # define Z_AI_NUMERICHOST	AI_NUMERICHOST
    171  1.2.2.2  msaitoh #endif
    172  1.2.2.2  msaitoh 
    173  1.2.2.2  msaitoh #ifndef AI_NUMERICSERV		/* not in RFC 2553 */
    174  1.2.2.2  msaitoh # define Z_AI_NUMERICSERV	0
    175  1.2.2.2  msaitoh #else
    176  1.2.2.2  msaitoh # define Z_AI_NUMERICSERV	AI_NUMERICSERV
    177  1.2.2.2  msaitoh #endif
    178  1.2.2.2  msaitoh 
    179  1.2.2.2  msaitoh #ifndef ISC_PLATFORM_HAVEIPV6
    180  1.2.2.2  msaitoh 
    181  1.2.2.2  msaitoh #ifdef SYS_WINNT
    182  1.2.2.2  msaitoh # define in6_addr in_addr6
    183  1.2.2.2  msaitoh #endif
    184  1.2.2.2  msaitoh 
    185  1.2.2.2  msaitoh struct addrinfo {
    186  1.2.2.2  msaitoh 	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
    187  1.2.2.2  msaitoh 	int	ai_family;	/* PF_xxx */
    188  1.2.2.2  msaitoh 	int	ai_socktype;	/* SOCK_xxx */
    189  1.2.2.2  msaitoh 	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
    190  1.2.2.2  msaitoh 	size_t	ai_addrlen;	/* length of ai_addr */
    191  1.2.2.2  msaitoh 	char	*ai_canonname;	/* canonical name for hostname */
    192  1.2.2.2  msaitoh 	struct	sockaddr *ai_addr;	/* binary address */
    193  1.2.2.2  msaitoh 	struct	addrinfo *ai_next;	/* next structure in linked list */
    194  1.2.2.2  msaitoh };
    195  1.2.2.2  msaitoh 
    196  1.2.2.2  msaitoh /*
    197  1.2.2.2  msaitoh  * Error return codes from getaddrinfo()
    198  1.2.2.2  msaitoh  */
    199  1.2.2.2  msaitoh #define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
    200  1.2.2.2  msaitoh #define	EAI_AGAIN	 2	/* temporary failure in name resolution */
    201  1.2.2.2  msaitoh #define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
    202  1.2.2.2  msaitoh #define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
    203  1.2.2.2  msaitoh #define	EAI_FAMILY	 5	/* ai_family not supported */
    204  1.2.2.2  msaitoh #define	EAI_MEMORY	 6	/* memory allocation failure */
    205  1.2.2.2  msaitoh #define	EAI_NODATA	 7	/* no address associated with hostname */
    206  1.2.2.2  msaitoh #define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
    207  1.2.2.2  msaitoh #define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
    208  1.2.2.2  msaitoh #define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
    209  1.2.2.2  msaitoh #define	EAI_SYSTEM	11	/* system error returned in errno */
    210  1.2.2.2  msaitoh #define	EAI_BADHINTS	12
    211  1.2.2.2  msaitoh #define	EAI_PROTOCOL	13
    212  1.2.2.2  msaitoh #define	EAI_MAX		14
    213  1.2.2.2  msaitoh 
    214  1.2.2.2  msaitoh 
    215  1.2.2.2  msaitoh int	getaddrinfo (const char *, const char *,
    216  1.2.2.2  msaitoh 			 const struct addrinfo *, struct addrinfo **);
    217  1.2.2.2  msaitoh int	getnameinfo (const struct sockaddr *, u_int, char *,
    218  1.2.2.2  msaitoh 			 size_t, char *, size_t, int);
    219  1.2.2.2  msaitoh void	freeaddrinfo (struct addrinfo *);
    220  1.2.2.2  msaitoh char	*gai_strerror (int);
    221  1.2.2.2  msaitoh 
    222  1.2.2.2  msaitoh /*
    223  1.2.2.2  msaitoh  * Constants for getnameinfo()
    224  1.2.2.2  msaitoh  */
    225  1.2.2.2  msaitoh #ifndef NI_MAXHOST
    226  1.2.2.2  msaitoh #define	NI_MAXHOST	1025
    227  1.2.2.2  msaitoh #define	NI_MAXSERV	32
    228  1.2.2.2  msaitoh #endif
    229  1.2.2.2  msaitoh 
    230  1.2.2.2  msaitoh /*
    231  1.2.2.2  msaitoh  * Flag values for getnameinfo()
    232  1.2.2.2  msaitoh  */
    233  1.2.2.2  msaitoh #ifndef NI_NUMERICHOST
    234  1.2.2.2  msaitoh #define	NI_NOFQDN	0x00000001
    235  1.2.2.2  msaitoh #define	NI_NUMERICHOST	0x00000002
    236  1.2.2.2  msaitoh #define	NI_NAMEREQD	0x00000004
    237  1.2.2.2  msaitoh #define	NI_NUMERICSERV	0x00000008
    238  1.2.2.2  msaitoh #define	NI_DGRAM	0x00000010
    239  1.2.2.2  msaitoh #define NI_WITHSCOPEID	0x00000020
    240  1.2.2.2  msaitoh #endif
    241  1.2.2.2  msaitoh 
    242  1.2.2.2  msaitoh #endif /* !ISC_PLATFORM_HAVEIPV6 */
    243  1.2.2.2  msaitoh 
    244  1.2.2.2  msaitoh /*
    245  1.2.2.2  msaitoh  * Set up some macros to look for IPv6 and IPv6 multicast
    246  1.2.2.2  msaitoh  */
    247  1.2.2.2  msaitoh 
    248  1.2.2.2  msaitoh #if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
    249  1.2.2.2  msaitoh # define INCLUDE_IPV6_SUPPORT
    250  1.2.2.2  msaitoh # if defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
    251  1.2.2.2  msaitoh #  define INCLUDE_IPV6_MULTICAST_SUPPORT
    252  1.2.2.2  msaitoh # endif	/* IPV6 Multicast Support */
    253  1.2.2.2  msaitoh #endif  /* IPv6 Support */
    254  1.2.2.2  msaitoh 
    255  1.2.2.2  msaitoh #endif /* !NTP_RFC2553_H */
    256