wip
This commit is contained in:
1 parent
87e8a86535
commit
29b4df31fd
4 files changed
+61
-32
No files matched your search
@@ -13,6 +13,7 @@ inotifywait -m -q -r -e close_write --format %f ../src/ | grep --line-buffered "
|
|||||||
|
|
||||||
#### Methods (Functions)
|
#### Methods (Functions)
|
||||||
- smallCammelCase
|
- smallCammelCase
|
||||||
|
*Note that this does not apply to getters and setters. These follow the name of the property without the prefixed '_'*
|
||||||
|
|
||||||
#### Properties (Variables)
|
#### Properties (Variables)
|
||||||
- _smallCammelCase
|
- _smallCammelCase
|
||||||
|
|||||||
+26
-13
@@ -4,20 +4,33 @@
|
|||||||
namespace Plains {
|
namespace Plains {
|
||||||
namespace Resolver {
|
namespace Resolver {
|
||||||
|
|
||||||
unsigned Message::Header::getID() const { return ntohs(_id); }
|
unsigned Message::Header::id() const { return ntohs(_id); }
|
||||||
unsigned Message::Header::getRCode() const { return ntohs(_rCode); }
|
unsigned Message::Header::rCode() const { return ntohs(_rCode); }
|
||||||
unsigned Message::Header::getQDCount() const { return ntohs(_qdCount); }
|
unsigned Message::Header::qdCount() const { return ntohs(_qdCount); }
|
||||||
unsigned Message::Header::getANCount() const { return ntohs(_anCount); }
|
unsigned Message::Header::anCount() const { return ntohs(_anCount); }
|
||||||
unsigned Message::Header::getNSCount() const { return ntohs(_nsCount); }
|
unsigned Message::Header::nsCount() const { return ntohs(_nsCount); }
|
||||||
unsigned Message::Header::getARCount() const { return ntohs(_arCount); }
|
unsigned Message::Header::arCount() const { return ntohs(_arCount); }
|
||||||
unsigned Message::Header::getOpCode() const { return ntohs(_opCode); }
|
unsigned Message::Header::opCode() const { return ntohs(_opCode); }
|
||||||
bool Message::Header::getRD() const { return ntohs(_rd); }
|
bool Message::Header::rd() const { return ntohs(_rd); }
|
||||||
bool Message::Header::getAA() const { return ntohs(_aa); }
|
bool Message::Header::aa() const { return ntohs(_aa); }
|
||||||
bool Message::Header::getTC() const { return ntohs(_tc); }
|
bool Message::Header::tc() const { return ntohs(_tc); }
|
||||||
bool Message::Header::getRA() const { return ntohs(_ra); }
|
bool Message::Header::ra() const { return ntohs(_ra); }
|
||||||
bool Message::Header::getQR() const { return ntohs(_qr); }
|
bool Message::Header::qr() const { return ntohs(_qr); }
|
||||||
|
|
||||||
void Message::Header::setQR(bool flag) { _qr = flag; }
|
void Message::Header::id (unsigned value) { _id = htons(value); }
|
||||||
|
void Message::Header::rCode (unsigned value) { _rCode = htons(value); }
|
||||||
|
void Message::Header::qdCount(unsigned value) { _qdCount = htons(value); }
|
||||||
|
void Message::Header::anCount(unsigned value) { _anCount = htons(value); }
|
||||||
|
void Message::Header::nsCount(unsigned value) { _nsCount = htons(value); }
|
||||||
|
void Message::Header::arCount(unsigned value) { _arCount = htons(value); }
|
||||||
|
void Message::Header::opCode (unsigned value) { _opCode = htons(value); }
|
||||||
|
void Message::Header::rd (bool flag) { _rd = flag; }
|
||||||
|
void Message::Header::aa (bool flag) { _aa = flag; }
|
||||||
|
void Message::Header::tc (bool flag) { _tc = flag; }
|
||||||
|
void Message::Header::ra (bool flag) { _ra = flag; }
|
||||||
|
void Message::Header::qr (QR::ENUM flag) { _qr = flag; }
|
||||||
|
|
||||||
|
size_t Message::size() { return 12; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -126,13 +126,13 @@ void Server::run() {
|
|||||||
std::cout << std::endl << std::endl;
|
std::cout << std::endl << std::endl;
|
||||||
*/
|
*/
|
||||||
Message* message = (Message*) &buffer;
|
Message* message = (Message*) &buffer;
|
||||||
_logger.warn << "ID: " << message->header.getID() << Logger::commit;
|
_logger.warn << "ID: " << message->header.id() << Logger::commit;
|
||||||
|
|
||||||
// Change message to response type and send back for testing
|
// Change message to response type and send back for testing
|
||||||
message->header.setQR(Message::Header::QR::RESPONSE);
|
message->header.qr(Message::Header::QR::RESPONSE);
|
||||||
|
|
||||||
//if ( sendto(udpServerSocket, msg, strlen(msg), 0, (struct sockaddr*)&clientAddress, clientAddressLength) < 0 ) {
|
//if ( sendto(udpServerSocket, msg, strlen(msg), 0, (struct sockaddr*)&clientAddress, clientAddressLength) < 0 ) {
|
||||||
if ( sendto(udpServerSocket, message, strlen(msg), 0, (struct sockaddr*)&clientAddress, clientAddressLength) < 0 ) {
|
if ( sendto(udpServerSocket, message, message->size(), 0, (struct sockaddr*)&clientAddress, clientAddressLength) < 0 ) {
|
||||||
close(udpServerSocket);
|
close(udpServerSocket);
|
||||||
_logger.warn.ln("sending error...");
|
_logger.warn.ln("sending error...");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
#ifndef MESSAGE_HPP
|
#ifndef MESSAGE_HPP
|
||||||
#define MESSAGE_HPP
|
#define MESSAGE_HPP
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Plains {
|
namespace Plains {
|
||||||
namespace Resolver {
|
namespace Resolver {
|
||||||
|
|
||||||
|
using std::size_t;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Message();
|
Message();
|
||||||
|
size_t size();
|
||||||
|
|
||||||
public: //change to private after debugging
|
public: //change to private after debugging
|
||||||
class Header {
|
class Header {
|
||||||
@@ -28,24 +32,35 @@ class Message
|
|||||||
| ARCOUNT |
|
| ARCOUNT |
|
||||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||||
*/
|
*/
|
||||||
struct QR { enum { QUERY, RESPONSE }; };
|
struct QR { enum ENUM { QUERY, RESPONSE }; };
|
||||||
struct OpCode { enum { QUERY, IQUERY, STATUS, reserved, NOTIFY, UPDATE }; };
|
struct OpCode { enum ENUM { QUERY, IQUERY, STATUS, reserved, NOTIFY, UPDATE }; };
|
||||||
struct RCode { enum { NO_ERR, FORMAT_ERR, SERVER_FAIL, NAME_ERR, NOT_IMPL, REFUSED, YX_DOM, YX_RR_SET, NX_RR_SET, NOT_AUTH, NOT_ZONE }; };
|
struct RCode { enum ENUM { NO_ERR, FORMAT_ERR, SERVER_FAIL, NAME_ERR, NOT_IMPL, REFUSED, YX_DOM, YX_RR_SET, NX_RR_SET, NOT_AUTH, NOT_ZONE }; };
|
||||||
|
|
||||||
unsigned getID() const;
|
unsigned id() const;
|
||||||
unsigned getRCode() const;
|
unsigned rCode() const;
|
||||||
unsigned getQDCount() const;
|
unsigned qdCount() const;
|
||||||
unsigned getANCount() const;
|
unsigned anCount() const;
|
||||||
unsigned getNSCount() const;
|
unsigned nsCount() const;
|
||||||
unsigned getARCount() const;
|
unsigned arCount() const;
|
||||||
unsigned getOpCode() const;
|
unsigned opCode() const;
|
||||||
bool getRD() const;
|
bool rd() const;
|
||||||
bool getAA() const;
|
bool aa() const;
|
||||||
bool getTC() const;
|
bool tc() const;
|
||||||
bool getRA() const;
|
bool ra() const;
|
||||||
bool getQR() const;
|
bool qr() const;
|
||||||
|
|
||||||
void setQR(bool flag);
|
void id (unsigned value);
|
||||||
|
void rCode (unsigned value);
|
||||||
|
void qdCount(unsigned value);
|
||||||
|
void anCount(unsigned value);
|
||||||
|
void nsCount(unsigned value);
|
||||||
|
void arCount(unsigned value);
|
||||||
|
void opCode (unsigned value);
|
||||||
|
void rd(bool flag);
|
||||||
|
void aa(bool flag);
|
||||||
|
void tc(bool flag);
|
||||||
|
void ra(bool flag);
|
||||||
|
void qr(QR::ENUM flag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned _id : 16; //Identifier: A 16-bit identification field generated by the device that creates the DNS query. It is copied by the server into the response, so it can be used by that device to match that query to the corresponding reply received from a DNS server. This is used in a manner similar to how the Identifier field is used in many of the ICMP message types.
|
unsigned _id : 16; //Identifier: A 16-bit identification field generated by the device that creates the DNS query. It is copied by the server into the response, so it can be used by that device to match that query to the corresponding reply received from a DNS server. This is used in a manner similar to how the Identifier field is used in many of the ICMP message types.
|
||||||
|
|||||||
Reference in new issue
Block a user