XMPP::NameRecord Class Reference

Provides a DNS record. More...

#include <netnames.h>

List of all members.

Public Types

enum  Type {
  A, Aaaa, Mx, Srv,
  Cname, Ptr, Txt, Hinfo,
  Ns, Null, Any
}

Public Member Functions

 NameRecord ()
 NameRecord (const QByteArray &owner, int ttl)
 NameRecord (const NameRecord &from)
 ~NameRecord ()
NameRecordoperator= (const NameRecord &from)
bool isNull () const
QByteArray owner () const
int ttl () const
Type type () const
QHostAddress address () const
QByteArray name () const
int priority () const
int weight () const
int port () const
QList< QByteArray > texts () const
QByteArray cpu () const
QByteArray os () const
QByteArray rawData () const
void setOwner (const QByteArray &name)
void setTTL (int seconds)
void setAddress (const QHostAddress &a)
void setMx (const QByteArray &name, int priority)
void setSrv (const QByteArray &name, int port, int priority, int weight)
void setCname (const QByteArray &name)
void setPtr (const QByteArray &name)
void setTxt (const QList< QByteArray > &texts)
void setHinfo (const QByteArray &cpu, const QByteArray &os)
void setNs (const QByteArray &name)
void setNull (const QByteArray &rawData)


Detailed Description

Provides a DNS record.

NameRecord provides a DNS (Domain Name System) record, which is information assicated with a domain name. For most purposes, the information is an IP address. However, DNS records are capable of holding a variety of data types, such as named pointers to other domain names and even arbitrary text strings. The results of a NameResolver operation are a list of NameRecords.

The most common type is the address record, "A", which contains an IPv4 address. Here is an example of how to get the IP address out of an address record:

NameRecord record = ... // obtain a record from somewhere
if(record.type() == NameRecord::A)
{
        QHostAddress ip = record.address(); // get the IP
        ...
}

Getting the data out of a NameRecord involves calling the right retrieval functions, depending on the type. Many types share retrieval functions. For example, the "AAAA" type holds an IPv6 address, which is accessed the same way as the "A" type, by calling address(). See the NameRecord::Type enum for further information about which retrieval functions should be called for each type.

To create a NameRecord, use setOwner() and setTTL() as necessary, and then call one of the setX functions (where X is the desired type). For example, to set an A or AAAA record, use setAddress() like this:

// make example.com the owner, with 1 hour TTL
NameRecord record("example.com", 3600);
record.setAddress(QHostAddress("1.2.3.4"));

Note that in the case of setAddress(), the record type need not be specified. NameRecord will determine the type to use based on the given QHostAddress.

See also:
NameResolver


Member Enumeration Documentation

enum XMPP::NameRecord::Type
 

The type of DNS record.

The retrieval functions are shown for each type.

Enumerator:
A  IPv4 address. Use address().
Aaaa  IPv6 address. Use address().
Mx  Mail server. Use name() and priority().
Srv  Generic server. Use name(), port(), priority(), and weight().
Cname  Canonical name. Use name().
Ptr  Pointer. Use name().
Txt  List of text strings. Use texts().
Hinfo  Host information. Use cpu() and os().
Ns  Name server. Use name().
Null  Null type. Use rawData().
Any  "Any record", for use with NameResolver::start() only. A NameRecord object will never be of this type.


Constructor & Destructor Documentation

XMPP::NameRecord::NameRecord  ) 
 

Constructs a null record object.

See also:
isNull

XMPP::NameRecord::NameRecord const QByteArray &  owner,
int  ttl
 

Constructs a partially initialized record object, with the given owner and ttl.

For the record to be usable, call an appropriate setX function (where X is the desired type) afterwards.

XMPP::NameRecord::NameRecord const NameRecord from  ) 
 

Constructs a copy of from.

XMPP::NameRecord::~NameRecord  ) 
 

Destroys the record object.


Member Function Documentation

QHostAddress XMPP::NameRecord::address  )  const
 

Returns the IP address.

For NameRecord::A and NameRecord::Aaaa types.

QByteArray XMPP::NameRecord::cpu  )  const
 

Returns the architecture identifier string.

For the NameRecord::Hinfo type.

bool XMPP::NameRecord::isNull  )  const
 

Returns true if this record object is null, otherwise returns false.

Be sure not to confuse a null object with the NULL type (NameRecord::Null). Don't ask why DNS has a type called NULL that contains valid data.

QByteArray XMPP::NameRecord::name  )  const
 

Returns the domain name.

For NameRecord::Mx, NameRecord::Srv, NameRecord::Cname, NameRecord::Ptr, and NameRecord::Ns types.

NameRecord& XMPP::NameRecord::operator= const NameRecord from  ) 
 

Assigns from to this object and returns a reference to this object.

QByteArray XMPP::NameRecord::os  )  const
 

Returns the operating system identifier string.

For the NameRecord::Hinfo type.

QByteArray XMPP::NameRecord::owner  )  const
 

Returns the owner of this record.

The owner is usually not a useful attribute, since it will be the same as the name searched for with NameResolver. For example, if the A record of "example.com" is looked up, then the resulting records will all have "example.com" as the owner.

See also:
setOwner

int XMPP::NameRecord::port  )  const
 

Returns the port.

For the NameRecord::Srv type.

int XMPP::NameRecord::priority  )  const
 

Returns the priority.

For NameRecord::Mx and NameRecord::Srv types.

QByteArray XMPP::NameRecord::rawData  )  const
 

Returns the raw data.

For the NameRecord::Null type.

void XMPP::NameRecord::setAddress const QHostAddress &  a  ) 
 

Set as A or AAAA record, with data a.

The protocol of a determines whether the type will be NameRecord::A or NameRecord::Aaaa.

void XMPP::NameRecord::setCname const QByteArray &  name  ) 
 

Set as CNAME record, with data name.

void XMPP::NameRecord::setHinfo const QByteArray &  cpu,
const QByteArray &  os
 

Set as HINFO record, with data cpu and os.

void XMPP::NameRecord::setMx const QByteArray &  name,
int  priority
 

Set as MX record, with data name and priority.

void XMPP::NameRecord::setNs const QByteArray &  name  ) 
 

Set as NS record, with data name.

void XMPP::NameRecord::setNull const QByteArray &  rawData  ) 
 

Set as NULL record, with data rawData.

void XMPP::NameRecord::setOwner const QByteArray &  name  ) 
 

Sets the owner of this record to name.

See also:
owner

void XMPP::NameRecord::setPtr const QByteArray &  name  ) 
 

Set as PTR record, with data name.

void XMPP::NameRecord::setSrv const QByteArray &  name,
int  port,
int  priority,
int  weight
 

Set as SRV record, with data name, port, priority, and weight.

void XMPP::NameRecord::setTTL int  seconds  ) 
 

Sets the TTL (time-to-live) of this record to ttl seconds.

See also:
ttl

void XMPP::NameRecord::setTxt const QList< QByteArray > &  texts  ) 
 

Set as TXT record, with data texts.

QList<QByteArray> XMPP::NameRecord::texts  )  const
 

Returns the list of text strings.

For the NameRecord::Txt type.

int XMPP::NameRecord::ttl  )  const
 

Returns the TTL (time-to-live) of this record.

This is the number of seconds the record should be considered valid, which is useful information when performing caching.

As a special exception, a TTL of 0 when performing a long-lived lookup indicates that a record is no longer available.

See also:
setTTL

Type XMPP::NameRecord::type  )  const
 

Returns the type of this record.

int XMPP::NameRecord::weight  )  const
 

Returns the weight.

For the NameRecord::Srv type.


The documentation for this class was generated from the following file:
Generated on Sun Mar 18 17:58:51 2007 for IrisNet by  doxygen 1.4.6