1*02a6e1c4Sguenther /* $OpenBSD: inet.h,v 1.21 2017/02/04 19:16:25 guenther Exp $ */ 21231c441Sdownsj 3df930be7Sderaadt /* 41ddd5cc1Sdm * ++Copyright++ 1983, 1993 51ddd5cc1Sdm * - 61ddd5cc1Sdm * Copyright (c) 1983, 1993 71ddd5cc1Sdm * The Regents of the University of California. All rights reserved. 8df930be7Sderaadt * 9df930be7Sderaadt * Redistribution and use in source and binary forms, with or without 10df930be7Sderaadt * modification, are permitted provided that the following conditions 11df930be7Sderaadt * are met: 12df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright 13df930be7Sderaadt * notice, this list of conditions and the following disclaimer. 14df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 15df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the 16df930be7Sderaadt * documentation and/or other materials provided with the distribution. 17e33d3bd3Smillert * 3. Neither the name of the University nor the names of its contributors 18df930be7Sderaadt * may be used to endorse or promote products derived from this software 19df930be7Sderaadt * without specific prior written permission. 20df930be7Sderaadt * 21df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df930be7Sderaadt * SUCH DAMAGE. 321ddd5cc1Sdm * - 331ddd5cc1Sdm * Portions Copyright (c) 1993 by Digital Equipment Corporation. 34df930be7Sderaadt * 351ddd5cc1Sdm * Permission to use, copy, modify, and distribute this software for any 361ddd5cc1Sdm * purpose with or without fee is hereby granted, provided that the above 371ddd5cc1Sdm * copyright notice and this permission notice appear in all copies, and that 381ddd5cc1Sdm * the name of Digital Equipment Corporation not be used in advertising or 391ddd5cc1Sdm * publicity pertaining to distribution of the document or software without 401ddd5cc1Sdm * specific, written prior permission. 411ddd5cc1Sdm * 421ddd5cc1Sdm * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 431ddd5cc1Sdm * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 441ddd5cc1Sdm * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 451ddd5cc1Sdm * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 461ddd5cc1Sdm * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 471ddd5cc1Sdm * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 481ddd5cc1Sdm * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 491ddd5cc1Sdm * SOFTWARE. 501ddd5cc1Sdm * - 511ddd5cc1Sdm * --Copyright-- 521ddd5cc1Sdm */ 531ddd5cc1Sdm 541ddd5cc1Sdm /* 551ddd5cc1Sdm * @(#)inet.h 8.1 (Berkeley) 6/2/93 561231c441Sdownsj * $From: inet.h,v 8.6 1996/08/08 06:54:29 vixie Exp $ 57df930be7Sderaadt */ 58df930be7Sderaadt 59df930be7Sderaadt #ifndef _INET_H_ 60df930be7Sderaadt #define _INET_H_ 61df930be7Sderaadt 62df930be7Sderaadt /* External definitions for functions in inet(3) */ 63df930be7Sderaadt 64828e760fSguenther #include <sys/cdefs.h> 65828e760fSguenther #include <sys/_endian.h> 667c5b55ffSguenther 677c5b55ffSguenther #ifndef htons 687c5b55ffSguenther #define htons(x) __htobe16(x) 697c5b55ffSguenther #define htonl(x) __htobe32(x) 707c5b55ffSguenther #define ntohs(x) __htobe16(x) 717c5b55ffSguenther #define ntohl(x) __htobe32(x) 727c5b55ffSguenther #endif 73df930be7Sderaadt 74*02a6e1c4Sguenther #ifndef _UINT16_T_DEFINED_ 75*02a6e1c4Sguenther #define _UINT16_T_DEFINED_ 76*02a6e1c4Sguenther typedef __uint16_t uint16_t; 77*02a6e1c4Sguenther #endif 78*02a6e1c4Sguenther 79*02a6e1c4Sguenther #ifndef _UINT32_T_DEFINED_ 80*02a6e1c4Sguenther #define _UINT32_T_DEFINED_ 81*02a6e1c4Sguenther typedef __uint32_t uint32_t; 82*02a6e1c4Sguenther #endif 83*02a6e1c4Sguenther 84de9f3fadSguenther #ifndef _SOCKLEN_T_DEFINED_ 85de9f3fadSguenther #define _SOCKLEN_T_DEFINED_ 86de9f3fadSguenther typedef __socklen_t socklen_t; /* length type for network syscalls */ 87de9f3fadSguenther #endif 88de9f3fadSguenther 89828e760fSguenther #ifndef _IN_TYPES_DEFINED_ 90828e760fSguenther #define _IN_TYPES_DEFINED_ 91828e760fSguenther typedef __in_addr_t in_addr_t; /* base type for internet address */ 92828e760fSguenther typedef __in_port_t in_port_t; /* IP port type */ 93828e760fSguenther #endif 94828e760fSguenther 9517c9ee9bSguenther /* 9617c9ee9bSguenther * Buffer lengths for strings containing printable IP addresses 9717c9ee9bSguenther */ 9817c9ee9bSguenther #ifndef INET_ADDRSTRLEN 9917c9ee9bSguenther #define INET_ADDRSTRLEN 16 10017c9ee9bSguenther #endif 10117c9ee9bSguenther #ifndef INET6_ADDRSTRLEN 10217c9ee9bSguenther #define INET6_ADDRSTRLEN 46 10317c9ee9bSguenther #endif 10417c9ee9bSguenther 10517c9ee9bSguenther #ifndef _IN_ADDR_DECLARED 10617c9ee9bSguenther #define _IN_ADDR_DECLARED 10717c9ee9bSguenther /* 10817c9ee9bSguenther * IP Version 4 Internet address (a structure for historical reasons) 10917c9ee9bSguenther */ 11017c9ee9bSguenther struct in_addr { 11117c9ee9bSguenther in_addr_t s_addr; 11217c9ee9bSguenther }; 11317c9ee9bSguenther #endif 11417c9ee9bSguenther 11517c9ee9bSguenther 116828e760fSguenther #if __BSD_VISIBLE 117828e760fSguenther /* need this for the non-standard stuff */ 118828e760fSguenther #ifndef _SIZE_T_DEFINED_ 119828e760fSguenther #define _SIZE_T_DEFINED_ 120828e760fSguenther typedef __size_t size_t; 121828e760fSguenther #endif 122828e760fSguenther #endif 123828e760fSguenther 124828e760fSguenther 125df930be7Sderaadt __BEGIN_DECLS 126c72b5b24Smillert in_addr_t inet_addr(const char *); 127fb11ead1Sguenther char *inet_ntoa(struct in_addr); 128fb11ead1Sguenther const char *inet_ntop(int, const void *__restrict, char *__restrict, 129fb11ead1Sguenther socklen_t) __attribute__ ((__bounded__(__string__,3,4))); 130fb11ead1Sguenther int inet_pton(int, const char *__restrict, void *__restrict); 131fb11ead1Sguenther 132fb11ead1Sguenther #if __BSD_VISIBLE 133c72b5b24Smillert int inet_aton(const char *, struct in_addr *); 134c72b5b24Smillert in_addr_t inet_lnaof(struct in_addr); 135c72b5b24Smillert struct in_addr inet_makeaddr(in_addr_t , in_addr_t); 13689b95c1cSavsm char * inet_neta(in_addr_t, char *, size_t) 13789b95c1cSavsm __attribute__((__bounded__(__string__,2,3))); 138c72b5b24Smillert in_addr_t inet_netof(struct in_addr); 139c72b5b24Smillert in_addr_t inet_network(const char *); 14089b95c1cSavsm char *inet_net_ntop(int, const void *, int, char *, size_t) 14189b95c1cSavsm __attribute__((__bounded__(__string__,4,5))); 14289b95c1cSavsm int inet_net_pton(int, const char *, void *, size_t) 14389b95c1cSavsm __attribute__((__bounded__(__string__,3,4))); 144fb11ead1Sguenther #endif /* __BSD_VISIBLE */ 145df930be7Sderaadt __END_DECLS 146df930be7Sderaadt 147df930be7Sderaadt #endif /* !_INET_H_ */ 148