From: Aki Tuomi Date: Mon, 13 May 2013 15:38:20 +0000 (+0300) Subject: AAAA now uses boilerplate_conv X-Git-Tag: auth-3.3-rc1~58^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc465b4128993abe1c0d877bb53830970679f322;p=thirdparty%2Fpdns.git AAAA now uses boilerplate_conv --- diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 47d379ecb7..10a6c30216 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -38,59 +38,7 @@ void ARecordContent::doRecordCheck(const DNSRecord& dr) throw MOADNSException("Wrong size for A record ("+lexical_cast(dr.d_clen)+")"); } -class AAAARecordContent : public DNSRecordContent -{ -public: - AAAARecordContent() : DNSRecordContent(ns_t_aaaa) - {} - - static void report(void) - { - regist(1, ns_t_aaaa, &make, &make, "AAAA"); - } - - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr) - { - if(dr.d_clen!=16) - throw MOADNSException("Wrong size for AAAA record"); - - AAAARecordContent* ret=new AAAARecordContent(); - pr.copyRecord((unsigned char*) &ret->d_ip6, 16); - return ret; - } - - static DNSRecordContent* make(const string& zone) - { - AAAARecordContent *ar=new AAAARecordContent(); - if(Utility::inet_pton( AF_INET6, zone.c_str(), static_cast< void * >( ar->d_ip6 )) <= 0) - throw MOADNSException("Asked to encode '"+zone+"' as an IPv6 address, but does not parse"); - return ar; - } - - void toPacket(DNSPacketWriter& pw) - { - string blob(d_ip6, d_ip6+16); - pw.xfrBlob(blob); - } - - string getZoneRepresentation() const - { - struct sockaddr_in6 addr; - memset(&addr, 0, sizeof(addr)); - addr.sin6_family=AF_INET6; - memcpy(&addr.sin6_addr, d_ip6, 16); - - char tmp[128]; - tmp[0]=0; - Utility::inet_ntop(AF_INET6, (const char*)& addr.sin6_addr, tmp, sizeof(tmp)); - return tmp; - } - -private: - unsigned char d_ip6[16]; -}; - - +boilerplate_conv(AAAA, ns_t_aaaa, conv.xfrIP6(d_ip6); ); boilerplate_conv(NS, ns_t_ns, conv.xfrLabel(d_content, true)); boilerplate_conv(PTR, ns_t_ptr, conv.xfrLabel(d_content, true)); diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index c60d3824e2..63d140cb3d 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -64,6 +64,15 @@ private: uint32_t d_ip; }; +class AAAARecordContent : public DNSRecordContent +{ +public: + AAAARecordContent(std::string &val); + includeboilerplate(AAAA); +private: + std::string d_ip6; +}; + class MXRecordContent : public DNSRecordContent { public: