Browse Source

- associate DNSProtocolError classes with corresponding RCODE
- define operator!= for Rcode


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1295 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya 15 years ago
parent
commit
c89027c881
2 changed files with 17 additions and 0 deletions
  1. 10 0
      src/lib/dns/message.cc
  2. 7 0
      src/lib/dns/message.h

+ 10 - 0
src/lib/dns/message.cc

@@ -153,6 +153,16 @@ static const char *opcodetext[] = {
 };
 }
 
+const Rcode&
+DNSMessageFORMERR::getRcode() const {
+    return (Rcode::FORMERR());
+}
+
+const Rcode&
+DNSMessageBADVERS::getRcode() const {
+    return (Rcode::BADVERS());
+}
+
 string
 Opcode::toText() const
 {

+ 7 - 0
src/lib/dns/message.h

@@ -30,22 +30,27 @@ namespace dns {
 ///
 /// \brief A standard DNS module exception ...[TBD]
 ///
+class Rcode;                    // forward declaration
+
 class DNSProtocolError : public Exception {
 public:
     DNSProtocolError(const char* file, size_t line, const char* what) :
         isc::Exception(file, line, what) {}
+    virtual const Rcode& getRcode() const = 0;
 };
 
 class DNSMessageFORMERR : public DNSProtocolError {
 public:
     DNSMessageFORMERR(const char* file, size_t line, const char* what) :
         DNSProtocolError(file, line, what) {}
+    virtual const Rcode& getRcode() const;
 };
 
 class DNSMessageBADVERS : public DNSProtocolError {
 public:
     DNSMessageBADVERS(const char* file, size_t line, const char* what) :
         DNSProtocolError(file, line, what) {}
+    virtual const Rcode& getRcode() const;
 };
 
 ///
@@ -156,6 +161,8 @@ public:
     uint16_t getCode() const { return (code_); }
     bool operator==(const Opcode& other) const
     { return (code_ == other.code_); }
+    bool operator!=(const Opcode& other) const
+    { return (code_ != other.code_); }
     std::string toText() const;
     static const Opcode& QUERY();
     static const Opcode& IQUERY();