ldns  1.7.0
Macros | Functions
dname.h File Reference

dname contains function to read and manipulate domain names. More...

Go to the source code of this file.

Macros

#define LDNS_DNAME_NORMALIZE   tolower
 

Functions

ldns_rdfldns_dname_cat_clone (const ldns_rdf *rd1, const ldns_rdf *rd2)
 concatenates two dnames together More...
 
ldns_status ldns_dname_cat (ldns_rdf *rd1, const ldns_rdf *rd2)
 concatenates rd2 after rd1 (rd2 is copied, rd1 is modified) More...
 
ldns_rdfldns_dname_reverse (const ldns_rdf *d)
 Returns a clone of the given dname with the labels reversed. More...
 
ldns_rdfldns_dname_clone_from (const ldns_rdf *d, uint16_t n)
 Clones the given dname from the nth label on. More...
 
ldns_rdfldns_dname_left_chop (const ldns_rdf *d)
 chop one label off the left side of a dname. More...
 
uint8_t ldns_dname_label_count (const ldns_rdf *r)
 count the number of labels inside a LDNS_RDF_DNAME type rdf. More...
 
ldns_rdfldns_dname_new_frm_str (const char *str)
 creates a new dname rdf from a string. More...
 
ldns_rdfldns_dname_new (uint16_t s, void *data)
 Create a new dname rdf from a string. More...
 
ldns_rdfldns_dname_new_frm_data (uint16_t size, const void *data)
 Create a new dname rdf from data (the data is copied) More...
 
void ldns_dname2canonical (const ldns_rdf *rdf)
 Put a dname into canonical fmt - ie. More...
 
signed char ldns_dname_is_subdomain (const ldns_rdf *sub, const ldns_rdf *parent)
 test wether the name sub falls under parent (i.e. More...
 
int ldns_dname_compare (const ldns_rdf *dname1, const ldns_rdf *dname2)
 Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6. More...
 
int ldns_dname_compare_v (const void *, const void *)
 Given in dnssec_zone.c, also used in dnssec_sign.c:w. More...
 
int ldns_dname_match_wildcard (const ldns_rdf *dname, const ldns_rdf *wildcard)
 Checks whether the dname matches the given wildcard. More...
 
int ldns_dname_interval (const ldns_rdf *prev, const ldns_rdf *middle, const ldns_rdf *next)
 check if middle lays in the interval defined by prev and next prev <= middle < next. More...
 
signed char ldns_dname_str_absolute (const char *dname_str)
 Checks whether the given dname string is absolute (i.e. More...
 
signed char ldns_dname_absolute (const ldns_rdf *dname)
 Checks whether the given dname is absolute (i.e. More...
 
ldns_rdfldns_dname_label (const ldns_rdf *rdf, uint8_t labelpos)
 look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label. More...
 
int ldns_dname_is_wildcard (const ldns_rdf *dname)
 Check if dname is a wildcard, starts with *. More...
 

Detailed Description

dname contains function to read and manipulate domain names.

Example domain names are "www.nlnetlabs.nl." and "." (the root)

If a domain name ends with a dot ("."), it is called a Fully Qualified Domain Name (FQDN). In certain places (for instance when reading a zone file), an origin (which is just another domain name) non-FQDNs will be placed after the current. For instance, if i have a zone file where the origin has been set to "nl.", and my file contains the name "www.nlnetlabs", it will result in "www.nlnetlabs.nl.". Internally, dnames are always absolute (the dot is added when it is missing and there is no origin).

An FQDN is also known as an absolute domain name, therefore the function to check this is called ldns_dname_str_absolute

Domain names are stored in ldns_rdf structures, with the type LDNS_RDF_TYPE_DNAME

This module is NOT about the RR type called DNAME.

Definition in file dname.h.

Macro Definition Documentation

§ LDNS_DNAME_NORMALIZE

#define LDNS_DNAME_NORMALIZE   tolower

Definition at line 49 of file dname.h.

Function Documentation

§ ldns_dname_cat_clone()

ldns_rdf* ldns_dname_cat_clone ( const ldns_rdf rd1,
const ldns_rdf rd2 
)

concatenates two dnames together

Parameters
[in]rd1the leftside
[in]rd2the rightside
Returns
a new rdf with leftside/rightside

Definition at line 52 of file dname.c.

References ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_cat()

ldns_status ldns_dname_cat ( ldns_rdf rd1,
const ldns_rdf rd2 
)

concatenates rd2 after rd1 (rd2 is copied, rd1 is modified)

Parameters
[in]rd1the leftside
[in]rd2the rightside
Returns
LDNS_STATUS_OK on success

Definition at line 90 of file dname.c.

References ldns_rdf_get_type(), ldns_rdf_size(), LDNS_RDF_TYPE_DNAME, and LDNS_STATUS_ERR.

§ ldns_dname_reverse()

ldns_rdf* ldns_dname_reverse ( const ldns_rdf d)

Returns a clone of the given dname with the labels reversed.

Parameters
[in]dthe dname to reverse
Returns
clone of the dname with the labels reversed.

Definition at line 124 of file dname.c.

References LDNS_FREE, ldns_rdf_get_type(), ldns_rdf_new(), ldns_rdf_size(), LDNS_RDF_TYPE_DNAME, and LDNS_XMALLOC.

§ ldns_dname_clone_from()

ldns_rdf* ldns_dname_clone_from ( const ldns_rdf d,
uint16_t  n 
)

Clones the given dname from the nth label on.

Parameters
[in]dThe dname to clone
[in]nthe label nr to clone from, if this is 0, the complete dname is cloned
Returns
A newly allocated *rdf structure, containing the cloned dname, or NULL if either d was NULL, not a dname, or if n >= label_count

Definition at line 160 of file dname.c.

References ldns_dname_label_count(), ldns_dname_new_frm_data(), ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_left_chop()

ldns_rdf* ldns_dname_left_chop ( const ldns_rdf d)

chop one label off the left side of a dname.

so wwww.nlnetlabs.nl, becomes nlnetlabs.nl This new name is a clone and must be freed with ldns_deep_free()

Parameters
[in]dthe dname to chop
Returns
the remaining dname

Definition at line 189 of file dname.c.

References ldns_dname_label_count(), ldns_dname_new_frm_data(), ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_label_count()

uint8_t ldns_dname_label_count ( const ldns_rdf r)

count the number of labels inside a LDNS_RDF_DNAME type rdf.

Parameters
[in]*rthe rdf
Returns
the number of labels

Definition at line 214 of file dname.c.

References ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_new_frm_str()

ldns_rdf* ldns_dname_new_frm_str ( const char *  str)

creates a new dname rdf from a string.

Parameters
[in]strstring to use
Returns
ldns_rdf* or NULL in case of an error

Definition at line 268 of file dname.c.

References ldns_rdf_new_frm_str(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_new()

ldns_rdf* ldns_dname_new ( uint16_t  s,
void *  data 
)

Create a new dname rdf from a string.

The data pointer is stored in the rdf, not a copy of the data

Parameters
[in]sthe size of the new dname
[in]*datapointer to the actual data
Returns
ldns_rdf*

Definition at line 250 of file dname.c.

References LDNS_MALLOC, ldns_rdf_set_data(), ldns_rdf_set_size(), ldns_rdf_set_type(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_new_frm_data()

ldns_rdf* ldns_dname_new_frm_data ( uint16_t  size,
const void *  data 
)

Create a new dname rdf from data (the data is copied)

Parameters
[in]sizethe size of the data
[in]*datapointer to the actual data
Returns
ldns_rdf*

Definition at line 274 of file dname.c.

References ldns_rdf_new_frm_data(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname2canonical()

void ldns_dname2canonical ( const ldns_rdf rdf)

Put a dname into canonical fmt - ie.

lowercase it

Parameters
[in]rdfthe dname to lowercase
Returns
void

Definition at line 280 of file dname.c.

References LDNS_DNAME_NORMALIZE, ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_is_subdomain()

signed char ldns_dname_is_subdomain ( const ldns_rdf sub,
const ldns_rdf parent 
)

test wether the name sub falls under parent (i.e.

is a subdomain of parent). This function will return false if the given dnames are equal.

Parameters
[in]subthe name to test
[in]parentthe parent's name
Returns
true if sub falls under parent, otherwise false

Definition at line 296 of file dname.c.

References ldns_dname2canonical(), ldns_dname_clone_from(), ldns_dname_label(), ldns_dname_label_count(), ldns_rdf_compare(), ldns_rdf_deep_free(), ldns_rdf_get_type(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_compare()

int ldns_dname_compare ( const ldns_rdf dname1,
const ldns_rdf dname2 
)

Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6.

Parameters
[in]dname1First dname rdf to compare
[in]dname2Second dname rdf to compare
Returns
-1 if dname1 comes before dname2, 1 if dname1 comes after dname2, and 0 if they are equal.

Definition at line 359 of file dname.c.

References ldns_dname_label_count(), LDNS_DNAME_NORMALIZE, ldns_rdf_data(), ldns_rdf_get_type(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_compare_v()

int ldns_dname_compare_v ( const void *  ,
const void *   
)

Given in dnssec_zone.c, also used in dnssec_sign.c:w.

Definition at line 827 of file dnssec_zone.c.

References ldns_dname_compare().

§ ldns_dname_match_wildcard()

int ldns_dname_match_wildcard ( const ldns_rdf dname,
const ldns_rdf wildcard 
)

Checks whether the dname matches the given wildcard.

Parameters
[in]dnameThe dname to check
[in]wildcardThe wildcard to check with
Returns
1 If the wildcard matches, OR if 'wildcard' is not a wildcard and the names are exactly the same 0 If the wildcard does not match, or if it is not a wildcard and the names are not the same

Definition at line 464 of file dname.c.

References ldns_dname_compare(), ldns_dname_is_subdomain(), ldns_dname_is_wildcard(), ldns_dname_left_chop(), and ldns_rdf_deep_free().

§ ldns_dname_interval()

int ldns_dname_interval ( const ldns_rdf prev,
const ldns_rdf middle,
const ldns_rdf next 
)

check if middle lays in the interval defined by prev and next prev <= middle < next.

This is useful for nsec checking

Parameters
[in]prevthe previous dname
[in]middlethe dname to check
[in]nextthe next dname return 0 on error or unknown, -1 when middle is in the interval, +1 when not

Definition at line 488 of file dname.c.

References ldns_dname_compare(), ldns_rdf_get_type(), and LDNS_RDF_TYPE_DNAME.

§ ldns_dname_str_absolute()

signed char ldns_dname_str_absolute ( const char *  dname_str)

Checks whether the given dname string is absolute (i.e.

ends with a '.')

Parameters
[in]*dname_stra string representing the dname
Returns
true or false

Definition at line 518 of file dname.c.

§ ldns_dname_absolute()

signed char ldns_dname_absolute ( const ldns_rdf dname)

Checks whether the given dname is absolute (i.e.

ends with a '.')

Parameters
[in]*dnamea rdf representing the dname
Returns
true or false

Definition at line 548 of file dname.c.

References ldns_dname_str_absolute(), LDNS_FREE, and ldns_rdf2str().

§ ldns_dname_label()

ldns_rdf* ldns_dname_label ( const ldns_rdf rdf,
uint8_t  labelpos 
)

look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.

The labels are numbered starting from 0 (left most).

Parameters
[in]rdfthe rdf to look in
[in]labelposreturn the label with this number
Returns
a ldns_rdf* with the label as name or NULL on error

Definition at line 560 of file dname.c.

References LDNS_FREE, ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_new(), ldns_rdf_size(), LDNS_RDF_TYPE_DNAME, and LDNS_XMALLOC.

§ ldns_dname_is_wildcard()

int ldns_dname_is_wildcard ( const ldns_rdf dname)

Check if dname is a wildcard, starts with *.

Parameters
[in]dnamethe rdf to look in
Returns
true if a wildcard, false if not.

Definition at line 456 of file dname.c.

References ldns_dname_label_count(), and ldns_rdf_data().