../../pdns/base64.cc \
../../pdns/dnsbackend.hh ../../pdns/dnsbackend.cc \
../../pdns/dnslabeltext.cc \
+ ../../pdns/dnsname.cc ../../pdns/dnsname.hh \
../../pdns/dnspacket.cc \
../../pdns/dnsparser.cc \
../../pdns/dnsrecords.cc \
lua-pdns.o lua-recursor.o randomhelper.o recpacketcache.o dns.o \
reczones.o base32.o nsecrecords.o json.o ws-recursor.o ws-api.o \
version.o responsestats.o webserver.o ext/yahttp/yahttp/reqresp.o ext/yahttp/yahttp/router.o \
-rec-carbon.o secpoll-recursor.o lua-iputils.o iputils.o
+rec-carbon.o secpoll-recursor.o lua-iputils.o iputils.o dnsname.o
REC_CONTROL_OBJECTS=rec_channel.o rec_control.o arguments.o misc.o \
unix_utility.o logger.o qtype.o
dns_random.cc dns_random.hh \
dnsbackend.cc dnsbackend.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnspacket.cc dnspacket.hh \
dnsparser.cc \
dnsproxy.cc dnsproxy.hh \
dnsbackend.cc \
dns.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnspacket.cc \
dnsparser.cc dnsparser.hh \
dns_random.cc \
bindparserclasses.hh \
dns.cc \
dns_random.cc \
+ dnsname.cc dnsname.hh \
dnslabeltext.cc \
dnsparser.cc \
dnsrecords.cc \
bindparser.yy \
bindparserclasses.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc \
dnsrecords.cc \
dnswriter.cc \
bindparser.yy \
bindparserclasses.hh \
dns_random.cc \
+ dnsname.cc dnsname.hh \
dnslabeltext.cc \
dnsparser.cc \
dnsrecords.cc \
dns.cc \
dns_random.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc \
dnsrecords.cc \
dnswriter.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnswriter.cc dnswriter.hh \
base64.cc base64.hh \
calidns.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnswriter.cc dnswriter.hh \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnssecinfra.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnstcpbench.cc \
nsec3dig_SOURCES = \
base32.cc \
base64.cc base64.hh \
+ dnsname.cc dnsname.hh \
dnslabeltext.cc \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
base32.cc \
base64.cc base64.hh \
dns_random.cc \
+ dnsname.cc dnsname.hh \
dnslabeltext.cc \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dns.cc \
dns_random.cc dns_random.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnssecinfra.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnswriter.cc dnswriter.hh \
base64.cc \
dnsbulktest.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc \
dnsrecords.cc \
dnswriter.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnspcap.cc dnspcap.hh \
dnsrecords.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnspcap.cc dnspcap.hh \
dnsrecords.cc \
base32.cc \
base64.cc base64.hh \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnswriter.cc dnswriter.hh \
base64.cc base64.hh \
dns.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnsrecords.cc \
dnswriter.cc dnswriter.hh \
base64.cc base64.hh \
dns.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnspcap.cc dnspcap.hh \
dnsrecords.cc \
base64.cc base64.hh \
dnsgram.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnspcap.cc dnspcap.hh \
dnsrecords.cc \
base64.cc base64.hh \
dnsdemog.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc dnsparser.hh \
dnspcap.cc dnspcap.hh \
dnsrecords.cc \
dns.cc \
dns_random.cc \
dnslabeltext.cc \
+ dnsname.cc dnsname.hh \
dnsparser.cc \
dnsrecords.cc dnsrecords.hh \
dnswriter.cc dnswriter.hh \
dns_random.hh lua-pdns.hh lua-recursor.hh namespaces.hh \
recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh \
ws-recursor.hh ws-api.hh secpoll-recursor.hh \
-responsestats.hh webserver.hh"
+responsestats.hh webserver.hh dnsname.hh"
CFILES="syncres.cc iputils.cc misc.cc unix_utility.cc qtype.cc \
logger.cc arguments.cc lwres.cc pdns_recursor.cc lua-iputils.cc \
sillyrecords.cc pubsuffix.cc lua-pdns.cc lua-recursor.cc randomhelper.cc \
devpollmplexer.cc recpacketcache.cc dns.cc reczones.cc base32.cc nsecrecords.cc \
dnslabeltext.cc json.cc ws-recursor.cc ws-api.cc version.cc dns_random.cc \
-responsestats.cc webserver.cc rec-carbon.cc secpoll-recursor.cc"
+responsestats.cc webserver.cc rec-carbon.cc secpoll-recursor.cc dnsname.cc"
./mkpubsuffixcc
return d_content.at(d_pos++);
}
-string PacketReader::getLabel(unsigned int recurs)
+string PacketReader::getLabel()
{
- string ret;
- ret.reserve(40);
- getLabelFromContent(d_content, d_pos, ret, recurs++);
+ unsigned int consumed;
+ vector<uint8_t> content(d_content);
+ content.insert(content.begin(), sizeof(dnsheader), 0);
+
+ string ret = DNSName((const char*) content.data(), content.size(), d_pos + sizeof(dnsheader), true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed).toString();
+
+ d_pos+=consumed;
return ret;
}
return ret;
}
-
-void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t& frompos, string& ret, int recurs)
-{
- if(recurs > 1000) // the forward reference-check below should make this test 100% obsolete
- throw MOADNSException("Loop");
- // it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop
- for(;;) {
- unsigned char labellen=content.at(frompos++);
-
- if(!labellen) {
- if(ret.empty())
- ret.append(1,'.');
- break;
- }
- else if((labellen & 0xc0) == 0xc0) {
- uint16_t offset=256*(labellen & ~0xc0) + (unsigned int)content.at(frompos++) - sizeof(dnsheader);
- // cout<<"This is an offset, need to go to: "<<offset<<endl;
-
- if(offset >= frompos-2)
- throw MOADNSException("forward reference during label decompression");
- return getLabelFromContent(content, offset, ret, ++recurs);
- }
- else if(labellen > 63)
- throw MOADNSException("Overly long label during label decompression ("+lexical_cast<string>((unsigned int)labellen)+")");
- else {
- // XXX FIXME THIS MIGHT BE VERY SLOW!
-
- for(string::size_type n = 0 ; n < labellen; ++n, frompos++) {
- if(content.at(frompos)=='.' || content.at(frompos)=='\\') {
- ret.append(1, '\\');
- ret.append(1, content[frompos]);
- }
- else if(content.at(frompos)==' ') {
- ret+="\\032";
- }
- else
- ret.append(1, content[frompos]);
- }
- ret.append(1,'.');
- }
- }
-}
-
void PacketReader::xfrBlob(string& blob)
try
{
string simpleCompress(const string& elabel, const string& root)
{
string label=elabel;
- // FIXME: this relies on the semi-canonical escaped output from getLabelFromContent
+ // FIXME: this relies on the semi-canonical escaped output from getLabel
if(strchr(label.c_str(), '\\')) {
boost::replace_all(label, "\\.", ".");
boost::replace_all(label, "\\032", " ");
#include <boost/tuple/tuple_comparison.hpp>
#include "dns.hh"
#include "dnswriter.hh"
+#include "dnsname.hh"
+#include "pdnsexception.hh"
/** DNS records have three representations:
1) in the packet
void xfrHexBlob(string& blob, bool keepReading=false);
static uint16_t get16BitInt(const vector<unsigned char>&content, uint16_t& pos);
- static void getLabelFromContent(const vector<uint8_t>& content, uint16_t& frompos, string& ret, int recurs);
void getDnsrecordheader(struct dnsrecordheader &ah);
void copyRecord(vector<unsigned char>& dest, uint16_t len);
void copyRecord(unsigned char* dest, uint16_t len);
- string getLabel(unsigned int recurs=0);
+ string getLabel();
string getText(bool multi);
uint16_t d_pos;
if(unescaped) {
string part(label.c_str() + i -> first, i->second - i->first);
- // FIXME: this relies on the semi-canonical escaped output from getLabelFromContent
+ // FIXME: this relies on the semi-canonical escaped output from getLabel
boost::replace_all(part, "\\.", ".");
boost::replace_all(part, "\\032", " ");
boost::replace_all(part, "\\\\", "\\");