~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to pdns/dnswriter.cc

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Haas
  • Date: 2009-02-25 23:25:51 UTC
  • mfrom: (1.1.7 upstream) (12.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090225232551-ts3d9k9q0ti442i9
Tags: 2.9.22-1
New upstream version (closes: #513409).

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
  d_stuff = 0; 
68
68
  d_rollbackmarker=d_content.size();
69
69
 
70
 
  if(d_qname == d_recordqname) {  // don't do the whole label compression thing if we *know* we can get away with "see question"
 
70
  if(!strcasecmp(d_qname.c_str(), d_recordqname.c_str())) {  // don't do the whole label compression thing if we *know* we can get away with "see question"
71
71
    static char marker[2]={0xc0, 0x0c};
72
72
    d_content.insert(d_content.end(), &marker[0], &marker[2]);
73
73
  }
81
81
  d_sor=d_content.size() + d_stuff; // start of real record 
82
82
}
83
83
 
84
 
void DNSPacketWriter::addOpt(int udpsize, int extRCode, int Z)
 
84
void DNSPacketWriter::addOpt(int udpsize, int extRCode, int Z, const vector<pair<uint16_t,string> >& options)
85
85
{
86
86
  uint32_t ttl=0;
87
87
 
90
90
  stuff.extRCode=extRCode;
91
91
  stuff.version=0;
92
92
  stuff.Z=htons(Z);
93
 
  
 
93
 
94
94
  memcpy(&ttl, &stuff, sizeof(stuff));
95
95
 
96
96
  ttl=ntohl(ttl); // will be reversed later on
97
97
  
98
98
  startRecord("", ns_t_opt, ttl, udpsize, ADDITIONAL);
99
 
}
 
99
  for(optvect_t::const_iterator iter = options.begin(); iter != options.end(); ++iter) {
 
100
    xfr16BitInt(iter->first);
 
101
    xfr16BitInt(iter->second.length());
 
102
    xfrBlob(iter->second);
 
103
  } 
 
104
}
 
105
 
 
106
void DNSPacketWriter::xfr48BitInt(uint64_t val)
 
107
{
 
108
  unsigned char bytes[6];
 
109
  bytes[5] = val % 0xff; val /= 0xff;  // untested code! XXX FIXME
 
110
  bytes[4] = val % 0xff; val /= 0xff;
 
111
  bytes[3] = val % 0xff; val /= 0xff;
 
112
  bytes[2] = val % 0xff; val /= 0xff;
 
113
  bytes[1] = val % 0xff; val /= 0xff;
 
114
  bytes[0] = val % 0xff; val /= 0xff;
 
115
 
 
116
  d_record.insert(d_record.end(), bytes, bytes + 6);
 
117
}
 
118
 
100
119
 
101
120
void DNSPacketWriter::xfr32BitInt(uint32_t val)
102
121
{
139
158
{
140
159
  DNSPacketWriter::lmap_t::iterator ret;
141
160
  for(ret=lmap.begin(); ret != lmap.end(); ++ret)
142
 
    if(ret->first == label)
 
161
    if(!strcasecmp(ret->first.c_str() ,label.c_str()))
143
162
      break;
144
163
  return ret;
145
164
}
224
243
 out:;
225
244
}
226
245
 
227
 
void DNSPacketWriter::xfrBlob(const string& blob)
 
246
void DNSPacketWriter::xfrBlob(const string& blob, int  )
228
247
{
229
248
  const uint8_t* ptr=reinterpret_cast<const uint8_t*>(blob.c_str());
230
249
 
271
290
 
272
291
  d_stuff=0;
273
292
 
274
 
  // write out d_record
 
293
  // write out pending d_record
275
294
  d_content.insert(d_content.end(), d_record.begin(), d_record.end());
276
295
 
277
296
  dnsheader* dh=reinterpret_cast<dnsheader*>( &*d_content.begin());