Kea 2.7.5
serial.h
Go to the documentation of this file.
1// Copyright (C) 2011-2024 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#ifndef SERIAL_H
8#define SERIAL_H
9
10#include <stdint.h>
11#include <iostream>
12
13namespace isc {
14namespace dns {
15
19const uint32_t MAX_SERIAL_INCREMENT = 2147483647;
20
22const uint64_t MAX_SERIAL_VALUE = 4294967296ull;
23
41class Serial {
42public:
46 explicit Serial(uint32_t value) : value_(value) {}
47
49 Serial(const Serial& other) : value_(other.getValue()) {}
50
54 Serial& operator=(const Serial& other) {
55 value_ = other.getValue();
56 return (*this);
57 }
58
62 void operator=(uint32_t value) { value_ = value; }
63
67 uint32_t getValue() const { return (value_); }
68
72 bool operator==(const Serial& other) const;
73
77 bool operator!=(const Serial& other) const;
78
85 bool operator<(const Serial& other) const;
86
94 bool operator<=(const Serial& other) const;
95
102 bool operator>(const Serial& other) const;
103
111 bool operator>=(const Serial& other) const;
112
122 Serial operator+(const Serial& other) const;
123
134 Serial operator+(uint32_t other_val) const;
135
136private:
137 uint32_t value_;
138};
139
145std::ostream& operator<<(std::ostream& os, const Serial& serial);
146
147} // end namespace dns
148} // end namespace isc
149
150#endif // SERIAL_H
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
uint32_t getValue() const
Returns the uint32_t representation of this serial value.
Definition serial.h:67
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
void operator=(uint32_t value)
Direct assignment from value.
Definition serial.h:62
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
Serial & operator=(const Serial &other)
Direct assignment from other Serial.
Definition serial.h:54
Serial(const Serial &other)
Copy constructor.
Definition serial.h:49
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.