/*++ /* NAME /* cidr_match 3 /* SUMMARY /* CIDR-style pattern matching /* SYNOPSIS /* #include <cidr_match.h> /* /* VSTRING *cidr_match_parse(info, pattern, match, why) /* CIDR_MATCH *info; /* char *pattern; /* VSTRING *why; /* /* int cidr_match_execute(info, address) /* CIDR_MATCH *info; /* const char *address; /* AUXILIARY FUNCTIONS /* VSTRING *cidr_match_parse_if(info, pattern, match, why) /* CIDR_MATCH *info; /* char *pattern; /* VSTRING *why; /* /* void cidr_match_endif(info) /* CIDR_MATCH *info; /* DESCRIPTION /* This module parses address or address/length patterns and /* provides simple address matching. The implementation is /* such that parsing and execution can be done without dynamic /* memory allocation. The purpose is to minimize overhead when /* called by functions that parse and execute on the fly, such /* as match_hostaddr(). /* /* cidr_match_parse() parses an address or address/mask /* expression and stores the result into the info argument. /* A non-zero (or zero) match argument requests a positive (or /* negative) match. The symbolic constants CIDR_MATCH_TRUE and /* CIDR_MATCH_FALSE may help to improve code readability. /* The result is non-zero in case of problems: either the /* value of the why argument, or a newly allocated VSTRING /* (the caller should give the latter to vstring_free()). /* The pattern argument is destroyed. /* /* cidr_match_parse_if() parses the address that follows an IF /* token, and stores the result into the info argument. /* The arguments are the same as for cidr_match_parse(). /* /* cidr_match_endif() handles the occurrence of an ENDIF token, /* and updates the info argument. /* /* cidr_match_execute() matches the specified address against /* a list of parsed expressions, and returns the matching /* expression's data structure. /* SEE ALSO /* dict_cidr(3) CIDR-style lookup table /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
case CIDR_MATCH_OP_MATCH: if (entry->addr_family == addr_family) if (cidr_match_entry(entry, addr_bytes)) return (entry); break;
case CIDR_MATCH_OP_IF: if (entry->addr_family == addr_family) if (cidr_match_entry(entry, addr_bytes)) continue; /* An IF without matching ENDIF has no end-of block entry. */ if ((entry = entry->block_end) == 0) return (0); /* FALLTHROUGH */
case CIDR_MATCH_OP_ENDIF: continue;
}
} return (0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.