1
#include "dnsrecords.hh"
3
void NSECRecordContent::report(void)
5
regist(1, 47, &make, &make, "NSEC");
8
DNSRecordContent* NSECRecordContent::make(const string& content)
10
return new NSECRecordContent(content);
13
NSECRecordContent::NSECRecordContent(const string& content, const string& zone) : DNSRecordContent(47)
15
RecordTextReader rtr(content, zone);
25
void NSECRecordContent::toPacket(DNSPacketWriter& pw)
30
memset(res, 0, sizeof(res));
32
set<uint16_t>::const_iterator i;
33
for(i=d_set.begin(); i != d_set.end() && *i<255; ++i){
34
res[2+*i/8] |= 1 << (7-(*i%8));
43
tmp.assign(res, res+len+2);
47
NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr)
49
NSECRecordContent* ret=new NSECRecordContent();
50
pr.xfrLabel(ret->d_next);
54
// 00 06 20 00 00 00 00 03 -> NS RRSIG NSEC ( 2, 46, 47 ) counts from left
57
throw MOADNSException("NSEC record with impossibly small bitmap");
60
throw MOADNSException("Can't deal with NSEC mappings > 255 yet");
62
unsigned int len=bitmap[1];
63
if(bitmap.size()!=2+len)
64
throw MOADNSException("Can't deal with multi-part NSEC mappings yet");
66
for(unsigned int n=0 ; n < len ; ++n) {
67
uint8_t val=bitmap[2+n];
68
for(int bit = 0; bit < 8 ; ++bit , val>>=1)
70
ret->d_set.insert((7-bit) + 8*(n));
77
string NSECRecordContent::getZoneRepresentation() const
80
RecordTextWriter rtw(ret);
83
for(set<uint16_t>::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) {
85
ret+=NumberToType(*i);
93
void NSEC3RecordContent::report(void)
95
regist(1, 50, &make, &make, "NSEC3");
98
DNSRecordContent* NSEC3RecordContent::make(const string& content)
100
return new NSEC3RecordContent(content);
103
NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone) : DNSRecordContent(50)
105
RecordTextReader rtr(content, zone);
106
rtr.xfr8BitInt(d_algorithm);
107
rtr.xfr8BitInt(d_flags);
108
rtr.xfr16BitInt(d_iterations);
110
rtr.xfrHexBlob(d_salt);
111
rtr.xfrBase32HexBlob(d_nexthash);
120
void NSEC3RecordContent::toPacket(DNSPacketWriter& pw)
122
pw.xfr8BitInt(d_algorithm);
123
pw.xfr8BitInt(d_flags);
124
pw.xfr16BitInt(d_iterations);
125
pw.xfr8BitInt(d_salt.length());
128
pw.xfr8BitInt(d_nexthash.length());
129
pw.xfrBlob(d_nexthash);
132
memset(res, 0, sizeof(res));
134
set<uint16_t>::const_iterator i;
135
for(i=d_set.begin(); i != d_set.end() && *i<255; ++i){
136
res[2+*i/8] |= 1 << (7-(*i%8));
145
tmp.assign(res, res+len+2);
149
NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr)
151
NSEC3RecordContent* ret=new NSEC3RecordContent();
152
pr.xfr8BitInt(ret->d_algorithm);
153
pr.xfr8BitInt(ret->d_flags);
154
pr.xfr16BitInt(ret->d_iterations);
157
pr.xfrBlob(ret->d_salt, len);
161
pr.xfrBlob(ret->d_nexthash, len);
166
// 00 06 20 00 00 00 00 03 -> NS RRSIG NSEC ( 2, 46, 47 ) counts from left
171
if(bitmap.size() < 2)
172
throw MOADNSException("NSEC3 record with impossibly small bitmap");
175
throw MOADNSException("Can't deal with NSEC3 mappings > 255 yet");
177
unsigned int bitmaplen=bitmap[1];
178
if(bitmap.size()!=2+bitmaplen)
179
throw MOADNSException("Can't deal with multi-part NSEC3 mappings yet");
181
for(unsigned int n=0 ; n < bitmaplen ; ++n) {
182
uint8_t val=bitmap[2+n];
183
for(int bit = 0; bit < 8 ; ++bit , val>>=1)
185
ret->d_set.insert((7-bit) + 8*(n));
192
string NSEC3RecordContent::getZoneRepresentation() const
195
RecordTextWriter rtw(ret);
196
rtw.xfr8BitInt(d_algorithm);
197
rtw.xfr8BitInt(d_flags);
198
rtw.xfr16BitInt(d_iterations);
200
rtw.xfrHexBlob(d_salt);
201
rtw.xfrBase32HexBlob(d_nexthash);
202
for(set<uint16_t>::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) {
204
ret+=NumberToType(*i);
211
void NSEC3PARAMRecordContent::report(void)
213
regist(1, 51, &make, &make, "NSEC3PARAM");
216
DNSRecordContent* NSEC3PARAMRecordContent::make(const string& content)
218
return new NSEC3PARAMRecordContent(content);
221
NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) : DNSRecordContent(51)
223
RecordTextReader rtr(content, zone);
224
rtr.xfr8BitInt(d_algorithm);
225
rtr.xfr8BitInt(d_flags);
226
rtr.xfr16BitInt(d_iterations);
227
rtr.xfrHexBlob(d_salt);
230
void NSEC3PARAMRecordContent::toPacket(DNSPacketWriter& pw)
232
pw.xfr8BitInt(d_algorithm);
233
pw.xfr8BitInt(d_flags);
234
pw.xfr16BitInt(d_iterations);
235
pw.xfr8BitInt(d_salt.length());
236
// cerr<<"salt: '"<<makeHexDump(d_salt)<<"', "<<d_salt.length()<<endl;
240
NSEC3PARAMRecordContent::DNSRecordContent* NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr)
242
NSEC3PARAMRecordContent* ret=new NSEC3PARAMRecordContent();
243
pr.xfr8BitInt(ret->d_algorithm);
244
pr.xfr8BitInt(ret->d_flags);
245
pr.xfr16BitInt(ret->d_iterations);
246
pr.xfr8BitInt(ret->d_saltlength);
247
pr.xfrHexBlob(ret->d_salt);
252
string NSEC3PARAMRecordContent::getZoneRepresentation() const
255
RecordTextWriter rtw(ret);
256
rtw.xfr8BitInt(d_algorithm);
257
rtw.xfr8BitInt(d_flags);
258
rtw.xfr16BitInt(d_iterations);
259
rtw.xfrHexBlob(d_salt);