Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

poslib/rr.h File Reference

Resource-record information database. More...

Go to the source code of this file.


Classes

struct   rr_type
  Resource Record information. More...


Enumerations

enum   _rr_flags { R_NONE = 0, R_ASP = 1, R_COMPRESS = 2, R_ASPCOMPRESS = 3 }
  flags for Resource Record types More...


Functions

rr_type rrtype_getinfo (u_int16 type)
  retrieves RR information

rr_type rrtype_getinfo (const char *name)
  retrieves RR information by name

char *  rrtype_getname (u_int16 type)
  retrieves RR name

uint16_t  qtype_getcode (const char *name)
  retrieves qtype code

bool  answers_qtype (uint16_t rrtype, uint16_t qtype)
  check whether RR type answers QTYPE

bool  is_common_rr (uint16_t rrtype)
  check whether the RR type is a common RR

void  rr_read (u_int16 RRTYPE, char *&RDATA, uint16_t &RDLEN, message_buff &buff, int ix, int len)
  read a Resource Record from a DNS message

void  rr_write (u_int16 RRTYPE, char *RDATA, uint16_t RDLEN, stl_string &dnsmessage, stl_slist(dom_compr_info)&comprinfo)
  write a Resource Record to a DNS message

stl_string  rr_tostring (u_int16 RRTYPE, const char *RDATA, int RDLENGTH)
  convert a binary RR to string

stl_string  rr_fromstring (u_int16 RRTYPE, const char *data, _domain origin="")
  convert a string to binary RR data

stl_string  rr_fromstring (u_int16 RRTYPE, const char *data, domainname origin)
  convert a string to binary RR data

_domain  rr_getbindomain (const char *RDATA, u_int16 RRTYPE, int ix=0)
  reads a domain name from RR data

domainname  rr_getdomain (const char *RDATA, u_int16 RRTYPE, int ix=0)
  reads a domain name from RR data

char *  rr_getbinmail (const char *RDATA, u_int16 RRTYPE, int ix=0)
  reads an email address from RR data

domainname  rr_getmail (const char *RDATA, u_int16 RRTYPE, int ix=0)
  reads a domain name from RR data

u_int16  rr_getshort (const char *RDATA, u_int16 RRTYPE, int ix=0)
  read a 16-bit value from RR data

u_int32  rr_getlong (const char *RDATA, u_int16 RRTYPE, int ix=0)
  read a 32-bit value from RR data

char *  rr_getip4 (const char *RDATA, u_int16 RRTYPE, int ix=0)
  read an IP address from RR data

char *  rr_getip6 (const char *RDATA, u_int16 RRTYPE, int ix=0)
  read an IPv6 addres from RR data

stl_string  read_entry (char *&data)
  read next item in a space-delimited string

void  read_line (char *buff, FILE *f, int *linenum=NULL, int *linenum2=NULL, int buffsz=1024)
  read line from master/configuration file


Variables

const int  n_rr_types
  number of supported rr types

const rr_type  rr_types []
  array of supported rr types


Detailed Description

Resource-record information database.

This file contains functions to deal with Resource Records, the information chunks contained by DNS messages. It has functions for converting RRs to text and back, and to extract information from them.

Definition in file rr.h.


Enumeration Type Documentation

enum _rr_flags
 

flags for Resource Record types

These are flags for the rr_type::flags member for Resource Record information.

Enumeration values:
R_NONE  No RR flags
R_ASP  Do additional section processing for domain names in this Resource Record
R_COMPRESS  Compress domain names in this RR in outgoing DNS messages
R_ASPCOMPRESS  Do both additional section processing and domain name compression

Definition at line 40 of file rr.h.


Function Documentation

bool answers_qtype uint16_t  rrtype,
uint16_t  qtype
 

check whether RR type answers QTYPE

This function checks whether the given RR type provides an answer to the given QTYPE. This is the case if qtype matches rrtype, or if qtype is QTYPE_ANY , or if qtype is QTYPE_MAILB or QTYPE_MAILA and rrtype is an appropriate RR type.

