Kea  2.3.5-git
isc::dns::Opcode Class Reference

The Opcode class objects represent standard OPCODEs of the header section of DNS messages as defined in RFC1035. More...

#include <opcode.h>

Public Types

enum  CodeValue {
  QUERY_CODE = 0, IQUERY_CODE = 1, STATUS_CODE = 2, RESERVED3_CODE = 3,
  NOTIFY_CODE = 4, UPDATE_CODE = 5, RESERVED6_CODE = 6, RESERVED7_CODE = 7,
  RESERVED8_CODE = 8, RESERVED9_CODE = 9, RESERVED10_CODE = 10, RESERVED11_CODE = 11,
  RESERVED12_CODE = 12, RESERVED13_CODE = 13, RESERVED14_CODE = 14, RESERVED15_CODE = 15
}
 Constants for standard OPCODE values. More...
 

Public Member Functions

bool equals (const Opcode &other) const
 Return true iff two Opcodes are equal. More...
 
CodeValue getCode () const
 Returns the Opcode code value. More...
 
bool nequals (const Opcode &other) const
 Return true iff two Opcodes are not equal. More...
 
bool operator!= (const Opcode &other) const
 Same as nequals(). More...
 
bool operator== (const Opcode &other) const
 Same as equals(). More...
 
std::string toText () const
 Convert the Opcode to a string. More...
 
Constructors and Destructor

We use the default versions of destructor, copy constructor, and assignment operator.

The default constructor is hidden as a result of defining the other constructors. This is intentional; we don't want to allow an Opcode object to be constructed with an invalid state.

 Opcode (const uint8_t code)
 Constructor from the code value. More...
 

Static Public Member Functions

static const OpcodeIQUERY ()
 A constant object for the IQUERY Opcode. More...
 
static const OpcodeNOTIFY ()
 A constant object for the NOTIFY Opcode. More...
 
static const OpcodeQUERY ()
 A constant object for the QUERY Opcode. More...
 
static const OpcodeRESERVED10 ()
 A constant object for a reserved (code 10) Opcode. More...
 
static const OpcodeRESERVED11 ()
 A constant object for a reserved (code 11) Opcode. More...
 
static const OpcodeRESERVED12 ()
 A constant object for a reserved (code 12) Opcode. More...
 
static const OpcodeRESERVED13 ()
 A constant object for a reserved (code 13) Opcode. More...
 
static const OpcodeRESERVED14 ()
 A constant object for a reserved (code 14) Opcode. More...
 
static const OpcodeRESERVED15 ()
 A constant object for a reserved (code 15) Opcode. More...
 
static const OpcodeRESERVED3 ()
 A constant object for a reserved (code 3) Opcode. More...
 
static const OpcodeRESERVED6 ()
 A constant object for a reserved (code 6) Opcode. More...
 
static const OpcodeRESERVED7 ()
 A constant object for a reserved (code 7) Opcode. More...
 
static const OpcodeRESERVED8 ()
 A constant object for a reserved (code 8) Opcode. More...
 
static const OpcodeRESERVED9 ()
 A constant object for a reserved (code 9) Opcode. More...
 
static const OpcodeSTATUS ()
 A constant object for the STATUS Opcode. More...
 
static const OpcodeUPDATE ()
 A constant object for the UPDATE Opcode. More...
 

Detailed Description

The Opcode class objects represent standard OPCODEs of the header section of DNS messages as defined in RFC1035.

This is a straightforward value class encapsulating the OPCODE code values. Since OPCODEs are 4-bit integers that are used in limited places and it's unlikely that new code values will be assigned, we could represent them as simple integers (via constant variables or enums). However, we define a separate class so that we can benefit from C++ type safety as much as possible. For convenience we also provide an enum type for standard OPCDE values, but it is generally advisable to handle OPCODEs through this class. In fact, public interfaces of this library uses this class to pass or return OPCODEs instead of the bare code values.

Definition at line 32 of file opcode.h.

Member Enumeration Documentation

◆ CodeValue

Constants for standard OPCODE values.

Enumerator
QUERY_CODE 

0: Standard query (RFC1035)

IQUERY_CODE 

1: Inverse query (RFC1035)

STATUS_CODE 

2: Server status request (RFC1035)

RESERVED3_CODE 

3: Reserved for future use (RFC1035)

NOTIFY_CODE 

4: Notify (RFC1996)

UPDATE_CODE 

5: Dynamic update (RFC2136)

RESERVED6_CODE 

6: Reserved for future use (RFC1035)

RESERVED7_CODE 

7: Reserved for future use (RFC1035)

RESERVED8_CODE 

8: Reserved for future use (RFC1035)

RESERVED9_CODE 

9: Reserved for future use (RFC1035)

RESERVED10_CODE 

10: Reserved for future use (RFC1035)

RESERVED11_CODE 

11: Reserved for future use (RFC1035)

RESERVED12_CODE 

12: Reserved for future use (RFC1035)

RESERVED13_CODE 

13: Reserved for future use (RFC1035)

RESERVED14_CODE 

14: Reserved for future use (RFC1035)

RESERVED15_CODE 

15: Reserved for future use (RFC1035)

Definition at line 35 of file opcode.h.

Constructor & Destructor Documentation

◆ Opcode()

isc::dns::Opcode::Opcode ( const uint8_t  code)
explicit

Constructor from the code value.

Since OPCODEs are 4-bit values, parameters larger than 15 are invalid. If code is larger than 15 an exception of class isc::OutOfRange will be thrown.

Parameters
codeThe underlying code value of the Opcode.

Definition at line 44 of file opcode.cc.

References isc_throw.

Member Function Documentation

◆ equals()

