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

DnsMessage Class Reference

DNS message. More...

List of all members.


Public Member Functions

  DnsMessage ()
  constructor

  ~DnsMessage ()
  destructor

  stl_list (DnsQuestion) questions
  question section

  stl_list (DnsRR) answers
  answer section

  stl_list (DnsRR) authority
  authority section

  stl_list (DnsRR) additional
  additional section

void  read_from_data (char *data, int len)
  read DNS message

message_buff  compile (int maxlen)
  compile DNS message


Public Attributes

u_int16  ID
  message ID

bool  QR
  query bit

u_int4  OPCODE
  operation

bool  AA
  authoritative answer

bool  TC
  truncated

bool  RD
  recursion desired

bool  RA
  recursion available

u_int3  Z
  reserved bits

u_int4  RCODE
  return code


Protected Member Functions

void  write_section (stl_list(DnsRR)§ion, int lenpos, stl_string &message, stl_slist(dom_compr_info)&comprinfo, int maxlen, bool is_additional=false)
void  read_section (stl_list(DnsRR)§ion, int count, message_buff &buff, int &pos)

Detailed Description

DNS message.

This structure holds a DNS message, the message type with which DNS servers talk to each other. It has member functions for reading data from binary DNS messages, and to create a binary DNS message from the structure.

Definition at line 314 of file dnsmessage.h.


Constructor & Destructor Documentation

DnsMessage::DnsMessage  ) 
 

constructor

This constructs an empty DNS message, with all fields set to defaults.

DnsMessage::~DnsMessage  ) 
 

destructor

This destroys the DNS message.


Member Function Documentation

message_buff DnsMessage::compile int  maxlen  ) 
 

compile DNS message

This function will compile the DNS message into the binary format sent over UDP or TCP connections.

Parameters:
maxlen  Maximum length. If the message exceeds this limit, it will be cut off and the TC bit will be set. This should be 65535 for TCP messages and 512 for UDP messages.
Returns:
The compiled DNS message

void DnsMessage::read_from_data char *  data,
int  len
 

read DNS message

This function will read DNS message information from the binary DNS message pointed to by data.

Parameters:
data  Binary DNS message
len  Length of message

DnsMessage::stl_list DnsRR   ) 
 

additional section

This section contains additional information that might be interesting for the client, for example addresses for NS or MX records in the answer or authority sections.

DnsMessage::stl_list DnsRR   ) 
 

authority section

This section contains pointers to authoritative sources for the information. Most nameservers put the nameserver list for the domain names in the section here.

DnsMessage::stl_list DnsRR   ) 
 

answer section

This section, filled by the server, contains the Resource Records that form a direct answer to the query.

DnsMessage::stl_list DnsQuestion   ) 
 

question section

This section should contain exactly one DnsQuestion object for common DNS queries. This query is usually copied into the response by the server.


Member Data Documentation

bool DnsMessage::AA
 

authoritative answer

This is set to true by the server if it was authoritative for the zone the query was in. Note that, if the answer contains CNAMEs, this does not nessecarily mean the server was also authoritative for the domain the CNAME pointed to.

Definition at line 365 of file dnsmessage.h.

u_int16 DnsMessage::ID
 

message ID

This is the message ID field of the DNS message. This number is set by client software, and is copied into the response by the server in order for clients to be able to track queries. Note that the Posadis resolver sets this value for you, so there's no need to do that yourself in client applications.

Definition at line 339 of file dnsmessage.h.

u_int4 DnsMessage::OPCODE
 

operation

This is the type of operation the query is. The most common are OPCODE_QUERY for queries, OPCODE_UPDATE for dynamic updates, and OPCODE_NOTIFY for DNS notifications. Possible values are in dnsdefs.h.

Definition at line 355 of file dnsmessage.h.

bool DnsMessage::QR
 

query bit

This bit is set to false for queries, and true for answers.

Definition at line 346 of file dnsmessage.h.

bool DnsMessage::RA
 

recursion available

Set to the server indicating whether it is willing to provide recursive service. Note that, even if recursion was not desired (see RD), this value might still be set.

Definition at line 392 of file dnsmessage.h.

u_int4 DnsMessage::RCODE
 

return code

Code indicating whether the query was succesful. Some famous RCODEs, which are #defined in dnsdefs.h, are: RCODE_NOERROR to indicate success, RCODE_NXDOMAIN if the domain name queried for didn't exist, or RCODE_SERVFAIL in case of a server failure.

Definition at line 411 of file dnsmessage.h.

bool DnsMessage::RD
 

recursion desired

Set this to true to instruct the server to do recursive operation (e.g. consult other nameservers to find the right answer). Note that servers may refuse to do this, and will set the RA field accordingly.

Definition at line 383 of file dnsmessage.h.

bool DnsMessage::TC
 

truncated

Set to true by the server if the answer was cut off because it didn't fit in a UDP packet. Unless you instruct it not to, the Posadis resolver will automatically retry using TCP to get the complete answer.

Definition at line 374 of file dnsmessage.h.

u_int3 DnsMessage::Z
 

reserved bits

This the value of three currently reserved bits in the DNS message. Though these bits currently have no meaning and servers might require them to be zero, Poslib is able to read and write them.

Definition at line 401 of file dnsmessage.h.


The documentation for this class was generated from the following file:
Generated on Fri Dec 24 19:55:16 2004 for Poslib by doxygen 1.3.7