From 74b3a069dcff07438f7fc9141a97ba578dadd71b Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Mon, 13 May 2013 18:36:59 +0300 Subject: [PATCH] IPSECKEY now uses boilerplate --- pdns/dnsrecords.cc | 78 ++-------------------------------------------- 1 file changed, 3 insertions(+), 75 deletions(-) diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 29585f75d..47d379ecb 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -156,79 +156,7 @@ boilerplate_conv(KX, ns_t_kx, conv.xfrLabel(d_exchanger, false); ) -//boilerplate_conv(IPSECKEY, 45, /* ns_t_ipsec */ -/* conv.xfr8BitInt(d_preference); - conv.xfr8BitInt(d_gatewaytype); - conv.xfr8BitInt(d_algorithm); - conv.xfrLabel(d_gateway, false); - conv.xfrBlob(d_publickey); - ) -*/ - -IPSECKEYRecordContent::DNSRecordContent* IPSECKEYRecordContent::make(const DNSRecord& dr, PacketReader& pr) -{ - return new IPSECKEYRecordContent(dr, pr); -} -IPSECKEYRecordContent::IPSECKEYRecordContent(const DNSRecord& dr, PacketReader& pr) : DNSRecordContent(ns_t_ipseckey) -{ - doRecordCheck(dr); xfrPacket(pr); -} -IPSECKEYRecordContent::DNSRecordContent* IPSECKEYRecordContent::make(const string& zonedata) -{ - return new IPSECKEYRecordContent(zonedata); -} -void IPSECKEYRecordContent::toPacket(DNSPacketWriter& pw) -{ - this->xfrPacket(pw); -} -void IPSECKEYRecordContent::report(void) { - regist(1, ns_t_ipseckey, &IPSECKEYRecordContent::make, &IPSECKEYRecordContent::make, "IPSECKEY"); -} -void IPSECKEYRecordContent::unreport(void) { - unregist(1, ns_t_ipseckey); -} -IPSECKEYRecordContent::IPSECKEYRecordContent(const std::string& zoneData) : DNSRecordContent(ns_t_ipseckey) { - try { - RecordTextReader rtr(zoneData); - xfrPacket(rtr); - } catch(RecordTextException& rtr) { - throw MOADNSException("Parsing record content: "+std::string(rtr.what())); - } -} - -std::string IPSECKEYRecordContent::getZoneRepresentation() const { - std::string ret; - RecordTextWriter conv(ret); - conv.xfr8BitInt(d_preference); - conv.xfr8BitInt(d_gatewaytype); - conv.xfr8BitInt(d_algorithm); - - // now we need to determine values - switch(d_gatewaytype) { - case 0: // no gateway - break; - case 1: // IPv4 GW - conv.xfrIP(d_ip4); - break; - case 2: // IPv6 GW - conv.xfrIP6(d_ip6); - break; - case 3: // DNS label - conv.xfrLabel(d_gateway, false); - }; - - switch(d_algorithm) { - case 0: - break; - default: - conv.xfrBlob(d_publickey); - } - return ret; -}; - -template -void IPSECKEYRecordContent::xfrPacket(Convertor& conv) -{ +boilerplate_conv(IPSECKEY, ns_t_ipseckey, conv.xfr8BitInt(d_preference); conv.xfr8BitInt(d_gatewaytype); conv.xfr8BitInt(d_algorithm); @@ -259,8 +187,8 @@ void IPSECKEYRecordContent::xfrPacket(Convertor& conv) break; default: throw MOADNSException("Parsing record content: invalid algorithm type"); - } -} + } +) boilerplate_conv(DHCID, 49, conv.xfrBlob(d_content); -- 2.50.1