QMdnsEngine  0.1.0
Multicast DNS library for Qt applications
Public Member Functions | List of all members
QMdnsEngine::Message Class Reference

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.
 
Messageoperator= (const Message &other)
 Assignment operator.
 
quint16 port () const
 Retrieve the port for the message. More...
 
QList< Queryqueries () const
 Retrieve a list of queries in the message.
 
QList< Recordrecords () 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...
 

Detailed Description

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:

connect(&server, &QMdnsEngine::Server::messageReceived, [](const QMdnsEngine::Message &message) {
reply.reply(message);
server.sendMessage(reply);
});

Member Function Documentation

◆ address()

QHostAddress QMdnsEngine::Message::address ( ) const

When receiving messages, this is the address that the message was received from.

◆ port()

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.

◆ reply()

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.

◆ setAddress()

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.

◆ setPort()

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.

◆ setTransactionId()

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.

◆ transactionId()

quint16 QMdnsEngine::Message::transactionId ( ) const

This is always set to 1 for mDNS messages. Traditional DNS queries may set this to an arbitrary integer.


The documentation for this class was generated from the following file: