159deaec5SRodney W. Grimes /* 25342d17fSHajimu UMEMOTO * ++Copyright++ 1983, 1993 35342d17fSHajimu UMEMOTO * - 459deaec5SRodney W. Grimes * Copyright (c) 1983, 1993 559deaec5SRodney W. Grimes * The Regents of the University of California. All rights reserved. 659deaec5SRodney W. Grimes * 759deaec5SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 859deaec5SRodney W. Grimes * modification, are permitted provided that the following conditions 959deaec5SRodney W. Grimes * are met: 1059deaec5SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 1159deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1259deaec5SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1359deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1459deaec5SRodney W. Grimes * documentation and/or other materials provided with the distribution. 1559deaec5SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 1659deaec5SRodney W. Grimes * must display the following acknowledgement: 1759deaec5SRodney W. Grimes * This product includes software developed by the University of 1859deaec5SRodney W. Grimes * California, Berkeley and its contributors. 1959deaec5SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 2059deaec5SRodney W. Grimes * may be used to endorse or promote products derived from this software 2159deaec5SRodney W. Grimes * without specific prior written permission. 2259deaec5SRodney W. Grimes * 2359deaec5SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2459deaec5SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2559deaec5SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2659deaec5SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2759deaec5SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2859deaec5SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2959deaec5SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3059deaec5SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3159deaec5SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3259deaec5SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3359deaec5SRodney W. Grimes * SUCH DAMAGE. 34f3f42e96SPeter Wemm * - 35f3f42e96SPeter Wemm * Portions Copyright (c) 1993 by Digital Equipment Corporation. 36f3f42e96SPeter Wemm * 37f3f42e96SPeter Wemm * Permission to use, copy, modify, and distribute this software for any 38f3f42e96SPeter Wemm * purpose with or without fee is hereby granted, provided that the above 39f3f42e96SPeter Wemm * copyright notice and this permission notice appear in all copies, and that 40f3f42e96SPeter Wemm * the name of Digital Equipment Corporation not be used in advertising or 41f3f42e96SPeter Wemm * publicity pertaining to distribution of the document or software without 42f3f42e96SPeter Wemm * specific, written prior permission. 43f3f42e96SPeter Wemm * 44f3f42e96SPeter Wemm * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 45f3f42e96SPeter Wemm * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 46f3f42e96SPeter Wemm * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 47f3f42e96SPeter Wemm * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 48f3f42e96SPeter Wemm * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 49f3f42e96SPeter Wemm * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 50f3f42e96SPeter Wemm * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 51f3f42e96SPeter Wemm * SOFTWARE. 525342d17fSHajimu UMEMOTO * - 535342d17fSHajimu UMEMOTO * --Copyright-- 545342d17fSHajimu UMEMOTO */ 555342d17fSHajimu UMEMOTO 56dde4a85dSHajimu UMEMOTO /*% 5759deaec5SRodney W. Grimes * @(#)inet.h 8.1 (Berkeley) 6/2/93 58dde4a85dSHajimu UMEMOTO * $Id: inet.h,v 1.2.18.1 2005/04/27 05:00:50 sra Exp $ 59a4add9a9SPeter Wemm * $FreeBSD$ 6059deaec5SRodney W. Grimes */ 6159deaec5SRodney W. Grimes 62385e380aSPaul Richards #ifndef _ARPA_INET_H_ 63385e380aSPaul Richards #define _ARPA_INET_H_ 6459deaec5SRodney W. Grimes 65ffd1512dSGarrett Wollman /* External definitions for functions in inet(3), addr2ascii(3) */ 6659deaec5SRodney W. Grimes 6759deaec5SRodney W. Grimes #include <sys/cdefs.h> 68abbd8902SMike Barcroft #include <sys/_types.h> 6959deaec5SRodney W. Grimes 70fd8e4ebcSMike Barcroft /* Required for byteorder(3) functions. */ 71fd8e4ebcSMike Barcroft #include <machine/endian.h> 72fd8e4ebcSMike Barcroft 736a6230d2SMike Barcroft #define INET_ADDRSTRLEN 16 746a6230d2SMike Barcroft #define INET6_ADDRSTRLEN 46 756a6230d2SMike Barcroft 768822d3fbSMike Barcroft #ifndef _UINT16_T_DECLARED 778822d3fbSMike Barcroft typedef __uint16_t uint16_t; 788822d3fbSMike Barcroft #define _UINT16_T_DECLARED 79de2656d0SMike Barcroft #endif 80de2656d0SMike Barcroft 818822d3fbSMike Barcroft #ifndef _UINT32_T_DECLARED 828822d3fbSMike Barcroft typedef __uint32_t uint32_t; 838822d3fbSMike Barcroft #define _UINT32_T_DECLARED 848822d3fbSMike Barcroft #endif 858822d3fbSMike Barcroft 868822d3fbSMike Barcroft #ifndef _IN_ADDR_T_DECLARED 878822d3fbSMike Barcroft typedef uint32_t in_addr_t; 888822d3fbSMike Barcroft #define _IN_ADDR_T_DECLARED 898822d3fbSMike Barcroft #endif 908822d3fbSMike Barcroft 918822d3fbSMike Barcroft #ifndef _IN_PORT_T_DECLARED 928822d3fbSMike Barcroft typedef uint16_t in_port_t; 938822d3fbSMike Barcroft #define _IN_PORT_T_DECLARED 94de2656d0SMike Barcroft #endif 95de2656d0SMike Barcroft 962cd998a2SMike Barcroft #if __BSD_VISIBLE 97abbd8902SMike Barcroft #ifndef _SIZE_T_DECLARED 98abbd8902SMike Barcroft typedef __size_t size_t; 99abbd8902SMike Barcroft #define _SIZE_T_DECLARED 100de2656d0SMike Barcroft #endif 1012cd998a2SMike Barcroft #endif 102de2656d0SMike Barcroft 103de2656d0SMike Barcroft /* 1046a6230d2SMike Barcroft * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by 1056a6230d2SMike Barcroft * POSIX.1-2001. 106de2656d0SMike Barcroft */ 107abbd8902SMike Barcroft #ifndef _SOCKLEN_T_DECLARED 108abbd8902SMike Barcroft typedef __socklen_t socklen_t; 109abbd8902SMike Barcroft #define _SOCKLEN_T_DECLARED 110de2656d0SMike Barcroft #endif 111de2656d0SMike Barcroft 112de2656d0SMike Barcroft #ifndef _STRUCT_IN_ADDR_DECLARED 113de2656d0SMike Barcroft struct in_addr { 114de2656d0SMike Barcroft in_addr_t s_addr; 115de2656d0SMike Barcroft }; 116de2656d0SMike Barcroft #define _STRUCT_IN_ADDR_DECLARED 117de2656d0SMike Barcroft #endif 118ffd1512dSGarrett Wollman 1190160f9c0SPeter Wemm /* XXX all new diversions!! argh!! */ 1200b787910SMike Barcroft #if __BSD_VISIBLE 1210160f9c0SPeter Wemm #define inet_addr __inet_addr 1220160f9c0SPeter Wemm #define inet_aton __inet_aton 1230160f9c0SPeter Wemm #define inet_lnaof __inet_lnaof 1240160f9c0SPeter Wemm #define inet_makeaddr __inet_makeaddr 1250160f9c0SPeter Wemm #define inet_neta __inet_neta 1260160f9c0SPeter Wemm #define inet_netof __inet_netof 1270160f9c0SPeter Wemm #define inet_network __inet_network 1280160f9c0SPeter Wemm #define inet_net_ntop __inet_net_ntop 1290160f9c0SPeter Wemm #define inet_net_pton __inet_net_pton 1305342d17fSHajimu UMEMOTO #define inet_cidr_ntop __inet_cidr_ntop 1315342d17fSHajimu UMEMOTO #define inet_cidr_pton __inet_cidr_pton 1320160f9c0SPeter Wemm #define inet_ntoa __inet_ntoa 1330160f9c0SPeter Wemm #define inet_pton __inet_pton 1340160f9c0SPeter Wemm #define inet_ntop __inet_ntop 1350160f9c0SPeter Wemm #define inet_nsap_addr __inet_nsap_addr 1360160f9c0SPeter Wemm #define inet_nsap_ntoa __inet_nsap_ntoa 1370b787910SMike Barcroft #endif /* __BSD_VISIBLE */ 1380160f9c0SPeter Wemm 139d846855dSMike Barcroft __BEGIN_DECLS 140d846855dSMike Barcroft #ifndef _BYTEORDER_PROTOTYPED 141d846855dSMike Barcroft #define _BYTEORDER_PROTOTYPED 1428822d3fbSMike Barcroft uint32_t htonl(uint32_t); 1438822d3fbSMike Barcroft uint16_t htons(uint16_t); 1448822d3fbSMike Barcroft uint32_t ntohl(uint32_t); 1458822d3fbSMike Barcroft uint16_t ntohs(uint16_t); 146fd8e4ebcSMike Barcroft #endif 147fd8e4ebcSMike Barcroft 148bb28f3c2SWarner Losh in_addr_t inet_addr(const char *); 1495342d17fSHajimu UMEMOTO /*const*/ char *inet_ntoa(struct in_addr); 150b7dbaf7bSRobert Drehmel const char *inet_ntop(int, const void * __restrict, char * __restrict, 151b7dbaf7bSRobert Drehmel socklen_t); 152b7dbaf7bSRobert Drehmel int inet_pton(int, const char * __restrict, void * __restrict); 153de2656d0SMike Barcroft 1540b787910SMike Barcroft #if __BSD_VISIBLE 155bb28f3c2SWarner Losh int ascii2addr(int, const char *, void *); 156bb28f3c2SWarner Losh char *addr2ascii(int, const void *, int, char *); 157bb28f3c2SWarner Losh int inet_aton(const char *, struct in_addr *); 158bb28f3c2SWarner Losh in_addr_t inet_lnaof(struct in_addr); 159bb28f3c2SWarner Losh struct in_addr inet_makeaddr(in_addr_t, in_addr_t); 160bb28f3c2SWarner Losh char * inet_neta(in_addr_t, char *, size_t); 161bb28f3c2SWarner Losh in_addr_t inet_netof(struct in_addr); 162bb28f3c2SWarner Losh in_addr_t inet_network(const char *); 163bb28f3c2SWarner Losh char *inet_net_ntop(int, const void *, int, char *, size_t); 164bb28f3c2SWarner Losh int inet_net_pton(int, const char *, void *, size_t); 1655342d17fSHajimu UMEMOTO char *inet_cidr_ntop(int, const void *, int, char *, size_t); 1665342d17fSHajimu UMEMOTO int inet_cidr_pton(int, const char *, void *, int *); 167bb28f3c2SWarner Losh unsigned inet_nsap_addr(const char *, unsigned char *, int); 168bb28f3c2SWarner Losh char *inet_nsap_ntoa(int, const unsigned char *, char *); 1690b787910SMike Barcroft #endif /* __BSD_VISIBLE */ 17059deaec5SRodney W. Grimes __END_DECLS 17159deaec5SRodney W. Grimes 172d846855dSMike Barcroft #ifndef _BYTEORDER_FUNC_DEFINED 173d846855dSMike Barcroft #define _BYTEORDER_FUNC_DEFINED 174d846855dSMike Barcroft #define htonl(x) __htonl(x) 175d846855dSMike Barcroft #define htons(x) __htons(x) 176d846855dSMike Barcroft #define ntohl(x) __ntohl(x) 177d846855dSMike Barcroft #define ntohs(x) __ntohs(x) 178d846855dSMike Barcroft #endif 179d846855dSMike Barcroft 180de2656d0SMike Barcroft #endif /* !_ARPA_INET_H_ */ 181dde4a85dSHajimu UMEMOTO 182dde4a85dSHajimu UMEMOTO /*! \file */ 183