00001 /* inet.h 00002 00003 Portable definitions for internet addresses */ 00004 00005 /* 00006 * Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC") 00007 * Copyright (c) 1996-2003 by Internet Software Consortium 00008 * 00009 * Permission to use, copy, modify, and distribute this software for any 00010 * purpose with or without fee is hereby granted, provided that the above 00011 * copyright notice and this permission notice appear in all copies. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 00014 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00015 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 00016 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00017 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00018 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 00019 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00020 * 00021 * Internet Systems Consortium, Inc. 00022 * 950 Charter Street 00023 * Redwood City, CA 94063 00024 * <info@isc.org> 00025 * https://www.isc.org/ 00026 * 00027 */ 00028 00029 /* An internet address of up to 128 bits. */ 00030 00031 struct iaddr { 00032 unsigned len; 00033 unsigned char iabuf [16]; 00034 }; 00035 00036 struct iaddrlist { 00037 struct iaddrlist *next; 00038 struct iaddr addr; 00039 }; 00040 00041 00042 /* struct iaddrmatch - used to compare a host IP against a subnet spec 00043 * 00044 * There is a space/speed tradeoff here implied by the use of a second 00045 * struct iaddr to hold the mask; while using an unsigned (byte!) to 00046 * represent the subnet prefix length would be more memory efficient, 00047 * it makes run-time mask comparisons more expensive. Since such 00048 * entries are used currently only in restricted circumstances 00049 * (wanting to reject a subnet), the decision is in favour of run-time 00050 * efficiency. 00051 */ 00052 00053 struct iaddrmatch { 00054 struct iaddr addr; 00055 struct iaddr mask; 00056 }; 00057 00058 /* its list ... */ 00059 00060 struct iaddrmatchlist { 00061 struct iaddrmatchlist *next; 00062 struct iaddrmatch match; 00063 }; 00064 00065 00066 /* 00067 * Structure to store information about a CIDR network. 00068 */ 00069 00070 struct iaddrcidrnet { 00071 struct iaddr lo_addr; 00072 int bits; 00073 }; 00074 00075 struct iaddrcidrnetlist { 00076 struct iaddrcidrnetlist *next; 00077 struct iaddrcidrnet cidrnet; 00078 }; 00079