enum Place : uint8_t {QUESTION=0, ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //!< Type describing the positioning of a DNSResourceRecord within, say, a DNSPacket
void setContent(const string& content);
- string getZoneRepresentation() const;
+ string getZoneRepresentation(bool noDot=false) const;
// data
DNSName qname; //!< the name of this record, for example: www.powerdns.com
d_record.insert(d_record.end(), out.begin(), out.end());
}
- string getZoneRepresentation() const override
+ string getZoneRepresentation(bool noDot) const override
{
ostringstream str;
str<<"\\# "<<(unsigned int)d_record.size()<<" ";
}
- void xfrName(DNSName &name, bool compress=false)
+ void xfrName(DNSName &name, bool compress=false, bool noDot=false)
{
name=getName();
}
static DNSRecordContent* mastermake(uint16_t qtype, uint16_t qclass, const string& zone);
static std::unique_ptr<DNSRecordContent> makeunique(uint16_t qtype, uint16_t qclass, const string& content);
- virtual std::string getZoneRepresentation() const = 0;
+ virtual std::string getZoneRepresentation(bool noDot=false) const = 0;
virtual ~DNSRecordContent() {}
virtual void toPacket(DNSPacketWriter& pw)=0;
virtual string serialize(const DNSName& qname, bool canonic=false, bool lowerCase=false) // it would rock if this were const, but it is too hard
}
}
-string DNSResourceRecord::getZoneRepresentation() const {
+string DNSResourceRecord::getZoneRepresentation(bool noDot) const {
ostringstream ret;
switch(qtype.getCode()) {
case QType::SRV:
case QType::MX:
case QType::CNAME:
case QType::NS:
- if (*(content.rbegin()) != '.')
- ret<<content<<".";
+ if (*(content.rbegin()) != '.') {
+ ret<<content;
+ if(!noDot)
+ ret<<".";
+ }
break;
default:
ret<<content;
string blob(d_eui48, d_eui48+6);
pw.xfrBlob(blob);
}
-string EUI48RecordContent::getZoneRepresentation() const
+string EUI48RecordContent::getZoneRepresentation(bool noDot) const
{
char tmp[18];
snprintf(tmp,18,"%02x-%02x-%02x-%02x-%02x-%02x",
string blob(d_eui64, d_eui64+8);
pw.xfrBlob(blob);
}
-string EUI64RecordContent::getZoneRepresentation() const
+string EUI64RecordContent::getZoneRepresentation(bool noDot) const
{
char tmp[24];
snprintf(tmp,24,"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
static void unreport(void); \
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); \
static DNSRecordContent* make(const string& zonedata); \
- string getZoneRepresentation() const override; \
+ string getZoneRepresentation(bool noDot=false) const override; \
void toPacket(DNSPacketWriter& pw) override; \
uint16_t getType() const override { return QType::RNAME; } \
- template<class Convertor> void xfrPacket(Convertor& conv);
+ template<class Convertor> void xfrPacket(Convertor& conv, bool noDot=false);
class NAPTRRecordContent : public DNSRecordContent
{
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& content);
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint16_t getType() const override
{
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& content);
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint8_t d_algorithm, d_flags;
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& content);
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint16_t getType() const override
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& content);
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint8_t d_version, d_size, d_horizpre, d_vertpre;
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& content);
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint32_t d_ip;
static void report(void);
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint16_t getType() const override { return QType::EUI48; }
private:
static void report(void);
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
- string getZoneRepresentation() const override;
+ string getZoneRepresentation(bool noDot=false) const override;
void toPacket(DNSPacketWriter& pw) override;
uint16_t getType() const override { return QType::EUI64; }
private:
} \
} \
\
-string RNAME##RecordContent::getZoneRepresentation() const \
+string RNAME##RecordContent::getZoneRepresentation(bool noDot) const \
{ \
string ret; \
- RecordTextWriter rtw(ret); \
+ RecordTextWriter rtw(ret, noDot); \
const_cast<RNAME##RecordContent*>(this)->xfrPacket(rtw); \
return ret; \
}
#define boilerplate_conv(RNAME, TYPE, CONV) \
boilerplate(RNAME, TYPE) \
template<class Convertor> \
-void RNAME##RecordContent::xfrPacket(Convertor& conv) \
+void RNAME##RecordContent::xfrPacket(Convertor& conv, bool noDot) \
{ \
CONV; \
if (conv.eof() == false) throw MOADNSException("All data was not consumed"); \
// }
// this is the absolute hottest function in the pdns recursor
-void DNSPacketWriter::xfrName(const DNSName& name, bool compress)
+void DNSPacketWriter::xfrName(const DNSName& name, bool compress, bool)
{
//cerr<<"xfrName: name=["<<name.toString()<<"] compress="<<compress<<endl;
// string label = d_lowerCase ? toLower(Label) : Label;
void xfr8BitInt(uint8_t val);
- void xfrName(const DNSName& label, bool compress=false);
+ void xfrName(const DNSName& label, bool compress=false, bool noDot=false);
void xfrText(const string& text, bool multi=false);
void xfrBlob(const string& blob, int len=-1);
void xfrBlobNoSpaces(const string& blob, int len=-1);
return ret;
}
-string NSECRecordContent::getZoneRepresentation() const
+string NSECRecordContent::getZoneRepresentation(bool noDot) const
{
string ret;
RecordTextWriter rtw(ret);
return ret;
}
-string NSEC3RecordContent::getZoneRepresentation() const
+string NSEC3RecordContent::getZoneRepresentation(bool noDot) const
{
string ret;
RecordTextWriter rtw(ret);
return ret;
}
-string NSEC3PARAMRecordContent::getZoneRepresentation() const
+string NSEC3PARAMRecordContent::getZoneRepresentation(bool noDot) const
{
string ret;
RecordTextWriter rtw(ret);
try {
shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content));
string tmp=drc->serialize(rr.qname);
- tmp = drc->getZoneRepresentation();
+ tmp = drc->getZoneRepresentation(true);
if (rr.qtype.getCode() != QType::AAAA) {
if (!pdns_iequals(tmp, rr.content)) {
cout<<"[Warning] Parsed and original record content are not equal: "<<rr.qname.toString()<<" IN " <<rr.qtype.getName()<< " '" << rr.content<<"' (Content parsed as '"<<tmp<<"')"<<endl;
}
// this code should leave all the escapes around
-void RecordTextReader::xfrName(DNSName& val, bool)
+void RecordTextReader::xfrName(DNSName& val, bool, bool)
{
skipSpaces();
string sval;
}
-RecordTextWriter::RecordTextWriter(string& str) : d_string(str)
+RecordTextWriter::RecordTextWriter(string& str, bool noDot) : d_string(str)
{
d_string.clear();
+ d_nodot=noDot;
}
void RecordTextWriter::xfr48BitInt(const uint64_t& val)
}
// should not mess with the escapes
-void RecordTextWriter::xfrName(const DNSName& val, bool)
+void RecordTextWriter::xfrName(const DNSName& val, bool, bool noDot)
{
if(!d_string.empty())
d_string.append(1,' ');
- d_string+=val.toString();
+ if(d_nodot) {
+ if(val.isRoot())
+ d_string+=".";
+ else
+ d_string+=val.toStringNoDot();
+ }
+ else
+ {
+ d_string+=val.toString();
+ }
}
void RecordTextWriter::xfrBlobNoSpaces(const string& val, int size)
void xfrIP6(std::string& val);
void xfrTime(uint32_t& val);
- void xfrName(DNSName& val, bool compress=false);
+ void xfrName(DNSName& val, bool compress=false, bool noDot=false);
void xfrText(string& val, bool multi=false);
void xfrHexBlob(string& val, bool keepReading=false);
void xfrBase32HexBlob(string& val);
class RecordTextWriter
{
public:
- RecordTextWriter(string& str);
+ RecordTextWriter(string& str, bool noDot=false);
void xfr48BitInt(const uint64_t& val);
void xfr32BitInt(const uint32_t& val);
void xfr16BitInt(const uint16_t& val);
void xfrBase32HexBlob(const string& val);
void xfrType(const uint16_t& val);
- void xfrName(const DNSName& val, bool compress=false);
+ void xfrName(const DNSName& val, bool compress=false, bool noDot=false);
void xfrText(const string& val, bool multi=false);
void xfrBlobNoSpaces(const string& val, int len=-1);
void xfrBlob(const string& val, int len=-1);
bool eof() { return true; };
private:
string& d_string;
+ bool d_nodot;
};
#endif
}
-string LOCRecordContent::getZoneRepresentation() const
+string LOCRecordContent::getZoneRepresentation(bool noDot) const
{
// convert d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude to:
// 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m