12321c474SPedro F. Giffuni /*- 2*6e778a7eSPedro F. Giffuni * SPDX-License-Identifier: (BSD-3-Clause AND ISC) 32321c474SPedro F. Giffuni * 45342d17fSHajimu UMEMOTO * ++Copyright++ 1983, 1993 55342d17fSHajimu UMEMOTO * - 659deaec5SRodney W. Grimes * Copyright (c) 1983, 1993 759deaec5SRodney W. Grimes * The Regents of the University of California. All rights reserved. 859deaec5SRodney W. Grimes * 959deaec5SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 1059deaec5SRodney W. Grimes * modification, are permitted provided that the following conditions 1159deaec5SRodney W. Grimes * are met: 1259deaec5SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 1359deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1459deaec5SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1559deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1659deaec5SRodney W. Grimes * documentation and/or other materials provided with the distribution. 172cca9f8fSWarner Losh * 3. Neither the name of the University nor the names of its contributors 1859deaec5SRodney W. Grimes * may be used to endorse or promote products derived from this software 1959deaec5SRodney W. Grimes * without specific prior written permission. 2059deaec5SRodney W. Grimes * 2159deaec5SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2259deaec5SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2359deaec5SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2459deaec5SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2559deaec5SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2659deaec5SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2759deaec5SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2859deaec5SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2959deaec5SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3059deaec5SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3159deaec5SRodney W. Grimes * SUCH DAMAGE. 32f3f42e96SPeter Wemm * - 33f3f42e96SPeter Wemm * Portions Copyright (c) 1993 by Digital Equipment Corporation. 34f3f42e96SPeter Wemm * 35f3f42e96SPeter Wemm * Permission to use, copy, modify, and distribute this software for any 36f3f42e96SPeter Wemm * purpose with or without fee is hereby granted, provided that the above 37f3f42e96SPeter Wemm * copyright notice and this permission notice appear in all copies, and that 38f3f42e96SPeter Wemm * the name of Digital Equipment Corporation not be used in advertising or 39f3f42e96SPeter Wemm * publicity pertaining to distribution of the document or software without 40f3f42e96SPeter Wemm * specific, written prior permission. 41f3f42e96SPeter Wemm * 42f3f42e96SPeter Wemm * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 43f3f42e96SPeter Wemm * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 44f3f42e96SPeter Wemm * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 45f3f42e96SPeter Wemm * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 46f3f42e96SPeter Wemm * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 47f3f42e96SPeter Wemm * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 48f3f42e96SPeter Wemm * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 49f3f42e96SPeter Wemm * SOFTWARE. 505342d17fSHajimu UMEMOTO * - 515342d17fSHajimu UMEMOTO * --Copyright-- 525342d17fSHajimu UMEMOTO */ 535342d17fSHajimu UMEMOTO 54dde4a85dSHajimu UMEMOTO /*% 55046c3635SPedro F. Giffuni * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $ 5659deaec5SRodney W. Grimes */ 5759deaec5SRodney W. Grimes 58385e380aSPaul Richards #ifndef _ARPA_INET_H_ 59385e380aSPaul Richards #define _ARPA_INET_H_ 6059deaec5SRodney W. Grimes 6148162ca1SMaxim Konovalov /* External definitions for functions in inet(3). */ 6259deaec5SRodney W. Grimes 6359deaec5SRodney W. Grimes #include <sys/cdefs.h> 64abbd8902SMike Barcroft #include <sys/_types.h> 6559deaec5SRodney W. Grimes 66fd8e4ebcSMike Barcroft /* Required for byteorder(3) functions. */ 67fd8e4ebcSMike Barcroft #include <machine/endian.h> 68fd8e4ebcSMike Barcroft 696a6230d2SMike Barcroft #define INET_ADDRSTRLEN 16 706a6230d2SMike Barcroft #define INET6_ADDRSTRLEN 46 716a6230d2SMike Barcroft 728822d3fbSMike Barcroft #ifndef _UINT16_T_DECLARED 738822d3fbSMike Barcroft typedef __uint16_t uint16_t; 748822d3fbSMike Barcroft #define _UINT16_T_DECLARED 75de2656d0SMike Barcroft #endif 76de2656d0SMike Barcroft 778822d3fbSMike Barcroft #ifndef _UINT32_T_DECLARED 788822d3fbSMike Barcroft typedef __uint32_t uint32_t; 798822d3fbSMike Barcroft #define _UINT32_T_DECLARED 808822d3fbSMike Barcroft #endif 818822d3fbSMike Barcroft 828822d3fbSMike Barcroft #ifndef _IN_ADDR_T_DECLARED 838822d3fbSMike Barcroft typedef uint32_t in_addr_t; 848822d3fbSMike Barcroft #define _IN_ADDR_T_DECLARED 858822d3fbSMike Barcroft #endif 868822d3fbSMike Barcroft 878822d3fbSMike Barcroft #ifndef _IN_PORT_T_DECLARED 888822d3fbSMike Barcroft typedef uint16_t in_port_t; 898822d3fbSMike Barcroft #define _IN_PORT_T_DECLARED 90de2656d0SMike Barcroft #endif 91de2656d0SMike Barcroft 922cd998a2SMike Barcroft #if __BSD_VISIBLE 93abbd8902SMike Barcroft #ifndef _SIZE_T_DECLARED 94abbd8902SMike Barcroft typedef __size_t size_t; 95abbd8902SMike Barcroft #define _SIZE_T_DECLARED 96de2656d0SMike Barcroft #endif 972cd998a2SMike Barcroft #endif 98de2656d0SMike Barcroft 99de2656d0SMike Barcroft /* 1006a6230d2SMike Barcroft * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by 1016a6230d2SMike Barcroft * POSIX.1-2001. 102de2656d0SMike Barcroft */ 103abbd8902SMike Barcroft #ifndef _SOCKLEN_T_DECLARED 104abbd8902SMike Barcroft typedef __socklen_t socklen_t; 105abbd8902SMike Barcroft #define _SOCKLEN_T_DECLARED 106de2656d0SMike Barcroft #endif 107de2656d0SMike Barcroft 108de2656d0SMike Barcroft #ifndef _STRUCT_IN_ADDR_DECLARED 109de2656d0SMike Barcroft struct in_addr { 110de2656d0SMike Barcroft in_addr_t s_addr; 111de2656d0SMike Barcroft }; 112de2656d0SMike Barcroft #define _STRUCT_IN_ADDR_DECLARED 113de2656d0SMike Barcroft #endif 114ffd1512dSGarrett Wollman 1150160f9c0SPeter Wemm /* XXX all new diversions!! argh!! */ 1160b787910SMike Barcroft #if __BSD_VISIBLE 1170160f9c0SPeter Wemm #define inet_addr __inet_addr 1180160f9c0SPeter Wemm #define inet_aton __inet_aton 1190160f9c0SPeter Wemm #define inet_lnaof __inet_lnaof 1200160f9c0SPeter Wemm #define inet_makeaddr __inet_makeaddr 1210160f9c0SPeter Wemm #define inet_neta __inet_neta 1220160f9c0SPeter Wemm #define inet_netof __inet_netof 1230160f9c0SPeter Wemm #define inet_network __inet_network 1240160f9c0SPeter Wemm #define inet_net_ntop __inet_net_ntop 1250160f9c0SPeter Wemm #define inet_net_pton __inet_net_pton 1265342d17fSHajimu UMEMOTO #define inet_cidr_ntop __inet_cidr_ntop 1275342d17fSHajimu UMEMOTO #define inet_cidr_pton __inet_cidr_pton 1280160f9c0SPeter Wemm #define inet_ntoa __inet_ntoa 1290c927cddSXin LI #define inet_ntoa_r __inet_ntoa_r 1300160f9c0SPeter Wemm #define inet_pton __inet_pton 1310160f9c0SPeter Wemm #define inet_ntop __inet_ntop 1320160f9c0SPeter Wemm #define inet_nsap_addr __inet_nsap_addr 1330160f9c0SPeter Wemm #define inet_nsap_ntoa __inet_nsap_ntoa 1340b787910SMike Barcroft #endif /* __BSD_VISIBLE */ 1350160f9c0SPeter Wemm 136d846855dSMike Barcroft __BEGIN_DECLS 137d846855dSMike Barcroft #ifndef _BYTEORDER_PROTOTYPED 138d846855dSMike Barcroft #define _BYTEORDER_PROTOTYPED 1398822d3fbSMike Barcroft uint32_t htonl(uint32_t); 1408822d3fbSMike Barcroft uint16_t htons(uint16_t); 1418822d3fbSMike Barcroft uint32_t ntohl(uint32_t); 1428822d3fbSMike Barcroft uint16_t ntohs(uint16_t); 143fd8e4ebcSMike Barcroft #endif 144fd8e4ebcSMike Barcroft 145bb28f3c2SWarner Losh in_addr_t inet_addr(const char *); 1465342d17fSHajimu UMEMOTO /*const*/ char *inet_ntoa(struct in_addr); 147b7dbaf7bSRobert Drehmel const char *inet_ntop(int, const void * __restrict, char * __restrict, 148b7dbaf7bSRobert Drehmel socklen_t); 149b7dbaf7bSRobert Drehmel int inet_pton(int, const char * __restrict, void * __restrict); 150de2656d0SMike Barcroft 1510b787910SMike Barcroft #if __BSD_VISIBLE 152bb28f3c2SWarner Losh int inet_aton(const char *, struct in_addr *); 153bb28f3c2SWarner Losh in_addr_t inet_lnaof(struct in_addr); 154bb28f3c2SWarner Losh struct in_addr inet_makeaddr(in_addr_t, in_addr_t); 155bb28f3c2SWarner Losh char * inet_neta(in_addr_t, char *, size_t); 156bb28f3c2SWarner Losh in_addr_t inet_netof(struct in_addr); 157bb28f3c2SWarner Losh in_addr_t inet_network(const char *); 158bb28f3c2SWarner Losh char *inet_net_ntop(int, const void *, int, char *, size_t); 159bb28f3c2SWarner Losh int inet_net_pton(int, const char *, void *, size_t); 160c0f43bd2SDavid Schultz char *inet_ntoa_r(struct in_addr, char *buf, socklen_t size); 1615342d17fSHajimu UMEMOTO char *inet_cidr_ntop(int, const void *, int, char *, size_t); 1625342d17fSHajimu UMEMOTO int inet_cidr_pton(int, const char *, void *, int *); 163bb28f3c2SWarner Losh unsigned inet_nsap_addr(const char *, unsigned char *, int); 164bb28f3c2SWarner Losh char *inet_nsap_ntoa(int, const unsigned char *, char *); 1650b787910SMike Barcroft #endif /* __BSD_VISIBLE */ 16659deaec5SRodney W. Grimes __END_DECLS 16759deaec5SRodney W. Grimes 168d846855dSMike Barcroft #ifndef _BYTEORDER_FUNC_DEFINED 169d846855dSMike Barcroft #define _BYTEORDER_FUNC_DEFINED 170d846855dSMike Barcroft #define htonl(x) __htonl(x) 171d846855dSMike Barcroft #define htons(x) __htons(x) 172d846855dSMike Barcroft #define ntohl(x) __ntohl(x) 173d846855dSMike Barcroft #define ntohs(x) __ntohs(x) 174d846855dSMike Barcroft #endif 175d846855dSMike Barcroft 176de2656d0SMike Barcroft #endif /* !_ARPA_INET_H_ */ 177dde4a85dSHajimu UMEMOTO 178dde4a85dSHajimu UMEMOTO /*! \file */ 179