Changeset 514 for trunk/pdns/pdns/dnswriter.cc
- Timestamp:
- 10/10/05 21:42:06 (8 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/dnswriter.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnswriter.cc
r513 r514 27 27 ptr=(const uint8_t*)&qclass; 28 28 d_content.insert(d_content.end(), ptr, ptr+2); 29 30 d_stuff=0xffff; 29 31 } 30 32 … … 34 36 } 35 37 36 void DNSPacketWriter::setRD(bool rd)37 {38 dnsheader* dh=reinterpret_cast<dnsheader*>( &*d_content.begin());39 dh->rd=rd;40 }41 38 42 39 void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place) … … 57 54 58 55 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 59 57 60 58 dnsheader* dh=reinterpret_cast<dnsheader*>( &*d_content.begin()); … … 95 93 void DNSPacketWriter::xfr32BitInt(uint32_t val) 96 94 { 97 uint8_t* ptr=reinterpret_cast<uint8_t*>(&val); 95 int rval=htonl(val); 96 uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval); 98 97 d_record.insert(d_record.end(), ptr, ptr+4); 99 98 } … … 101 100 void DNSPacketWriter::xfr16BitInt(uint16_t val) 102 101 { 103 uint8_t* ptr=reinterpret_cast<uint8_t*>(&val); 102 int rval=htons(val); 103 uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval); 104 104 d_record.insert(d_record.end(), ptr, ptr+2); 105 105 } … … 160 160 } 161 161 162 void DNSPacketWriter::getRecords(string& records) 163 { 164 records.assign(d_content.begin() + d_sor, d_content.end()); 165 } 162 166 163 167 void DNSPacketWriter::commit() 164 168 { 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"); 165 171 // build dnsrecordheader 166 172 struct dnsrecordheader drh;