inet.h revision 94353
1168404Spjd/*
2168404Spjd * Copyright (c) 1983, 1993
3168404Spjd *	The Regents of the University of California.  All rights reserved.
4168404Spjd *
5168404Spjd * Redistribution and use in source and binary forms, with or without
6168404Spjd * modification, are permitted provided that the following conditions
7168404Spjd * are met:
8168404Spjd * 1. Redistributions of source code must retain the above copyright
9168404Spjd *    notice, this list of conditions and the following disclaimer.
10168404Spjd * 2. Redistributions in binary form must reproduce the above copyright
11168404Spjd *    notice, this list of conditions and the following disclaimer in the
12168404Spjd *    documentation and/or other materials provided with the distribution.
13168404Spjd * 3. All advertising materials mentioning features or use of this software
14168404Spjd *    must display the following acknowledgement:
15168404Spjd *	This product includes software developed by the University of
16168404Spjd *	California, Berkeley and its contributors.
17168404Spjd * 4. Neither the name of the University nor the names of its contributors
18168404Spjd *    may be used to endorse or promote products derived from this software
19168404Spjd *    without specific prior written permission.
20168404Spjd *
21168404Spjd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22168404Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23168404Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24168404Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25168404Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26168404Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27168404Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28168404Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29168404Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30168404Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31168404Spjd * SUCH DAMAGE.
32168404Spjd * -
33168404Spjd * Portions Copyright (c) 1993 by Digital Equipment Corporation.
34168404Spjd *
35168404Spjd * Permission to use, copy, modify, and distribute this software for any
36168404Spjd * purpose with or without fee is hereby granted, provided that the above
37168404Spjd * copyright notice and this permission notice appear in all copies, and that
38168404Spjd * the name of Digital Equipment Corporation not be used in advertising or
39168404Spjd * publicity pertaining to distribution of the document or software without
40168404Spjd * specific, written prior permission.
41168404Spjd *
42168404Spjd * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
43168404Spjd * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
44168404Spjd * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
45168404Spjd * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
46168404Spjd * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
47168404Spjd * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
48168404Spjd * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49168404Spjd * SOFTWARE.
50168404Spjd *
51168404Spjd *	@(#)inet.h	8.1 (Berkeley) 6/2/93
52168404Spjd *	From: Id: inet.h,v 8.5 1997/01/29 08:48:09 vixie Exp $
53168404Spjd * $FreeBSD: head/include/arpa/inet.h 94353 2002-04-10 10:51:53Z mike $
54168404Spjd */
55168404Spjd
56168404Spjd#ifndef _ARPA_INET_H_
57168404Spjd#define	_ARPA_INET_H_
58168404Spjd
59168404Spjd/* External definitions for functions in inet(3), addr2ascii(3) */
60168404Spjd
61168404Spjd#include <sys/cdefs.h>
62168404Spjd#include <machine/ansi.h>
63168404Spjd
64168404Spjd/* Required for byteorder(3) functions. */
65168404Spjd#include <machine/endian.h>
66168404Spjd
67168404Spjd#define	INET_ADDRSTRLEN		16
68168404Spjd#define	INET6_ADDRSTRLEN	46
69168404Spjd
70168404Spjd#ifndef _UINT16_T_DECLARED
71168404Spjdtypedef	__uint16_t	uint16_t;
72168404Spjd#define	_UINT16_T_DECLARED
73168404Spjd#endif
74168404Spjd
75168404Spjd#ifndef _UINT32_T_DECLARED
76168404Spjdtypedef	__uint32_t	uint32_t;
77168404Spjd#define	_UINT32_T_DECLARED
78168404Spjd#endif
79168404Spjd
80168404Spjd#ifndef	_IN_ADDR_T_DECLARED
81168404Spjdtypedef	uint32_t	in_addr_t;
82168404Spjd#define	_IN_ADDR_T_DECLARED
83168404Spjd#endif
84168404Spjd
85168404Spjd#ifndef	_IN_PORT_T_DECLARED
86168404Spjdtypedef	uint16_t	in_port_t;
87168404Spjd#define	_IN_PORT_T_DECLARED
88168404Spjd#endif
89168404Spjd
90168404Spjd#ifndef _POSIX_SOURCE
91168404Spjd#ifdef	_BSD_SIZE_T_
92168404Spjdtypedef	_BSD_SIZE_T_	size_t;
93168404Spjd#undef	_BSD_SIZE_T_
94168404Spjd#endif
95168404Spjd#endif /* !_POSIX_SOURCE */
96168404Spjd
97168404Spjd/*
98168404Spjd * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
99168404Spjd * POSIX.1-2001.
100168404Spjd */
101168404Spjd#ifdef	_BSD_SOCKLEN_T_
102168404Spjdtypedef	_BSD_SOCKLEN_T_	socklen_t;
103168404Spjd#undef	_BSD_SOCKLEN_T_
104168404Spjd#endif
105168404Spjd
106168404Spjd#ifndef _STRUCT_IN_ADDR_DECLARED
107168404Spjdstruct in_addr {
108168404Spjd	in_addr_t s_addr;
109168404Spjd};
110168404Spjd#define	_STRUCT_IN_ADDR_DECLARED
111168404Spjd#endif
112168404Spjd
113168404Spjd/* XXX all new diversions!! argh!! */
114168404Spjd#if __BSD_VISIBLE
115168404Spjd#define	inet_addr	__inet_addr
116168404Spjd#define	inet_aton	__inet_aton
117168404Spjd#define	inet_lnaof	__inet_lnaof
118168404Spjd#define	inet_makeaddr	__inet_makeaddr
119168404Spjd#define	inet_neta	__inet_neta
120168404Spjd#define	inet_netof	__inet_netof
121168404Spjd#define	inet_network	__inet_network
122168404Spjd#define	inet_net_ntop	__inet_net_ntop
123168404Spjd#define	inet_net_pton	__inet_net_pton
124168404Spjd#define	inet_ntoa	__inet_ntoa
125168404Spjd#define	inet_pton	__inet_pton
126168404Spjd#define	inet_ntop	__inet_ntop
127168404Spjd#define	inet_nsap_addr	__inet_nsap_addr
128168404Spjd#define	inet_nsap_ntoa	__inet_nsap_ntoa
129168404Spjd#endif /* __BSD_VISIBLE */
130168404Spjd
131168404Spjd__BEGIN_DECLS
132168404Spjd#ifndef _BYTEORDER_PROTOTYPED
133168404Spjd#define	_BYTEORDER_PROTOTYPED
134168404Spjduint32_t	 htonl(uint32_t);
135168404Spjduint16_t	 htons(uint16_t);
136168404Spjduint32_t	 ntohl(uint32_t);
137168404Spjduint16_t	 ntohs(uint16_t);
138168404Spjd#endif
139168404Spjd
140168404Spjdin_addr_t	 inet_addr(const char *);
141168404Spjdchar		*inet_ntoa(struct in_addr);
142168404Spjdconst char	*inet_ntop(int, const void *, char *, socklen_t);
143168404Spjdint		 inet_pton(int, const char *, void *);
144168404Spjd
145168404Spjd#if __BSD_VISIBLE
146168404Spjdint		 ascii2addr(int, const char *, void *);
147168404Spjdchar		*addr2ascii(int, const void *, int, char *);
148168404Spjdint		 inet_aton(const char *, struct in_addr *);
149168404Spjdin_addr_t	 inet_lnaof(struct in_addr);
150168404Spjdstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
151168404Spjdchar *		 inet_neta(in_addr_t, char *, size_t);
152168404Spjdin_addr_t	 inet_netof(struct in_addr);
153168473Spjdin_addr_t	 inet_network(const char *);
154168473Spjdchar		*inet_net_ntop(int, const void *, int, char *, size_t);
155168473Spjdint		 inet_net_pton(int, const char *, void *, size_t);
156168473Spjdunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
157168473Spjdchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
158172030Spjd#endif /* __BSD_VISIBLE */
159168473Spjd__END_DECLS
160172030Spjd
161168473Spjd#ifndef _BYTEORDER_FUNC_DEFINED
162168404Spjd#define	_BYTEORDER_FUNC_DEFINED
163168404Spjd#define	htonl(x)	__htonl(x)
164168404Spjd#define	htons(x)	__htons(x)
165168404Spjd#define	ntohl(x)	__ntohl(x)
166168404Spjd#define	ntohs(x)	__ntohs(x)
167168404Spjd#endif
168168404Spjd
169168404Spjd#endif /* !_ARPA_INET_H_ */
170168404Spjd