Changeset 1370
- Timestamp:
- 07/12/09 21:17:22 (4 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 2 modified
-
dnswriter.cc (modified) (4 diffs)
-
dnswriter.hh (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnswriter.cc
r1353 r1370 7 7 8 8 DNSPacketWriter::DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) 9 : d_pos(0), d_content(content), d_qname(qname), d_qtype(qtype), d_qclass(qclass) 9 : d_pos(0), d_content(content), d_qname(qname), d_qtype(qtype), d_qclass(qclass), d_canonic(false) 10 10 { 11 11 d_content.clear(); … … 200 200 parts_t parts; 201 201 202 if(label.size()==1 && label[0]=='.') { // otherwise we encode '..' 202 if(d_canonic) 203 compress=false; 204 205 string::size_type labellen = label.size(); 206 if(labellen==1 && label[0]=='.') { // otherwise we encode '..' 203 207 d_record.push_back(0); 204 208 return; … … 210 214 unsigned int pos=d_content.size() + d_record.size() + d_stuff; 211 215 string chopped; 216 bool deDot = labellen && (label[labellen-1]=='.'); // make sure we don't store trailing dots in the labelmap 217 212 218 for(parts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { 213 chopped.assign(label.c_str() + i->first); 219 if(deDot) 220 chopped.assign(label.c_str() + i->first, labellen - i->first -1); 221 else 222 chopped.assign(label.c_str() + i->first); 223 214 224 lmap_t::iterator li=d_labelmap.end(); 215 225 // see if we've written out this domain before 226 // cerr<<"Searching for compression pointer to '"<<chopped<<"', "<<d_labelmap.size()<<" cmp-records"<<endl; 216 227 if(compress && (li=find(d_labelmap, chopped))!=d_labelmap.end()) { 228 // cerr<<"\tFound a compression pointer to '"<<chopped<<"': "<<li->second<<endl; 217 229 uint16_t offset=li->second; 218 230 offset|=0xc000; … … 222 234 } 223 235 224 if(li==d_labelmap.end() && pos< 16384) 236 if(li==d_labelmap.end() && pos< 16384) { 237 // cerr<<"\tStoring a compression pointer to '"<<chopped<<"': "<<pos<<endl; 225 238 d_labelmap.push_back(make_pair(chopped, pos)); // if untrue, we need to count - also, don't store offsets > 16384, won't work 239 } 226 240 227 241 if(unescaped) { -
trunk/pdns/pdns/dnswriter.hh
r1359 r1370 39 39 */ 40 40 41 class DNSPacketWriter 41 class DNSPacketWriter : public boost::noncopyable 42 42 { 43 43 … … 96 96 const vector<uint8_t>& getRecordBeingWritten() { return d_record; } 97 97 98 void setCanonic(bool val) 99 { 100 d_canonic=val; 101 } 102 98 103 private: 99 104 vector <uint8_t>& d_content; … … 109 114 uint16_t d_rollbackmarker; // start of last complete packet, for rollback 110 115 Place d_recordplace; 116 bool d_canonic; 111 117 }; 112 118 #endif