Home | History | Annotate | Line # | Download | only in includes
      1 /*	$NetBSD: inet.h,v 1.3 2022/04/03 01:10:58 christos Exp $	*/
      2 
      3 /* inet.h
      4 
      5    Portable definitions for internet addresses */
      6 
      7 /*
      8  * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
      9  * Copyright (c) 1996-2003 by Internet Software Consortium
     10  *
     11  * This Source Code Form is subject to the terms of the Mozilla Public
     12  * License, v. 2.0. If a copy of the MPL was not distributed with this
     13  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
     16  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     17  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
     18  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     20  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
     21  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     22  *
     23  *   Internet Systems Consortium, Inc.
     24  *   PO Box 360
     25  *   Newmarket, NH 03857 USA
     26  *   <info (at) isc.org>
     27  *   https://www.isc.org/
     28  *
     29  */
     30 
     31 /* An internet address of up to 128 bits. */
     32 
     33 struct iaddr {
     34 	unsigned len;
     35 	unsigned char iabuf [16];
     36 };
     37 
     38 struct iaddrlist {
     39 	struct iaddrlist *next;
     40 	struct iaddr addr;
     41 };
     42 
     43 
     44 /* struct iaddrmatch - used to compare a host IP against a subnet spec
     45  *
     46  * There is a space/speed tradeoff here implied by the use of a second
     47  * struct iaddr to hold the mask; while using an unsigned (byte!) to
     48  * represent the subnet prefix length would be more memory efficient,
     49  * it makes run-time mask comparisons more expensive.  Since such
     50  * entries are used currently only in restricted circumstances
     51  * (wanting to reject a subnet), the decision is in favour of run-time
     52  * efficiency.
     53  */
     54 
     55 struct iaddrmatch {
     56 	struct iaddr addr;
     57 	struct iaddr mask;
     58 };
     59 
     60 /* its list ... */
     61 
     62 struct iaddrmatchlist {
     63 	struct iaddrmatchlist *next;
     64 	struct iaddrmatch match;
     65 };
     66 
     67 
     68 /*
     69  * Structure to store information about a CIDR network.
     70  */
     71 
     72 struct iaddrcidrnet {
     73 	struct iaddr lo_addr;
     74 	int bits;
     75 };
     76 
     77 struct iaddrcidrnetlist {
     78 	struct iaddrcidrnetlist *next;
     79 	struct iaddrcidrnet cidrnet;
     80 };
     81