Fix Line Endings
This commit is contained in:
@@ -1,32 +1,32 @@
|
||||
#include "Dns/MulticastDnsClient.h"
|
||||
#include "MulticastDnsClientImpl.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
MulticastDnsClient::MulticastDnsClient(std::function<void(const std::vector<ResourceRecord>&)> callback) :
|
||||
m_pMulticastDnsClientImpl(new MulticastDnsClientImpl(std::bind(&MulticastDnsClient::Callback, this, std::placeholders::_1))),
|
||||
m_callback(callback)
|
||||
{
|
||||
}
|
||||
|
||||
MulticastDnsClient::~MulticastDnsClient() = default;
|
||||
|
||||
void MulticastDnsClient::Query(const Dns::Query& query)
|
||||
{
|
||||
m_pMulticastDnsClientImpl->Query(*query.PImpl());
|
||||
}
|
||||
|
||||
void MulticastDnsClient::Callback(const std::vector<ResourceRecordImpl>& answers)
|
||||
{
|
||||
std::vector<ResourceRecord> ans;
|
||||
|
||||
for (auto& answer : answers)
|
||||
ans.push_back(ResourceRecord(std::make_shared<ResourceRecordImpl>(answer)));
|
||||
|
||||
m_callback(ans);
|
||||
}
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
#include "Dns/MulticastDnsClient.h"
|
||||
#include "MulticastDnsClientImpl.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
MulticastDnsClient::MulticastDnsClient(std::function<void(const std::vector<ResourceRecord>&)> callback) :
|
||||
m_pMulticastDnsClientImpl(new MulticastDnsClientImpl(std::bind(&MulticastDnsClient::Callback, this, std::placeholders::_1))),
|
||||
m_callback(callback)
|
||||
{
|
||||
}
|
||||
|
||||
MulticastDnsClient::~MulticastDnsClient() = default;
|
||||
|
||||
void MulticastDnsClient::Query(const Dns::Query& query)
|
||||
{
|
||||
m_pMulticastDnsClientImpl->Query(*query.PImpl());
|
||||
}
|
||||
|
||||
void MulticastDnsClient::Callback(const std::vector<ResourceRecordImpl>& answers)
|
||||
{
|
||||
std::vector<ResourceRecord> ans;
|
||||
|
||||
for (auto& answer : answers)
|
||||
ans.push_back(ResourceRecord(std::make_shared<ResourceRecordImpl>(answer)));
|
||||
|
||||
m_callback(ans);
|
||||
}
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
@@ -1,146 +1,146 @@
|
||||
#include "MulticastDnsClientImpl.h"
|
||||
#include "MalformedPacket.h"
|
||||
#include "Packet.h"
|
||||
#include <Logging.h>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
MulticastDnsClientImpl::MulticastDnsClientImpl(std::function<void(const std::vector<ResourceRecordImpl>&)> callback) :
|
||||
m_timer(m_ioService),
|
||||
m_responseBuffer(1024),
|
||||
m_socket(m_ioService, asio::ip::udp::v4()),
|
||||
m_multicastEndpoint(asio::ip::address::from_string("224.0.0.251"), 5353),
|
||||
m_callback(callback)
|
||||
{
|
||||
m_socket.set_option(asio::socket_base::reuse_address(true));
|
||||
m_socket.set_option(asio::ip::multicast::join_group(m_multicastEndpoint.address()));
|
||||
m_socket.set_option(asio::ip::multicast::hops(255));
|
||||
m_socket.bind(asio::ip::udp::endpoint(asio::ip::udp::v4(), 5353));
|
||||
|
||||
m_thread = std::thread([&] { m_ioService.run(); });
|
||||
}
|
||||
|
||||
MulticastDnsClientImpl::~MulticastDnsClientImpl()
|
||||
{
|
||||
m_ioService.stop();
|
||||
m_thread.join();
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::Query(const QueryImpl& query)
|
||||
{
|
||||
m_query = query;
|
||||
m_iterations = 3;
|
||||
SendQuery();
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::SetTimer(int milliseconds)
|
||||
{
|
||||
m_timer.cancel();
|
||||
m_timer.expires_from_now(std::chrono::milliseconds(milliseconds));
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::SendQuery()
|
||||
{
|
||||
if (m_iterations == 0)
|
||||
return;
|
||||
m_iterations--;
|
||||
|
||||
Packet packet;
|
||||
packet.AddQuery(m_query);
|
||||
|
||||
auto data = std::make_shared<Data>(packet.GetData());
|
||||
|
||||
m_socket.async_send_to(
|
||||
asio::buffer(data->GetPtr(), data->GetLength()),
|
||||
m_multicastEndpoint,
|
||||
std::bind(&MulticastDnsClientImpl::HandleQuerySent, this,
|
||||
std::placeholders::_1,
|
||||
data
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQuerySent(const asio::error_code & error, std::shared_ptr<Data> data)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
SendQuery();
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQuerySent: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTimer(1000);
|
||||
m_timer.async_wait(std::bind(
|
||||
&MulticastDnsClientImpl::HandleQueryTimeout, this,
|
||||
std::placeholders::_1
|
||||
));
|
||||
ReceiveQuery();
|
||||
}
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::ReceiveQuery()
|
||||
{
|
||||
m_socket.async_receive_from(
|
||||
asio::buffer(m_responseBuffer),
|
||||
m_receiveEndpoint,
|
||||
std::bind(&MulticastDnsClientImpl::HandleQueryResponse, this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQueryResponse(const asio::error_code & error, std::size_t size)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
SendQuery();
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQueryResponse: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet packet(DataReader(m_responseBuffer.data(), size), 0);
|
||||
if (packet.GetQuery())
|
||||
m_callback(packet.GetAnswers());
|
||||
}
|
||||
catch(MalformedPacket& mp)
|
||||
{
|
||||
}
|
||||
|
||||
ReceiveQuery();
|
||||
}
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQueryTimeout(const asio::error_code & error)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQueryTimeout: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_socket.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
#include "MulticastDnsClientImpl.h"
|
||||
#include "MalformedPacket.h"
|
||||
#include "Packet.h"
|
||||
#include <Logging.h>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
MulticastDnsClientImpl::MulticastDnsClientImpl(std::function<void(const std::vector<ResourceRecordImpl>&)> callback) :
|
||||
m_timer(m_ioService),
|
||||
m_responseBuffer(1024),
|
||||
m_socket(m_ioService, asio::ip::udp::v4()),
|
||||
m_multicastEndpoint(asio::ip::address::from_string("224.0.0.251"), 5353),
|
||||
m_callback(callback)
|
||||
{
|
||||
m_socket.set_option(asio::socket_base::reuse_address(true));
|
||||
m_socket.set_option(asio::ip::multicast::join_group(m_multicastEndpoint.address()));
|
||||
m_socket.set_option(asio::ip::multicast::hops(255));
|
||||
m_socket.bind(asio::ip::udp::endpoint(asio::ip::udp::v4(), 5353));
|
||||
|
||||
m_thread = std::thread([&] { m_ioService.run(); });
|
||||
}
|
||||
|
||||
MulticastDnsClientImpl::~MulticastDnsClientImpl()
|
||||
{
|
||||
m_ioService.stop();
|
||||
m_thread.join();
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::Query(const QueryImpl& query)
|
||||
{
|
||||
m_query = query;
|
||||
m_iterations = 3;
|
||||
SendQuery();
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::SetTimer(int milliseconds)
|
||||
{
|
||||
m_timer.cancel();
|
||||
m_timer.expires_from_now(std::chrono::milliseconds(milliseconds));
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::SendQuery()
|
||||
{
|
||||
if (m_iterations == 0)
|
||||
return;
|
||||
m_iterations--;
|
||||
|
||||
Packet packet;
|
||||
packet.AddQuery(m_query);
|
||||
|
||||
auto data = std::make_shared<Data>(packet.GetData());
|
||||
|
||||
m_socket.async_send_to(
|
||||
asio::buffer(data->GetPtr(), data->GetLength()),
|
||||
m_multicastEndpoint,
|
||||
std::bind(&MulticastDnsClientImpl::HandleQuerySent, this,
|
||||
std::placeholders::_1,
|
||||
data
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQuerySent(const asio::error_code & error, std::shared_ptr<Data> data)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
SendQuery();
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQuerySent: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTimer(1000);
|
||||
m_timer.async_wait(std::bind(
|
||||
&MulticastDnsClientImpl::HandleQueryTimeout, this,
|
||||
std::placeholders::_1
|
||||
));
|
||||
ReceiveQuery();
|
||||
}
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::ReceiveQuery()
|
||||
{
|
||||
m_socket.async_receive_from(
|
||||
asio::buffer(m_responseBuffer),
|
||||
m_receiveEndpoint,
|
||||
std::bind(&MulticastDnsClientImpl::HandleQueryResponse, this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQueryResponse(const asio::error_code & error, std::size_t size)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
SendQuery();
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQueryResponse: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet packet(DataReader(m_responseBuffer.data(), size), 0);
|
||||
if (packet.GetQuery())
|
||||
m_callback(packet.GetAnswers());
|
||||
}
|
||||
catch(MalformedPacket& mp)
|
||||
{
|
||||
}
|
||||
|
||||
ReceiveQuery();
|
||||
}
|
||||
}
|
||||
|
||||
void MulticastDnsClientImpl::HandleQueryTimeout(const asio::error_code & error)
|
||||
{
|
||||
if (error == asio::error::operation_aborted)
|
||||
{
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "MulticastDnsClientImpl::HandleQueryTimeout: " << error.message();
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_socket.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
#ifndef NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
#define NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
|
||||
#include "QueryImpl.h"
|
||||
#include "ResourceRecordImpl.h"
|
||||
#include <asio.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class MulticastDnsClientImpl
|
||||
{
|
||||
public:
|
||||
MulticastDnsClientImpl(std::function<void(const std::vector<ResourceRecordImpl>&)> callback);
|
||||
~MulticastDnsClientImpl();
|
||||
|
||||
public:
|
||||
void Query(const QueryImpl& query);
|
||||
|
||||
private:
|
||||
void SetTimer(int milliseconds);
|
||||
void SendQuery();
|
||||
void HandleQuerySent(const asio::error_code & error, std::shared_ptr<Data> data);
|
||||
void ReceiveQuery();
|
||||
void HandleQueryResponse(const asio::error_code & error, std::size_t size);
|
||||
void HandleQueryTimeout(const asio::error_code & error);
|
||||
|
||||
private:
|
||||
std::thread m_thread;
|
||||
asio::io_service m_ioService;
|
||||
asio::system_timer m_timer;
|
||||
|
||||
std::vector<uint8_t> m_responseBuffer;
|
||||
|
||||
asio::ip::udp::socket m_socket;
|
||||
asio::ip::udp::endpoint m_multicastEndpoint;
|
||||
asio::ip::udp::endpoint m_receiveEndpoint;
|
||||
|
||||
int m_iterations;
|
||||
QueryImpl m_query;
|
||||
std::function<void(const std::vector<ResourceRecordImpl>&)> m_callback;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
#ifndef NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
#define NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
|
||||
#include "QueryImpl.h"
|
||||
#include "ResourceRecordImpl.h"
|
||||
#include <asio.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class MulticastDnsClientImpl
|
||||
{
|
||||
public:
|
||||
MulticastDnsClientImpl(std::function<void(const std::vector<ResourceRecordImpl>&)> callback);
|
||||
~MulticastDnsClientImpl();
|
||||
|
||||
public:
|
||||
void Query(const QueryImpl& query);
|
||||
|
||||
private:
|
||||
void SetTimer(int milliseconds);
|
||||
void SendQuery();
|
||||
void HandleQuerySent(const asio::error_code & error, std::shared_ptr<Data> data);
|
||||
void ReceiveQuery();
|
||||
void HandleQueryResponse(const asio::error_code & error, std::size_t size);
|
||||
void HandleQueryTimeout(const asio::error_code & error);
|
||||
|
||||
private:
|
||||
std::thread m_thread;
|
||||
asio::io_service m_ioService;
|
||||
asio::system_timer m_timer;
|
||||
|
||||
std::vector<uint8_t> m_responseBuffer;
|
||||
|
||||
asio::ip::udp::socket m_socket;
|
||||
asio::ip::udp::endpoint m_multicastEndpoint;
|
||||
asio::ip::udp::endpoint m_receiveEndpoint;
|
||||
|
||||
int m_iterations;
|
||||
QueryImpl m_query;
|
||||
std::function<void(const std::vector<ResourceRecordImpl>&)> m_callback;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_MULTICASTDNSCLIENTIMPL_H
|
||||
|
||||
+52
-52
@@ -1,52 +1,52 @@
|
||||
#ifndef NETWORK_DNS_NAMEIMPL_H
|
||||
#define NETWORK_DNS_NAMEIMPL_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class NameImpl
|
||||
{
|
||||
public:
|
||||
NameImpl();
|
||||
|
||||
template<typename ...Args>
|
||||
NameImpl(const std::string& label, const Args& ...args) : NameImpl(args...)
|
||||
{
|
||||
m_labels.insert(m_labels.begin(), label);
|
||||
}
|
||||
|
||||
NameImpl(const std::vector<std::string>& labels);
|
||||
|
||||
std::string GetFirstLabel() const;
|
||||
std::string GetName() const;
|
||||
bool empty() const;
|
||||
bool endsWith(const NameImpl& suffix) const;
|
||||
Data GetData() const;
|
||||
|
||||
void append(const std::string& label);
|
||||
void prepend(const std::string& label);
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
void swap(NameImpl& x) noexcept;
|
||||
|
||||
bool operator==(const NameImpl& name) const;
|
||||
bool operator!=(const NameImpl& name) const;
|
||||
bool operator<(const NameImpl& name) const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const NameImpl& name);
|
||||
|
||||
private:
|
||||
std::vector<std::string> m_labels;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_NAMEIMPL_H
|
||||
#ifndef NETWORK_DNS_NAMEIMPL_H
|
||||
#define NETWORK_DNS_NAMEIMPL_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class NameImpl
|
||||
{
|
||||
public:
|
||||
NameImpl();
|
||||
|
||||
template<typename ...Args>
|
||||
NameImpl(const std::string& label, const Args& ...args) : NameImpl(args...)
|
||||
{
|
||||
m_labels.insert(m_labels.begin(), label);
|
||||
}
|
||||
|
||||
NameImpl(const std::vector<std::string>& labels);
|
||||
|
||||
std::string GetFirstLabel() const;
|
||||
std::string GetName() const;
|
||||
bool empty() const;
|
||||
bool endsWith(const NameImpl& suffix) const;
|
||||
Data GetData() const;
|
||||
|
||||
void append(const std::string& label);
|
||||
void prepend(const std::string& label);
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
void swap(NameImpl& x) noexcept;
|
||||
|
||||
bool operator==(const NameImpl& name) const;
|
||||
bool operator!=(const NameImpl& name) const;
|
||||
bool operator<(const NameImpl& name) const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const NameImpl& name);
|
||||
|
||||
private:
|
||||
std::vector<std::string> m_labels;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_NAMEIMPL_H
|
||||
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
#ifndef NETWORK_DNS_OPERATIONCODE_H
|
||||
#define NETWORK_DNS_OPERATIONCODE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class OperationCode
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
QUERY = 0,
|
||||
IQUERY = 1,
|
||||
STATUS = 2
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_OPERATIONCODE_H
|
||||
#ifndef NETWORK_DNS_OPERATIONCODE_H
|
||||
#define NETWORK_DNS_OPERATIONCODE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class OperationCode
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
QUERY = 0,
|
||||
IQUERY = 1,
|
||||
STATUS = 2
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_OPERATIONCODE_H
|
||||
|
||||
+79
-79
@@ -1,79 +1,79 @@
|
||||
#ifndef NETWORK_DNS_PACKET_H
|
||||
#define NETWORK_DNS_PACKET_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "OperationCode.h"
|
||||
#include "QueryImpl.h"
|
||||
#include "ResourceRecordImpl.h"
|
||||
#include "ResponseCode.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Packet
|
||||
{
|
||||
public:
|
||||
Packet();
|
||||
Packet(DataReader reader, unsigned pos);
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
uint16_t GetIdentifier() const;
|
||||
bool GetQuery() const;
|
||||
OperationCode::type GetOperationCode() const;
|
||||
bool GetAuthorativeAnswer() const;
|
||||
bool GetTruncation() const;
|
||||
bool GetRecursionDesired() const;
|
||||
bool GetRecursionAvailable() const;
|
||||
uint8_t GetZero() const;
|
||||
ResponseCode::type GetResponseCode() const;
|
||||
|
||||
std::vector<QueryImpl> GetQueries() const;
|
||||
std::vector<ResourceRecordImpl> GetAnswers() const;
|
||||
std::vector<ResourceRecordImpl> GetAuthorities() const;
|
||||
std::vector<ResourceRecordImpl> GetAdditionalRecords() const;
|
||||
|
||||
unsigned GetQueryCount() const;
|
||||
unsigned GetAnswerCount() const;
|
||||
unsigned GetAuthorityCount() const;
|
||||
unsigned GetAdditionalRecordsCount() const;
|
||||
|
||||
void SetIdentifier(uint16_t identifier);
|
||||
void SetQuery(bool query);
|
||||
void SetOperationCode(OperationCode::type oerationCode);
|
||||
void SetAuthorativeAnswer(bool authorativeAnswer);
|
||||
void SetTruncation(bool truncation);
|
||||
void SetRecursionDesired(bool recursionDesired);
|
||||
void SetRecursionAvailable(bool recursionAvailable);
|
||||
void SetZero(uint8_t zero);
|
||||
void SetResponseCode(ResponseCode::type responseCode);
|
||||
|
||||
void AddQuery(const QueryImpl& query);
|
||||
void AddAnswer(const ResourceRecordImpl& record);
|
||||
void AddAuthority(const ResourceRecordImpl& record);
|
||||
void AddAdditionalRecords(const ResourceRecordImpl& record);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const Packet& packet);
|
||||
|
||||
private:
|
||||
unsigned m_identifier : 16;
|
||||
unsigned m_query : 1;
|
||||
unsigned m_authorativeAnswer : 1;
|
||||
unsigned m_truncation : 1;
|
||||
unsigned m_recursionDesired : 1;
|
||||
unsigned m_recursionAvailable : 1;
|
||||
unsigned m_zero : 3;
|
||||
OperationCode::type m_operationCode;
|
||||
ResponseCode::type m_responseCode;
|
||||
std::vector<QueryImpl> m_queries;
|
||||
std::vector<ResourceRecordImpl> m_answers;
|
||||
std::vector<ResourceRecordImpl> m_authorities;
|
||||
std::vector<ResourceRecordImpl> m_additionalRecords;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_PACKET_H
|
||||
#ifndef NETWORK_DNS_PACKET_H
|
||||
#define NETWORK_DNS_PACKET_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "OperationCode.h"
|
||||
#include "QueryImpl.h"
|
||||
#include "ResourceRecordImpl.h"
|
||||
#include "ResponseCode.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Packet
|
||||
{
|
||||
public:
|
||||
Packet();
|
||||
Packet(DataReader reader, unsigned pos);
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
uint16_t GetIdentifier() const;
|
||||
bool GetQuery() const;
|
||||
OperationCode::type GetOperationCode() const;
|
||||
bool GetAuthorativeAnswer() const;
|
||||
bool GetTruncation() const;
|
||||
bool GetRecursionDesired() const;
|
||||
bool GetRecursionAvailable() const;
|
||||
uint8_t GetZero() const;
|
||||
ResponseCode::type GetResponseCode() const;
|
||||
|
||||
std::vector<QueryImpl> GetQueries() const;
|
||||
std::vector<ResourceRecordImpl> GetAnswers() const;
|
||||
std::vector<ResourceRecordImpl> GetAuthorities() const;
|
||||
std::vector<ResourceRecordImpl> GetAdditionalRecords() const;
|
||||
|
||||
unsigned GetQueryCount() const;
|
||||
unsigned GetAnswerCount() const;
|
||||
unsigned GetAuthorityCount() const;
|
||||
unsigned GetAdditionalRecordsCount() const;
|
||||
|
||||
void SetIdentifier(uint16_t identifier);
|
||||
void SetQuery(bool query);
|
||||
void SetOperationCode(OperationCode::type oerationCode);
|
||||
void SetAuthorativeAnswer(bool authorativeAnswer);
|
||||
void SetTruncation(bool truncation);
|
||||
void SetRecursionDesired(bool recursionDesired);
|
||||
void SetRecursionAvailable(bool recursionAvailable);
|
||||
void SetZero(uint8_t zero);
|
||||
void SetResponseCode(ResponseCode::type responseCode);
|
||||
|
||||
void AddQuery(const QueryImpl& query);
|
||||
void AddAnswer(const ResourceRecordImpl& record);
|
||||
void AddAuthority(const ResourceRecordImpl& record);
|
||||
void AddAdditionalRecords(const ResourceRecordImpl& record);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const Packet& packet);
|
||||
|
||||
private:
|
||||
unsigned m_identifier : 16;
|
||||
unsigned m_query : 1;
|
||||
unsigned m_authorativeAnswer : 1;
|
||||
unsigned m_truncation : 1;
|
||||
unsigned m_recursionDesired : 1;
|
||||
unsigned m_recursionAvailable : 1;
|
||||
unsigned m_zero : 3;
|
||||
OperationCode::type m_operationCode;
|
||||
ResponseCode::type m_responseCode;
|
||||
std::vector<QueryImpl> m_queries;
|
||||
std::vector<ResourceRecordImpl> m_answers;
|
||||
std::vector<ResourceRecordImpl> m_authorities;
|
||||
std::vector<ResourceRecordImpl> m_additionalRecords;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_PACKET_H
|
||||
|
||||
+45
-45
@@ -1,45 +1,45 @@
|
||||
#ifndef NETWORK_DNS_QUERYIMPL_H
|
||||
#define NETWORK_DNS_QUERYIMPL_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "NameImpl.h"
|
||||
#include "Dns/QueryClass.h"
|
||||
#include "Dns/QueryType.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryImpl
|
||||
{
|
||||
public:
|
||||
QueryImpl();
|
||||
|
||||
bool GetUnicast() const;
|
||||
QueryType::type GetType() const;
|
||||
QueryClass::type GetClass() const;
|
||||
NameImpl GetName() const;
|
||||
|
||||
void SetUnicast(bool unicast);
|
||||
void SetType(QueryType::type type);
|
||||
void SetClass(QueryClass::type class_);
|
||||
void SetName(const NameImpl& name);
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream & stream, const QueryImpl& query);
|
||||
|
||||
private:
|
||||
bool m_unicast;
|
||||
NameImpl m_name;
|
||||
QueryType::type m_type;
|
||||
QueryClass::type m_class;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_QUERYIMPL_H
|
||||
#ifndef NETWORK_DNS_QUERYIMPL_H
|
||||
#define NETWORK_DNS_QUERYIMPL_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "NameImpl.h"
|
||||
#include "Dns/QueryClass.h"
|
||||
#include "Dns/QueryType.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryImpl
|
||||
{
|
||||
public:
|
||||
QueryImpl();
|
||||
|
||||
bool GetUnicast() const;
|
||||
QueryType::type GetType() const;
|
||||
QueryClass::type GetClass() const;
|
||||
NameImpl GetName() const;
|
||||
|
||||
void SetUnicast(bool unicast);
|
||||
void SetType(QueryType::type type);
|
||||
void SetClass(QueryClass::type class_);
|
||||
void SetName(const NameImpl& name);
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream & stream, const QueryImpl& query);
|
||||
|
||||
private:
|
||||
bool m_unicast;
|
||||
NameImpl m_name;
|
||||
QueryType::type m_type;
|
||||
QueryClass::type m_class;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_QUERYIMPL_H
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
#ifndef NETWORK_DNS_RESOURCERECORD_H
|
||||
#define NETWORK_DNS_RESOURCERECORD_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "NameImpl.h"
|
||||
#include "Dns/Class.h"
|
||||
#include "Dns/Type.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResourceRecordImpl
|
||||
{
|
||||
public:
|
||||
NameImpl GetName() const;
|
||||
Type::type GetType() const;
|
||||
Class::type GetClass() const;
|
||||
uint32_t GetTTL() const;
|
||||
Data GetResourceData() const;
|
||||
NameImpl GetResourceDataName() const;
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
void SetName(const NameImpl& name);
|
||||
void SetType(Type::type type);
|
||||
void SetClass(Class::type dnsClass);
|
||||
void SetTTL(uint32_t ttl);
|
||||
void SetData(const Data& resourceData);
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const ResourceRecordImpl& record);
|
||||
|
||||
private:
|
||||
NameImpl m_name;
|
||||
Type::type m_type;
|
||||
Class::type m_class;
|
||||
uint32_t m_ttl;
|
||||
Data m_resourceData;
|
||||
NameImpl m_resourceDataName;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_RESOURCERECORD_H
|
||||
#ifndef NETWORK_DNS_RESOURCERECORD_H
|
||||
#define NETWORK_DNS_RESOURCERECORD_H
|
||||
|
||||
#include "Data.h"
|
||||
#include "DataReader.h"
|
||||
#include "NameImpl.h"
|
||||
#include "Dns/Class.h"
|
||||
#include "Dns/Type.h"
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResourceRecordImpl
|
||||
{
|
||||
public:
|
||||
NameImpl GetName() const;
|
||||
Type::type GetType() const;
|
||||
Class::type GetClass() const;
|
||||
uint32_t GetTTL() const;
|
||||
Data GetResourceData() const;
|
||||
NameImpl GetResourceDataName() const;
|
||||
|
||||
Data GetData() const;
|
||||
|
||||
void SetName(const NameImpl& name);
|
||||
void SetType(Type::type type);
|
||||
void SetClass(Class::type dnsClass);
|
||||
void SetTTL(uint32_t ttl);
|
||||
void SetData(const Data& resourceData);
|
||||
|
||||
unsigned ReadFromData(DataReader reader, unsigned pos);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const ResourceRecordImpl& record);
|
||||
|
||||
private:
|
||||
NameImpl m_name;
|
||||
Type::type m_type;
|
||||
Class::type m_class;
|
||||
uint32_t m_ttl;
|
||||
Data m_resourceData;
|
||||
NameImpl m_resourceDataName;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_RESOURCERECORD_H
|
||||
|
||||
+25
-25
@@ -1,25 +1,25 @@
|
||||
#ifndef NETWORK_DNS_RESPONSECODE_H
|
||||
#define NETWORK_DNS_RESPONSECODE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResponseCode
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NO_ERROR = 0,
|
||||
FORMAT_ERROR = 1,
|
||||
SERVER_FAILURE = 2,
|
||||
NAME_ERROR = 3,
|
||||
NOT_IMPLEMENTED = 4,
|
||||
REFUSED = 5
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_RESPONSECODE_H
|
||||
#ifndef NETWORK_DNS_RESPONSECODE_H
|
||||
#define NETWORK_DNS_RESPONSECODE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResponseCode
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NO_ERROR = 0,
|
||||
FORMAT_ERROR = 1,
|
||||
SERVER_FAILURE = 2,
|
||||
NAME_ERROR = 3,
|
||||
NOT_IMPLEMENTED = 4,
|
||||
REFUSED = 5
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NETWORK_DNS_RESPONSECODE_H
|
||||
|
||||
+24
-24
@@ -1,24 +1,24 @@
|
||||
#ifndef CLASS_H
|
||||
#define CLASS_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Class
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
IN = 1,
|
||||
CS = 2,
|
||||
CH = 3,
|
||||
HS = 4
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // CLASS_H
|
||||
#ifndef CLASS_H
|
||||
#define CLASS_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Class
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
IN = 1,
|
||||
CS = 2,
|
||||
CH = 3,
|
||||
HS = 4
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // CLASS_H
|
||||
|
||||
+73
-73
@@ -1,73 +1,73 @@
|
||||
#ifndef NAME_H
|
||||
#define NAME_H
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class NameImpl;
|
||||
|
||||
class Name
|
||||
{
|
||||
public:
|
||||
Name();
|
||||
|
||||
template<typename ...Args>
|
||||
Name(const Args& ...args) :
|
||||
Name(toStringVector(args...))
|
||||
{
|
||||
}
|
||||
|
||||
Name(const std::vector<std::string>& labels);
|
||||
|
||||
std::string GetFirstLabel() const;
|
||||
std::string GetName() const;
|
||||
bool empty() const;
|
||||
bool endsWith(const Name& suffix) const;
|
||||
|
||||
void append(const std::string& label);
|
||||
void prepend(const std::string& label);
|
||||
|
||||
void swap(Name& x) noexcept;
|
||||
|
||||
bool operator==(const Name& name) const;
|
||||
bool operator!=(const Name& name) const;
|
||||
bool operator<(const Name& name) const;
|
||||
|
||||
private:
|
||||
Name(std::shared_ptr<NameImpl> pNameImpl);
|
||||
NameImpl* PImpl() const;
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
std::string toString(T&& t)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << std::forward<T>(t);
|
||||
return s.str();
|
||||
}
|
||||
|
||||
template <class... T>
|
||||
std::vector<std::string> toStringVector(T&&... args)
|
||||
{
|
||||
std::vector<std::string> res { toString(std::forward<T>(args))... };
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Query;
|
||||
friend class ResourceRecord;
|
||||
|
||||
private:
|
||||
std::shared_ptr<NameImpl> m_pNameImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NAME_H
|
||||
#ifndef NAME_H
|
||||
#define NAME_H
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class NameImpl;
|
||||
|
||||
class Name
|
||||
{
|
||||
public:
|
||||
Name();
|
||||
|
||||
template<typename ...Args>
|
||||
Name(const Args& ...args) :
|
||||
Name(toStringVector(args...))
|
||||
{
|
||||
}
|
||||
|
||||
Name(const std::vector<std::string>& labels);
|
||||
|
||||
std::string GetFirstLabel() const;
|
||||
std::string GetName() const;
|
||||
bool empty() const;
|
||||
bool endsWith(const Name& suffix) const;
|
||||
|
||||
void append(const std::string& label);
|
||||
void prepend(const std::string& label);
|
||||
|
||||
void swap(Name& x) noexcept;
|
||||
|
||||
bool operator==(const Name& name) const;
|
||||
bool operator!=(const Name& name) const;
|
||||
bool operator<(const Name& name) const;
|
||||
|
||||
private:
|
||||
Name(std::shared_ptr<NameImpl> pNameImpl);
|
||||
NameImpl* PImpl() const;
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
std::string toString(T&& t)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << std::forward<T>(t);
|
||||
return s.str();
|
||||
}
|
||||
|
||||
template <class... T>
|
||||
std::vector<std::string> toStringVector(T&&... args)
|
||||
{
|
||||
std::vector<std::string> res { toString(std::forward<T>(args))... };
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Query;
|
||||
friend class ResourceRecord;
|
||||
|
||||
private:
|
||||
std::shared_ptr<NameImpl> m_pNameImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // NAME_H
|
||||
|
||||
+43
-43
@@ -1,43 +1,43 @@
|
||||
#ifndef QUERY_H
|
||||
#define QUERY_H
|
||||
|
||||
#include "Name.h"
|
||||
#include "QueryClass.h"
|
||||
#include "QueryType.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryImpl;
|
||||
|
||||
class Query
|
||||
{
|
||||
public:
|
||||
Query();
|
||||
|
||||
bool GetUnicast() const;
|
||||
QueryType::type GetType() const;
|
||||
QueryClass::type GetClass() const;
|
||||
Name GetName() const;
|
||||
|
||||
void SetUnicast(bool unicast);
|
||||
void SetType(QueryType::type type);
|
||||
void SetClass(QueryClass::type class_);
|
||||
void SetName(const Name& name);
|
||||
|
||||
private:
|
||||
QueryImpl* PImpl() const;
|
||||
|
||||
private:
|
||||
friend class MulticastDnsClient;
|
||||
|
||||
private:
|
||||
std::shared_ptr<QueryImpl> m_pQueryImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERY_H
|
||||
#ifndef QUERY_H
|
||||
#define QUERY_H
|
||||
|
||||
#include "Name.h"
|
||||
#include "QueryClass.h"
|
||||
#include "QueryType.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryImpl;
|
||||
|
||||
class Query
|
||||
{
|
||||
public:
|
||||
Query();
|
||||
|
||||
bool GetUnicast() const;
|
||||
QueryType::type GetType() const;
|
||||
QueryClass::type GetClass() const;
|
||||
Name GetName() const;
|
||||
|
||||
void SetUnicast(bool unicast);
|
||||
void SetType(QueryType::type type);
|
||||
void SetClass(QueryClass::type class_);
|
||||
void SetName(const Name& name);
|
||||
|
||||
private:
|
||||
QueryImpl* PImpl() const;
|
||||
|
||||
private:
|
||||
friend class MulticastDnsClient;
|
||||
|
||||
private:
|
||||
std::shared_ptr<QueryImpl> m_pQueryImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERY_H
|
||||
|
||||
+25
-25
@@ -1,25 +1,25 @@
|
||||
#ifndef QUERYCLASS_H
|
||||
#define QUERYCLASS_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryClass
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
IN = 1,
|
||||
CS = 2,
|
||||
CH = 3,
|
||||
HS = 4,
|
||||
ANY = 255
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERYCLASS_H
|
||||
#ifndef QUERYCLASS_H
|
||||
#define QUERYCLASS_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryClass
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
IN = 1,
|
||||
CS = 2,
|
||||
CH = 3,
|
||||
HS = 4,
|
||||
ANY = 255
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERYCLASS_H
|
||||
|
||||
+40
-40
@@ -1,40 +1,40 @@
|
||||
#ifndef QUERYTYPE_H
|
||||
#define QUERYTYPE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryType
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
A = 1,
|
||||
NC = 2,
|
||||
MD = 3,
|
||||
MF = 4,
|
||||
CNAME = 5,
|
||||
SOA = 6,
|
||||
MB = 7,
|
||||
MG = 8,
|
||||
MR = 9,
|
||||
NULL_ = 10,
|
||||
WKS = 11,
|
||||
PTR = 12,
|
||||
HINFO = 13,
|
||||
MINFO = 14,
|
||||
MX = 15,
|
||||
TXT = 16,
|
||||
AXFR = 252,
|
||||
MAILB = 253,
|
||||
MAILA = 254,
|
||||
ANY = 255
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERYTYPE_H
|
||||
#ifndef QUERYTYPE_H
|
||||
#define QUERYTYPE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class QueryType
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
A = 1,
|
||||
NC = 2,
|
||||
MD = 3,
|
||||
MF = 4,
|
||||
CNAME = 5,
|
||||
SOA = 6,
|
||||
MB = 7,
|
||||
MG = 8,
|
||||
MR = 9,
|
||||
NULL_ = 10,
|
||||
WKS = 11,
|
||||
PTR = 12,
|
||||
HINFO = 13,
|
||||
MINFO = 14,
|
||||
MX = 15,
|
||||
TXT = 16,
|
||||
AXFR = 252,
|
||||
MAILB = 253,
|
||||
MAILA = 254,
|
||||
ANY = 255
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // QUERYTYPE_H
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
#ifndef RESOURCERECORD_H
|
||||
#define RESOURCERECORD_H
|
||||
|
||||
#include "Class.h"
|
||||
#include "Name.h"
|
||||
#include "Type.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResourceRecordImpl;
|
||||
|
||||
class ResourceRecord
|
||||
{
|
||||
public:
|
||||
Name GetName() const;
|
||||
Type::type GetType() const;
|
||||
Class::type GetClass() const;
|
||||
uint32_t GetTTL() const;
|
||||
|
||||
std::vector<uint8_t> GetResourceData() const;
|
||||
std::vector<uint8_t> GetData() const;
|
||||
|
||||
void SetName(const Name& name);
|
||||
void SetType(Type::type type);
|
||||
void SetClass(Class::type class_);
|
||||
void SetTTL(uint32_t ttl);
|
||||
|
||||
private:
|
||||
ResourceRecord(std::shared_ptr<ResourceRecordImpl> pResourceRecordImpl);
|
||||
|
||||
private:
|
||||
friend class MulticastDnsClient;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ResourceRecordImpl> m_pResourceRecordImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // RESOURCERECORD_H
|
||||
#ifndef RESOURCERECORD_H
|
||||
#define RESOURCERECORD_H
|
||||
|
||||
#include "Class.h"
|
||||
#include "Name.h"
|
||||
#include "Type.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class ResourceRecordImpl;
|
||||
|
||||
class ResourceRecord
|
||||
{
|
||||
public:
|
||||
Name GetName() const;
|
||||
Type::type GetType() const;
|
||||
Class::type GetClass() const;
|
||||
uint32_t GetTTL() const;
|
||||
|
||||
std::vector<uint8_t> GetResourceData() const;
|
||||
std::vector<uint8_t> GetData() const;
|
||||
|
||||
void SetName(const Name& name);
|
||||
void SetType(Type::type type);
|
||||
void SetClass(Class::type class_);
|
||||
void SetTTL(uint32_t ttl);
|
||||
|
||||
private:
|
||||
ResourceRecord(std::shared_ptr<ResourceRecordImpl> pResourceRecordImpl);
|
||||
|
||||
private:
|
||||
friend class MulticastDnsClient;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ResourceRecordImpl> m_pResourceRecordImpl;
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // RESOURCERECORD_H
|
||||
|
||||
+36
-36
@@ -1,36 +1,36 @@
|
||||
#ifndef TYPE_H
|
||||
#define TYPE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Type
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
A = 1,
|
||||
NC = 2,
|
||||
MD = 3,
|
||||
MF = 4,
|
||||
CNAME = 5,
|
||||
SOA = 6,
|
||||
MB = 7,
|
||||
MG = 8,
|
||||
MR = 9,
|
||||
NULL_ = 10,
|
||||
WKS = 11,
|
||||
PTR = 12,
|
||||
HINFO = 13,
|
||||
MINFO = 14,
|
||||
MX = 15,
|
||||
TXT = 16
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // TYPE_H
|
||||
#ifndef TYPE_H
|
||||
#define TYPE_H
|
||||
|
||||
|
||||
namespace Network {
|
||||
namespace Dns {
|
||||
|
||||
class Type
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
NONE = 0,
|
||||
A = 1,
|
||||
NC = 2,
|
||||
MD = 3,
|
||||
MF = 4,
|
||||
CNAME = 5,
|
||||
SOA = 6,
|
||||
MB = 7,
|
||||
MG = 8,
|
||||
MR = 9,
|
||||
NULL_ = 10,
|
||||
WKS = 11,
|
||||
PTR = 12,
|
||||
HINFO = 13,
|
||||
MINFO = 14,
|
||||
MX = 15,
|
||||
TXT = 16
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Dns
|
||||
} // namespace Network
|
||||
|
||||
#endif // TYPE_H
|
||||
|
||||
Reference in New Issue
Block a user