inet.h revision 102227
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 102227 2002-08-21 16:20:02Z 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>
62102227Smike#include <sys/_types.h>
631539Srgrimes
6490868Smike/* Required for byteorder(3) functions. */
6590868Smike#include <machine/endian.h>
6690868Smike
6791984Smike#define	INET_ADDRSTRLEN		16
6891984Smike#define	INET6_ADDRSTRLEN	46
6991984Smike
7093514Smike#ifndef _UINT16_T_DECLARED
7193514Smiketypedef	__uint16_t	uint16_t;
7293514Smike#define	_UINT16_T_DECLARED
7387158Smike#endif
7416352Swollman
7593514Smike#ifndef _UINT32_T_DECLARED
7693514Smiketypedef	__uint32_t	uint32_t;
7793514Smike#define	_UINT32_T_DECLARED
7887158Smike#endif
7987158Smike
80101995Smike#ifndef _IN_ADDR_T_DECLARED
8193514Smiketypedef	uint32_t	in_addr_t;
8293514Smike#define	_IN_ADDR_T_DECLARED
8393514Smike#endif
8493514Smike
85101995Smike#ifndef _IN_PORT_T_DECLARED
8693514Smiketypedef	uint16_t	in_port_t;
8793514Smike#define	_IN_PORT_T_DECLARED
8893514Smike#endif
8993514Smike
90101995Smike#if __BSD_VISIBLE
91102227Smike#ifndef _SIZE_T_DECLARED
92102227Smiketypedef	__size_t	size_t;
93102227Smike#define	_SIZE_T_DECLARED
9487158Smike#endif
95101995Smike#endif
9687158Smike
9787158Smike/*
9891984Smike * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
9991984Smike * POSIX.1-2001.
10087158Smike */
101102227Smike#ifndef _SOCKLEN_T_DECLARED
102102227Smiketypedef	__socklen_t	socklen_t;
103102227Smike#define	_SOCKLEN_T_DECLARED
10487158Smike#endif
10587158Smike
10687158Smike#ifndef _STRUCT_IN_ADDR_DECLARED
10787158Smikestruct in_addr {
10887158Smike	in_addr_t s_addr;
10987158Smike};
11087158Smike#define	_STRUCT_IN_ADDR_DECLARED
11187158Smike#endif
11287158Smike
11336888Speter/* XXX all new diversions!! argh!! */
11494353Smike#if __BSD_VISIBLE
11536888Speter#define	inet_addr	__inet_addr
11636888Speter#define	inet_aton	__inet_aton
11736888Speter#define	inet_lnaof	__inet_lnaof
11836888Speter#define	inet_makeaddr	__inet_makeaddr
11936888Speter#define	inet_neta	__inet_neta
12036888Speter#define	inet_netof	__inet_netof
12136888Speter#define	inet_network	__inet_network
12236888Speter#define	inet_net_ntop	__inet_net_ntop
12336888Speter#define	inet_net_pton	__inet_net_pton
12436888Speter#define	inet_ntoa	__inet_ntoa
12536888Speter#define	inet_pton	__inet_pton
12636888Speter#define	inet_ntop	__inet_ntop
12736888Speter#define	inet_nsap_addr	__inet_nsap_addr
12836888Speter#define	inet_nsap_ntoa	__inet_nsap_ntoa
12994353Smike#endif /* __BSD_VISIBLE */
13036888Speter
13191959Smike__BEGIN_DECLS
13291959Smike#ifndef _BYTEORDER_PROTOTYPED
13391959Smike#define	_BYTEORDER_PROTOTYPED
13493514Smikeuint32_t	 htonl(uint32_t);
13593514Smikeuint16_t	 htons(uint16_t);
13693514Smikeuint32_t	 ntohl(uint32_t);
13793514Smikeuint16_t	 ntohs(uint16_t);
13890868Smike#endif
13990868Smike
14093032Simpin_addr_t	 inet_addr(const char *);
14193032Simpchar		*inet_ntoa(struct in_addr);
142101995Smikeconst char	*inet_ntop(int, const void * __restrict, char * __restrict,
143101995Smike		    socklen_t);
144101995Smikeint		 inet_pton(int, const char * __restrict, void * __restrict);
14587158Smike
14694353Smike#if __BSD_VISIBLE
14793032Simpint		 ascii2addr(int, const char *, void *);
14893032Simpchar		*addr2ascii(int, const void *, int, char *);
14993032Simpint		 inet_aton(const char *, struct in_addr *);
15093032Simpin_addr_t	 inet_lnaof(struct in_addr);
15193032Simpstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
15293032Simpchar *		 inet_neta(in_addr_t, char *, size_t);
15393032Simpin_addr_t	 inet_netof(struct in_addr);
15493032Simpin_addr_t	 inet_network(const char *);
15593032Simpchar		*inet_net_ntop(int, const void *, int, char *, size_t);
15693032Simpint		 inet_net_pton(int, const char *, void *, size_t);
15793032Simpunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
15893032Simpchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
15994353Smike#endif /* __BSD_VISIBLE */
1601539Srgrimes__END_DECLS
1611539Srgrimes
16291959Smike#ifndef _BYTEORDER_FUNC_DEFINED
16391959Smike#define	_BYTEORDER_FUNC_DEFINED
16491959Smike#define	htonl(x)	__htonl(x)
16591959Smike#define	htons(x)	__htons(x)
16691959Smike#define	ntohl(x)	__ntohl(x)
16791959Smike#define	ntohs(x)	__ntohs(x)
16891959Smike#endif
16991959Smike
17087158Smike#endif /* !_ARPA_INET_H_ */
171