inet.h revision 91984
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1983, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
3221056Speter * -
3321056Speter * Portions Copyright (c) 1993 by Digital Equipment Corporation.
341539Srgrimes *
3521056Speter * Permission to use, copy, modify, and distribute this software for any
3621056Speter * purpose with or without fee is hereby granted, provided that the above
3721056Speter * copyright notice and this permission notice appear in all copies, and that
3821056Speter * the name of Digital Equipment Corporation not be used in advertising or
3921056Speter * publicity pertaining to distribution of the document or software without
4021056Speter * specific, written prior permission.
4121056Speter *
4221056Speter * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
4321056Speter * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
4421056Speter * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
4521056Speter * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
4621056Speter * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
4721056Speter * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
4821056Speter * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
4921056Speter * SOFTWARE.
5090868Smike *
511539Srgrimes *	@(#)inet.h	8.1 (Berkeley) 6/2/93
5236888Speter *	From: Id: inet.h,v 8.5 1997/01/29 08:48:09 vixie Exp $
5350473Speter * $FreeBSD: head/include/arpa/inet.h 91984 2002-03-10 06:42:27Z mike $
541539Srgrimes */
551539Srgrimes
562163Spaul#ifndef _ARPA_INET_H_
572163Spaul#define	_ARPA_INET_H_
581539Srgrimes
5916352Swollman/* External definitions for functions in inet(3), addr2ascii(3) */
601539Srgrimes
611539Srgrimes#include <sys/cdefs.h>
6287158Smike#include <machine/ansi.h>
631539Srgrimes
6490868Smike/* Required for byteorder(3) functions. */
6590868Smike#include <machine/endian.h>
6690868Smike
6791984Smike#ifndef INET_ADDRSTRLEN
6891984Smike#define	INET_ADDRSTRLEN		16
6991984Smike#endif
7091984Smike
7191984Smike#ifndef INET6_ADDRSTRLEN
7291984Smike#define	INET6_ADDRSTRLEN	46
7391984Smike#endif
7491984Smike
7587158Smike#ifndef	_IN_ADDR_T_DECLARED_
7687158Smiketypedef	__uint32_t	in_addr_t;
7787158Smike#define	_IN_ADDR_T_DECLARED_
7887158Smike#endif
7916352Swollman
8087158Smike#ifndef	_IN_PORT_T_DECLARED_
8187159Smiketypedef	__uint16_t	in_port_t;
8287158Smike#define	_IN_PORT_T_DECLARED_
8387158Smike#endif
8487158Smike
8587158Smike#ifndef _POSIX_SOURCE
8687158Smike#ifdef	_BSD_SIZE_T_
8787158Smiketypedef	_BSD_SIZE_T_	size_t;
8887158Smike#undef	_BSD_SIZE_T_
8987158Smike#endif
9087158Smike#endif /* !_POSIX_SOURCE */
9187158Smike
9287158Smike/*
9391984Smike * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
9491984Smike * POSIX.1-2001.
9587158Smike */
9687158Smike#ifdef	_BSD_SOCKLEN_T_
9787158Smiketypedef	_BSD_SOCKLEN_T_	socklen_t;
9887158Smike#undef	_BSD_SOCKLEN_T_
9987158Smike#endif
10087158Smike
10187158Smike#ifndef _STRUCT_IN_ADDR_DECLARED
10287158Smikestruct in_addr {
10387158Smike	in_addr_t s_addr;
10487158Smike};
10587158Smike#define	_STRUCT_IN_ADDR_DECLARED
10687158Smike#endif
10787158Smike
10891984Smike/*
10991984Smike * XXX missing typedefs for uint16_t and uint32_t.
11091984Smike */
11191984Smike
11236888Speter/* XXX all new diversions!! argh!! */
11387158Smike#ifndef _POSIX_SOURCE
11436888Speter#define	inet_addr	__inet_addr
11536888Speter#define	inet_aton	__inet_aton
11636888Speter#define	inet_lnaof	__inet_lnaof
11736888Speter#define	inet_makeaddr	__inet_makeaddr
11836888Speter#define	inet_neta	__inet_neta
11936888Speter#define	inet_netof	__inet_netof
12036888Speter#define	inet_network	__inet_network
12136888Speter#define	inet_net_ntop	__inet_net_ntop
12236888Speter#define	inet_net_pton	__inet_net_pton
12336888Speter#define	inet_ntoa	__inet_ntoa
12436888Speter#define	inet_pton	__inet_pton
12536888Speter#define	inet_ntop	__inet_ntop
12636888Speter#define	inet_nsap_addr	__inet_nsap_addr
12736888Speter#define	inet_nsap_ntoa	__inet_nsap_ntoa
12887158Smike#endif /* !_POSIX_SOURCE */
12936888Speter
13091959Smike__BEGIN_DECLS
13191959Smike#ifndef _BYTEORDER_PROTOTYPED
13291959Smike#define	_BYTEORDER_PROTOTYPED
13391959Smike__uint32_t	 htonl __P((__uint32_t));
13491959Smike__uint16_t	 htons __P((__uint16_t));
13591959Smike__uint32_t	 ntohl __P((__uint32_t));
13691959Smike__uint16_t	 ntohs __P((__uint16_t));
13790868Smike#endif
13890868Smike
13987158Smikein_addr_t	 inet_addr __P((const char *));
14087158Smikechar		*inet_ntoa __P((struct in_addr));
14187158Smikeconst char	*inet_ntop __P((int, const void *, char *, socklen_t));
14287158Smikeint		 inet_pton __P((int, const char *, void *));
14387158Smike
14487158Smike/* Nonstandard functions. */
14587158Smike#ifndef _POSIX_SOURCE
14616352Swollmanint		 ascii2addr __P((int, const char *, void *));
14716352Swollmanchar		*addr2ascii __P((int, const void *, int, char *));
1481539Srgrimesint		 inet_aton __P((const char *, struct in_addr *));
14974700Sumein_addr_t	 inet_lnaof __P((struct in_addr));
15074700Sumestruct in_addr	 inet_makeaddr __P((in_addr_t, in_addr_t));
15174700Sumechar *		 inet_neta __P((in_addr_t, char *, size_t));
15274700Sumein_addr_t	 inet_netof __P((struct in_addr));
15374700Sumein_addr_t	 inet_network __P((const char *));
15421056Speterchar		*inet_net_ntop __P((int, const void *, int, char *, size_t));
15521056Speterint		 inet_net_pton __P((int, const char *, void *, size_t));
15687158Smikeunsigned	 inet_nsap_addr __P((const char *, unsigned char *, int));
15787158Smikechar		*inet_nsap_ntoa __P((int, const unsigned char *, char *));
15887158Smike#endif /* !_POSIX_SOURCE */
1591539Srgrimes__END_DECLS
1601539Srgrimes
16191959Smike#ifndef _BYTEORDER_FUNC_DEFINED
16291959Smike#define	_BYTEORDER_FUNC_DEFINED
16391959Smike#define	htonl(x)	__htonl(x)
16491959Smike#define	htons(x)	__htons(x)
16591959Smike#define	ntohl(x)	__ntohl(x)
16691959Smike#define	ntohs(x)	__ntohs(x)
16791959Smike#endif
16891959Smike
16987158Smike#endif /* !_ARPA_INET_H_ */
170