Kea 2.7.5
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
24bool
25Serial::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
36bool
37Serial::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
52Serial::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
59Serial::operator+(const Serial& other) const {
60 return (operator+(other.getValue()));
61}
62
63std::ostream&
64operator<<(std::ostream& os, const Serial& serial) {
65 return (os << serial.getValue());
66}
67
68} // end namespace dns
69} // end namespace isc
70
This class defines DNS serial numbers and serial arithmetic.
Definition serial.h:41
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
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
bool operator==(const Serial &other) const
Returns true if the serial values are equal.
Definition serial.cc:15
Serial(uint32_t value)
Constructor with value.
Definition serial.h:46
bool operator!=(const Serial &other) const
Returns true if the serial values are not equal.
Definition serial.cc:20
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
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
Serial operator+(const Serial &other) const
Adds the given value to the serial number.
Definition serial.cc:59
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
const uint32_t MAX_SERIAL_INCREMENT
The maximum difference between two serial numbers.
Definition serial.h:19
const uint64_t MAX_SERIAL_VALUE
Maximum value a serial can have, used in + operator.
Definition serial.h:22
Defines the logger used by the top-level component of kea-lfc.