Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
domainfn.cpp File Reference
#include "dnsmessage.h"
#include "domainfn.h"
#include "lexfn.h"
#include "exception.h"
#include "sysstl.h"
#include "sysstring.h"
+ Include dependency graph for domainfn.cpp:

Macros

#define DOM_RECLEVEL   10

Functions

int dom_comprlen (message_buff &buff, int ix)
 compressed length
std::string dom_label (_cdomain dom, int label)
 label of domain name
int dom_nlabels (_cdomain dom)
 number of labels
int dom_partiallength (_cdomain _dom, int n)
_domain dom_plabel (_cdomain dom, int label)
 label of domain name
std::string dom_tostring (_cdomain dom)
 to-string conversion
_domain dom_uncompress (message_buff &buff, int ix)
 uncompress domain name
void dom_write (std::string &ret, _cdomain dom, std::list< dom_compr_info > *comprinfo)
 compress domain name
void domcat (_domain res, _cdomain src)
 domain name concatenation
int domccmp (_cdomain _dom1, _cdomain _dom2)
 compare domain names
bool domcmp (_cdomain _dom1, _cdomain _dom2)
 compare binary domain names
void domcpy (_domain res, _cdomain src)
 static copy of binary domain name
_domain domdup (_cdomain dom)
 dynamic copy of binary domain name
_domain domfrom (_cdomain dom, int ix)
 domain name portion pointer
void domfromlabel (_domain dom, const char *label, int len)
 create domain name from label
bool domisparent (_cdomain parent, _cdomain child)
 test for parent<->child relationship
bool domlcmp (_cdomain dom1, _cdomain dom2)
 compare binary domain labels
int domlen (_cdomain dom)
 length of binary domain name
int domncommon (_cdomain _dom1, _cdomain _dom2)
 check label match count
void domto (_domain ret, _cdomain src, int labels)
 return domain name portion
void * memdup (const void *src, int len)
 dump memory

Macro Definition Documentation

#define DOM_RECLEVEL   10

Function Documentation

int dom_comprlen ( message_buff buff,
int  ix 
)

compressed length

This function returns the compressed length - that is, the length the domain takes up in the DNS message - of a domain name.

Parameters
buffA DNS messagee
ixIndex of the domain name
Returns
Length in bytes the domain name takes up.
std::string dom_label ( _cdomain  dom,
int  label 
)

label of domain name

Returns a label of the domain name in human-readable form.

Parameters
domThe domain name
labelLabel index (0 <= label < dom_nlabels(dom))
Returns
The label
See Also
dom_nlabels()
int dom_nlabels ( _cdomain  dom)

number of labels

Returns the number of labels, also counting the empty '\0' label, of the domain name.

Parameters
domThe domain name
Returns
Number of labels
int dom_partiallength ( _cdomain  _dom,
int  n 
)
_domain dom_plabel ( _cdomain  dom,
int  label 
)

label of domain name

Returns a label of the domain name as a pointer to the position in the domain.

Parameters
domThe domain name
labelLabel index (0 < label < dom_nlabels(dom))
Returns
The label
See Also
dom_nlabels()
std::string dom_tostring ( _cdomain  dom)

to-string conversion

Converts the domain name to a human-readable string. Contains the trailing dot.

Parameters
domThe domain name
Returns
Human-readable string.
_domain dom_uncompress ( message_buff buff,
int  ix 
)

uncompress domain name

This function decompresses a domain name in a DNS message. It returns the binary, decompressed data describing the domain name.

Parameters
buffA DNS message
ixIndex of the domain name
Returns
Uncompressed binary domain name (dynamically allocated)
void dom_write ( std::string &  ret,
_cdomain  dom,
std::list< dom_compr_info > *  compr 
)

compress domain name

This function writes a domain name to the end of a DNS message, compressing it if possible.

Parameters
retA (partial) DNS message
domDomain name to write
comprList of earlier compressed domain names, or NULL if no compression
void domcat ( _domain  target,
_cdomain  src 
)

domain name concatenation

Appends src to target. Since it does not re-allocate memory, Make sure that target can hold at least DOM_MAX bytes.

Parameters
targetTarget
srcSource
int domccmp ( _cdomain  dom1,
_cdomain  dom2 
)

compare domain names

This function offers a way to compare domain names the way the strcmp do. It operates in such a way that child domains are greater than parent domains, and for for other domains, the first non-matching domain label is compared using strcmpi. For example, www.foo.acdam.net is greater than bar.acdam.net because foo is greater than bar which is the first non-matching label after the common acdam.net part of the domain names.

Parameters
dom1First domain name
dom2Second domain name
Returns
<0, 0 or >0 if the first domain name is smaller than, equal to, or larger than the second one, respectively.
bool domcmp ( _cdomain  dom1,
_cdomain  dom2 
)

compare binary domain names

Checks whether both binary domain names are equal.

Parameters
dom1First domain name
dom2Second domain name
Returns
true if the domain names are equal
void domcpy ( _domain  res,
_cdomain  src 
)

static copy of binary domain name

Makes a static copy of a domain name. Make sure that res can hold at least DOM_MAX bytes.

Parameters
resTarget
srcSource
See Also
domdup()
_domain domdup ( _cdomain  dom)

dynamic copy of binary domain name

Makes a dynamically allocated copy of a domain name.

Parameters
domDomain name
Returns
Copy of domain name
See Also
domcpy()
_domain domfrom ( _cdomain  dom,
int  ix 
)

domain name portion pointer

Returns a pointer to the portion of the domain name from the ix'th label.

Parameters
domDomain name
ixIndex
Returns
Domain name portion
void domfromlabel ( _domain  dom,
const char *  label,
int  len = -1 
)

create domain name from label

Creates a domain name containing just one label: the string argument given. If a length is given, only the first few characters of the string are used. Make sure that dom can hold at least DOM_MAX bytes.

Parameters
domResult
labelString label
lenIf given, length of string label (default: strlen(label)).
bool domisparent ( _cdomain  parent,
_cdomain  child 
)

test for parent<->child relationship

Tests whether the first domain name is a parent of the second domain name.

Parameters
parentParent domain
childChild domain
Returns
True if parent is indeed a parent of child .
bool domlcmp ( _cdomain  dom1,
_cdomain  dom2 
)

compare binary domain labels

Checks whether both binary domain name start with the same label.

Parameters
dom1First domain name
dom2Second domain name
Returns
true if the domain names start with the same label
int domlen ( _cdomain  dom)

length of binary domain name

Returns the length, in bytes, including the trailing '\0' character, of the domain name.

Parameters
domDomain name
Returns
Length of the domain name
int domncommon ( _cdomain  dom1,
_cdomain  dom2 
)

check label match count

Returns the number of labels the two domain names have in common at their ends; for example this returns 2 for www.acdam.net and www.foo.acdam.net .

Parameters
dom1The domain name to check with
dom2The domain name to check against
Returns
Number of common labels
See Also
nlabels()
void domto ( _domain  ret,
_cdomain  src,
int  labels 
)

return domain name portion

Returns a domain name consisting of the first label labels of the given domain name. The ret buffer should be large enough to hold the result to prevent a buffer overflow.

Parameters
retResult buffer
srcSource domain
labelsNumber of labels to include
void* memdup ( const void *  src,
int  len 
)

dump memory

This is an alternative to the c strdup() function, but instead it can dump any type of memory, as long as you give the right length.

Parameters
srcSource memory location
lenLength of data
Returns
A newly-allocated copy of src.