Kea: serial.cc Source File

| Kea 3.2.0-git

serial.cc
Go to the documentation of this file.
1// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <dns/serial.h>
10
11namespace isc {
12namespace dns {
13
14bool
15Serial::operator==(const Serial& other) const {
16 return (value_ == other.getValue());
17}
18
19bool
20Serial::operator!=(const Serial& other) const {
21 return (value_ != other.getValue());
22}
23
24 bool
25 Serial::operator<(const Serial& other) const {
26 uint32_t other_val = other.getValue();
27 bool result = false;
28 if (value_ < other_val) {
29 result = ((other_val - value_) <= MAX_SERIAL_INCREMENT);
30 } else if (other_val < value_) {
31 result = ((value_ - other_val) > MAX_SERIAL_INCREMENT);
32 }
33 return (result);
34}
35
36 bool
37 Serial::operator<=(const Serial& other) const {
38 return (operator==(other) || operator<(other));
39}
40
41bool
42Serial::operator>(const Serial& other) const {
43 return (!operator==(other) && !operator<(other));
44}
45
46bool
47Serial::operator>=(const Serial& other) const {
48 return (!operator<(other));
49}
50
51 Serial
52 Serial::operator+(uint32_t other_val) const {
53 uint64_t new_val = static_cast<uint64_t>(value_) +
54 static_cast<uint64_t>(other_val);
55 return Serial(static_cast<uint32_t>(new_val % MAX_SERIAL_VALUE));
56}
57
58 Serial
59Serial::operator+(const Serial& other) const {
60 return (operator+(other.getValue()));
61}
62
63std::ostream&
64 operator<<(std::ostream& os, const Serial& serial) {
65 return (os << serial.getValue());
66}
67
68} // end namespace dns
69} // end namespace isc
70
isc::dns::Serial
This class defines DNS serial numbers and serial arithmetic.
Definition serial.h:41
isc::dns::Serial::operator>=
bool operator>=(const Serial &other) const
Returns true if the serial value of this serial is equal to or greater than the other,...
Definition serial.cc:47
isc::dns::Serial::operator>
bool operator>(const Serial &other) const
Returns true if the serial value of this serial is greater than the other, according to serial arithm...
Definition serial.cc:42
isc::dns::Serial::getValue
uint32_t getValue() const
Returns the uint32_t representation of this serial value.
Definition serial.h:67
isc::dns::Serial::operator==
bool operator==(const Serial &other) const
Returns true if the serial values are equal.
Definition serial.cc:15
isc::dns::Serial::Serial
Serial(uint32_t value)
Constructor with value.
Definition serial.h:46
isc::dns::Serial::operator!=
bool operator!=(const Serial &other) const
Returns true if the serial values are not equal.
Definition serial.cc:20
isc::dns::Serial::operator<
bool operator<(const Serial &other) const
Returns true if the serial value of this serial is smaller than the other, according to serial arithm...
Definition serial.cc:25
isc::dns::Serial::operator<=
bool operator<=(const Serial &other) const
Returns true if the serial value of this serial is equal to or smaller than the other,...
Definition serial.cc:37
isc::dns::Serial::operator+
Serial operator+(const Serial &other) const
Adds the given value to the serial number.
Definition serial.cc:59
isc::dns
Definition char_string.cc:26
isc::dns::operator<<
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
isc::dns::MAX_SERIAL_INCREMENT
const uint32_t MAX_SERIAL_INCREMENT
The maximum difference between two serial numbers.
Definition serial.h:19
isc::dns::MAX_SERIAL_VALUE
const uint64_t MAX_SERIAL_VALUE
Maximum value a serial can have, used in + operator.
Definition serial.h:22
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
serial.h