Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / util / cidr_match.h
blob140b6b25578adf0bbab5f216233125b4217c45e0
1 /* $NetBSD$ */
3 #ifndef _CIDR_MATCH_H_INCLUDED_
4 #define _CIDR_MATCH_H_INCLUDED_
6 /*++
7 /* NAME
8 /* dict_cidr 3h
9 /* SUMMARY
10 /* CIDR-style pattern matching
11 /* SYNOPSIS
12 /* #include <cidr_match.h>
13 /* DESCRIPTION
14 /* .nf
17 * System library.
19 #include <limits.h> /* CHAR_BIT */
22 * Utility library.
24 #include <myaddrinfo.h> /* MAI_V6ADDR_BYTES etc. */
25 #include <vstring.h>
28 * External interface.
30 * Address length is protocol dependent. Find out how large our address byte
31 * strings should be.
33 #ifdef HAS_IPV6
34 # define CIDR_MATCH_ABYTES MAI_V6ADDR_BYTES
35 #else
36 # define CIDR_MATCH_ABYTES MAI_V4ADDR_BYTES
37 #endif
40 * Each parsed CIDR pattern can be member of a linked list.
42 typedef struct CIDR_MATCH {
43 unsigned char net_bytes[CIDR_MATCH_ABYTES]; /* network portion */
44 unsigned char mask_bytes[CIDR_MATCH_ABYTES]; /* network mask */
45 unsigned char addr_family; /* AF_XXX */
46 unsigned char addr_byte_count; /* typically, 4 or 16 */
47 unsigned char addr_bit_count; /* optimization */
48 unsigned char mask_shift; /* optimization */
49 struct CIDR_MATCH *next; /* next entry */
50 } CIDR_MATCH;
52 extern VSTRING *cidr_match_parse(CIDR_MATCH *, char *, VSTRING *);
53 extern CIDR_MATCH *cidr_match_execute(CIDR_MATCH *, const char *);
55 /* LICENSE
56 /* .ad
57 /* .fi
58 /* The Secure Mailer license must be distributed with this software.
59 /* AUTHOR(S)
60 /* Wietse Venema
61 /* IBM T.J. Watson Research
62 /* P.O. Box 704
63 /* Yorktown Heights, NY 10598, USA
64 /*--*/
66 #endif