#endif
#include "utility.hh"
#include "dnsrecords.hh"
+#include "iputils.hh"
#include <boost/foreach.hpp>
void DNSResourceRecord::setContent(const string &cont) {
setContent(p.d_content->getZoneRepresentation());
}
-
boilerplate_conv(A, QType::A, conv.xfrIP(d_ip));
ARecordContent::ARecordContent(uint32_t ip) : DNSRecordContent(QType::A)
d_ip = ip;
}
-uint32_t ARecordContent::getIP() const
+ARecordContent::ARecordContent(const ComboAddress& ca) : DNSRecordContent(QType::A)
+{
+ d_ip = ca.sin4.sin_addr.s_addr;
+}
+
+AAAARecordContent::AAAARecordContent(const ComboAddress& ca) : DNSRecordContent(QType::AAAA)
{
- return d_ip;
+ d_ip6.assign((const char*)ca.sin6.sin6_addr.s6_addr, 16);
}
+
+ComboAddress ARecordContent::getCA(int port) const
+{
+ ComboAddress ret;
+ ret.sin4.sin_family=AF_INET;
+ ret.sin4.sin_port=htons(port);
+ memcpy(&ret.sin4.sin_addr.s_addr, &d_ip, 4);
+ return ret;
+}
+
+ComboAddress AAAARecordContent::getCA(int port) const
+{
+ ComboAddress ret;
+ memset(&ret, 0, sizeof(ret));
+
+ ret.sin4.sin_family=AF_INET6;
+ ret.sin6.sin6_port = htons(port);
+ memcpy(&ret.sin6.sin6_addr.s6_addr, d_ip6.c_str(), 16);
+ return ret;
+}
+
+
void ARecordContent::doRecordCheck(const DNSRecord& dr)
{
if(dr.d_clen!=4)
#include <boost/lexical_cast.hpp>
#include <set>
#include <bitset>
-
-#include "namespaces.hh"
#include "namespaces.hh"
#define includeboilerplate(RNAME) RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr); \
class ARecordContent : public DNSRecordContent
{
public:
+ explicit ARecordContent(const ComboAddress& ca);
explicit ARecordContent(uint32_t ip);
includeboilerplate(A);
void doRecordCheck(const DNSRecord& dr);
- uint32_t getIP() const;
-
+ ComboAddress getCA(int port=0) const;
private:
uint32_t d_ip;
};
{
public:
AAAARecordContent(std::string &val);
+ explicit AAAARecordContent(const ComboAddress& ca);
includeboilerplate(AAAA);
+ ComboAddress getCA(int port=0) const;
private:
- std::string d_ip6;
+ string d_ip6; // why??
};
class MXRecordContent : public DNSRecordContent
{
public:
includeboilerplate(NS)
-
+ explicit NSRecordContent(const DNSName& content) : DNSRecordContent(QType::NS), d_content(content){}
+ DNSName getNS() const { return d_content; }
private:
DNSName d_content;
};
{
public:
includeboilerplate(CNAME)
-
+ DNSName getTarget() const { return d_content; }
private:
DNSName d_content;
};
{
enum zFlags { DNSSECOK=32768 };
vector<pair<uint16_t, string> > d_options;
- uint16_t d_packetsize;
- uint16_t d_Z;
+ uint16_t d_packetsize{0};
+ uint16_t d_Z{0};
uint8_t d_extRCode, d_version;
};
//! Convenience function that fills out EDNS0 options, and returns true if there are any