void PacketReader::xfrBlob(string& blob, int length)
{
if(length) {
- blob.assign(&d_content.at(d_pos), &d_content.at(d_pos + length ) );
+ blob.assign(&d_content.at(d_pos), &d_content.at(d_pos + length - 1 ) + 1 );
d_pos += length;
}
/*
PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2005 - 2008 PowerDNS.COM BV
+ Copyright (C) 2005 - 2009 PowerDNS.COM BV
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
PTRRecordContent::report();
DNSRecordContent::regist(3, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT");
TXTRecordContent::report();
- DNSRecordContent::regist(1, 255, 0, 0, "ANY");
+ DNSRecordContent::regist(1, QType::ANY, 0, 0, "ANY");
}
void reportOtherTypes()
SSHFPRecordContent::report();
CERTRecordContent::report();
NSECRecordContent::report();
- TSIGRecordContent::report();
+ DNSRecordContent::regist(0xff, QType::TSIG, &TSIGRecordContent::make, &TSIGRecordContent::make, "TSIG");
OPTRecordContent::report();
}
{
public:
includeboilerplate(TSIG)
+ TSIGRecordContent() : DNSRecordContent(QType::TSIG) {}
string d_algoName;
uint64_t d_time; // 48 bits
void DNSPacketWriter::xfr48BitInt(uint64_t val)
{
unsigned char bytes[6];
- bytes[5] = val % 0xff; val /= 0xff; // untested code! XXX FIXME
- bytes[4] = val % 0xff; val /= 0xff;
- bytes[3] = val % 0xff; val /= 0xff;
- bytes[2] = val % 0xff; val /= 0xff;
- bytes[1] = val % 0xff; val /= 0xff;
- bytes[0] = val % 0xff; val /= 0xff;
+ uint16_t theLeft = htons(val >> 32);
+ uint32_t theRight = htonl(val & 0xffffffffU);
+ memcpy(bytes, (void*)&theLeft, 2);
+ memcpy(bytes+2, (void*)&theRight, 4);
d_record.insert(d_record.end(), bytes, bytes + 6);
}
#undef DS
enum typeenum {A=1,NS=2,CNAME=5,SOA=6, MR=9, PTR=12,HINFO=13,MX=15,TXT=16,RP=17,AFSDB=18,KEY=25,AAAA=28,LOC=29,SRV=33,NAPTR=35, KX=36,
CERT=37,OPT=41, DS=43, SSHDP=44, IPSECKEY=45, RRSIG=46, NSEC=47, DNSKEY=48, DHCID=49,
- SPF=99, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259} types;
+ SPF=99, TSIG=250, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259} types;
typedef pair<string,int> namenum;
static vector<namenum> names;
private: