Kea: isc::dns::Serial Class Reference

| Kea 3.2.0-git

isc::dns::Serial Class Reference

This class defines DNS serial numbers and serial arithmetic. More...

`#include <serial.h>`

## Public Member Functions
| Serial (const Serial &other)
| Copy constructor.
| Serial (uint32_t value)
| Constructor with value.
uint32_t | getValue () const
| Returns the uint32_t representation of this serial value.
bool | operator!= (const Serial &other) const
| Returns true if the serial values are not equal.
Serial | operator+ (const Serial &other) const
| Adds the given value to the serial number.
Serial | operator+ (uint32_t other_val) const
| Adds the given value to the serial number.
bool | operator< (const Serial &other) const
| Returns true if the serial value of this serial is smaller than the other, according to serial arithmetic as described in RFC 1982.
bool | operator<= (const Serial &other) const
| Returns true if the serial value of this serial is equal to or smaller than the other, according to serial arithmetic as described in RFC 1982.
Serial & | operator= (const Serial &other)
| Direct assignment from other Serial.
void | operator= (uint32_t value)
| Direct assignment from value.
bool | operator== (const Serial &other) const
| Returns true if the serial values are equal.
bool | operator> (const Serial &other) const
| Returns true if the serial value of this serial is greater than the other, according to serial arithmetic as described in RFC 1982.
bool | operator>= (const Serial &other) const
| Returns true if the serial value of this serial is equal to or greater than the other, according to serial arithmetic as described in RFC 1982.

## Detailed Description

This class defines DNS serial numbers and serial arithmetic.

DNS Serial number are in essence unsigned 32-bits numbers, with one catch; they should be compared using sequence space arithmetic. So given that they are 32-bits; as soon as the difference between two serial numbers is greater than 2147483647 (2^31 - 1), the lower number (in plain comparison) is considered the higher one.

In order to do this as transparently as possible, these numbers are stored in the Serial class, which overrides the basic comparison operators.

In this specific context, these operations are called 'serial number arithmetic', and they are defined in RFC 1982.

Note
  RFC 1982 defines everything based on the value SERIAL_BITS. Since the serial number has a fixed length of 32 bits, the values we use are hard-coded, and not computed based on variable bit lengths.

Definition at line 41 of file serial.h.

## Constructor & Destructor Documentation

## ◆ Serial() [1/2]

isc::dns::Serial::Serial | ( | uint32_t | value | ) |
| inlineexplicit

Constructor with value.

Parameters

  value | The uint32_t value of the serial

Definition at line 46 of file serial.h.

Referenced by Serial(), operator!=(), operator+(), operator+(), operator<(), operator<=(), operator=(), operator==(), operator>(), and operator>=().

## ◆ Serial() [2/2]

isc::dns::Serial::Serial | ( | const Serial & | other | ) |
| inline

Copy constructor.

Definition at line 49 of file serial.h.

References Serial(), and getValue().

Here is the call graph for this function:

## Member Function Documentation

## ◆ getValue()

uint32_t isc::dns::Serial::getValue | ( |  | ) | const
| inline

Returns the uint32_t representation of this serial value.

Returns
  The uint32_t value of this Serial

Definition at line 67 of file serial.h.

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

## ◆ operator!=()

bool isc::dns::Serial::operator!= | ( | const Serial & | other | ) | const

Returns true if the serial values are not equal.

Returns
  True if the values are not equal

Definition at line 20 of file serial.cc.

References Serial(), and getValue().

Here is the call graph for this function:

## ◆ operator+() [1/2]

Serial isc::dns::Serial::operator+ | ( | const Serial & | other | ) | const

Adds the given value to the serial number.

If this would make the number greater than 2^32-1, it is 'wrapped'.

Note
  According to the specification, an addition greater than MAX_SERIAL_INCREMENT is undefined. We do NOT catch this error (so as not to raise exceptions), but this behaviour remains undefined.

Parameters

  other | The Serial to add

Returns
  The result of the addition

Definition at line 59 of file serial.cc.

References Serial(), and getValue().

Here is the call graph for this function:

## ◆ operator+() [2/2]

Serial isc::dns::Serial::operator+ | ( | uint32_t | other_val | ) | const

Adds the given value to the serial number.

If this would make the number greater than 2^32-1, it is 'wrapped'.

Note
  According to the specification, an addition greater than MAX_SERIAL_INCREMENT is undefined. We do NOT catch this error (so as not to raise exceptions), but this behaviour remains undefined.

Parameters

  other_val | The uint32_t value to add

Returns
  The result of the addition

Definition at line 52 of file serial.cc.

References Serial(), and isc::dns::MAX_SERIAL_VALUE.

Here is the call graph for this function:

## ◆ operator<()

bool isc::dns::Serial::operator< | ( | const Serial & | other | ) | const

Returns true if the serial value of this serial is smaller than the other, according to serial arithmetic as described in RFC 1982.

Parameters

  other | The Serial to compare to

Returns
  True if this is smaller than the given value

Definition at line 24 of file serial.cc.

References Serial(), getValue(), and isc::dns::MAX_SERIAL_INCREMENT.

Here is the call graph for this function:

## ◆ operator<=()

bool isc::dns::Serial::operator<= | ( | const Serial & | other | ) | const

Returns true if the serial value of this serial is equal to or smaller than the other, according to serial arithmetic as described in RFC 1982.

Parameters

  other | The Serial to compare to

Returns
  True if this is smaller than or equal to the given value

Definition at line 36 of file serial.cc.

References Serial().

Here is the call graph for this function:

## ◆ operator=() [1/2]

Serial & isc::dns::Serial::operator= | ( | const Serial & | other | ) |
| inline

Direct assignment from other Serial.

Parameters

  other | The Serial to assign the value from

Definition at line 54 of file serial.h.

References Serial(), and getValue().

Here is the call graph for this function:

## ◆ operator=() [2/2]

void isc::dns::Serial::operator= | ( | uint32_t | value | ) |
| inline

Direct assignment from value.

Parameters

  value | the uint32_t value to assign

Definition at line 62 of file serial.h.

## ◆ operator==()

bool isc::dns::Serial::operator== | ( | const Serial & | other | ) | const

Returns true if the serial values are equal.

Returns
  True if the values are equal

Definition at line 15 of file serial.cc.

References Serial(), and getValue().

Here is the call graph for this function:

## ◆ operator>()

bool isc::dns::Serial::operator> | ( | const Serial & | other | ) | const

Returns true if the serial value of this serial is greater than the other, according to serial arithmetic as described in RFC 1982.

Parameters

  other | The Serial to compare to

Returns
  True if this is greater than the given value

Definition at line 42 of file serial.cc.

References Serial().

Here is the call graph for this function:

## ◆ operator>=()

bool isc::dns::Serial::operator>= | ( | const Serial & | other | ) | const

Returns true if the serial value of this serial is equal to or greater than the other, according to serial arithmetic as described in RFC 1982.

Parameters

  other | The Serial to compare to

Returns
  True if this is greater than or equal to the given value

Definition at line 47 of file serial.cc.

References Serial().

Here is the call graph for this function:

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

- serial.h
- serial.cc