QMdnsEngine
0.1.0
Multicast DNS library for Qt applications
|
DNS message. More...
#include <qmdnsengine/message.h>
Public Member Functions | |
Message () | |
Create an empty message. | |
Message (const Message &other) | |
Create a copy of an existing message. | |
virtual | ~Message () |
Destroy the message. | |
void | addQuery (const Query &query) |
Add a query to the message. | |
void | addRecord (const Record &record) |
Add a record to the message. | |
QHostAddress | address () const |
Retrieve the address for the message. More... | |
bool | isResponse () const |
Determine if the message is a response. | |
Message & | operator= (const Message &other) |
Assignment operator. | |
quint16 | port () const |
Retrieve the port for the message. More... | |
QList< Query > | queries () const |
Retrieve a list of queries in the message. | |
QList< Record > | records () const |
Retrieve a list of records in the message. | |
void | reply (const Message &other) |
Reply to another message. More... | |
void | setAddress (const QHostAddress &address) |
Set the address for the message. More... | |
void | setPort (quint16 port) |
Set the port for the message. More... | |
void | setResponse (bool isResponse) |
Set whether the message is a response. | |
void | setTransactionId (quint16 transactionId) |
Set the transaction ID for the message. More... | |
quint16 | transactionId () const |
Retrieve the transaction ID for the message. More... | |
A DNS message consists of a header and zero or more queries and records. Instances of this class are created and initialized by AbstractServer when messages are received from the network.
If a message is being constructed in reply to one received from the network, the reply() method can be used to simplify initialization:
QHostAddress QMdnsEngine::Message::address | ( | ) | const |
When receiving messages, this is the address that the message was received from.
quint16 QMdnsEngine::Message::port | ( | ) | const |
When receiving messages, this is the port that the message was received from. For traditional queries, this will be an ephemeral port. For mDNS queries, this will always equal QMdnsEngine::MdnsPort.
void QMdnsEngine::Message::reply | ( | const Message & | other | ) |
The message will be correctly initialized to respond to the other message. This includes setting the target address, port, and transaction ID.
void QMdnsEngine::Message::setAddress | ( | const QHostAddress & | address | ) |
When sending messages, this is the address that the message will be sent to. QMdnsEngine::MdnsIpv4Address and QMdnsEngine::MdnsIpv6Address can be used for mDNS messages.
void QMdnsEngine::Message::setPort | ( | quint16 | port | ) |
When sending messages, this is the port that the message will be sent to. This should be set to QMdnsEngine::MdnsPort unless the message is a reply to a traditional DNS query.
void QMdnsEngine::Message::setTransactionId | ( | quint16 | transactionId | ) |
The default transaction ID is 0. This value should not be changed unless responding to a traditional DNS query.
quint16 QMdnsEngine::Message::transactionId | ( | ) | const |
This is always set to 1 for mDNS messages. Traditional DNS queries may set this to an arbitrary integer.