Loading...
Searching...
No Matches
hostdomain.h File Reference

Predicates for handling host names: IP addresses or domain names. More...

`#include <sofia-sip/su_config.h>`
Include dependency graph for hostdomain.h:

Go to the source code of this file.

## Macros

#define | SOFIA_SIP_HOSTDOMAIN_H
| Defined when <sofia-sip/hostdomain.h> has been included.

## Functions

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_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 *string)
| 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.
int | host_ip6_reference (char const *string)
| This is typo.

## Detailed Description

Predicates for handling host names: IP addresses or domain names.

Author
  Pekka Pessi Pekka.nosp@m..Pes.nosp@m.si@no.nosp@m.kia..nosp@m.com

Date
  Created: Thu Mar 9 16:15:22 EET 2006 ppessi

## Function Documentation

## host_cmp()

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.

## host_ip6_reference()

int host_ip6_reference | ( | char const * | string | ) |

This is typo.

Deprecated
  Use host_is_ip6_reference() instead.

## host_is_domain()

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
ALPHA
#define ALPHA
Alphabetic characters.
Definition bnf.h:69

## host_is_ip4_address()

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.

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

## host_is_ip6_reference()

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.

## host_is_ip_address()

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 ([]).

## host_is_local()

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.

## host_is_valid()

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.

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