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

Classes

class  PTruncatedException

Macros

#define COMPARE(expr)   { int tmp; if ((tmp = (expr)) != 0) return tmp; }
#define INTCMP(x, y)   ( (x)<(y)?-1: ((x)==(y)?0:-1) )
#define SPECIFIC(x, y, expr)

Functions

_answer_type check_answer_type (DnsMessage *msg, domainname &qname, unsigned short qtype)
 Returns the answer type of an answer message for a given query.
DnsMessagecreate_query (domainname qname, unsigned short qtype, bool rd, unsigned short qclass)
 create a query message
a_record get_a_record (DnsMessage *a)
 Gets the first address in the answer to an address query.
std::list< a_recordget_a_records (DnsMessage *a, bool fail_if_none)
 Gets a list of addresses in the answer to an address query.
aaaa_record get_aaaa_record (DnsMessage *a)
 Gets the first IPv6 address in the answer to an IPv6 address query.
std::list< aaaa_recordget_aaaa_records (DnsMessage *a, bool fail_if_none)
 Gets a list of addresses in the answer to an IPv6 address query.
mx_record get_mx_record (DnsMessage *a)
 Gets the first MX record in te answer to a MX query.
std::list< mx_recordget_mx_records (DnsMessage *a, bool fail_if_none)
 Gets a list of MX records in te answer to a MX query.
domainname get_ns_record (DnsMessage *a)
 Gets the first NS record in te answer to a NS query.
std::list< domainnameget_ns_records (DnsMessage *a, bool fail_if_none)
 Gets the list of NS records in te answer to a NS query.
domainname get_ptr_record (DnsMessage *a)
 Gets the first PTR record in te answer to a PTR query.
std::list< domainnameget_ptr_records (DnsMessage *a, bool fail_if_none)
 Gets the list of PTR records in te answer to a PTR query.
std::list< rrdatget_records (DnsMessage *a, bool fail_if_none, bool follow_cname, std::list< domainname > *fcn)
bool has_parental_rrset (std::list< DnsRR > &section, domainname &qname, unsigned short type)
bool has_rrset (std::list< DnsRR > &rrlist, domainname &name, unsigned short type)
 Returns true if the given RRset is present in the DNS message section.
std::list< rrdati_get_records (DnsMessage *a, bool fail_if_none, bool follow_cname, int reclevel, domainname &dname, unsigned short qtype, std::list< domainname > *fcn)
unsigned char * uint16_buff (unsigned short val)
u_int16 uint16_value (const unsigned char *buff)
unsigned char * uint32_buff (unsigned int val)
u_int32 uint32_value (const unsigned char *buff)
unsigned char * uint48_buff (u_int48 val)
u_int48 uint48_value (const unsigned char *buff)

Variables

unsigned char _tmp [6]

Macro Definition Documentation

#define COMPARE (   expr)    { int tmp; if ((tmp = (expr)) != 0) return tmp; }
#define INTCMP (   x,
 
)    ( (x)<(y)?-1: ((x)==(y)?0:-1) )
#define SPECIFIC (   x,
  y,
  expr 
)
Value:
if ( (x)==(expr) && (y)!=(expr) ) return -1; \
else if ( (y)==(expr) && (x)!=(expr) ) return 1

Function Documentation

_answer_type check_answer_type ( DnsMessage msg,
domainname qname,
unsigned short  qtype 
)

Returns the answer type of an answer message for a given query.

Parameters
msg
qname
qtype
Returns
answer type

< No error

< Domain name doesn't exist

< Canonical Name RR type

< Canonical Name RR type

< Domain name doesn't exist

< Nameserver RR type

< Start of Authority RR type

DnsMessage* create_query ( domainname  qname,
unsigned short  qtype = 1,
bool  rd = true,
unsigned short  qclass = 1 
)

create a query message

Creates a Dns question message which can be used to query a DNS server. This message is dynamically allocated, so you'll have to delete it yourself.

Parameters
qnameDomain name to query. See DnsQuestion::QNAME.
qtypeType of RR to query. See DnsQuestion::QTYPE for more information. Defaults to DNS_TYPE_A .
rdwhether we want the server to do recursion. See DnsMessage::RD. Defaults to true .
qclassThe class to query in. See DnsQuestion::QCLASS. Defaults to CLASS_IN .
Returns
DNS message containing the query.
Parameters
qtypeIPv4 address RR type
qclassInternet class
a_record get_a_record ( DnsMessage a)

Gets the first address in the answer to an address query.

std::list< a_record > get_a_records ( DnsMessage a,
bool  fail_if_none 
)

Gets a list of addresses in the answer to an address query.

aaaa_record get_aaaa_record ( DnsMessage a)

Gets the first IPv6 address in the answer to an IPv6 address query.

std::list< aaaa_record > get_aaaa_records ( DnsMessage a,
bool  fail_if_none 
)

Gets a list of addresses in the answer to an IPv6 address query.

< IPv6 address RR type

mx_record get_mx_record ( DnsMessage a)

Gets the first MX record in te answer to a MX query.

std::list< mx_record > get_mx_records ( DnsMessage a,
bool  fail_if_none 
)

Gets a list of MX records in te answer to a MX query.

< Mail eXchanger RR type

< Mail eXchanger RR type

domainname get_ns_record ( DnsMessage a)

Gets the first NS record in te answer to a NS query.

std::list< domainname > get_ns_records ( DnsMessage a,
bool  fail_if_none 
)

Gets the list of NS records in te answer to a NS query.

< Nameserver RR type

domainname get_ptr_record ( DnsMessage a)

Gets the first PTR record in te answer to a PTR query.

std::list< domainname > get_ptr_records ( DnsMessage a,
bool  fail_if_none 
)

Gets the list of PTR records in te answer to a PTR query.

< Pointer RR type

std::list< rrdat > get_records ( DnsMessage a,
bool  fail_if_none = false,
bool  follow_cname = true,
std::list< domainname > *  followed_cnames = NULL 
)

Gets a list of all RRs in the answer section answering the DNS query. May follow CNAMEs.

Parameters
a
fail_if_none
follow_cname
followed_cnames
Returns

< No error

bool has_parental_rrset ( std::list< DnsRR > &  section,
domainname qname,
unsigned short  type 
)
bool has_rrset ( std::list< DnsRR > &  rrlist,
domainname name,
unsigned short  type = 255 
)

Returns true if the given RRset is present in the DNS message section.

Parameters
rrlista list of Resource Records
namethe name that is looked for
typetype of query
Returns
true, if requested domainname exists, false otherwise
Parameters
typeAll RR types QTYPE
std::list< rrdat > i_get_records ( DnsMessage a,
bool  fail_if_none,
bool  follow_cname,
int  reclevel,
domainname dname,
unsigned short  qtype,
std::list< domainname > *  fcn 
)

< Canonical Name RR type

< Canonical Name RR type

< All RR types QTYPE

unsigned char* uint16_buff ( unsigned short  val)
u_int16 uint16_value ( const unsigned char *  buff)
unsigned char* uint32_buff ( unsigned int  val)
u_int32 uint32_value ( const unsigned char *  buff)
unsigned char* uint48_buff ( u_int48  val)
u_int48 uint48_value ( const unsigned char *  buff)

Variable Documentation

unsigned char _tmp[6]