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

« back to all changes in this revision

Viewing changes to pdns/dnsrecords.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Mohlmann, Matthijs Mohlmann, Christoph Haas
  • Date: 2007-04-15 23:23:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070415232339-5x3scc8gx04e50um
Tags: 2.9.21-1
[ Matthijs Mohlmann ]
* New upstream release. (Closes: #420294)
* Remove meta pdns package.
* Added new sqlite3 backend package.
* Months and minutes where mixed up. (Closes: #406462)
* Case sensitivity in bind backend caused PowerDNS to not serve a certain
  zone. (Closes: #406461)
* Bind backend forgot about zones on a notify. (Closes: #398213)

[ Christoph Haas ]
* Documented incorporated backend bind. (Closes: #415471)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    PowerDNS Versatile Database Driven Nameserver
3
 
    Copyright (C) 2005  PowerDNS.COM BV
 
3
    Copyright (C) 2005 - 2007  PowerDNS.COM BV
4
4
 
5
5
    This program is free software; you can redistribute it and/or modify
6
6
    it under the terms of the GNU General Public License version 2 as 
13
13
 
14
14
    You should have received a copy of the GNU General Public License
15
15
    along with this program; if not, write to the Free Software
16
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
*/
18
18
 
 
19
#include "utility.hh"
19
20
#include "dnsrecords.hh"
20
21
 
21
22
boilerplate_conv(A, ns_t_a, conv.xfrIP(d_ip));
22
23
 
 
24
uint32_t ARecordContent::getIP() const
 
25
{
 
26
  return d_ip;
 
27
}
 
28
 
23
29
void ARecordContent::doRecordCheck(const DNSRecord& dr)
24
30
{  
25
31
  if(dr.d_clen!=4)
26
 
    throw MOADNSException("Wrong size for A record");
 
32
    throw MOADNSException("Wrong size for A record ("+lexical_cast<string>(dr.d_clen)+")");
27
33
}
28
34
 
29
35
class AAAARecordContent : public DNSRecordContent
63
69
  
64
70
  string getZoneRepresentation() const
65
71
  {
66
 
    ostringstream str;
67
 
 
68
 
    char hex[4];
69
 
    for(size_t n=0; n< 16 ; n+=2) {
70
 
      snprintf(hex,sizeof(hex)-1, "%x", d_ip6[n]);
71
 
      str << hex;
72
 
      snprintf(hex,sizeof(hex)-1, "%02x", d_ip6[n+1]);
73
 
      str << hex;
74
 
      if(n!=14)
75
 
        str<<":";
76
 
    }
77
 
 
78
 
    return str.str();
 
72
    struct sockaddr_in6 addr;
 
73
    memset(&addr, 0, sizeof(addr));
 
74
    addr.sin6_family=AF_INET6;
 
75
    memcpy(&addr.sin6_addr, d_ip6, 16);
 
76
 
 
77
    char tmp[128];
 
78
    tmp[0]=0;
 
79
    Utility::inet_ntop(AF_INET6, (const char*)& addr.sin6_addr, tmp, sizeof(tmp));
 
80
    return tmp;
79
81
  }
80
82
 
81
83
private:
171
173
  return ret;
172
174
}
173
175
 
174
 
 
175
 
 
176
176
boilerplate_conv(NS, ns_t_ns, conv.xfrLabel(d_content, true));
177
177
boilerplate_conv(PTR, ns_t_ptr, conv.xfrLabel(d_content, true));
178
178
boilerplate_conv(CNAME, ns_t_cname, conv.xfrLabel(d_content, true));
179
 
boilerplate_conv(TXT, ns_t_txt, conv.xfrText(d_text));
180
 
boilerplate_conv(SPF, 99, conv.xfrText(d_text));
 
179
boilerplate_conv(MR, ns_t_mr, conv.xfrLabel(d_alias, false));
 
180
boilerplate_conv(TXT, ns_t_txt, conv.xfrText(d_text, true));
 
181
boilerplate_conv(SPF, 99, conv.xfrText(d_text, true));
181
182
boilerplate_conv(HINFO, ns_t_hinfo,  conv.xfrText(d_cpu);   conv.xfrText(d_host));
182
183
 
183
184
boilerplate_conv(RP, ns_t_rp,
199
200
                 conv.xfrLabel(d_mxname, true);
200
201
                 )
201
202
 
 
203
boilerplate_conv(AFSDB, ns_t_afsdb, 
 
204
                 conv.xfr16BitInt(d_subtype);
 
205
                 conv.xfrLabel(d_hostname);
 
206
                 )
 
207
 
202
208
 
203
209
boilerplate_conv(NAPTR, ns_t_naptr,
204
210
                 conv.xfr16BitInt(d_order);    conv.xfr16BitInt(d_preference);
207
213
                 )
208
214
 
209
215
 
210
 
 
211
216
SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target) 
212
217
  : DNSRecordContent(ns_t_srv), d_preference(preference), d_weight(weight), d_port(port), d_target(target)
213
218
{}
234
239
                 conv.xfr32BitInt(d_st.expire);
235
240
                 conv.xfr32BitInt(d_st.minimum);
236
241
                 );
237
 
 
238
 
 
 
242
#undef KEY
 
243
boilerplate_conv(KEY, ns_t_key, 
 
244
                 conv.xfr16BitInt(d_flags); 
 
245
                 conv.xfr8BitInt(d_protocol); 
 
246
                 conv.xfr8BitInt(d_algorithm); 
 
247
                 conv.xfrBlob(d_certificate);
 
248
                 );
 
249
 
 
250
boilerplate_conv(CERT, 37, 
 
251
                 conv.xfr16BitInt(d_type); 
 
252
                 conv.xfr16BitInt(d_tag); 
 
253
                 conv.xfr8BitInt(d_algorithm); 
 
254
                 conv.xfrBlob(d_certificate);
 
255
                 )
 
256
#undef DS
239
257
boilerplate_conv(DS, 43, 
240
258
                 conv.xfr16BitInt(d_tag); 
241
259
                 conv.xfr8BitInt(d_algorithm); 
242
260
                 conv.xfr8BitInt(d_digesttype); 
243
 
                 conv.xfrBlob(d_digest);
 
261
                 conv.xfrHexBlob(d_digest);
 
262
                 )
 
263
 
 
264
boilerplate_conv(SSHFP, 44, 
 
265
                 conv.xfr8BitInt(d_algorithm); 
 
266
                 conv.xfr8BitInt(d_fptype); 
 
267
                 conv.xfrHexBlob(d_fingerprint);
244
268
                 )
245
269
 
246
270
boilerplate_conv(RRSIG, 46, 
265
289
 
266
290
void reportBasicTypes()
267
291
{
268
 
    ARecordContent::report();
269
 
    AAAARecordContent::report();
270
 
    NSRecordContent::report();
271
 
    CNAMERecordContent::report();
272
 
    MXRecordContent::report();
273
 
    SOARecordContent::report();
274
 
    SRVRecordContent::report();
275
 
    PTRRecordContent::report();
 
292
  ARecordContent::report();
 
293
  AAAARecordContent::report();
 
294
  NSRecordContent::report();
 
295
  CNAMERecordContent::report();
 
296
  MXRecordContent::report();
 
297
  SOARecordContent::report();
 
298
  SRVRecordContent::report();
 
299
  PTRRecordContent::report();
 
300
  DNSRecordContent::regist(3, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT");
 
301
  TXTRecordContent::report();
 
302
  DNSRecordContent::regist(1, 255, 0, 0, "ANY");
276
303
}
277
304
 
278
305
void reportOtherTypes()
279
306
{
280
 
   TXTRecordContent::report();
 
307
   AFSDBRecordContent::report();
281
308
   SPFRecordContent::report();
282
309
   NAPTRRecordContent::report();
 
310
   LOCRecordContent::report();
 
311
   HINFORecordContent::report();
283
312
   RPRecordContent::report();
 
313
   KEYRecordContent::report();
284
314
   DNSKEYRecordContent::report();
285
315
   RRSIGRecordContent::report();
286
316
   DSRecordContent::report();
 
317
   SSHFPRecordContent::report();
 
318
   CERTRecordContent::report();
287
319
   NSECRecordContent::report();
288
320
   OPTRecordContent::report();
289
 
   DNSRecordContent::regist(1,255, 0, 0, "ANY");
290
321
}
291
322
 
292
323
void reportAllTypes()