1*4a5d661aSToomas Soome /* 2*4a5d661aSToomas Soome * ++Copyright++ 1983, 1993 3*4a5d661aSToomas Soome * - 4*4a5d661aSToomas Soome * Copyright (c) 1983, 1993 5*4a5d661aSToomas Soome * The Regents of the University of California. All rights reserved. 6*4a5d661aSToomas Soome * 7*4a5d661aSToomas Soome * Redistribution and use in source and binary forms, with or without 8*4a5d661aSToomas Soome * modification, are permitted provided that the following conditions 9*4a5d661aSToomas Soome * are met: 10*4a5d661aSToomas Soome * 1. Redistributions of source code must retain the above copyright 11*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer. 12*4a5d661aSToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 13*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer in the 14*4a5d661aSToomas Soome * documentation and/or other materials provided with the distribution. 15*4a5d661aSToomas Soome * 3. Neither the name of the University nor the names of its contributors 16*4a5d661aSToomas Soome * may be used to endorse or promote products derived from this software 17*4a5d661aSToomas Soome * without specific prior written permission. 18*4a5d661aSToomas Soome * 19*4a5d661aSToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20*4a5d661aSToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21*4a5d661aSToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22*4a5d661aSToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23*4a5d661aSToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24*4a5d661aSToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25*4a5d661aSToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26*4a5d661aSToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27*4a5d661aSToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28*4a5d661aSToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29*4a5d661aSToomas Soome * SUCH DAMAGE. 30*4a5d661aSToomas Soome * - 31*4a5d661aSToomas Soome * Portions Copyright (c) 1993 by Digital Equipment Corporation. 32*4a5d661aSToomas Soome * 33*4a5d661aSToomas Soome * Permission to use, copy, modify, and distribute this software for any 34*4a5d661aSToomas Soome * purpose with or without fee is hereby granted, provided that the above 35*4a5d661aSToomas Soome * copyright notice and this permission notice appear in all copies, and that 36*4a5d661aSToomas Soome * the name of Digital Equipment Corporation not be used in advertising or 37*4a5d661aSToomas Soome * publicity pertaining to distribution of the document or software without 38*4a5d661aSToomas Soome * specific, written prior permission. 39*4a5d661aSToomas Soome * 40*4a5d661aSToomas Soome * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 41*4a5d661aSToomas Soome * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 42*4a5d661aSToomas Soome * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 43*4a5d661aSToomas Soome * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 44*4a5d661aSToomas Soome * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 45*4a5d661aSToomas Soome * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 46*4a5d661aSToomas Soome * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 47*4a5d661aSToomas Soome * SOFTWARE. 48*4a5d661aSToomas Soome * - 49*4a5d661aSToomas Soome * --Copyright-- 50*4a5d661aSToomas Soome */ 51*4a5d661aSToomas Soome 52*4a5d661aSToomas Soome /*% 53*4a5d661aSToomas Soome * @(#)inet.h 8.1 (Berkeley) 6/2/93 54*4a5d661aSToomas Soome * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $ 55*4a5d661aSToomas Soome * $FreeBSD$ 56*4a5d661aSToomas Soome */ 57*4a5d661aSToomas Soome 58*4a5d661aSToomas Soome #ifndef _ARPA_INET_H_ 59*4a5d661aSToomas Soome #define _ARPA_INET_H_ 60*4a5d661aSToomas Soome 61*4a5d661aSToomas Soome /* External definitions for functions in inet(3). */ 62*4a5d661aSToomas Soome 63*4a5d661aSToomas Soome #include <sys/cdefs.h> 64*4a5d661aSToomas Soome #include <sys/_types.h> 65*4a5d661aSToomas Soome 66*4a5d661aSToomas Soome /* Required for byteorder(3) functions. */ 67*4a5d661aSToomas Soome #include <machine/endian.h> 68*4a5d661aSToomas Soome 69*4a5d661aSToomas Soome #define INET_ADDRSTRLEN 16 70*4a5d661aSToomas Soome #define INET6_ADDRSTRLEN 46 71*4a5d661aSToomas Soome 72*4a5d661aSToomas Soome #ifndef _UINT16_T_DECLARED 73*4a5d661aSToomas Soome typedef __uint16_t uint16_t; 74*4a5d661aSToomas Soome #define _UINT16_T_DECLARED 75*4a5d661aSToomas Soome #endif 76*4a5d661aSToomas Soome 77*4a5d661aSToomas Soome #ifndef _UINT32_T_DECLARED 78*4a5d661aSToomas Soome typedef __uint32_t uint32_t; 79*4a5d661aSToomas Soome #define _UINT32_T_DECLARED 80*4a5d661aSToomas Soome #endif 81*4a5d661aSToomas Soome 82*4a5d661aSToomas Soome #ifndef _IN_ADDR_T_DECLARED 83*4a5d661aSToomas Soome typedef uint32_t in_addr_t; 84*4a5d661aSToomas Soome #define _IN_ADDR_T_DECLARED 85*4a5d661aSToomas Soome #endif 86*4a5d661aSToomas Soome 87*4a5d661aSToomas Soome #ifndef _IN_PORT_T_DECLARED 88*4a5d661aSToomas Soome typedef uint16_t in_port_t; 89*4a5d661aSToomas Soome #define _IN_PORT_T_DECLARED 90*4a5d661aSToomas Soome #endif 91*4a5d661aSToomas Soome 92*4a5d661aSToomas Soome #if __BSD_VISIBLE 93*4a5d661aSToomas Soome #ifndef _SIZE_T_DECLARED 94*4a5d661aSToomas Soome typedef __size_t size_t; 95*4a5d661aSToomas Soome #define _SIZE_T_DECLARED 96*4a5d661aSToomas Soome #endif 97*4a5d661aSToomas Soome #endif 98*4a5d661aSToomas Soome 99*4a5d661aSToomas Soome /* 100*4a5d661aSToomas Soome * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by 101*4a5d661aSToomas Soome * POSIX.1-2001. 102*4a5d661aSToomas Soome */ 103*4a5d661aSToomas Soome #ifndef _SOCKLEN_T_DECLARED 104*4a5d661aSToomas Soome typedef __socklen_t socklen_t; 105*4a5d661aSToomas Soome #define _SOCKLEN_T_DECLARED 106*4a5d661aSToomas Soome #endif 107*4a5d661aSToomas Soome 108*4a5d661aSToomas Soome #ifndef _STRUCT_IN_ADDR_DECLARED 109*4a5d661aSToomas Soome struct in_addr { 110*4a5d661aSToomas Soome in_addr_t s_addr; 111*4a5d661aSToomas Soome }; 112*4a5d661aSToomas Soome #define _STRUCT_IN_ADDR_DECLARED 113*4a5d661aSToomas Soome #endif 114*4a5d661aSToomas Soome 115*4a5d661aSToomas Soome /* XXX all new diversions!! argh!! */ 116*4a5d661aSToomas Soome #if __BSD_VISIBLE 117*4a5d661aSToomas Soome #define inet_addr __inet_addr 118*4a5d661aSToomas Soome #define inet_aton __inet_aton 119*4a5d661aSToomas Soome #define inet_lnaof __inet_lnaof 120*4a5d661aSToomas Soome #define inet_makeaddr __inet_makeaddr 121*4a5d661aSToomas Soome #define inet_neta __inet_neta 122*4a5d661aSToomas Soome #define inet_netof __inet_netof 123*4a5d661aSToomas Soome #define inet_network __inet_network 124*4a5d661aSToomas Soome #define inet_net_ntop __inet_net_ntop 125*4a5d661aSToomas Soome #define inet_net_pton __inet_net_pton 126*4a5d661aSToomas Soome #define inet_cidr_ntop __inet_cidr_ntop 127*4a5d661aSToomas Soome #define inet_cidr_pton __inet_cidr_pton 128*4a5d661aSToomas Soome #define inet_ntoa __inet_ntoa 129*4a5d661aSToomas Soome #define inet_ntoa_r __inet_ntoa_r 130*4a5d661aSToomas Soome #define inet_pton __inet_pton 131*4a5d661aSToomas Soome #define inet_ntop __inet_ntop 132*4a5d661aSToomas Soome #define inet_nsap_addr __inet_nsap_addr 133*4a5d661aSToomas Soome #define inet_nsap_ntoa __inet_nsap_ntoa 134*4a5d661aSToomas Soome #endif /* __BSD_VISIBLE */ 135*4a5d661aSToomas Soome 136*4a5d661aSToomas Soome __BEGIN_DECLS 137*4a5d661aSToomas Soome #ifndef _BYTEORDER_PROTOTYPED 138*4a5d661aSToomas Soome #define _BYTEORDER_PROTOTYPED 139*4a5d661aSToomas Soome uint32_t htonl(uint32_t); 140*4a5d661aSToomas Soome uint16_t htons(uint16_t); 141*4a5d661aSToomas Soome uint32_t ntohl(uint32_t); 142*4a5d661aSToomas Soome uint16_t ntohs(uint16_t); 143*4a5d661aSToomas Soome #endif 144*4a5d661aSToomas Soome 145*4a5d661aSToomas Soome in_addr_t inet_addr(const char *); 146*4a5d661aSToomas Soome /*const*/ char *inet_ntoa(struct in_addr); 147*4a5d661aSToomas Soome const char *inet_ntop(int, const void * __restrict, char * __restrict, 148*4a5d661aSToomas Soome socklen_t); 149*4a5d661aSToomas Soome int inet_pton(int, const char * __restrict, void * __restrict); 150*4a5d661aSToomas Soome 151*4a5d661aSToomas Soome #if __BSD_VISIBLE 152*4a5d661aSToomas Soome int inet_aton(const char *, struct in_addr *); 153*4a5d661aSToomas Soome in_addr_t inet_lnaof(struct in_addr); 154*4a5d661aSToomas Soome struct in_addr inet_makeaddr(in_addr_t, in_addr_t); 155*4a5d661aSToomas Soome char * inet_neta(in_addr_t, char *, size_t); 156*4a5d661aSToomas Soome in_addr_t inet_netof(struct in_addr); 157*4a5d661aSToomas Soome in_addr_t inet_network(const char *); 158*4a5d661aSToomas Soome char *inet_net_ntop(int, const void *, int, char *, size_t); 159*4a5d661aSToomas Soome int inet_net_pton(int, const char *, void *, size_t); 160*4a5d661aSToomas Soome char *inet_ntoa_r(struct in_addr, char *buf, socklen_t size); 161*4a5d661aSToomas Soome char *inet_cidr_ntop(int, const void *, int, char *, size_t); 162*4a5d661aSToomas Soome int inet_cidr_pton(int, const char *, void *, int *); 163*4a5d661aSToomas Soome unsigned inet_nsap_addr(const char *, unsigned char *, int); 164*4a5d661aSToomas Soome char *inet_nsap_ntoa(int, const unsigned char *, char *); 165*4a5d661aSToomas Soome #endif /* __BSD_VISIBLE */ 166*4a5d661aSToomas Soome __END_DECLS 167*4a5d661aSToomas Soome 168*4a5d661aSToomas Soome #ifndef _BYTEORDER_FUNC_DEFINED 169*4a5d661aSToomas Soome #define _BYTEORDER_FUNC_DEFINED 170*4a5d661aSToomas Soome #define htonl(x) __htonl(x) 171*4a5d661aSToomas Soome #define htons(x) __htons(x) 172*4a5d661aSToomas Soome #define ntohl(x) __ntohl(x) 173*4a5d661aSToomas Soome #define ntohs(x) __ntohs(x) 174*4a5d661aSToomas Soome #endif 175*4a5d661aSToomas Soome 176*4a5d661aSToomas Soome #endif /* !_ARPA_INET_H_ */ 177*4a5d661aSToomas Soome 178*4a5d661aSToomas Soome /*! \file */ 179