xref: /freebsd/include/arpa/inet.h (revision fd8e4ebc8c18caec3eefac6527831f9ee6a92959)
159deaec5SRodney W. Grimes /*
259deaec5SRodney W. Grimes  * Copyright (c) 1983, 1993
359deaec5SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
459deaec5SRodney W. Grimes  *
559deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
659deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
759deaec5SRodney W. Grimes  * are met:
859deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
959deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
1059deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1159deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1259deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1359deaec5SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
1459deaec5SRodney W. Grimes  *    must display the following acknowledgement:
1559deaec5SRodney W. Grimes  *	This product includes software developed by the University of
1659deaec5SRodney W. Grimes  *	California, Berkeley and its contributors.
1759deaec5SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
1859deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
1959deaec5SRodney W. Grimes  *    without specific prior written permission.
2059deaec5SRodney W. Grimes  *
2159deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2259deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2359deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2459deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2559deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2659deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2759deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2859deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2959deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3059deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3159deaec5SRodney W. Grimes  * SUCH DAMAGE.
32f3f42e96SPeter Wemm  * -
33f3f42e96SPeter Wemm  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
34f3f42e96SPeter Wemm  *
35f3f42e96SPeter Wemm  * Permission to use, copy, modify, and distribute this software for any
36f3f42e96SPeter Wemm  * purpose with or without fee is hereby granted, provided that the above
37f3f42e96SPeter Wemm  * copyright notice and this permission notice appear in all copies, and that
38f3f42e96SPeter Wemm  * the name of Digital Equipment Corporation not be used in advertising or
39f3f42e96SPeter Wemm  * publicity pertaining to distribution of the document or software without
40f3f42e96SPeter Wemm  * specific, written prior permission.
41f3f42e96SPeter Wemm  *
42f3f42e96SPeter Wemm  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
43f3f42e96SPeter Wemm  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
44f3f42e96SPeter Wemm  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
45f3f42e96SPeter Wemm  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
46f3f42e96SPeter Wemm  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
47f3f42e96SPeter Wemm  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
48f3f42e96SPeter Wemm  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49f3f42e96SPeter Wemm  * SOFTWARE.
50fd8e4ebcSMike Barcroft  *
5159deaec5SRodney W. Grimes  *	@(#)inet.h	8.1 (Berkeley) 6/2/93
520160f9c0SPeter Wemm  *	From: Id: inet.h,v 8.5 1997/01/29 08:48:09 vixie Exp $
53a4add9a9SPeter Wemm  * $FreeBSD$
5459deaec5SRodney W. Grimes  */
5559deaec5SRodney W. Grimes 
56385e380aSPaul Richards #ifndef _ARPA_INET_H_
57385e380aSPaul Richards #define	_ARPA_INET_H_
5859deaec5SRodney W. Grimes 
59ffd1512dSGarrett Wollman /* External definitions for functions in inet(3), addr2ascii(3) */
6059deaec5SRodney W. Grimes 
6159deaec5SRodney W. Grimes #include <sys/cdefs.h>
62de2656d0SMike Barcroft #include <machine/ansi.h>
6359deaec5SRodney W. Grimes 
64fd8e4ebcSMike Barcroft /* Required for byteorder(3) functions. */
65fd8e4ebcSMike Barcroft #include <machine/endian.h>
66fd8e4ebcSMike Barcroft 
67de2656d0SMike Barcroft #ifndef	_IN_ADDR_T_DECLARED_
68de2656d0SMike Barcroft typedef	__uint32_t	in_addr_t;
69de2656d0SMike Barcroft #define	_IN_ADDR_T_DECLARED_
70de2656d0SMike Barcroft #endif
71de2656d0SMike Barcroft 
72de2656d0SMike Barcroft #ifndef	_IN_PORT_T_DECLARED_
734f25b0aaSMike Barcroft typedef	__uint16_t	in_port_t;
74de2656d0SMike Barcroft #define	_IN_PORT_T_DECLARED_
75de2656d0SMike Barcroft #endif
76de2656d0SMike Barcroft 
77de2656d0SMike Barcroft #ifndef _POSIX_SOURCE
78de2656d0SMike Barcroft #ifdef	_BSD_SIZE_T_
79de2656d0SMike Barcroft typedef	_BSD_SIZE_T_	size_t;
80de2656d0SMike Barcroft #undef	_BSD_SIZE_T_
81de2656d0SMike Barcroft #endif
82de2656d0SMike Barcroft #endif /* !_POSIX_SOURCE */
83de2656d0SMike Barcroft 
84de2656d0SMike Barcroft /*
85de2656d0SMike Barcroft  * XXX socklen_t is used by a POSIX.1-200x interface, but not required by
86de2656d0SMike Barcroft  * POSIX.1-200x.
87de2656d0SMike Barcroft  */
88de2656d0SMike Barcroft #ifdef	_BSD_SOCKLEN_T_
89de2656d0SMike Barcroft typedef	_BSD_SOCKLEN_T_	socklen_t;
90de2656d0SMike Barcroft #undef	_BSD_SOCKLEN_T_
91de2656d0SMike Barcroft #endif
92de2656d0SMike Barcroft 
93de2656d0SMike Barcroft #ifndef _STRUCT_IN_ADDR_DECLARED
94de2656d0SMike Barcroft struct in_addr {
95de2656d0SMike Barcroft 	in_addr_t s_addr;
96de2656d0SMike Barcroft };
97de2656d0SMike Barcroft #define	_STRUCT_IN_ADDR_DECLARED
98de2656d0SMike Barcroft #endif
99ffd1512dSGarrett Wollman 
1000160f9c0SPeter Wemm /* XXX all new diversions!! argh!! */
101de2656d0SMike Barcroft #ifndef _POSIX_SOURCE
1020160f9c0SPeter Wemm #define	inet_addr	__inet_addr
1030160f9c0SPeter Wemm #define	inet_aton	__inet_aton
1040160f9c0SPeter Wemm #define	inet_lnaof	__inet_lnaof
1050160f9c0SPeter Wemm #define	inet_makeaddr	__inet_makeaddr
1060160f9c0SPeter Wemm #define	inet_neta	__inet_neta
1070160f9c0SPeter Wemm #define	inet_netof	__inet_netof
1080160f9c0SPeter Wemm #define	inet_network	__inet_network
1090160f9c0SPeter Wemm #define	inet_net_ntop	__inet_net_ntop
1100160f9c0SPeter Wemm #define	inet_net_pton	__inet_net_pton
1110160f9c0SPeter Wemm #define	inet_ntoa	__inet_ntoa
1120160f9c0SPeter Wemm #define	inet_pton	__inet_pton
1130160f9c0SPeter Wemm #define	inet_ntop	__inet_ntop
1140160f9c0SPeter Wemm #define	inet_nsap_addr	__inet_nsap_addr
1150160f9c0SPeter Wemm #define	inet_nsap_ntoa	__inet_nsap_ntoa
116de2656d0SMike Barcroft #endif /* !_POSIX_SOURCE */
1170160f9c0SPeter Wemm 
118fd8e4ebcSMike Barcroft #ifndef _BYTEORDER_FUNC_DEFINED
119fd8e4ebcSMike Barcroft #define	_BYTEORDER_FUNC_DEFINED
120fd8e4ebcSMike Barcroft #define	htonl(x)	__htonl(x)
121fd8e4ebcSMike Barcroft #define	htons(x)	__htons(x)
122fd8e4ebcSMike Barcroft #define	ntohl(x)	__ntohl(x)
123fd8e4ebcSMike Barcroft #define	ntohs(x)	__ntohs(x)
124fd8e4ebcSMike Barcroft #endif
125fd8e4ebcSMike Barcroft 
12659deaec5SRodney W. Grimes __BEGIN_DECLS
127fd8e4ebcSMike Barcroft __uint32_t	 htonl(__uint32_t);
128fd8e4ebcSMike Barcroft __uint16_t	 htons(__uint16_t);
129de2656d0SMike Barcroft in_addr_t	 inet_addr __P((const char *));
130de2656d0SMike Barcroft char		*inet_ntoa __P((struct in_addr));
131de2656d0SMike Barcroft const char	*inet_ntop __P((int, const void *, char *, socklen_t));
132de2656d0SMike Barcroft int		 inet_pton __P((int, const char *, void *));
133fd8e4ebcSMike Barcroft __uint32_t	 ntohl(__uint32_t);
134fd8e4ebcSMike Barcroft __uint16_t	 ntohs(__uint16_t);
135de2656d0SMike Barcroft 
136de2656d0SMike Barcroft /* Nonstandard functions. */
137de2656d0SMike Barcroft #ifndef _POSIX_SOURCE
138ffd1512dSGarrett Wollman int		 ascii2addr __P((int, const char *, void *));
139ffd1512dSGarrett Wollman char		*addr2ascii __P((int, const void *, int, char *));
14059deaec5SRodney W. Grimes int		 inet_aton __P((const char *, struct in_addr *));
1412da24fa6SHajimu UMEMOTO in_addr_t	 inet_lnaof __P((struct in_addr));
1422da24fa6SHajimu UMEMOTO struct in_addr	 inet_makeaddr __P((in_addr_t, in_addr_t));
1432da24fa6SHajimu UMEMOTO char *		 inet_neta __P((in_addr_t, char *, size_t));
1442da24fa6SHajimu UMEMOTO in_addr_t	 inet_netof __P((struct in_addr));
1452da24fa6SHajimu UMEMOTO in_addr_t	 inet_network __P((const char *));
146f3f42e96SPeter Wemm char		*inet_net_ntop __P((int, const void *, int, char *, size_t));
147f3f42e96SPeter Wemm int		 inet_net_pton __P((int, const char *, void *, size_t));
148de2656d0SMike Barcroft unsigned	 inet_nsap_addr __P((const char *, unsigned char *, int));
149de2656d0SMike Barcroft char		*inet_nsap_ntoa __P((int, const unsigned char *, char *));
150de2656d0SMike Barcroft #endif /* !_POSIX_SOURCE */
15159deaec5SRodney W. Grimes __END_DECLS
15259deaec5SRodney W. Grimes 
153de2656d0SMike Barcroft #endif /* !_ARPA_INET_H_ */
154