inet.h revision 189806
1154941Sjhb/*
2154941Sjhb * ++Copyright++ 1983, 1993
3154941Sjhb * -
4154941Sjhb * Copyright (c) 1983, 1993
5154941Sjhb *    The Regents of the University of California.  All rights reserved.
6154941Sjhb *
7154941Sjhb * Redistribution and use in source and binary forms, with or without
8154941Sjhb * modification, are permitted provided that the following conditions
9154941Sjhb * are met:
10154941Sjhb * 1. Redistributions of source code must retain the above copyright
11154941Sjhb *    notice, this list of conditions and the following disclaimer.
12154941Sjhb * 2. Redistributions in binary form must reproduce the above copyright
13154941Sjhb *    notice, this list of conditions and the following disclaimer in the
14154941Sjhb *    documentation and/or other materials provided with the distribution.
15154941Sjhb * 3. All advertising materials mentioning features or use of this software
16154941Sjhb *    must display the following acknowledgement:
17154941Sjhb * 	This product includes software developed by the University of
18154941Sjhb * 	California, Berkeley and its contributors.
19154941Sjhb * 4. Neither the name of the University nor the names of its contributors
20154941Sjhb *    may be used to endorse or promote products derived from this software
21154941Sjhb *    without specific prior written permission.
22154941Sjhb *
23154941Sjhb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24154941Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25154941Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26154941Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27154941Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28154941Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29154941Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30154941Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31154941Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32154941Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33154941Sjhb * SUCH DAMAGE.
34154941Sjhb * -
35154941Sjhb * Portions Copyright (c) 1993 by Digital Equipment Corporation.
36154941Sjhb *
37154941Sjhb * Permission to use, copy, modify, and distribute this software for any
38154941Sjhb * purpose with or without fee is hereby granted, provided that the above
39154941Sjhb * copyright notice and this permission notice appear in all copies, and that
40154941Sjhb * the name of Digital Equipment Corporation not be used in advertising or
41154941Sjhb * publicity pertaining to distribution of the document or software without
42154941Sjhb * specific, written prior permission.
43154941Sjhb *
44154941Sjhb * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
45154941Sjhb * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
46154941Sjhb * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
47154941Sjhb * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
48154941Sjhb * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
49154941Sjhb * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
50154941Sjhb * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
51154941Sjhb * SOFTWARE.
52154941Sjhb * -
53154941Sjhb * --Copyright--
54154941Sjhb */
55154941Sjhb
56154941Sjhb/*%
57154941Sjhb *	@(#)inet.h	8.1 (Berkeley) 6/2/93
58157882Sjhb *	$Id: inet.h,v 1.2.18.1 2005/04/27 05:00:50 sra Exp $
59154941Sjhb * $FreeBSD: head/include/arpa/inet.h 189806 2009-03-14 19:00:16Z das $
60154941Sjhb */
61154941Sjhb
62154941Sjhb#ifndef _ARPA_INET_H_
63154941Sjhb#define	_ARPA_INET_H_
64157826Sjhb
65157826Sjhb/* External definitions for functions in inet(3), addr2ascii(3) */
66157826Sjhb
67157826Sjhb#include <sys/cdefs.h>
68157826Sjhb#include <sys/_types.h>
69154941Sjhb
70154941Sjhb/* Required for byteorder(3) functions. */
71154941Sjhb#include <machine/endian.h>
72157826Sjhb
73157826Sjhb#define	INET_ADDRSTRLEN		16
74157826Sjhb#define	INET6_ADDRSTRLEN	46
75157826Sjhb
76157826Sjhb#ifndef _UINT16_T_DECLARED
77157826Sjhbtypedef	__uint16_t	uint16_t;
78157826Sjhb#define	_UINT16_T_DECLARED
79154941Sjhb#endif
80154941Sjhb
81154941Sjhb#ifndef _UINT32_T_DECLARED
82154941Sjhbtypedef	__uint32_t	uint32_t;
83154941Sjhb#define	_UINT32_T_DECLARED
84154941Sjhb#endif
85154941Sjhb
86154941Sjhb#ifndef _IN_ADDR_T_DECLARED
87154941Sjhbtypedef	uint32_t	in_addr_t;
88154941Sjhb#define	_IN_ADDR_T_DECLARED
89154941Sjhb#endif
90157882Sjhb
91154941Sjhb#ifndef _IN_PORT_T_DECLARED
92154941Sjhbtypedef	uint16_t	in_port_t;
93154941Sjhb#define	_IN_PORT_T_DECLARED
94154941Sjhb#endif
95154941Sjhb
96154941Sjhb#if __BSD_VISIBLE
97154941Sjhb#ifndef _SIZE_T_DECLARED
98154941Sjhbtypedef	__size_t	size_t;
99154941Sjhb#define	_SIZE_T_DECLARED
100154941Sjhb#endif
101154941Sjhb#endif
102154941Sjhb
103154941Sjhb/*
104154941Sjhb * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
105154941Sjhb * POSIX.1-2001.
106154941Sjhb */
107154941Sjhb#ifndef _SOCKLEN_T_DECLARED
108154941Sjhbtypedef	__socklen_t	socklen_t;
109154941Sjhb#define	_SOCKLEN_T_DECLARED
110154941Sjhb#endif
111154941Sjhb
112154941Sjhb#ifndef _STRUCT_IN_ADDR_DECLARED
113154941Sjhbstruct in_addr {
114157826Sjhb	in_addr_t s_addr;
115154941Sjhb};
116154941Sjhb#define	_STRUCT_IN_ADDR_DECLARED
117154941Sjhb#endif
118154941Sjhb
119154941Sjhb/* XXX all new diversions!! argh!! */
120154941Sjhb#if __BSD_VISIBLE
121154941Sjhb#define	inet_addr		__inet_addr
122154941Sjhb#define	inet_aton		__inet_aton
123154941Sjhb#define	inet_lnaof		__inet_lnaof
124154941Sjhb#define	inet_makeaddr		__inet_makeaddr
125154941Sjhb#define	inet_neta		__inet_neta
126154941Sjhb#define	inet_netof		__inet_netof
127154941Sjhb#define	inet_network		__inet_network
128154941Sjhb#define	inet_net_ntop		__inet_net_ntop
129154941Sjhb#define	inet_net_pton		__inet_net_pton
130154941Sjhb#define	inet_cidr_ntop		__inet_cidr_ntop
131154941Sjhb#define	inet_cidr_pton		__inet_cidr_pton
132154941Sjhb#define	inet_ntoa		__inet_ntoa
133154941Sjhb#define	inet_ntoa_r		__inet_ntoa_r
134154941Sjhb#define	inet_pton		__inet_pton
135154941Sjhb#define	inet_ntop		__inet_ntop
136154941Sjhb#define	inet_nsap_addr		__inet_nsap_addr
137154941Sjhb#define	inet_nsap_ntoa		__inet_nsap_ntoa
138157851Swkoszek#endif /* __BSD_VISIBLE */
139157846Sjhb
140157851Swkoszek__BEGIN_DECLS
141154941Sjhb#ifndef _BYTEORDER_PROTOTYPED
142154941Sjhb#define	_BYTEORDER_PROTOTYPED
143157826Sjhbuint32_t	 htonl(uint32_t);
144154941Sjhbuint16_t	 htons(uint16_t);
145154941Sjhbuint32_t	 ntohl(uint32_t);
146154941Sjhbuint16_t	 ntohs(uint16_t);
147154941Sjhb#endif
148154941Sjhb
149154941Sjhbin_addr_t	 inet_addr(const char *);
150154941Sjhb/*const*/ char	*inet_ntoa(struct in_addr);
151154941Sjhbconst char	*inet_ntop(int, const void * __restrict, char * __restrict,
152154941Sjhb		    socklen_t);
153154941Sjhbint		 inet_pton(int, const char * __restrict, void * __restrict);
154154941Sjhb
155154941Sjhb#if __BSD_VISIBLE
156154941Sjhbint		 inet_aton(const char *, struct in_addr *);
157154941Sjhbin_addr_t	 inet_lnaof(struct in_addr);
158154941Sjhbstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
159154941Sjhbchar *		 inet_neta(in_addr_t, char *, size_t);
160154941Sjhbin_addr_t	 inet_netof(struct in_addr);
161154941Sjhbin_addr_t	 inet_network(const char *);
162154941Sjhbchar		*inet_net_ntop(int, const void *, int, char *, size_t);
163154941Sjhbint		 inet_net_pton(int, const char *, void *, size_t);
164154941Sjhbchar		*inet_ntoa_r(struct in_addr, char *buf, socklen_t size);
165154941Sjhbchar		*inet_cidr_ntop(int, const void *, int, char *, size_t);
166154941Sjhbint		 inet_cidr_pton(int, const char *, void *, int *);
167154941Sjhbunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
168154941Sjhbchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
169154941Sjhb#endif /* __BSD_VISIBLE */
170154941Sjhb__END_DECLS
171154941Sjhb
172154941Sjhb#ifndef _BYTEORDER_FUNC_DEFINED
173154941Sjhb#define	_BYTEORDER_FUNC_DEFINED
174154941Sjhb#define	htonl(x)	__htonl(x)
175154941Sjhb#define	htons(x)	__htons(x)
176154941Sjhb#define	ntohl(x)	__ntohl(x)
177154941Sjhb#define	ntohs(x)	__ntohs(x)
178154941Sjhb#endif
179154941Sjhb
180154941Sjhb#endif /* !_ARPA_INET_H_ */
181154941Sjhb
182154941Sjhb/*! \file */
183154941Sjhb