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