bnf.c File Reference


Detailed Description

Character syntax table for HTTP-like protocols.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>

Kai Vehmanen <Kai.Vehmanen@nokia-email.address.hidden>

Date:
Created: Thu Jun 8 19:28:55 2000 ppessi

#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.

Function Documentation

int canonize_ip6_address ( char *  host,
char *  hexparts[9] 
) [inline]

Canonize scanned IP6 address.

Return values:
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.

Parameters:
a IP address or domain name
b IP address or domain name
Return values:
-1 if a < b
0 if a == b
1 if a > b
Since:
New in 1.12.4.

int host_ip6_reference ( char const *  string  ) 

This is typo.

Deprecated:
Use host_is_ip6_reference() instead.

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.

 hostname         =  *( domainlabel "." ) toplabel [ "." ]
 domainlabel      =  alphanum
                     / alphanum *( alphanum / "-" ) alphanum
 toplabel         =  ALPHA / ALPHA *( alphanum / "-" ) alphanum

int host_is_ip4_address ( char const *  string  ) 

Return true if string is valid IP4 address in dot-notation.

Note:
Only 4-octet form is accepted, e.g., 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.

Parameters:
inout_host input pointer to string to scan output pointer to first character after valid IP6 address
Return values:
Length of valid IP6 address or -1 upon an error.
Note:
Scanned IP6 is not always NUL-terminated.

isize_t span_domain ( char const *  host  ) 

Return length of a valid domain name.

 hostname         =  *( domainlabel "." ) toplabel [ "." ]
 domainlabel      =  alphanum
                     / alphanum *( alphanum / "-" ) alphanum
 toplabel         =  ALPHA / ALPHA *( alphanum / "-" ) alphanum

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.


Sofia-SIP 1.12.6 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.