|
NAMErgxg_net_cidr_string, rgxg_net_cidr_ipv4, rgxg_net_cidr_ipv6 - create regex that matches all addresses of the given CIDR blockSYNOPSIS#include <rgxg/net.h> int rgxg_net_cidr_string (const char *cidr, char **endptr, char *regex, rgxg_options_t options); int rgxg_net_cidr_ipv4 (const rgxg_ipv4_t *address, int prefix, char *regex, rgxg_options_t options); int rgxg_net_cidr_ipv6 (const rgxg_ipv6_t *address, int prefix, char *regex, rgxg_options_t options); DESCRIPTIONrgxg_net_cidr_string() generates the (extended) regular expression that matches all addresses of the CIDR block given as string in cidr (e.g. "192.168.0.0/24" or "2001:db8:aaaa::/64"). cidr must be valid and not NULL.If endptr is not NULL, rgxg_net_cidr_string() stores on success the address of the first character which is not part of the CIDR block in *endptr. If there is no error and **endptr is '\0', then the entire string has been parsed. The *endptr values in case of an error are described in the ERRORS section below. rgxg_net_cidr_ipv4() and rgxg_net_cidr_ipv6() generate the (extended) regular expression that matches all addresses of the CIDR block specified by address and prefix (network identifier), which must be between 0 and 32 (rgxg_net_cidr_ipv4()) respectively 128 (rgxg_net_cidr_ipv6()) inclusive. address must be valid and not NULL. The rgxg_ipv4_t and rgxg_ipv6_t structures which are the types of address are defined in <rgxg/net.h>.
typedef struct { uint8_t octet[4]; } rgxg_ipv4_t; typedef struct { uint16_t hextet[8]; } rgxg_ipv6_t; The n-th element of the octet/hextet array stores the (n+1)-th octet/hextet of the IPv4 respectively IPv6 address (i.e. for instance the first octet '192' in '192.168.0.0' is stored in octet[0]). The generated regular expression is written to the character string regex, including the terminating null byte ('\0'), unless RGXG_NONULLBYTE is set. If regex is NULL the return value is the number of characters (excluding the terminating null byte) that would have been written in case regex has been initialized. Note that the functions assume an arbitrarily long regex string, callers must ensure that the given string is large enough to not overflow the actual space. options is either zero, or the bitwise-or of one or more of the following macros: Options marked as 'IPv6 only' can be used with rgxg_net_cidr_string() (when parsing IPv6 CIDR blocks) and with rgxg_net_cidr_ipv6().
Note that RGXG_NOUPPERCASE and RGXG_NOLOWERCASE are mutual exclusive options. RETURN VALUEUpon successful return, these functions return the number of characters (excluding the terminating null byte) written to regex.If an error occurs, a (negative) error code is returned (see ERRORS section). ERRORSThe following errors can be returned:
AVAILABILITYThese functions are available since rgxg 0.1.SEE ALSOregex(7), rgxg_number_greaterequal(3), rgxg_number_range(3).AUTHORHannes von Haugwitz <hannes@vonhaugwitz.com>
Visit the GSP FreeBSD Man Page Interface. |