inet.h revision 302408
133965Sjdp/*
233965Sjdp * ++Copyright++ 1983, 1993
333965Sjdp * -
433965Sjdp * Copyright (c) 1983, 1993
533965Sjdp *    The Regents of the University of California.  All rights reserved.
633965Sjdp *
733965Sjdp * Redistribution and use in source and binary forms, with or without
833965Sjdp * modification, are permitted provided that the following conditions
933965Sjdp * are met:
1033965Sjdp * 1. Redistributions of source code must retain the above copyright
1133965Sjdp *    notice, this list of conditions and the following disclaimer.
1233965Sjdp * 2. Redistributions in binary form must reproduce the above copyright
1333965Sjdp *    notice, this list of conditions and the following disclaimer in the
1433965Sjdp *    documentation and/or other materials provided with the distribution.
1533965Sjdp * 3. Neither the name of the University nor the names of its contributors
1633965Sjdp *    may be used to endorse or promote products derived from this software
1733965Sjdp *    without specific prior written permission.
1833965Sjdp *
1933965Sjdp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2033965Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2133965Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2233965Sjdp * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2333965Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2433965Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2533965Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2633965Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2733965Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2833965Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2933965Sjdp * SUCH DAMAGE.
3033965Sjdp * -
3133965Sjdp * Portions Copyright (c) 1993 by Digital Equipment Corporation.
3233965Sjdp *
3333965Sjdp * Permission to use, copy, modify, and distribute this software for any
3433965Sjdp * purpose with or without fee is hereby granted, provided that the above
3533965Sjdp * copyright notice and this permission notice appear in all copies, and that
3633965Sjdp * the name of Digital Equipment Corporation not be used in advertising or
3733965Sjdp * publicity pertaining to distribution of the document or software without
3833965Sjdp * specific, written prior permission.
3933965Sjdp *
4033965Sjdp * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
4133965Sjdp * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
4233965Sjdp * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
4333965Sjdp * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
4433965Sjdp * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
4533965Sjdp * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
4633965Sjdp * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
4733965Sjdp * SOFTWARE.
4833965Sjdp * -
4933965Sjdp * --Copyright--
5033965Sjdp */
5133965Sjdp
5233965Sjdp/*%
5333965Sjdp *	@(#)inet.h	8.1 (Berkeley) 6/2/93
5433965Sjdp *	$Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
5533965Sjdp * $FreeBSD: stable/11/include/arpa/inet.h 269867 2014-08-12 12:36:06Z ume $
5633965Sjdp */
5733965Sjdp
5833965Sjdp#ifndef _ARPA_INET_H_
5933965Sjdp#define	_ARPA_INET_H_
6033965Sjdp
6133965Sjdp/* External definitions for functions in inet(3). */
6233965Sjdp
6333965Sjdp#include <sys/cdefs.h>
6433965Sjdp#include <sys/_types.h>
6533965Sjdp
6633965Sjdp/* Required for byteorder(3) functions. */
6733965Sjdp#include <machine/endian.h>
6833965Sjdp
6933965Sjdp#define	INET_ADDRSTRLEN		16
7033965Sjdp#define	INET6_ADDRSTRLEN	46
7133965Sjdp
7233965Sjdp#ifndef _UINT16_T_DECLARED
7333965Sjdptypedef	__uint16_t	uint16_t;
7433965Sjdp#define	_UINT16_T_DECLARED
7533965Sjdp#endif
7633965Sjdp
7733965Sjdp#ifndef _UINT32_T_DECLARED
7833965Sjdptypedef	__uint32_t	uint32_t;
7933965Sjdp#define	_UINT32_T_DECLARED
8033965Sjdp#endif
8133965Sjdp
8233965Sjdp#ifndef _IN_ADDR_T_DECLARED
8333965Sjdptypedef	uint32_t	in_addr_t;
8433965Sjdp#define	_IN_ADDR_T_DECLARED
8533965Sjdp#endif
8633965Sjdp
8733965Sjdp#ifndef _IN_PORT_T_DECLARED
8833965Sjdptypedef	uint16_t	in_port_t;
8933965Sjdp#define	_IN_PORT_T_DECLARED
9033965Sjdp#endif
9133965Sjdp
9233965Sjdp#if __BSD_VISIBLE
9333965Sjdp#ifndef _SIZE_T_DECLARED
9433965Sjdptypedef	__size_t	size_t;
9533965Sjdp#define	_SIZE_T_DECLARED
9633965Sjdp#endif
9733965Sjdp#endif
9833965Sjdp
9933965Sjdp/*
10033965Sjdp * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
10133965Sjdp * POSIX.1-2001.
10233965Sjdp */
10333965Sjdp#ifndef _SOCKLEN_T_DECLARED
10433965Sjdptypedef	__socklen_t	socklen_t;
10533965Sjdp#define	_SOCKLEN_T_DECLARED
10633965Sjdp#endif
10733965Sjdp
10833965Sjdp#ifndef _STRUCT_IN_ADDR_DECLARED
10933965Sjdpstruct in_addr {
11033965Sjdp	in_addr_t s_addr;
11133965Sjdp};
11233965Sjdp#define	_STRUCT_IN_ADDR_DECLARED
11333965Sjdp#endif
11433965Sjdp
11533965Sjdp/* XXX all new diversions!! argh!! */
11633965Sjdp#if __BSD_VISIBLE
11733965Sjdp#define	inet_addr		__inet_addr
11833965Sjdp#define	inet_aton		__inet_aton
11933965Sjdp#define	inet_lnaof		__inet_lnaof
12033965Sjdp#define	inet_makeaddr		__inet_makeaddr
12133965Sjdp#define	inet_neta		__inet_neta
12233965Sjdp#define	inet_netof		__inet_netof
12333965Sjdp#define	inet_network		__inet_network
12433965Sjdp#define	inet_net_ntop		__inet_net_ntop
12533965Sjdp#define	inet_net_pton		__inet_net_pton
12633965Sjdp#define	inet_cidr_ntop		__inet_cidr_ntop
12733965Sjdp#define	inet_cidr_pton		__inet_cidr_pton
12833965Sjdp#define	inet_ntoa		__inet_ntoa
12933965Sjdp#define	inet_ntoa_r		__inet_ntoa_r
13033965Sjdp#define	inet_pton		__inet_pton
13133965Sjdp#define	inet_ntop		__inet_ntop
13233965Sjdp#define	inet_nsap_addr		__inet_nsap_addr
13333965Sjdp#define	inet_nsap_ntoa		__inet_nsap_ntoa
13433965Sjdp#endif /* __BSD_VISIBLE */
13533965Sjdp
13633965Sjdp__BEGIN_DECLS
13733965Sjdp#ifndef _BYTEORDER_PROTOTYPED
13833965Sjdp#define	_BYTEORDER_PROTOTYPED
13933965Sjdpuint32_t	 htonl(uint32_t);
14033965Sjdpuint16_t	 htons(uint16_t);
14133965Sjdpuint32_t	 ntohl(uint32_t);
14233965Sjdpuint16_t	 ntohs(uint16_t);
14333965Sjdp#endif
14433965Sjdp
14533965Sjdpin_addr_t	 inet_addr(const char *);
14633965Sjdp/*const*/ char	*inet_ntoa(struct in_addr);
14733965Sjdpconst char	*inet_ntop(int, const void * __restrict, char * __restrict,
14833965Sjdp		    socklen_t);
14933965Sjdpint		 inet_pton(int, const char * __restrict, void * __restrict);
15033965Sjdp
15133965Sjdp#if __BSD_VISIBLE
15233965Sjdpint		 inet_aton(const char *, struct in_addr *);
15333965Sjdpin_addr_t	 inet_lnaof(struct in_addr);
15433965Sjdpstruct in_addr	 inet_makeaddr(in_addr_t, in_addr_t);
15533965Sjdpchar *		 inet_neta(in_addr_t, char *, size_t);
15633965Sjdpin_addr_t	 inet_netof(struct in_addr);
15733965Sjdpin_addr_t	 inet_network(const char *);
15833965Sjdpchar		*inet_net_ntop(int, const void *, int, char *, size_t);
15933965Sjdpint		 inet_net_pton(int, const char *, void *, size_t);
16033965Sjdpchar		*inet_ntoa_r(struct in_addr, char *buf, socklen_t size);
16133965Sjdpchar		*inet_cidr_ntop(int, const void *, int, char *, size_t);
16233965Sjdpint		 inet_cidr_pton(int, const char *, void *, int *);
16333965Sjdpunsigned	 inet_nsap_addr(const char *, unsigned char *, int);
16433965Sjdpchar		*inet_nsap_ntoa(int, const unsigned char *, char *);
16533965Sjdp#endif /* __BSD_VISIBLE */
16633965Sjdp__END_DECLS
16733965Sjdp
16833965Sjdp#ifndef _BYTEORDER_FUNC_DEFINED
16933965Sjdp#define	_BYTEORDER_FUNC_DEFINED
17033965Sjdp#define	htonl(x)	__htonl(x)
17133965Sjdp#define	htons(x)	__htons(x)
17233965Sjdp#define	ntohl(x)	__ntohl(x)
17333965Sjdp#define	ntohs(x)	__ntohs(x)
17433965Sjdp#endif
17533965Sjdp
17633965Sjdp#endif /* !_ARPA_INET_H_ */
17733965Sjdp
17833965Sjdp/*! \file */
17933965Sjdp