Kea  1.9.9-git
rrtype.h
Go to the documentation of this file.
1 
8 // Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC")
9 //
10 // This Source Code Form is subject to the terms of the Mozilla Public
11 // License, v. 2.0. If a copy of the MPL was not distributed with this
12 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 
14 #ifndef RRTYPE_H
15 #define RRTYPE_H 1
16 
17 #include <stdint.h>
18 
19 #include <string>
20 #include <ostream>
21 
22 #include <dns/exceptions.h>
23 
24 // Solaris x86 defines DS in <sys/regset.h>, which gets pulled in by Boost
25 #if defined(__sun) && defined(DS)
26 # undef DS
27 #endif
28 
29 namespace isc {
30 namespace util {
31 class InputBuffer;
32 class OutputBuffer;
33 }
34 
35 namespace dns {
36 
37 // forward declarations
38 class AbstractMessageRenderer;
39 
44 class InvalidRRType : public DNSTextError {
45 public:
46  InvalidRRType(const char* file, size_t line, const char* what) :
47  DNSTextError(file, line, what) {}
48 };
49 
55 public:
56  IncompleteRRType(const char* file, size_t line, const char* what) :
57  isc::dns::Exception(file, line, what) {}
58 };
59 
106 class RRType {
107 public:
111 
112  explicit RRType(uint16_t typecode) : typecode_(typecode) {}
144  explicit RRType(const std::string& typestr);
155  explicit RRType(isc::util::InputBuffer& buffer);
158 
159 
165 
166  const std::string toText() const;
189  void toWire(AbstractMessageRenderer& renderer) const;
199  void toWire(isc::util::OutputBuffer& buffer) const;
201 
205 
206  uint16_t getCode() const { return (typecode_); }
213 
217 
218  bool equals(const RRType& other) const
227  { return (typecode_ == other.typecode_); }
229  bool operator==(const RRType& other) const { return (equals(other)); }
230 
237  bool nequals(const RRType& other) const
238  { return (typecode_ != other.typecode_); }
240  bool operator!=(const RRType& other) const { return (nequals(other)); }
241 
257  bool operator<(const RRType& other) const
258  { return (typecode_ < other.typecode_); }
260 
261  // BEGIN_WELL_KNOWN_TYPE_DECLARATIONS
262  static const RRType& TSIG();
263  static const RRType& A();
264  static const RRType& AFSDB();
265  static const RRType& CAA();
266  static const RRType& CNAME();
267  static const RRType& DLV();
268  static const RRType& DNAME();
269  static const RRType& DNSKEY();
270  static const RRType& DS();
271  static const RRType& HINFO();
272  static const RRType& MINFO();
273  static const RRType& MX();
274  static const RRType& NAPTR();
275  static const RRType& NS();
276  static const RRType& NSEC3();
277  static const RRType& NSEC3PARAM();
278  static const RRType& NSEC();
279  static const RRType& OPT();
280  static const RRType& PTR();
281  static const RRType& RP();
282  static const RRType& RRSIG();
283  static const RRType& SOA();
284  static const RRType& SPF();
285  static const RRType& SSHFP();
286  static const RRType& TKEY();
287  static const RRType& TLSA();
288  static const RRType& TXT();
289  static const RRType& AAAA();
290  static const RRType& DHCID();
291  static const RRType& SRV();
292  static const RRType& IXFR();
293  static const RRType& AXFR();
294  static const RRType& ANY();
295  static const RRType& MD();
296  static const RRType& MF();
297  static const RRType& MB();
298  static const RRType& MG();
299  static const RRType& MR();
300  static const RRType& NXT();
301  static const RRType& A6();
302  static const RRType& MAILA();
303  static const RRType& Null();
304  static const RRType& WKS();
305  static const RRType& X25();
306  static const RRType& RT();
307  static const RRType& NSAP();
308  static const RRType& NSAP_PTR();
309  static const RRType& SIG();
310  static const RRType& ISDN();
311  static const RRType& KEY();
312  static const RRType& PX();
313  static const RRType& GPOS();
314  static const RRType& LOC();
315  static const RRType& KX();
316  static const RRType& CERT();
317  static const RRType& APL();
318  static const RRType& IPSECKEY();
319  static const RRType& HIP();
320  static const RRType& UNSPEC();
321  static const RRType& NID();
322  static const RRType& L32();
323  static const RRType& L64();
324  static const RRType& LP();
325  static const RRType& MAILB();
326  static const RRType& URI();
327  // END_WELL_KNOWN_TYPE_DECLARATIONS
328 
329 private:
330  uint16_t typecode_;
331 };
332 
333 // BEGIN_WELL_KNOWN_TYPE_DEFINITIONS
334 inline const RRType&
336  static RRType rrtype(250);
337  return (rrtype);
338 }
339 
340 inline const RRType&
342  static RRType rrtype(1);
343  return (rrtype);
344 }
345 
346 inline const RRType&
348  static RRType rrtype(18);
349  return (rrtype);
350 }
351 
352 inline const RRType&
354  static RRType rrtype(257);
355  return (rrtype);
356 }
357 
358 inline const RRType&
360  static RRType rrtype(5);
361  return (rrtype);
362 }
363 
364 inline const RRType&
366  static RRType rrtype(32769);
367  return (rrtype);
368 }
369 
370 inline const RRType&
372  static RRType rrtype(39);
373  return (rrtype);
374 }
375 
376 inline const RRType&
378  static RRType rrtype(48);
379  return (rrtype);
380 }
381 
382 inline const RRType&
384  static RRType rrtype(43);
385  return (rrtype);
386 }
387 
388 inline const RRType&
390  static RRType rrtype(13);
391  return (rrtype);
392 }
393 
394 inline const RRType&
396  static RRType rrtype(14);
397  return (rrtype);
398 }
399 
400 inline const RRType&
402  static RRType rrtype(15);
403  return (rrtype);
404 }
405 
406 inline const RRType&
408  static RRType rrtype(35);
409  return (rrtype);
410 }
411 
412 inline const RRType&
414  static RRType rrtype(2);
415  return (rrtype);
416 }
417 
418 inline const RRType&
420  static RRType rrtype(50);
421  return (rrtype);
422 }
423 
424 inline const RRType&
426  static RRType rrtype(51);
427  return (rrtype);
428 }
429 
430 inline const RRType&
432  static RRType rrtype(47);
433  return (rrtype);
434 }
435 
436 inline const RRType&
438  static RRType rrtype(41);
439  return (rrtype);
440 }
441 
442 inline const RRType&
444  static RRType rrtype(12);
445  return (rrtype);
446 }
447 
448 inline const RRType&
450  static RRType rrtype(17);
451  return (rrtype);
452 }
453 
454 inline const RRType&
456  static RRType rrtype(46);
457  return (rrtype);
458 }
459 
460 inline const RRType&
462  static RRType rrtype(6);
463  return (rrtype);
464 }
465 
466 inline const RRType&
468  static RRType rrtype(99);
469  return (rrtype);
470 }
471 
472 inline const RRType&
474  static RRType rrtype(44);
475  return (rrtype);
476 }
477 
478 inline const RRType&
480  static RRType rrtype(249);
481  return (rrtype);
482 }
483 
484 inline const RRType&
486  static RRType rrtype(52);
487  return (rrtype);
488 }
489 
490 inline const RRType&
492  static RRType rrtype(16);
493  return (rrtype);
494 }
495 
496 inline const RRType&
498  static RRType rrtype(28);
499  return (rrtype);
500 }
501 
502 inline const RRType&
504  static RRType rrtype(49);
505  return (rrtype);
506 }
507 
508 inline const RRType&
510  static RRType rrtype(33);
511  return (rrtype);
512 }
513 
514 inline const RRType&
516  static RRType rrtype(251);
517  return (rrtype);
518 }
519 
520 inline const RRType&
522  static RRType rrtype(252);
523  return (rrtype);
524 }
525 
526 inline const RRType&
528  static RRType rrtype(255);
529  return (rrtype);
530 }
531 
532 inline const RRType&
534  static RRType rrtype(3);
535  return (rrtype);
536 }
537 
538 inline const RRType&
540  static RRType rrtype(4);
541  return (rrtype);
542 }
543 
544 inline const RRType&
546  static RRType rrtype(7);
547  return (rrtype);
548 }
549 
550 inline const RRType&
552  static RRType rrtype(8);
553  return (rrtype);
554 }
555 
556 inline const RRType&
558  static RRType rrtype(9);
559  return (rrtype);
560 }
561 
562 inline const RRType&
564  static RRType rrtype(30);
565  return (rrtype);
566 }
567 
568 inline const RRType&
570  static RRType rrtype(38);
571  return (rrtype);
572 }
573 
574 inline const RRType&
576  static RRType rrtype(254);
577  return (rrtype);
578 }
579 
580 inline const RRType&
582  static RRType rrtype(10);
583  return (rrtype);
584 }
585 
586 inline const RRType&
588  static RRType rrtype(11);
589  return (rrtype);
590 }
591 
592 inline const RRType&
594  static RRType rrtype(19);
595  return (rrtype);
596 }
597 
598 inline const RRType&
600  static RRType rrtype(21);
601  return (rrtype);
602 }
603 
604 inline const RRType&
606  static RRType rrtype(22);
607  return (rrtype);
608 }
609 
610 inline const RRType&
612  static RRType rrtype(23);
613  return (rrtype);
614 }
615 
616 inline const RRType&
618  static RRType rrtype(24);
619  return (rrtype);
620 }
621 
622 inline const RRType&
624  static RRType rrtype(20);
625  return (rrtype);
626 }
627 
628 inline const RRType&
630  static RRType rrtype(25);
631  return (rrtype);
632 }
633 
634 inline const RRType&
636  static RRType rrtype(26);
637  return (rrtype);
638 }
639 
640 inline const RRType&
642  static RRType rrtype(27);
643  return (rrtype);
644 }
645 
646 inline const RRType&
648  static RRType rrtype(29);
649  return (rrtype);
650 }
651 
652 inline const RRType&
654  static RRType rrtype(36);
655  return (rrtype);
656 }
657 
658 inline const RRType&
660  static RRType rrtype(37);
661  return (rrtype);
662 }
663 
664 inline const RRType&
666  static RRType rrtype(42);
667  return (rrtype);
668 }
669 
670 inline const RRType&
672  static RRType rrtype(45);
673  return (rrtype);
674 }
675 
676 inline const RRType&
678  static RRType rrtype(55);
679  return (rrtype);
680 }
681 
682 inline const RRType&
684  static RRType rrtype(103);
685  return (rrtype);
686 }
687 
688 inline const RRType&
690  static RRType rrtype(104);
691  return (rrtype);
692 }
693 
694 inline const RRType&
696  static RRType rrtype(105);
697  return (rrtype);
698 }
699 
700 inline const RRType&
702  static RRType rrtype(106);
703  return (rrtype);
704 }
705 
706 inline const RRType&
708  static RRType rrtype(107);
709  return (rrtype);
710 }
711 
712 inline const RRType&
714  static RRType rrtype(253);
715  return (rrtype);
716 }
717 
718 inline const RRType&
720  static RRType rrtype(256);
721  return (rrtype);
722 }
723 
724 // END_WELL_KNOWN_TYPE_DEFINITIONS
725 
740 std::ostream&
741 operator<<(std::ostream& os, const RRType& rrtype);
742 }
743 }
744 #endif // RRTYPE_H
745 
746 // Local Variables:
747 // mode: c++
748 // End:
static const RRType & A6()
Definition: rrtype.h:569
static const RRType & DLV()
Definition: rrtype.h:365
static const RRType & DHCID()
Definition: rrtype.h:503
static const RRType & DS()
Definition: rrtype.h:383
bool operator!=(const RRType &other) const
Same as nequals().
Definition: rrtype.h:240
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
Base class for all sorts of text parse errors.
static const RRType & DNSKEY()
Definition: rrtype.h:377
static const RRType & TSIG()
Definition: rrtype.h:335
static const RRType & RP()
Definition: rrtype.h:449
static const RRType & PTR()
Definition: rrtype.h:443
static const RRType & CNAME()
Definition: rrtype.h:359
static const RRType & MR()
Definition: rrtype.h:557
static const RRType & TXT()
Definition: rrtype.h:491
static const RRType & HIP()
Definition: rrtype.h:677
static const RRType & NSEC3PARAM()
Definition: rrtype.h:425
static const RRType & MB()
Definition: rrtype.h:545
static const RRType & SOA()
Definition: rrtype.h:461
A standard DNS module exception that is thrown if an RRType object is being constructed from a incomp...
Definition: rrtype.h:54
static const RRType & X25()
Definition: rrtype.h:593
static const RRType & TKEY()
Definition: rrtype.h:479
uint16_t getCode() const
Returns the RR type code as a 16-bit unsigned integer.
Definition: rrtype.h:211
static const RRType & IXFR()
Definition: rrtype.h:515
static const RRType & RRSIG()
Definition: rrtype.h:455
static const RRType & OPT()
Definition: rrtype.h:437
static const RRType & NS()
Definition: rrtype.h:413
bool operator<(const RRType &other) const
Less-than comparison for RRType against other.
Definition: rrtype.h:257
InvalidRRType(const char *file, size_t line, const char *what)
Definition: rrtype.h:46
static const RRType & CAA()
Definition: rrtype.h:353
static const RRType & Null()
Definition: rrtype.h:581
const std::string toText() const
Convert the RRType to a string.
Definition: rrtype.cc:45
static const RRType & MX()
Definition: rrtype.h:401
static const RRType & NSEC3()
Definition: rrtype.h:419
static const RRType & KX()
Definition: rrtype.h:653
IncompleteRRType(const char *file, size_t line, const char *what)
Definition: rrtype.h:56
static const RRType & NSEC()
Definition: rrtype.h:431
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
static const RRType & GPOS()
Definition: rrtype.h:641
static const RRType & MAILB()
Definition: rrtype.h:713
static const RRType & SRV()
Definition: rrtype.h:509
static const RRType & A()
Definition: rrtype.h:341
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
Definition: rrtype.cc:55
static const RRType & MF()
Definition: rrtype.h:539
static const RRType & NID()
Definition: rrtype.h:689
RRType(uint16_t typecode)
Constructor from an integer type code.
Definition: rrtype.h:117
static const RRType & UNSPEC()
Definition: rrtype.h:683
static const RRType & ISDN()
Definition: rrtype.h:623
static const RRType & KEY()
Definition: rrtype.h:629
static const RRType & TLSA()
Definition: rrtype.h:485
static const RRType & SIG()
Definition: rrtype.h:617
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
static const RRType & MD()
Definition: rrtype.h:533
static const RRType & NXT()
Definition: rrtype.h:563
static const RRType & NSAP_PTR()
Definition: rrtype.h:611
Defines the logger used by the top-level component of kea-dhcp-ddns.
static const RRType & APL()
Definition: rrtype.h:665
static const RRType & CERT()
Definition: rrtype.h:659
static const RRType & PX()
Definition: rrtype.h:635
static const RRType & MINFO()
Definition: rrtype.h:395
static const RRType & LOC()
Definition: rrtype.h:647
bool equals(const RRType &other) const
Return true iff two RRTypes are equal.
Definition: rrtype.h:226
static const RRType & NSAP()
Definition: rrtype.h:605
static const RRType & NAPTR()
Definition: rrtype.h:407
static const RRType & MG()
Definition: rrtype.h:551
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
static const RRType & RT()
Definition: rrtype.h:599
static const RRType & MAILA()
Definition: rrtype.h:575
static const RRType & DNAME()
Definition: rrtype.h:371
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
A standard DNS module exception that is thrown if an RRType object is being constructed from an unrec...
Definition: rrtype.h:44
static const RRType & AXFR()
Definition: rrtype.h:521
static const RRType & WKS()
Definition: rrtype.h:587
bool operator==(const RRType &other) const
Same as equals().
Definition: rrtype.h:229
static const RRType & IPSECKEY()
Definition: rrtype.h:671
static const RRType & HINFO()
Definition: rrtype.h:389
static const RRType & LP()
Definition: rrtype.h:707
bool nequals(const RRType &other) const
Return true iff two RRTypes are not equal.
Definition: rrtype.h:237
static const RRType & AFSDB()
Definition: rrtype.h:347
static const RRType & ANY()
Definition: rrtype.h:527
static const RRType & AAAA()
Definition: rrtype.h:497
static const RRType & L32()
Definition: rrtype.h:695
static const RRType & L64()
Definition: rrtype.h:701
static const RRType & SSHFP()
Definition: rrtype.h:473
static const RRType & URI()
Definition: rrtype.h:719
static const RRType & SPF()
Definition: rrtype.h:467