inet.h revision 156960
11539Srgrimes/*
2156960Sume * ++Copyright++ 1983, 1993
3156960Sume * -
41539Srgrimes * Copyright (c) 1983, 1993
5156960Sume *    The Regents of the University of California.  All rights reserved.
6156960Sume *
71539Srgrimes * Redistribution and use in source and binary forms, with or without
81539Srgrimes * modification, are permitted provided that the following conditions
91539Srgrimes * are met:
101539Srgrimes * 1. Redistributions of source code must retain the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer.
121539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
131539Srgrimes *    notice, this list of conditions and the following disclaimer in the
141539Srgrimes *    documentation and/or other materials provided with the distribution.
151539Srgrimes * 3. All advertising materials mentioning features or use of this software
161539Srgrimes *    must display the following acknowledgement:
17156960Sume * 	This product includes software developed by the University of
18156960Sume * 	California, Berkeley and its contributors.
191539Srgrimes * 4. Neither the name of the University nor the names of its contributors
201539Srgrimes *    may be used to endorse or promote products derived from this software
211539Srgrimes *    without specific prior written permission.
22156960Sume *
231539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331539Srgrimes * SUCH DAMAGE.
3421056Speter * -
3521056Speter * Portions Copyright (c) 1993 by Digital Equipment Corporation.
36156960Sume *
3721056Speter * Permission to use, copy, modify, and distribute this software for any
3821056Speter * purpose with or without fee is hereby granted, provided that the above
3921056Speter * copyright notice and this permission notice appear in all copies, and that
4021056Speter * the name of Digital Equipment Corporation not be used in advertising or
4121056Speter * publicity pertaining to distribution of the document or software without
4221056Speter * specific, written prior permission.
4321056Speter *
4421056Speter * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
4521056Speter * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
4621056Speter * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
4721056Speter * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
4821056Speter * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
4921056Speter * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
5021056Speter * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
5121056Speter * SOFTWARE.
52156960Sume * -
53156960Sume * --Copyright--
54156960Sume */
55156960Sume
56156960Sume/*
571539Srgrimes *	@(#)inet.h	8.1 (Berkeley) 6/2/93
58156960Sume *	$Id: inet.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp $
5950473Speter * $FreeBSD: head/include/arpa/inet.h 156960 2006-03-21 16:11:11Z ume $
601539Srgrimes */
611539Srgrimes
622163Spaul#ifndef _ARPA_INET_H_
632163Spaul#define	_ARPA_INET_H_
641539Srgrimes
6516352Swollman/* External definitions for functions in inet(3), addr2ascii(3) */
661539Srgrimes
671539Srgrimes#include <sys/cdefs.h>
68102227Smike#include <sys/_types.h>
691539Srgrimes
7090868Smike/* Required for byteorder(3) functions. */
7190868Smike#include <machine/endian.h>
7290868Smike
7391984Smike#define	INET_ADDRSTRLEN		16
7491984Smike#define	INET6_ADDRSTRLEN	46
7591984Smike
7693514Smike#ifndef _UINT16_T_DECLARED
7793514Smiketypedef	__uint16_t	uint16_t;
7893514Smike#define	_UINT16_T_DECLARED
7987158Smike#endif
8016352Swollman
8193514Smike#ifndef _UINT32_T_DECLARED
8293514Smiketypedef	__uint32_t	uint32_t;
8393514Smike#define	_UINT32_T_DECLARED
8487158Smike#endif
8587158Smike
86101995Smike#ifndef _IN_ADDR_T_DECLARED
8793514Smiketypedef	uint32_t	in_addr_t;
8893514Smike#define	_IN_ADDR_T_DECLARED
8993514Smike#endif
9093514Smike
91101995Smike#ifndef _IN_PORT_T_DECLARED
9293514Smiketypedef	uint16_t	in_port_t;
9393514Smike#define	_IN_PORT_T_DECLARED
9493514Smike#endif
9593514Smike
96101995Smike#if __BSD_VISIBLE
97102227Smike#ifndef _SIZE_T_DECLARED
98102227Smiketypedef	__size_t	size_t;
99102227Smike#define	_SIZE_T_DECLARED
10087158Smike#endif
101101995Smike#endif
10287158Smike
10387158Smike/*
10491984Smike * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
10591984Smike * POSIX.1-2001.
10687158Smike */
107102227Smike#ifndef _SOCKLEN_T_DECLARED
108102227Smiketypedef	__socklen_t	socklen_t;
109102227Smike#define	_SOCKLEN_T_DECLARED
11087158Smike#endif
11187158Smike
11287158Smike#ifndef _STRUCT_IN_ADDR_DECLARED
11387158Smikestruct in_addr {
11487158Smike	in_addr_t s_addr;
11587158Smike};
11687158Smike#define	_STRUCT_IN_ADDR_DECLARED
11787158Smike#endif
11887158Smike
11936888Speter/* XXX all new diversions!! argh!! */
12094353Smike#if __BSD_VISIBLE
121156960Sume#define	inet_addr		__inet_addr
122156960Sume#define	inet_aton		__inet_aton
123156960Sume#define	inet_lnaof		__inet_lnaof
124156960Sume#define	inet_makeaddr		__inet_makeaddr
125156960Sume#define	inet_neta		__inet_neta
126156960Sume#define	inet_netof		__inet_netof
127156960Sume#define	inet_network		__inet_network
128156960Sume#define	inet_net_ntop		__inet_net_ntop
129156960Sume#define	inet_net_pton		__inet_net_pton
130156960Sume#define	inet_cidr_ntop		__inet_cidr_ntop
131156960Sume#define	inet_cidr_pton		__inet_cidr_pton
132156960Sume#define	inet_ntoa		__inet_ntoa
133156960Sume#define	inet_pton		__inet_pton
134156960Sume#define	inet_ntop		__inet_ntop
135156960Sume#define	inet_nsap_addr		__inet_nsap_addr
136156960Sume#define	inet_nsap_ntoa		__inet_nsap_ntoa
13794353Smike#endif /* __BSD_VISIBLE */
13836888Speter
13991959Smike__BEGIN_DECLS
14091959Smike#ifndef _BYTEORDER_PROTOTYPED
14191959Smike#define	_BYTEORDER_PROTOTYPED
14293514Smikeuint32_t	 htonl(uint32_t);
14393514Smikeuint16_t	 htons(uint16_t);
14493514Smikeuint32_t	 ntohl(uint32_t);
14593514Smikeuint16_t	 ntohs(uint16_t);
14690868Smike#endif
14790868Smike
14893032Simpin_addr_t	 inet_addr(const char *);
149156960Sume/*const*/ char	*inet_ntoa(struct in_addr);
150101995Smikeconst char	*inet_ntop(int, const void * __restrict, char * __restrict,
151101995Smike		    socklen_t);
152101995Smikeint		 inet_pton(int, const char * __restrict, void * __restrict);
15387158Smike
15494353Smike#if __BSD_VISIBLE
15593032Simpint		 ascii2addr(int, const char *, void *);
15693032Simpchar		*addr2ascii(int, const void *, int, char *);
15793032Simpint		 inet_aton(const char *, struct in_addr *);
15893032Simpin_addr_t	 inet_lnaof(struct in_addr);
15993032Simpstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
16093032Simpchar *		 inet_neta(in_addr_t, char *, size_t);
16193032Simpin_addr_t	 inet_netof(struct in_addr);
16293032Simpin_addr_t	 inet_network(const char *);
16393032Simpchar		*inet_net_ntop(int, const void *, int, char *, size_t);
16493032Simpint		 inet_net_pton(int, const char *, void *, size_t);
165156960Sumechar		*inet_cidr_ntop(int, const void *, int, char *, size_t);
166156960Sumeint		 inet_cidr_pton(int, const char *, void *, int *);
16793032Simpunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
16893032Simpchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
16994353Smike#endif /* __BSD_VISIBLE */
1701539Srgrimes__END_DECLS
1711539Srgrimes
17291959Smike#ifndef _BYTEORDER_FUNC_DEFINED
17391959Smike#define	_BYTEORDER_FUNC_DEFINED
17491959Smike#define	htonl(x)	__htonl(x)
17591959Smike#define	htons(x)	__htons(x)
17691959Smike#define	ntohl(x)	__ntohl(x)
17791959Smike#define	ntohs(x)	__ntohs(x)
17891959Smike#endif
17991959Smike
18087158Smike#endif /* !_ARPA_INET_H_ */
181