Show
Ignore:
Timestamp:
10/10/05 21:42:06 (8 years ago)
Author:
ahu
Message:

the gist is: move pdns_recursor over to new {zone,packet}-{parser,generator} stuff
this means the pdns_recursor does not use DNSPacket anymore (yay)
Commit adds:

d_qtype storage to all DNSRecordContent classes
infrastructure to extract *only* the record for a packet, assuming it came with a qname
add reportAllTypes() if you want to be able to parse all types,

reportBasicTypes() for the pdns_recursor
reportOtherTypes() if you want the rest too

updates Makefile.am so everything compiles again
fix endian issues in packetwriter/parser

remove virtualness/inheritance from the pdns_recursor storage cache (teeny speedup)

Things might be a bit scary in the recursor now.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnswriter.cc

    r513 r514  
    2727  ptr=(const uint8_t*)&qclass; 
    2828  d_content.insert(d_content.end(), ptr, ptr+2); 
     29 
     30  d_stuff=0xffff; 
    2931} 
    3032 
     
    3436} 
    3537 
    36 void DNSPacketWriter::setRD(bool rd) 
    37 { 
    38   dnsheader* dh=reinterpret_cast<dnsheader*>( &*d_content.begin()); 
    39   dh->rd=rd; 
    40 } 
    4138 
    4239void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place) 
     
    5754 
    5855  d_stuff = sizeof(dnsrecordheader); // this is needed to get compressed label offsets right, the dnsrecordheader will be interspersed 
     56  d_sor=d_content.size() + d_stuff; // start of real record  
    5957 
    6058  dnsheader* dh=reinterpret_cast<dnsheader*>( &*d_content.begin()); 
     
    9593void DNSPacketWriter::xfr32BitInt(uint32_t val) 
    9694{ 
    97   uint8_t* ptr=reinterpret_cast<uint8_t*>(&val); 
     95  int rval=htonl(val); 
     96  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval); 
    9897  d_record.insert(d_record.end(), ptr, ptr+4); 
    9998} 
     
    101100void DNSPacketWriter::xfr16BitInt(uint16_t val) 
    102101{ 
    103   uint8_t* ptr=reinterpret_cast<uint8_t*>(&val); 
     102  int rval=htons(val); 
     103  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval); 
    104104  d_record.insert(d_record.end(), ptr, ptr+2); 
    105105} 
     
    160160} 
    161161 
     162void DNSPacketWriter::getRecords(string& records) 
     163{ 
     164  records.assign(d_content.begin() + d_sor, d_content.end()); 
     165} 
    162166 
    163167void DNSPacketWriter::commit() 
    164168{ 
     169  if(d_stuff==0xffff && (d_content.size()!=d_sor || !d_record.empty())) 
     170    throw MOADNSException("DNSPacketWriter::commit() called without startRecord ever having been called, but a record was added"); 
    165171  // build dnsrecordheader 
    166172  struct dnsrecordheader drh;