inet.h revision 93514
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 93514 2002-04-01 08:12:25Z 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
7593514Smike#ifndef _UINT16_T_DECLARED
7693514Smiketypedef	__uint16_t	uint16_t;
7793514Smike#define	_UINT16_T_DECLARED
7887158Smike#endif
7916352Swollman
8093514Smike#ifndef _UINT32_T_DECLARED
8193514Smiketypedef	__uint32_t	uint32_t;
8293514Smike#define	_UINT32_T_DECLARED
8387158Smike#endif
8487158Smike
8593514Smike#ifndef	_IN_ADDR_T_DECLARED
8693514Smiketypedef	uint32_t	in_addr_t;
8793514Smike#define	_IN_ADDR_T_DECLARED
8893514Smike#endif
8993514Smike
9093514Smike#ifndef	_IN_PORT_T_DECLARED
9193514Smiketypedef	uint16_t	in_port_t;
9293514Smike#define	_IN_PORT_T_DECLARED
9393514Smike#endif
9493514Smike
9587158Smike#ifndef _POSIX_SOURCE
9687158Smike#ifdef	_BSD_SIZE_T_
9787158Smiketypedef	_BSD_SIZE_T_	size_t;
9887158Smike#undef	_BSD_SIZE_T_
9987158Smike#endif
10087158Smike#endif /* !_POSIX_SOURCE */
10187158Smike
10287158Smike/*
10391984Smike * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
10491984Smike * POSIX.1-2001.
10587158Smike */
10687158Smike#ifdef	_BSD_SOCKLEN_T_
10787158Smiketypedef	_BSD_SOCKLEN_T_	socklen_t;
10887158Smike#undef	_BSD_SOCKLEN_T_
10987158Smike#endif
11087158Smike
11187158Smike#ifndef _STRUCT_IN_ADDR_DECLARED
11287158Smikestruct in_addr {
11387158Smike	in_addr_t s_addr;
11487158Smike};
11587158Smike#define	_STRUCT_IN_ADDR_DECLARED
11687158Smike#endif
11787158Smike
11836888Speter/* XXX all new diversions!! argh!! */
11987158Smike#ifndef _POSIX_SOURCE
12036888Speter#define	inet_addr	__inet_addr
12136888Speter#define	inet_aton	__inet_aton
12236888Speter#define	inet_lnaof	__inet_lnaof
12336888Speter#define	inet_makeaddr	__inet_makeaddr
12436888Speter#define	inet_neta	__inet_neta
12536888Speter#define	inet_netof	__inet_netof
12636888Speter#define	inet_network	__inet_network
12736888Speter#define	inet_net_ntop	__inet_net_ntop
12836888Speter#define	inet_net_pton	__inet_net_pton
12936888Speter#define	inet_ntoa	__inet_ntoa
13036888Speter#define	inet_pton	__inet_pton
13136888Speter#define	inet_ntop	__inet_ntop
13236888Speter#define	inet_nsap_addr	__inet_nsap_addr
13336888Speter#define	inet_nsap_ntoa	__inet_nsap_ntoa
13487158Smike#endif /* !_POSIX_SOURCE */
13536888Speter
13691959Smike__BEGIN_DECLS
13791959Smike#ifndef _BYTEORDER_PROTOTYPED
13891959Smike#define	_BYTEORDER_PROTOTYPED
13993514Smikeuint32_t	 htonl(uint32_t);
14093514Smikeuint16_t	 htons(uint16_t);
14193514Smikeuint32_t	 ntohl(uint32_t);
14293514Smikeuint16_t	 ntohs(uint16_t);
14390868Smike#endif
14490868Smike
14593032Simpin_addr_t	 inet_addr(const char *);
14693032Simpchar		*inet_ntoa(struct in_addr);
14793032Simpconst char	*inet_ntop(int, const void *, char *, socklen_t);
14893032Simpint		 inet_pton(int, const char *, void *);
14987158Smike
15087158Smike/* Nonstandard functions. */
15187158Smike#ifndef _POSIX_SOURCE
15293032Simpint		 ascii2addr(int, const char *, void *);
15393032Simpchar		*addr2ascii(int, const void *, int, char *);
15493032Simpint		 inet_aton(const char *, struct in_addr *);
15593032Simpin_addr_t	 inet_lnaof(struct in_addr);
15693032Simpstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
15793032Simpchar *		 inet_neta(in_addr_t, char *, size_t);
15893032Simpin_addr_t	 inet_netof(struct in_addr);
15993032Simpin_addr_t	 inet_network(const char *);
16093032Simpchar		*inet_net_ntop(int, const void *, int, char *, size_t);
16193032Simpint		 inet_net_pton(int, const char *, void *, size_t);
16293032Simpunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
16393032Simpchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
16487158Smike#endif /* !_POSIX_SOURCE */
1651539Srgrimes__END_DECLS
1661539Srgrimes
16791959Smike#ifndef _BYTEORDER_FUNC_DEFINED
16891959Smike#define	_BYTEORDER_FUNC_DEFINED
16991959Smike#define	htonl(x)	__htonl(x)
17091959Smike#define	htons(x)	__htons(x)
17191959Smike#define	ntohl(x)	__ntohl(x)
17291959Smike#define	ntohs(x)	__ntohs(x)
17391959Smike#endif
17491959Smike
17587158Smike#endif /* !_ARPA_INET_H_ */
176