1 /* $NetBSD: inet.h,v 1.1.1.3 2014/07/12 11:57:56 spz Exp $ */ 2 /* inet.h 3 4 Portable definitions for internet addresses */ 5 6 /* 7 * Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC") 8 * Copyright (c) 1996-2003 by Internet Software Consortium 9 * 10 * Permission to use, copy, modify, and distribute this software for any 11 * purpose with or without fee is hereby granted, provided that the above 12 * copyright notice and this permission notice appear in all copies. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 * 22 * Internet Systems Consortium, Inc. 23 * 950 Charter Street 24 * Redwood City, CA 94063 25 * <info@isc.org> 26 * https://www.isc.org/ 27 * 28 */ 29 30 /* An internet address of up to 128 bits. */ 31 32 struct iaddr { 33 unsigned len; 34 unsigned char iabuf [16]; 35 }; 36 37 struct iaddrlist { 38 struct iaddrlist *next; 39 struct iaddr addr; 40 }; 41 42 43 /* struct iaddrmatch - used to compare a host IP against a subnet spec 44 * 45 * There is a space/speed tradeoff here implied by the use of a second 46 * struct iaddr to hold the mask; while using an unsigned (byte!) to 47 * represent the subnet prefix length would be more memory efficient, 48 * it makes run-time mask comparisons more expensive. Since such 49 * entries are used currently only in restricted circumstances 50 * (wanting to reject a subnet), the decision is in favour of run-time 51 * efficiency. 52 */ 53 54 struct iaddrmatch { 55 struct iaddr addr; 56 struct iaddr mask; 57 }; 58 59 /* its list ... */ 60 61 struct iaddrmatchlist { 62 struct iaddrmatchlist *next; 63 struct iaddrmatch match; 64 }; 65 66 67 /* 68 * Structure to store information about a CIDR network. 69 */ 70 71 struct iaddrcidrnet { 72 struct iaddr lo_addr; 73 int bits; 74 }; 75 76 struct iaddrcidrnetlist { 77 struct iaddrcidrnetlist *next; 78 struct iaddrcidrnet cidrnet; 79 }; 80 81