#include "config.h"
#include "sofia-sip/bnf.h"
#include <assert.h>
#include <sofia-sip/hostdomain.h>
#include <sofia-sip/su.h>
Include dependency graph for bnf.c:
Functions | |
size_t | bnf_span_token (char const *s) |
Span of a token. | |
size_t | bnf_span_token4 (char const *s) |
Span of a token. | |
int | span_ip4_octet (char const *host) |
Return length of decimal-octet. | |
int | span_canonic_ip4_address (char const *host, int *return_canonize) |
Return length of valid IP4 address. | |
int | span_ip4_address (char const *host) |
Return length of valid IP4 address. | |
int | scan_ip4_address (char **inout_host) |
Scan and canonize a valid IP4 address. | |
int | span_hex4 (char const *host) |
Return length of hex4. | |
int | span_canonic_ip6_address (char const *host, int *return_canonize, char *hexparts[9]) |
Return length of valid IP6 address. | |
int | canonize_ip6_address (char *host, char *hexparts[9]) |
Canonize scanned IP6 address. | |
int | span_ip6_address (char const *host) |
Return length of valid IP6 address. | |
int | scan_ip6_address (char **inout_host) |
Scan and canonize valid IP6 address. | |
int | span_ip6_reference (char const *host) |
Return length of valid IP6 reference. | |
int | scan_ip6_reference (char **inout_host) |
Scan valid IP6 reference. | |
int | span_ip_address (char const *host) |
Return length of valid IP4 or IP6 address. | |
int | scan_ip_address (char **inout_host) |
Scan valid IP4/IP6 address. | |
size_t | span_domain_label (char const *label) |
Return length of a valid domain label. | |
size_t | span_domain_labels (char const *host, size_t *return_labels) |
Scan valid domain name and count number of labels in it. | |
isize_t | span_domain (char const *host) |
Return length of a valid domain name. | |
issize_t | scan_domain (char **inout_host) |
Scan valid domain name. | |
isize_t | span_host (char const *host) |
Return length of a valid domain name or IP address. | |
issize_t | scan_host (char **inout_host) |
Scan valid domain name or IP address. | |
int | host_is_ip4_address (char const *string) |
Return true if string is valid IP4 address in dot-notation. | |
int | host_is_ip6_address (char const *string) |
Return true if string is valid IP6 address in hex notation. | |
int | host_ip6_reference (char const *string) |
This is typo. | |
int | host_is_ip6_reference (char const *string) |
Return true if string is valid IP6 reference, i.e. | |
int | host_is_ip_address (char const *string) |
Return true if string is valid IP address. | |
int | host_is_domain (char const *string) |
Return true if string is valid a domain name. | |
int | host_is_valid (char const *string) |
Return true if string is valid a host name. | |
int | host_is_local (char const *host) |
Returns true if string is describing a local address. | |
int | host_has_domain_invalid (char const *string) |
Return true if string has domain name in "invalid." domain. | |
int | host_cmp (char const *a, char const *b) |
Compare two host names or IP addresses. | |
Variables | |
unsigned char const | _bnf_table [256] |
Table for determining class of a character. |
int canonize_ip6_address | ( | char * | host, | |
char * | hexparts[9] | |||
) | [inline] |
Canonize scanned IP6 address.
Length | of canonized IP6 address. |
int host_cmp | ( | char const * | a, | |
char const * | b | |||
) |
Compare two host names or IP addresses.
Converts valid IP addresses to the binary format before comparing them. Note that IP6-mapped IP4 addresses and IP6-compatible IP4 addresses are compared as IP4 addresses; that is, ffff:127.0.0.1, ::127.0.0.1 and 127.0.0.1 all are all equal.
a | IP address or domain name | |
b | IP address or domain name |
-1 | if a < b | |
0 | if a == b | |
1 | if a > b |
int host_ip6_reference | ( | char const * | string | ) |
int host_is_domain | ( | char const * | string | ) |
Return true if string is valid a domain name.
Valid domain name consists of alphanumeric labels separated with dot ("."). There can be a "-" in the middle of label. The last label must start with a letter.
int host_is_ip4_address | ( | char const * | string | ) |
Return true if string is valid IP4 address in dot-notation.
127.1
is not considered valid IP4 address. int host_is_ip6_address | ( | char const * | string | ) |
Return true if string is valid IP6 address in hex notation.
E.g., fe80::1 is a valid IP6 address.
int host_is_ip6_reference | ( | char const * | string | ) |
Return true if string is valid IP6 reference, i.e.
hex notation in square brackets.
E.g., [::1] is a valid IP6 reference.
int host_is_ip_address | ( | char const * | string | ) |
Return true if string is valid IP address.
Valid IP address is either a IP4 adddress in quad-octet notation, IP6 hex address or IP6 reference in square brackets ([]).
int host_is_local | ( | char const * | host | ) |
Returns true if string is describing a local address.
Uses the definitions of local addresses found in RFC1700 and RFC4291.
int host_is_valid | ( | char const * | string | ) |
Return true if string is valid a host name.
Check if the string is a domain name, IP address or IP6 reference.
int scan_ip6_address | ( | char ** | inout_host | ) |
Scan and canonize valid IP6 address.
inout_host | input pointer to string to scan output pointer to first character after valid IP6 address |
Length | of valid IP6 address or -1 upon an error. |
isize_t span_domain | ( | char const * | host | ) |
int span_ip4_address | ( | char const * | host | ) |
Return length of valid IP4 address.
Note that we accept here up to two leading zeroes which makes "dotted decimal" notation ambiguous: 127.000.000.001 is interpreted same as 127.0.0.1
Note that traditionally IP address octets starting with zero have been interpreted as octal: 172.055.055.001 has been same as 172.45.45.1
However, we interpret them as decimal, 172.055.055.001 is same as 172.55.55.1.