xref: /illumos-gate/usr/src/boot/include/arpa/inet.h (revision 55fea89d)
1199767f8SToomas Soome /*
2199767f8SToomas Soome  * ++Copyright++ 1983, 1993
3199767f8SToomas Soome  * -
4199767f8SToomas Soome  * Copyright (c) 1983, 1993
5199767f8SToomas Soome  *    The Regents of the University of California.  All rights reserved.
6*55fea89dSDan Cross  *
7199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
8199767f8SToomas Soome  * modification, are permitted provided that the following conditions
9199767f8SToomas Soome  * are met:
10199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
11199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
12199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
13199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
14199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
15199767f8SToomas Soome  * 3. Neither the name of the University nor the names of its contributors
16199767f8SToomas Soome  *    may be used to endorse or promote products derived from this software
17199767f8SToomas Soome  *    without specific prior written permission.
18*55fea89dSDan Cross  *
19199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29199767f8SToomas Soome  * SUCH DAMAGE.
30199767f8SToomas Soome  * -
31199767f8SToomas Soome  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
32*55fea89dSDan Cross  *
33199767f8SToomas Soome  * Permission to use, copy, modify, and distribute this software for any
34199767f8SToomas Soome  * purpose with or without fee is hereby granted, provided that the above
35199767f8SToomas Soome  * copyright notice and this permission notice appear in all copies, and that
36199767f8SToomas Soome  * the name of Digital Equipment Corporation not be used in advertising or
37199767f8SToomas Soome  * publicity pertaining to distribution of the document or software without
38199767f8SToomas Soome  * specific, written prior permission.
39*55fea89dSDan Cross  *
40199767f8SToomas Soome  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
41199767f8SToomas Soome  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
42199767f8SToomas Soome  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
43199767f8SToomas Soome  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
44199767f8SToomas Soome  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
45199767f8SToomas Soome  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
46199767f8SToomas Soome  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47199767f8SToomas Soome  * SOFTWARE.
48199767f8SToomas Soome  * -
49199767f8SToomas Soome  * --Copyright--
50199767f8SToomas Soome  */
51199767f8SToomas Soome 
52199767f8SToomas Soome /*%
53199767f8SToomas Soome  *	@(#)inet.h	8.1 (Berkeley) 6/2/93
54199767f8SToomas Soome  *	$Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
55199767f8SToomas Soome  * $FreeBSD$
56199767f8SToomas Soome  */
57199767f8SToomas Soome 
58199767f8SToomas Soome #ifndef _ARPA_INET_H_
59199767f8SToomas Soome #define	_ARPA_INET_H_
60199767f8SToomas Soome 
61199767f8SToomas Soome /* External definitions for functions in inet(3). */
62199767f8SToomas Soome 
63199767f8SToomas Soome #include <sys/cdefs.h>
64199767f8SToomas Soome #include <sys/_types.h>
65199767f8SToomas Soome 
66199767f8SToomas Soome /* Required for byteorder(3) functions. */
67199767f8SToomas Soome #include <machine/endian.h>
68199767f8SToomas Soome 
69199767f8SToomas Soome #define	INET_ADDRSTRLEN		16
70199767f8SToomas Soome #define	INET6_ADDRSTRLEN	46
71199767f8SToomas Soome 
72199767f8SToomas Soome #ifndef _UINT16_T_DECLARED
73199767f8SToomas Soome typedef	__uint16_t	uint16_t;
74199767f8SToomas Soome #define	_UINT16_T_DECLARED
75199767f8SToomas Soome #endif
76199767f8SToomas Soome 
77199767f8SToomas Soome #ifndef _UINT32_T_DECLARED
78199767f8SToomas Soome typedef	__uint32_t	uint32_t;
79199767f8SToomas Soome #define	_UINT32_T_DECLARED
80199767f8SToomas Soome #endif
81199767f8SToomas Soome 
82199767f8SToomas Soome #ifndef _IN_ADDR_T_DECLARED
83199767f8SToomas Soome typedef	uint32_t	in_addr_t;
84199767f8SToomas Soome #define	_IN_ADDR_T_DECLARED
85199767f8SToomas Soome #endif
86199767f8SToomas Soome 
87199767f8SToomas Soome #ifndef _IN_PORT_T_DECLARED
88199767f8SToomas Soome typedef	uint16_t	in_port_t;
89199767f8SToomas Soome #define	_IN_PORT_T_DECLARED
90199767f8SToomas Soome #endif
91199767f8SToomas Soome 
92199767f8SToomas Soome #if __BSD_VISIBLE
93199767f8SToomas Soome #ifndef _SIZE_T_DECLARED
94199767f8SToomas Soome typedef	__size_t	size_t;
95199767f8SToomas Soome #define	_SIZE_T_DECLARED
96199767f8SToomas Soome #endif
97199767f8SToomas Soome #endif
98199767f8SToomas Soome 
99199767f8SToomas Soome /*
100199767f8SToomas Soome  * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
101199767f8SToomas Soome  * POSIX.1-2001.
102199767f8SToomas Soome  */
103199767f8SToomas Soome #ifndef _SOCKLEN_T_DECLARED
104199767f8SToomas Soome typedef	__socklen_t	socklen_t;
105199767f8SToomas Soome #define	_SOCKLEN_T_DECLARED
106199767f8SToomas Soome #endif
107199767f8SToomas Soome 
108199767f8SToomas Soome #ifndef _STRUCT_IN_ADDR_DECLARED
109199767f8SToomas Soome struct in_addr {
110199767f8SToomas Soome 	in_addr_t s_addr;
111199767f8SToomas Soome };
112199767f8SToomas Soome #define	_STRUCT_IN_ADDR_DECLARED
113199767f8SToomas Soome #endif
114199767f8SToomas Soome 
115199767f8SToomas Soome /* XXX all new diversions!! argh!! */
116199767f8SToomas Soome #if __BSD_VISIBLE
117199767f8SToomas Soome #define	inet_addr		__inet_addr
118199767f8SToomas Soome #define	inet_aton		__inet_aton
119199767f8SToomas Soome #define	inet_lnaof		__inet_lnaof
120199767f8SToomas Soome #define	inet_makeaddr		__inet_makeaddr
121199767f8SToomas Soome #define	inet_neta		__inet_neta
122199767f8SToomas Soome #define	inet_netof		__inet_netof
123199767f8SToomas Soome #define	inet_network		__inet_network
124199767f8SToomas Soome #define	inet_net_ntop		__inet_net_ntop
125199767f8SToomas Soome #define	inet_net_pton		__inet_net_pton
126199767f8SToomas Soome #define	inet_cidr_ntop		__inet_cidr_ntop
127199767f8SToomas Soome #define	inet_cidr_pton		__inet_cidr_pton
128199767f8SToomas Soome #define	inet_ntoa		__inet_ntoa
129199767f8SToomas Soome #define	inet_ntoa_r		__inet_ntoa_r
130199767f8SToomas Soome #define	inet_pton		__inet_pton
131199767f8SToomas Soome #define	inet_ntop		__inet_ntop
132199767f8SToomas Soome #define	inet_nsap_addr		__inet_nsap_addr
133199767f8SToomas Soome #define	inet_nsap_ntoa		__inet_nsap_ntoa
134199767f8SToomas Soome #endif /* __BSD_VISIBLE */
135199767f8SToomas Soome 
136199767f8SToomas Soome __BEGIN_DECLS
137199767f8SToomas Soome #ifndef _BYTEORDER_PROTOTYPED
138199767f8SToomas Soome #define	_BYTEORDER_PROTOTYPED
139199767f8SToomas Soome uint32_t	 htonl(uint32_t);
140199767f8SToomas Soome uint16_t	 htons(uint16_t);
141199767f8SToomas Soome uint32_t	 ntohl(uint32_t);
142199767f8SToomas Soome uint16_t	 ntohs(uint16_t);
143199767f8SToomas Soome #endif
144199767f8SToomas Soome 
145199767f8SToomas Soome in_addr_t	 inet_addr(const char *);
146199767f8SToomas Soome /*const*/ char	*inet_ntoa(struct in_addr);
147199767f8SToomas Soome const char	*inet_ntop(int, const void * __restrict, char * __restrict,
148199767f8SToomas Soome 		    socklen_t);
149199767f8SToomas Soome int		 inet_pton(int, const char * __restrict, void * __restrict);
150199767f8SToomas Soome 
151199767f8SToomas Soome #if __BSD_VISIBLE
152199767f8SToomas Soome int		 inet_aton(const char *, struct in_addr *);
153199767f8SToomas Soome in_addr_t	 inet_lnaof(struct in_addr);
154199767f8SToomas Soome struct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
155199767f8SToomas Soome char *		 inet_neta(in_addr_t, char *, size_t);
156199767f8SToomas Soome in_addr_t	 inet_netof(struct in_addr);
157199767f8SToomas Soome in_addr_t	 inet_network(const char *);
158199767f8SToomas Soome char		*inet_net_ntop(int, const void *, int, char *, size_t);
159199767f8SToomas Soome int		 inet_net_pton(int, const char *, void *, size_t);
160199767f8SToomas Soome char		*inet_ntoa_r(struct in_addr, char *buf, socklen_t size);
161199767f8SToomas Soome char		*inet_cidr_ntop(int, const void *, int, char *, size_t);
162199767f8SToomas Soome int		 inet_cidr_pton(int, const char *, void *, int *);
163199767f8SToomas Soome unsigned	 inet_nsap_addr(const char *, unsigned char *, int);
164199767f8SToomas Soome char		*inet_nsap_ntoa(int, const unsigned char *, char *);
165199767f8SToomas Soome #endif /* __BSD_VISIBLE */
166199767f8SToomas Soome __END_DECLS
167199767f8SToomas Soome 
168199767f8SToomas Soome #ifndef _BYTEORDER_FUNC_DEFINED
169199767f8SToomas Soome #define	_BYTEORDER_FUNC_DEFINED
170199767f8SToomas Soome #define	htonl(x)	__htonl(x)
171199767f8SToomas Soome #define	htons(x)	__htons(x)
172199767f8SToomas Soome #define	ntohl(x)	__ntohl(x)
173199767f8SToomas Soome #define	ntohs(x)	__ntohs(x)
174199767f8SToomas Soome #endif
175199767f8SToomas Soome 
176199767f8SToomas Soome #endif /* !_ARPA_INET_H_ */
177199767f8SToomas Soome 
178199767f8SToomas Soome /*! \file */
179