bool isc::dns::Opcode::equals ( const Opcode other) const
inline

Return true iff two Opcodes are equal.

Two Opcodes are equal iff their type codes are equal.

This method never throws an exception.

Parameters
otherthe Opcode object to compare against.
Returns
true if the two Opcodes are equal; otherwise false.

Definition at line 88 of file opcode.h.

Referenced by operator==().

◆ getCode()

CodeValue isc::dns::Opcode::getCode ( ) const
inline

Returns the Opcode code value.

This method never throws an exception.

Returns
The underlying code value corresponding to the Opcode.

Definition at line 78 of file opcode.h.

Referenced by isc::d2::D2UpdateMessage::fromWire(), and isc::dns::MessageImpl::toWire().

◆ IQUERY()

const Opcode & isc::dns::Opcode::IQUERY ( )
inlinestatic

A constant object for the IQUERY Opcode.

Definition at line 176 of file opcode.h.

Referenced by operator!=().

◆ nequals()

bool isc::dns::Opcode::nequals ( const Opcode other) const
inline

Return true iff two Opcodes are not equal.

This method never throws an exception.

Parameters
otherthe Opcode object to compare against.
Returns
true if the two Opcodes are not equal; otherwise false.

Definition at line 100 of file opcode.h.

Referenced by operator!=().

◆ NOTIFY()

const Opcode & isc::dns::Opcode::NOTIFY ( )
inlinestatic

A constant object for the NOTIFY Opcode.

Definition at line 194 of file opcode.h.

Referenced by operator!=().

◆ operator!=()

bool isc::dns::Opcode::operator!= ( const Opcode other) const
inline

◆ operator==()

bool isc::dns::Opcode::operator== ( const Opcode other) const
inline

Same as equals().

Definition at line 92 of file opcode.h.

References equals().

+ Here is the call graph for this function:

◆ QUERY()

const Opcode & isc::dns::Opcode::QUERY ( )
inlinestatic

A constant object for the QUERY Opcode.

Definition at line 170 of file opcode.h.

Referenced by operator!=().

◆ RESERVED10()

const Opcode & isc::dns::Opcode::RESERVED10 ( )
inlinestatic

A constant object for a reserved (code 10) Opcode.

Definition at line 230 of file opcode.h.

Referenced by operator!=().

◆ RESERVED11()

const Opcode & isc::dns::Opcode::RESERVED11 ( )
inlinestatic

A constant object for a reserved (code 11) Opcode.

Definition at line 236 of file opcode.h.

Referenced by operator!=().

◆ RESERVED12()

const Opcode & isc::dns::Opcode::RESERVED12 ( )
inlinestatic

A constant object for a reserved (code 12) Opcode.

Definition at line 242 of file opcode.h.

Referenced by operator!=().

◆ RESERVED13()

const Opcode & isc::dns::Opcode::RESERVED13 ( )
inlinestatic

A constant object for a reserved (code 13) Opcode.

Definition at line 248 of file opcode.h.

Referenced by operator!=().

◆ RESERVED14()

const Opcode & isc::dns::Opcode::RESERVED14 ( )
inlinestatic

A constant object for a reserved (code 14) Opcode.

Definition at line 254 of file opcode.h.

Referenced by operator!=().

◆ RESERVED15()

const Opcode & isc::dns::Opcode::RESERVED15 ( )
inlinestatic

A constant object for a reserved (code 15) Opcode.

Definition at line 260 of file opcode.h.

References isc::dns::operator<<().

Referenced by operator!=().

+ Here is the call graph for this function:

◆ RESERVED3()

const Opcode & isc::dns::Opcode::RESERVED3 ( )
inlinestatic

A constant object for a reserved (code 3) Opcode.

Definition at line 188 of file opcode.h.

Referenced by operator!=().

◆ RESERVED6()

const Opcode & isc::dns::Opcode::RESERVED6 ( )
inlinestatic

A constant object for a reserved (code 6) Opcode.

Definition at line 206 of file opcode.h.

Referenced by operator!=().

◆ RESERVED7()

const Opcode & isc::dns::Opcode::RESERVED7 ( )
inlinestatic

A constant object for a reserved (code 7) Opcode.

Definition at line 212 of file opcode.h.

Referenced by operator!=().

◆ RESERVED8()

const Opcode & isc::dns::Opcode::RESERVED8 ( )
inlinestatic

A constant object for a reserved (code 8) Opcode.

Definition at line 218 of file opcode.h.

Referenced by operator!=().

◆ RESERVED9()

const Opcode & isc::dns::Opcode::RESERVED9 ( )
inlinestatic

A constant object for a reserved (code 9) Opcode.

Definition at line 224 of file opcode.h.

Referenced by operator!=().

◆ STATUS()

const Opcode & isc::dns::Opcode::STATUS ( )
inlinestatic

A constant object for the STATUS Opcode.

Definition at line 182 of file opcode.h.

Referenced by operator!=().

◆ toText()

string isc::dns::Opcode::toText ( ) const

Convert the Opcode to a string.

This method returns a string representation of the "mnemonic' used for the enum and constant objects. For example, the string for code value 0 is "QUERY", etc.

If resource allocation for the string fails, a corresponding standard exception will be thrown.

Returns
A string representation of the Opcode.

Definition at line 53 of file opcode.cc.

Referenced by operator!=(), and isc::dns::operator<<().

◆ UPDATE()

const Opcode & isc::dns::Opcode::UPDATE ( )
inlinestatic

A constant object for the UPDATE Opcode.

Definition at line 200 of file opcode.h.

Referenced by isc::d2::D2UpdateMessage::fromWire(), and operator!=().


The documentation for this class was generated from the following files: