Changeset 1555
- Timestamp:
- 04/18/10 15:52:44 (3 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 7 modified
-
Makefile.am (modified) (2 diffs)
-
common_startup.cc (modified) (1 diff)
-
dnsrecords.cc (modified) (5 diffs)
-
dnsrecords.hh (modified) (6 diffs)
-
nsecrecords.cc (modified) (4 diffs)
-
rcpgenerator.cc (modified) (2 diffs)
-
rcpgenerator.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/Makefile.am
r1485 r1555 21 21 22 22 EXTRA_PROGRAMS=pdns_recursor sdig tsig-tests speedtest dnspbench pdns_control dnsscope dnsgram \ 23 dnsdemog dnswasher dnsreplay dnsscan dnslog nproxy notify 23 dnsdemog dnswasher dnsreplay dnsscan dnslog nproxy notify 24 24 25 25 pdns_server_SOURCES=dnspacket.cc nameserver.cc tcpreceiver.hh \ … … 43 43 aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ 44 44 aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ 45 randomhelper.cc namespaces.hh 45 randomhelper.cc namespaces.hh nsecrecords.cc base32.cc 46 46 47 47 # -
trunk/pdns/pdns/common_startup.cc
r1472 r1555 100 100 ::arg().set("webserver-port","Port of webserver to listen on")="8081"; 101 101 ::arg().set("webserver-password","Password required for accessing the webserver")=""; 102 ::arg().set("key-repository", "Where DNSSEC keying material lives")="./keys"; 102 103 103 104 ::arg().setSwitch("out-of-zone-additional-processing","Do out of zone additional processing")="yes"; -
trunk/pdns/pdns/dnsrecords.cc
r1472 r1555 91 91 92 92 93 void NSECRecordContent::report(void)94 {95 regist(1, 47, &make, &make, "NSEC");96 }97 98 DNSRecordContent* NSECRecordContent::make(const string& content)99 {100 return new NSECRecordContent(content);101 }102 103 NSECRecordContent::NSECRecordContent(const string& content, const string& zone) : DNSRecordContent(47)104 {105 RecordTextReader rtr(content, zone);106 rtr.xfrLabel(d_next);107 108 while(!rtr.eof()) {109 uint16_t type;110 rtr.xfrType(type);111 d_set.insert(type);112 }113 }114 115 void NSECRecordContent::toPacket(DNSPacketWriter& pw)116 {117 pw.xfrLabel(d_next);118 119 uint8_t res[34];120 memset(res, 0, sizeof(res));121 122 set<uint16_t>::const_iterator i;123 for(i=d_set.begin(); i != d_set.end() && *i<255; ++i){124 res[2+*i/8] |= 1 << (7-(*i%8));125 }126 int len=0;127 if(!d_set.empty())128 len=1+*--i/8;129 130 res[1]=len;131 132 string tmp;133 tmp.assign(res, res+len+2);134 pw.xfrBlob(tmp);135 }136 137 NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr)138 {139 NSECRecordContent* ret=new NSECRecordContent();140 pr.xfrLabel(ret->d_next);141 string bitmap;142 pr.xfrBlob(bitmap);143 144 // 00 06 20 00 00 00 00 03 -> NS RRSIG NSEC ( 2, 46, 47 ) counts from left145 146 if(bitmap.size() < 2)147 throw MOADNSException("NSEC record with impossibly small bitmap");148 149 if(bitmap[0])150 throw MOADNSException("Can't deal with NSEC mappings > 255 yet");151 152 unsigned int len=bitmap[1];153 if(bitmap.size()!=2+len)154 throw MOADNSException("Can't deal with multi-part NSEC mappings yet");155 156 for(unsigned int n=0 ; n < len ; ++n) {157 uint8_t val=bitmap[2+n];158 for(int bit = 0; bit < 8 ; ++bit , val>>=1)159 if(val & 1) {160 ret->d_set.insert((7-bit) + 8*(n));161 }162 }163 164 return ret;165 }166 167 string NSECRecordContent::getZoneRepresentation() const168 {169 string ret;170 RecordTextWriter rtw(ret);171 rtw.xfrLabel(d_next);172 173 for(set<uint16_t>::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) {174 ret+=" ";175 ret+=NumberToType(*i);176 }177 178 return ret;179 }180 93 181 94 boilerplate_conv(NS, ns_t_ns, conv.xfrLabel(d_content, true)); … … 310 223 ) 311 224 #undef DS 225 DSRecordContent::DSRecordContent() : DNSRecordContent(43) {} 312 226 boilerplate_conv(DS, 43, 313 227 conv.xfr16BitInt(d_tag); … … 336 250 ) 337 251 252 RRSIGRecordContent::RRSIGRecordContent() : DNSRecordContent(46) {} 253 338 254 boilerplate_conv(DNSKEY, 48, 339 255 conv.xfr16BitInt(d_flags); … … 342 258 conv.xfrBlob(d_key); 343 259 ) 260 DNSKEYRecordContent::DNSKEYRecordContent() : DNSRecordContent(48) {} 261 262 uint16_t DNSKEYRecordContent::getTag() 263 { 264 string data=this->serialize(""); 265 const unsigned char* key=(const unsigned char*)data.c_str(); 266 unsigned int keysize=data.length(); 267 268 unsigned long ac; /* assumed to be 32 bits or larger */ 269 unsigned int i; /* loop index */ 270 271 for ( ac = 0, i = 0; i < keysize; ++i ) 272 ac += (i & 1) ? key[i] : key[i] << 8; 273 ac += (ac >> 16) & 0xFFFF; 274 return ac & 0xFFFF; 275 } 276 277 void DNSKEYRecordContent::getExpLen(uint16_t& startPos, uint16_t& expLen) const 278 { 279 unsigned char* decoded=(unsigned char*) d_key.c_str(); 280 if(decoded[0] != 0) { 281 startPos=1; 282 expLen=decoded[0]; 283 } 284 else { 285 startPos=3; 286 expLen=decoded[1]*0xff + decoded[2]; // XXX FIXME 287 } 288 } 289 290 string DNSKEYRecordContent::getExponent() const 291 { 292 uint16_t startPos, expLen; 293 getExpLen(startPos, expLen); 294 return d_key.substr(startPos, expLen); 295 } 296 297 string DNSKEYRecordContent::getModulus() const 298 { 299 uint16_t startPos, expLen; 300 getExpLen(startPos, expLen); 301 302 return d_key.substr(startPos+expLen); 303 } 304 344 305 345 306 // "fancy records" … … 408 369 CERTRecordContent::report(); 409 370 NSECRecordContent::report(); 371 NSEC3RecordContent::report(); 372 NSEC3PARAMRecordContent::report(); 410 373 DNSRecordContent::regist(0xff, QType::TSIG, &TSIGRecordContent::make, &TSIGRecordContent::make, "TSIG"); 411 374 OPTRecordContent::report(); -
trunk/pdns/pdns/dnsrecords.hh
r1526 r1555 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2005 - 200 7PowerDNS.COM BV3 Copyright (C) 2005 - 2009 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 228 228 { 229 229 public: 230 DNSKEYRecordContent(); 230 231 includeboilerplate(DNSKEY) 231 232 private: 232 uint16_t getTag(); 233 string getExponent() const; 234 string getModulus() const; 235 233 236 uint16_t d_flags; 234 237 uint8_t d_protocol; 235 238 uint8_t d_algorithm; 236 239 string d_key; 240 private: 241 void getExpLen(uint16_t& startPos, uint16_t& expLen) const; 237 242 }; 238 243 … … 240 245 { 241 246 public: 247 DSRecordContent(); 242 248 includeboilerplate(DS) 243 249 244 private:245 250 uint16_t d_tag; 246 251 uint8_t d_algorithm, d_digesttype; … … 294 299 { 295 300 public: 301 RRSIGRecordContent(); 296 302 includeboilerplate(RRSIG) 297 303 298 private:299 304 uint16_t d_type; 300 305 uint8_t d_algorithm, d_labels; … … 329 334 }; 330 335 331 class HIPRecordContent : public DNSRecordContent332 {333 public:334 includeboilerplate(HIP)335 HIPRecordContent(uint8_t algorithm, const string& hit, const string& key);336 };337 338 339 336 class NSECRecordContent : public DNSRecordContent 340 337 { … … 353 350 private: 354 351 }; 352 353 class NSEC3RecordContent : public DNSRecordContent 354 { 355 public: 356 static void report(void); 357 NSEC3RecordContent() : DNSRecordContent(50) 358 {} 359 NSEC3RecordContent(const string& content, const string& zone=""); 360 361 static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); 362 static DNSRecordContent* make(const string& content); 363 string getZoneRepresentation() const; 364 void toPacket(DNSPacketWriter& pw); 365 366 uint8_t d_algorithm, d_flags; 367 uint16_t d_iterations; 368 uint8_t d_saltlength; 369 string d_salt; 370 uint8_t d_nexthashlength; 371 string d_nexthash; 372 std::set<uint16_t> d_set; 373 374 private: 375 }; 376 377 378 class NSEC3PARAMRecordContent : public DNSRecordContent 379 { 380 public: 381 includeboilerplate(NSEC3PARAM) 382 383 uint8_t d_algorithm, d_flags; 384 uint16_t d_iterations; 385 uint8_t d_saltlength; 386 string d_salt; 387 }; 388 355 389 356 390 class LOCRecordContent : public DNSRecordContent -
trunk/pdns/pdns/nsecrecords.cc
r1472 r1555 68 68 for(int bit = 0; bit < 8 ; ++bit , val>>=1) 69 69 if(val & 1) { 70 ret->d_set.insert((7-bit) + 8*(n));70 ret->d_set.insert((7-bit) + 8*(n)); 71 71 } 72 72 } … … 182 182 for(int bit = 0; bit < 8 ; ++bit , val>>=1) 183 183 if(val & 1) { 184 ret->d_set.insert((7-bit) + 8*(n));184 ret->d_set.insert((7-bit) + 8*(n)); 185 185 } 186 186 } … … 198 198 199 199 rtw.xfrHexBlob(d_salt); 200 rtw.xfr HexBlob(d_nexthash);200 rtw.xfrBase32HexBlob(d_nexthash); 201 201 202 202 for(set<uint16_t>::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) { … … 210 210 211 211 boilerplate_conv(NSEC3PARAM, 51, 212 conv.xfr8BitInt(d_algorithm);213 conv.xfr8BitInt(d_flags);214 conv.xfr16BitInt(d_iterations);215 conv.xfr8BitInt(d_saltlength);216 conv.xfrHexBlob(d_salt);217 )212 conv.xfr8BitInt(d_algorithm); 213 conv.xfr8BitInt(d_flags); 214 conv.xfr16BitInt(d_iterations); 215 conv.xfr8BitInt(d_saltlength); 216 conv.xfrHexBlob(d_salt); 217 ) -
trunk/pdns/pdns/rcpgenerator.cc
r1547 r1555 23 23 #include <boost/algorithm/string.hpp> 24 24 #include <iostream> 25 #include "base32.hh" 25 26 #include "base64.hh" 26 27 #include "namespaces.hh" … … 244 245 HEXDecode(d_string.c_str()+pos, d_string.c_str() + d_pos, val); 245 246 } 247 248 void RecordTextWriter::xfrBase32HexBlob(const string& val) 249 { 250 if(!d_string.empty()) 251 d_string.append(1,' '); 252 253 d_string.append(toBase32Hex(val)); 254 } 255 246 256 247 257 void RecordTextReader::xfrText(string& val, bool multi) -
trunk/pdns/pdns/rcpgenerator.hh
r1440 r1555 55 55 void xfrText(string& val, bool multi=false); 56 56 void xfrHexBlob(string& val); 57 58 57 59 void xfrBlob(string& val, int len=-1); 58 60 … … 76 78 void xfrIP(const uint32_t& val); 77 79 void xfrTime(const uint32_t& val); 80 void xfrBase32HexBlob(const string& val); 78 81 79 82 void xfrType(const uint16_t& val);