Parameters:
rrtype  Resource Record type
qtype  Question type
Returns:
true if the rrtype provides an answer to the qtype.

bool is_common_rr uint16_t  rrtype  ) 
 

check whether the RR type is a common RR

This function returns true if rrtype is a common RR type (that is, not a query type like QTYPE_ANY or QTYPE_IXFR . Note that this does not nessecarily mean Poslib supports the given RR type.

Parameters:
rrtype  Resource Record type to check
Returns:
true if the rrtype is a common RR type

uint16_t qtype_getcode const char *  name  ) 
 

retrieves qtype code

This function tries to return the QTYPE code for a given string, that can either be a RR, "any", "ixfr", "axfr", "maila" or "mailb", or a numeric value.

Parameters:
type  The query type
Returns:
The 16-bit QTYPE value for the given string

stl_string read_entry char *&  data  ) 
 

read next item in a space-delimited string

This function reads the next item from a space-delimited string. It will raise an exception if none is found, and it will update the char pointer on the way. Quotes, unless escaped by a backslash, will not be included in the resulting string. Note that currently the maximum length of an entry is 256 bytes.

Parameters:
data  Pointer to string (gets updated)
Returns:
The next entry in the string
See also:
read_line

void read_line char *  buff,
FILE *  f,
int *  linenum = NULL,
int *  linenum2 = NULL,
int  buffsz = 1024
 

read line from master/configuration file

This function attempts to read a line from the file pointed to by f, placing the results in the "buff" buffer of "buffsz" bytes. This function, which is suitable for reading entries in a DNS master file, can automagically detect escaping characters with special meaning, and it can read multi-line lines with "(" and ")". The results that are placed in the buffer are suitable for use in the read_entry function.

One important thing in this context is the line number counter: as you can see there are two line number counters, which is nessecary because the line read function will always go to the beginning of the next source line before exiting. Thus, the line number counter would point to the beginning of the next (non-read) line. To prevent this, another pointer is given which is at the beginning of the function set to the current, accurate, line number. For this, a right value of the first pointer is required, though. Note that linenum should be initially set to 1 before the first read_line call.

Parameters:
buff  Buffer to place the results in
f  The file to read from
linenum  Pointer to line number counter (may be NULL; points to next source line)
linenum2  Pointer to current line number.
buffsz  Size in bytes of the buffer (defaults to 1024)
See also:
read_entry

stl_string rr_fromstring u_int16  RRTYPE,
const char *  data,
domainname  origin
 

convert a string to binary RR data

This function converts a string describing a Resource Record to binary RR data. The string should be in master file format - that is, if multiple arguments are to be put in the RR data, they should be separated by any number of spaces and tabs. For example, MX data might be "10 mail.yo.net.". You can specify an origin to which domain names are considered relative by means of the origin parameter.

Parameters:
RRTYTPE  Type of the RR
data  The text describing the RR
origin  If given, the domain name relative domain names are considered relative to. This should be a binary domain name, like the domainname::domain field. If not given, domain names are considered relative to the root domain.
Returns:
The domainname
See also:
rr_tostring()

stl_string rr_fromstring u_int16  RRTYPE,
const char *  data,
_domain  origin = ""
 

convert a string to binary RR data

This function converts a string describing a Resource Record to binary RR data. The string should be in master file format - that is, if multiple arguments are to be put in the RR data, they should be separated by any number of spaces and tabs. For example, MX data might be "10 mail.yo.net.". You can specify an origin to which domain names are considered relative by means of the origin parameter.

Parameters:
RRTYTPE  Type of the RR
data  The text describing the RR
origin  If given, the domain name relative domain names are considered relative to. This should be a binary domain name, like the domainname::domain field. If not given, domain names are considered relative to the root domain.
Returns:
Binary data describing the RR
See also:
rr_tostring()

_domain rr_getbindomain const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

reads a domain name from RR data

This function will read a domain name, in binary for, from RR data. The _domain it returns is dynamically allocated. The index is the property index in the RR data, beginning with 0, e.g. the domain name in the MX RR is one.

Parameters:
RDATA  The RR data
RRTYPE  Type of RR
ix  If given, property index in the RR (defaults to zero)
Returns:
Domain name at the specified position in the RR

char* rr_getbinmail const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

reads an email address from RR data

This is currently an alias for rr_getdomain().

domainname rr_getdomain const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

reads a domain name from RR data

Variant of the rr_getbindomain() function returning a domainname structure.

char* rr_getip4 const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

read an IP address from RR data

For details, see rr_getdomain(). Data is dynamically allocated.

char* rr_getip6 const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

read an IPv6 addres from RR data

For details, see rr_getdomain(). Data is dynamically allocated.

u_int32 rr_getlong const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

read a 32-bit value from RR data

For details, see rr_getdomain().

domainname rr_getmail const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

reads a domain name from RR data

Variant of the rr_getbinmail() function returning a domainname structure.

u_int16 rr_getshort const char *  RDATA,
u_int16  RRTYPE,
int  ix = 0
 

read a 16-bit value from RR data

For details, see rr_getdomain().

void rr_read u_int16  RRTYPE,
char *&  RDATA,
uint16_t &  RDLEN,
message_buff buff,
int  ix,
int  len
 

read a Resource Record from a DNS message

This function reads a Resource Record from a DNS message or other binary data source. It will decompress compressed domain names in the RR on the way, and return the data in the RDLEN and RDATA arguments.

Parameters:
RRTYPE  The type of RR to read
RDATA  This will hold the RR data if the function succeeds
RDLEN  This will hold the length of the RR if the function succeeds
buff  The message_buff the RR is stored in
ix  Index in the buffer the RR begins
len  Length the RR takes in the buffer

stl_string rr_tostring u_int16  RRTYPE,
const char *  RDATA,
int  RDLENGTH
 

convert a binary RR to string

This function converts the binary RR to a human-readable string in master file format.

Parameters:
RRTYPE  The RR type
RDATA  The binary RR data
RDLENGTH  Length of the binary RR data
Returns:
A string describing the RR
See also:
rr_fromstring()

void rr_write u_int16  RRTYPE,
char *  RDATA,
uint16_t  RDLEN,
stl_string &  dnsmessage,
stl_slist(dom_compr_info)&  comprinfo
 

write a Resource Record to a DNS message

This function writes a Resource Record to a DNS message. It will compress domain names along the way.

Parameters:
RRTYPE  The type of RR to write
RDATA  Pointer to the RR data
RDLEN  Length of the RR data
dnsmessage  The message to write to
comprinfo  List of compressed domain names in DNS message

rr_type* rrtype_getinfo const char *  name  ) 
 

retrieves RR information by name

This function retrieves information a Resource Record by its name. If no matching RR type is found, this function returns NULL.

Parameters:
name  The RR name (case insensitive)
Returns:
The RR type information, or NULL if none was found

rr_type* rrtype_getinfo u_int16  type  ) 
 

retrieves RR information

This function retrieves information about a Resource Record by its 16-bit unique identifier as found in DNS messages. If no matching RR type is found, this function returnes NULL.

Parameters:
type  The RR type code
Returns:
The RR type information, or NULL if none was found

char* rrtype_getname u_int16  type  ) 
 

retrieves RR name

This function returns the name for a RR type by its 16-bit code. If no matching RR type is found, this function returns NULL.

Parameters:
type  The 16-bit RR code
Returns:
Name of the RR, or NULL if none was found

Variable Documentation

const int n_rr_types
 

number of supported rr types

This is the number of RR types supported by Poslib. Thus, it is also the number of entries in the rr_types array.

See also:
rr_types

Definition at line 111 of file rr.h.

const rr_type rr_types[]
 

array of supported rr types

This array contains information for all RR types supported by Poslib. For information about the meaning of the fields, see the rr_type documentation. This array contains exactly n_rr_types elements.

See also:
n_rr_types

rr_type

Definition at line 122 of file rr.h.


Generated on Fri Dec 24 19:55:15 2004 for Poslib by doxygen 1.3.7