Kea  2.1.7-git
rrtype.h
Go to the documentation of this file.
1 
8 // Copyright (C) 2010-2021 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&
335 RRType::TSIG() {
336  static RRType rrtype(250);
337  return (rrtype);
338 }
339 
340 inline const RRType&
341 RRType::A() {
342  static RRType rrtype(1);
343  return (rrtype);
344 }
345 
346 inline const RRType&
347 RRType::AFSDB() {
348  static RRType rrtype(18);
349  return (rrtype);
350 }
351 
352 inline const RRType&
353 RRType::CAA() {
354  static RRType rrtype(257);
355  return (rrtype);
356 }
357 
358 inline const RRType&
359 RRType::CNAME() {
360  static RRType rrtype(5);
361  return (rrtype);
362 }
363 
364 inline const RRType&
365 RRType::DLV() {
366  static RRType rrtype(32769);
367  return (rrtype);
368 }
369 
370 inline const RRType&
371 RRType::DNAME() {
372  static RRType rrtype(39);
373  return (rrtype);
374 }
375 
376 inline const RRType&
377 RRType::DNSKEY() {
378  static RRType rrtype(48);
379  return (rrtype);
380 }
381 
382 inline const RRType&
383 RRType::DS() {
384  static RRType rrtype(43);
385  return (rrtype);
386 }
387 
388 inline const RRType&
389 RRType::HINFO() {
390  static RRType rrtype(13);
391  return (rrtype);
392 }
393 
394 inline const RRType&
395 RRType::MINFO() {
396  static RRType rrtype(14);
397  return (rrtype);
398 }
399 
400 inline const RRType&
401 RRType::MX() {
402  static RRType rrtype(15);
403  return (rrtype);
404 }
405 
406 inline const RRType&
407 RRType::NAPTR() {
408  static RRType rrtype(35);
409  return (rrtype);
410 }
411 
412 inline const RRType&
413 RRType::NS() {
414  static RRType rrtype(2);
415  return (rrtype);
416 }
417 
418 inline const RRType&
419 RRType::NSEC3() {
420  static RRType rrtype(50);
421  return (rrtype);
422 }
423 
424 inline const RRType&
425 RRType::NSEC3PARAM() {
426  static RRType rrtype(51);
427  return (rrtype);
428 }
429 
430 inline const RRType&
431 RRType::NSEC() {
432  static RRType rrtype(47);
433  return (rrtype);
434 }
435 
436 inline const RRType&
437 RRType::OPT() {
438  static RRType rrtype(41);
439  return (rrtype);
440 }
441 
442 inline const RRType&
443 RRType::PTR() {
444  static RRType rrtype(12);
445  return (rrtype);
446 }
447 
448 inline const RRType&
449 RRType::RP() {
450  static RRType rrtype(17);
451  return (rrtype);
452 }
453 
454 inline const RRType&
455 RRType::RRSIG() {
456  static RRType rrtype(46);
457  return (rrtype);
458 }
459 
460 inline const RRType&
461 RRType::SOA() {
462  static RRType rrtype(6);
463  return (rrtype);
464 }
465 
466 inline const RRType&
467 RRType::SPF() {
468  static RRType rrtype(99);
469  return (rrtype);
470 }
471 
472 inline const RRType&
473 RRType::SSHFP() {
474  static RRType rrtype(44);
475  return (rrtype);
476 }
477 
478 inline const RRType&
479 RRType::TKEY() {
480  static RRType rrtype(249);
481  return (rrtype);
482 }
483 
484 inline const RRType&
485 RRType::TLSA() {
486  static RRType rrtype(52);
487  return (rrtype);
488 }
489 
490 inline const RRType&
491 RRType::TXT() {
492  static RRType rrtype(16);
493  return (rrtype);
494 }
495 
496 inline const RRType&
497 RRType::AAAA() {
498  static RRType rrtype(28);
499  return (rrtype);
500 }
501 
502 inline const RRType&
503 RRType::DHCID() {
504  static RRType rrtype(49);
505  return (rrtype);
506 }
507 
508 inline const RRType&
509 RRType::SRV() {
510  static RRType rrtype(33);
511  return (rrtype);
512 }
513 
514 inline const RRType&
515 RRType::IXFR() {
516  static RRType rrtype(251);
517  return (rrtype);
518 }
519 
520 inline const RRType&
521 RRType::AXFR() {
522  static RRType rrtype(252);
523  return (rrtype);
524 }
525 
526 inline const RRType&
527 RRType::ANY() {
528  static RRType rrtype(255);
529  return (rrtype);
530 }
531 
532 inline const RRType&
533 RRType::MD() {
534  static RRType rrtype(3);
535  return (rrtype);
536 }
537 
538 inline const RRType&
539 RRType::MF() {
540  static RRType rrtype(4);
541  return (rrtype);
542 }
543 
544 inline const RRType&
545 RRType::MB() {
546  static RRType rrtype(7);
547  return (rrtype);
548 }
549 
550 inline const RRType&
551 RRType::MG() {
552  static RRType rrtype(8);
553  return (rrtype);
554 }
555 
556 inline const RRType&
557 RRType::MR() {
558  static RRType rrtype(9);
559  return (rrtype);
560 }
561 
562 inline const RRType&
563 RRType::NXT() {
564  static RRType rrtype(30);
565  return (rrtype);
566 }
567 
568 inline const RRType&
569 RRType::A6() {
570  static RRType rrtype(38);
571  return (rrtype);
572 }
573 
574 inline const RRType&
575 RRType::MAILA() {
576  static RRType rrtype(254);
577  return (rrtype);
578 }
579 
580 inline const RRType&
581 RRType::Null() {
582  static RRType rrtype(10);
583  return (rrtype);
584 }
585 
586 inline const RRType&
587 RRType::WKS() {
588  static RRType rrtype(11);
589  return (rrtype);
590 }
591 
592 inline const RRType&
593 RRType::X25() {
594  static RRType rrtype(19);
595  return (rrtype);
596 }
597 
598 inline const RRType&
599 RRType::RT() {
600  static RRType rrtype(21);
601  return (rrtype);
602 }
603 
604 inline const RRType&
605 RRType::NSAP() {
606  static RRType rrtype(22);
607  return (rrtype);
608 }
609 
610 inline const RRType&
611 RRType::NSAP_PTR() {
612  static RRType rrtype(23);
613  return (rrtype);
614 }
615 
616 inline const RRType&
617 RRType::SIG() {
618  static RRType rrtype(24);
619  return (rrtype);
620 }
621 
622 inline const RRType&
623 RRType::ISDN() {
624  static RRType rrtype(20);
625  return (rrtype);
626 }
627 
628 inline const RRType&
629 RRType::KEY() {
630  static RRType rrtype(25);
631  return (rrtype);
632 }
633 
634 inline const RRType&
635 RRType::PX() {
636  static RRType rrtype(26);
637  return (rrtype);
638 }
639 
640 inline const RRType&
641 RRType::GPOS() {
642  static RRType rrtype(27);
643  return (rrtype);
644 }
645 
646 inline const RRType&
647 RRType::LOC() {
648  static RRType rrtype(29);
649  return (rrtype);
650 }
651 
652 inline const RRType&
653 RRType::KX() {
654  static RRType rrtype(36);
655  return (rrtype);
656 }
657 
658 inline const RRType&
659 RRType::CERT() {
660  static RRType rrtype(37);
661  return (rrtype);
662 }
663 
664 inline const RRType&
665 RRType::APL() {
666  static RRType rrtype(42);
667  return (rrtype);
668 }
669 
670 inline const RRType&
671 RRType::IPSECKEY() {
672  static RRType rrtype(45);
673  return (rrtype);
674 }
675 
676 inline const RRType&
677 RRType::HIP() {
678  static RRType rrtype(55);
679  return (rrtype);
680 }
681 
682 inline const RRType&
683 RRType::UNSPEC() {
684  static RRType rrtype(103);
685  return (rrtype);
686 }
687 
688 inline const RRType&
689 RRType::NID() {
690  static RRType rrtype(104);
691  return (rrtype);
692 }
693 
694 inline const RRType&
695 RRType::L32() {
696  static RRType rrtype(105);
697  return (rrtype);
698 }
699 
700 inline const RRType&
701 RRType::L64() {
702  static RRType rrtype(106);
703  return (rrtype);
704 }
705 
706 inline const RRType&
707 RRType::LP() {
708  static RRType rrtype(107);
709  return (rrtype);
710 }
711 
712 inline const RRType&
713 RRType::MAILB() {
714  static RRType rrtype(253);
715  return (rrtype);
716 }
717 
718 inline const RRType&
719 RRType::URI() {
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:
bool operator<(const RRType &other) const
Less-than comparison for RRType against other.
Definition: rrtype.h:257
Base class for all sorts of text parse errors.
A standard DNS module exception that is thrown if an RRType object is being constructed from a incomp...
Definition: rrtype.h:54
std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Overrides standard output stream operator for CSVRow object.
Definition: csv_file.cc:100
bool operator==(const RRType &other) const
Same as equals().
Definition: rrtype.h:229
InvalidRRType(const char *file, size_t line, const char *what)
Definition: rrtype.h:46
IncompleteRRType(const char *file, size_t line, const char *what)
Definition: rrtype.h:56
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
bool nequals(const RRType &other) const
Return true iff two RRTypes are not equal.
Definition: rrtype.h:237
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-lfc.
bool operator!=(const RRType &other) const
Same as nequals().
Definition: rrtype.h:240
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
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