Kea 2.7.6
isc::util Namespace Reference

Namespaces

namespace  detail
 
namespace  encode
 
namespace  file
 
namespace  io
 
namespace  str
 
namespace  unittests
 

Classes

struct  CSCallbackSet
 Embodies a named set of CriticalSection callbacks. More...
 
class  CSCallbackSetList
 Maintains list of unique CSCallbackSets. More...
 
class  CSVFile
 Provides input/output access to CSV files. More...
 
class  CSVFileError
 Exception thrown when an error occurs during CSV file processing. More...
 
class  CSVRow
 Represents a single row of the CSV file. More...
 
struct  Hash64
 Hash implementation based on Fowler-Noll-Vo hash function. More...
 
class  InputBuffer
 The InputBuffer class is a buffer abstraction for manipulating read-only data. More...
 
class  InvalidTime
 A standard DNS (or ISC) module exception that is thrown if a time conversion function encounters bad input. More...
 
class  LabeledValue
 Implements the concept of a constant value with a text label. More...
 
class  LabeledValueError
 Thrown if an error is encountered handling a LabeledValue. More...
 
class  LabeledValueSet
 Implements a set of unique LabeledValues. More...
 
class  MemorySegment
 Memory Segment Class. More...
 
class  MemorySegmentError
 General error that can be thrown by a MemorySegment implementation. More...
 
class  MemorySegmentGrown
 Exception that is thrown, when allocating space in a MemorySegment results in growing the underlying segment. More...
 
class  MemorySegmentLocal
 malloc/free based Memory Segment class More...
 
class  MemorySegmentOpenError
 Exception that can be thrown when constructing a MemorySegment object. More...
 
class  MultiThreadingCriticalSection
 RAII class creating a critical section. More...
 
struct  MultiThreadingLock
 RAII lock object to protect the code in the same scope with a mutex. More...
 
class  MultiThreadingMgr
 Multi Threading Manager. More...
 
class  Optional
 A template representing an optional value. More...
 
class  OutputBuffer
 The OutputBuffer class is a buffer abstraction for manipulating mutable data. More...
 
class  PIDCantReadPID
 Exception thrown when an error occurs trying to read a PID from an opened file. More...
 
class  PIDFile
 Class to help with processing PID files. More...
 
class  PIDFileError
 Exception thrown when an error occurs during PID file processing. More...
 
class  ReadLockGuard
 Read mutex RAII handler. More...
 
class  ReadWriteMutex
 Read-Write Mutex. More...
 
class  ReconnectCtl
 Warehouses reconnect control values. More...
 
class  StagedValue
 This class implements set/commit mechanism for a single object. More...
 
class  State
 Defines a State within the State Model. More...
 
class  StateModel
 Implements a finite state machine. More...
 
class  StateModelError
 Thrown if the state machine encounters a general error. More...
 
class  StateSet
 Implements a unique set or dictionary of states. More...
 
class  Stopwatch
 Utility class to measure code execution times. More...
 
class  StopwatchImpl
 Stopwatch class implementation. More...
 
struct  ThreadPool
 Defines a thread pool which uses a thread pool queue for managing work items. More...
 
class  Triplet
 This template specifies a parameter value. More...
 
class  UnlockGuard
 Unlock Guard. More...
 
class  VersionedColumn
 Contains the metadata for a single column in a file. More...
 
class  VersionedCSVFile
 Implements a CSV file that supports multiple versions of the file's "schema". More...
 
class  VersionedCSVFileError
 Exception thrown when an error occurs during CSV file processing. More...
 
class  WatchedThread
 Provides a thread and controls for monitoring its activities. More...
 
class  WatchSocket
 Provides an IO "ready" semaphore for use with select() or poll() WatchSocket exposes a single open file descriptor, the "select-fd" which can be marked as being ready to read (i.e. More...
 
class  WatchSocketError
 Exception thrown if an error occurs during IO source open. More...
 
class  WriteLockGuard
 Write mutex RAII handler. More...
 

Typedefs

typedef LabeledValue Event
 Define an Event.
 
typedef LabeledValuePtr EventPtr
 Define Event pointer.
 
typedef boost::shared_ptr< InputBufferInputBufferPtr
 Type of pointers to input buffer.
 
using int128_t = boost::multiprecision::checked_int128_t
 
typedef std::map< unsigned int, LabeledValuePtrLabeledValueMap
 Defines a map of pointers to LabeledValues keyed by value.
 
typedef boost::shared_ptr< LabeledValueLabeledValuePtr
 Defines a shared pointer to a LabeledValue instance.
 
typedef boost::shared_ptr< OutputBufferOutputBufferPtr
 Type of pointers to output buffers.
 
typedef boost::shared_ptr< PIDFilePIDFilePtr
 Defines a shared pointer to a PIDFile.
 
typedef boost::shared_ptr< ReconnectCtlReconnectCtlPtr
 Pointer to an instance of ReconnectCtl.
 
typedef std::function< void()> StateHandler
 Defines a pointer to an instance method for handling a state.
 
typedef boost::shared_ptr< StateModelStateModelPtr
 Defines a pointer to a StateModel.
 
typedef boost::shared_ptr< StateStatePtr
 Defines a shared pointer to a State.
 
typedef boost::shared_ptr< std::thread > ThreadPtr
 Thread pointer type.
 
using uint128_t = boost::multiprecision::checked_uint128_t
 
typedef boost::shared_ptr< VersionedColumnVersionedColumnPtr
 Defines a smart pointer to VersionedColumn.
 
typedef boost::shared_ptr< WatchedThreadWatchedThreadPtr
 Defines a pointer to a WatchedThread.
 
typedef boost::shared_ptr< WatchSocketWatchSocketPtr
 Defines a smart pointer to an instance of a WatchSocket.
 

Enumerations

enum  DhcpSpace { DHCPv4 , DHCPv6 }
 
enum class  OnFailAction { STOP_RETRY_EXIT , SERVE_RETRY_EXIT , SERVE_RETRY_CONTINUE }
 Type of action to take on connection loss. More...
 
enum  StatePausing { STATE_PAUSE_ALWAYS , STATE_PAUSE_NEVER , STATE_PAUSE_ONCE }
 State machine pausing modes. More...
 

Functions

bool areDoublesEquivalent (double a, double b, double tolerance=0.000001)
 Tests two doubles for equivalence within a given tolerance.
 
std::string clockToText (std::chrono::system_clock::time_point t, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts chrono time point structure to text.
 
template<DhcpSpace D>
char const * cStringDhcpSpace ()
 Provides the C string representation of the DHCP space.
 
template<>
char const * cStringDhcpSpace< DHCPv4 > ()
 
template<>
char const * cStringDhcpSpace< DHCPv6 > ()
 
std::string durationToText (boost::posix_time::time_duration dur, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts StatsDuration to text.
 
template<typename Duration >
std::string durationToText (Duration dur, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts StatsDuration to text.
 
template std::string durationToText< steady_clock::duration > (steady_clock::duration dur, size_t fsecs_precision)
 
template std::string durationToText< system_clock::duration > (system_clock::duration dur, size_t fsecs_precision)
 
template<typename T >
bool equalValues (const T &ptr1, const T &ptr2)
 This function checks if two pointers are non-null and values are equal.
 
template<typename Iterator >
void fillRandom (Iterator begin, Iterator end)
 Fill in specified range with a random data.
 
template<DhcpSpace D>
std::string formatDhcpSpace (char const *const format_string)
 Replaces all occurrences of {} with 4 or 6 based on the templated DHCP space.
 
template<typename Iterator >
bool isRangeZero (Iterator begin, Iterator end)
 Checks if specified range in a container contains only zeros.
 
template<typename T >
bool nullOrEqualValues (const T &ptr1, const T &ptr2)
 This function checks if two pointers are both null or both are non-null and they point to equal values.
 
std::ostream & operator<< (std::ostream &os, const CSVRow &row)
 Overrides standard output stream operator for CSVRow object.
 
std::ostream & operator<< (std::ostream &os, const LabeledValue &vlp)
 Dumps the label to ostream.
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Optional< T > &optional_value)
 Inserts an optional value to a stream.
 
std::string ptimeToText (boost::posix_time::ptime t, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts ptime structure to text.
 
template<typename uint_t >
uint_t readUint (void const *const buffer, size_t const length)
 Read an unsigned integer from given buffer.
 
uint16_t readUint16 (void const *const buffer, size_t const length)
 uint16_t wrapper over readUint.
 
uint32_t readUint32 (void const *const buffer, size_t const length)
 uint32_t wrapper over readUint.
 
uint64_t readUint64 (void const *const buffer, size_t const length)
 uint16_t wrapper over readUint.
 
template<typename uint_t >
uint8_t * writeUint (uint_t const value, void *const buffer, size_t const length)
 Write the given unsigned integer to the given buffer.
 
uint8_t * writeUint16 (uint16_t const value, void *const buffer, size_t const length)
 uint16_t wrapper over writeUint.
 
uint8_t * writeUint32 (uint32_t const value, void *const buffer, size_t const length)
 uint32_t wrapper over writeUint.
 
uint8_t * writeUint64 (uint64_t const value, void *const buffer, size_t const length)
 uint64_t wrapper over writeUint.
 
DNSSEC time conversion functions.

These functions convert between times represented in seconds (in integer) since epoch and those in the textual form used in the RRSIG records.

For integers we provide both 32-bit and 64-bit versions. The RRSIG expiration and inception fields are both 32-bit unsigned integers, so 32-bit versions would be more useful for protocol operations. However, with 32-bit integers we need to take into account wrap-around points and compare values using the serial number arithmetic as specified in RFC4034, which would be more error prone. We therefore provide 64-bit versions, too.

The timezone is always UTC for these functions.

string timeToText64 (uint64_t value)
 Convert integral DNSSEC time to textual form, 64-bit version.
 
string timeToText32 (uint32_t value)
 Convert integral DNSSEC time to textual form, 32-bit version.
 
uint64_t timeFromText64 (const std::string &time_txt)
 Convert textual DNSSEC time to integer, 64-bit version.
 
uint32_t timeFromText32 (const std::string &time_txt)
 Convert textual DNSSEC time to integer, 32-bit version.
 

Variables

const size_t MAX_FSECS_PRECISION =boost::posix_time::time_duration::num_fractional_digits()
 The number of digits of fractional seconds supplied by the underlying class, boost::posix_time.
 

Typedef Documentation

◆ Event

Define an Event.

Definition at line 31 of file state_model.h.

◆ EventPtr

Define Event pointer.

Definition at line 34 of file state_model.h.

◆ InputBufferPtr

typedef boost::shared_ptr<InputBuffer> isc::util::InputBufferPtr

Type of pointers to input buffer.

Definition at line 276 of file buffer.h.

◆ int128_t

using isc::util::int128_t = boost::multiprecision::checked_int128_t

Definition at line 19 of file bigints.h.

◆ LabeledValueMap

typedef std::map<unsigned int, LabeledValuePtr> isc::util::LabeledValueMap

Defines a map of pointers to LabeledValues keyed by value.

Definition at line 95 of file labeled_value.h.

◆ LabeledValuePtr

typedef boost::shared_ptr<LabeledValue> isc::util::LabeledValuePtr

Defines a shared pointer to a LabeledValue instance.

Definition at line 92 of file labeled_value.h.

◆ OutputBufferPtr

typedef boost::shared_ptr<OutputBuffer> isc::util::OutputBufferPtr

Type of pointers to output buffers.

Definition at line 571 of file buffer.h.

◆ PIDFilePtr

typedef boost::shared_ptr<PIDFile> isc::util::PIDFilePtr

Defines a shared pointer to a PIDFile.

Definition at line 92 of file pid_file.h.

◆ ReconnectCtlPtr

typedef boost::shared_ptr<ReconnectCtl> isc::util::ReconnectCtlPtr

Pointer to an instance of ReconnectCtl.

Definition at line 138 of file reconnect_ctl.h.

◆ StateHandler

typedef std::function<void()> isc::util::StateHandler

Defines a pointer to an instance method for handling a state.

Definition at line 37 of file state_model.h.

◆ StateModelPtr

typedef boost::shared_ptr<StateModel> isc::util::StateModelPtr

Defines a pointer to a StateModel.

Definition at line 846 of file state_model.h.

◆ StatePtr

typedef boost::shared_ptr<State> isc::util::StatePtr

Defines a shared pointer to a State.

Definition at line 111 of file state_model.h.

◆ ThreadPtr

typedef boost::shared_ptr<std::thread> isc::util::ThreadPtr

Thread pointer type.

Definition at line 22 of file watched_thread.h.

◆ uint128_t

using isc::util::uint128_t = boost::multiprecision::checked_uint128_t

Definition at line 21 of file bigints.h.

◆ VersionedColumnPtr

typedef boost::shared_ptr<VersionedColumn> isc::util::VersionedColumnPtr

Defines a smart pointer to VersionedColumn.

Definition at line 53 of file versioned_csv_file.h.

◆ WatchedThreadPtr

typedef boost::shared_ptr<WatchedThread> isc::util::WatchedThreadPtr

Defines a pointer to a WatchedThread.

Definition at line 140 of file watched_thread.h.

◆ WatchSocketPtr

typedef boost::shared_ptr<WatchSocket> isc::util::WatchSocketPtr

Defines a smart pointer to an instance of a WatchSocket.

Definition at line 138 of file watch_socket.h.

Enumeration Type Documentation

◆ DhcpSpace

Enumerator
DHCPv4 
DHCPv6 

Definition at line 17 of file dhcp_space.h.

◆ OnFailAction

enum class isc::util::OnFailAction
strong

Type of action to take on connection loss.

Enumerator
STOP_RETRY_EXIT 
SERVE_RETRY_EXIT 
SERVE_RETRY_CONTINUE 

Definition at line 17 of file reconnect_ctl.h.

◆ StatePausing

State machine pausing modes.

Supported modes are:

  • always pause in the given state,
  • never pause in the given state,
  • pause upon first transition to the given state.
Enumerator
STATE_PAUSE_ALWAYS 
STATE_PAUSE_NEVER 
STATE_PAUSE_ONCE 

Definition at line 45 of file state_model.h.

Function Documentation

◆ areDoublesEquivalent()

bool isc::util::areDoublesEquivalent ( double a,
double b,
double tolerance = 0.000001 )
inline

Tests two doubles for equivalence within a given tolerance.

Parameters
acomparison operand one
bcomparison operand two
tolerancethe amount by which the two values may differ and still be considered "equal".
Returns
True if the two values differ by less than the tolerance.

Definition at line 22 of file doubles.h.

◆ clockToText()

std::string isc::util::clockToText ( std::chrono::system_clock::time_point t,
size_t fsecs_precision = MAX_FSECS_PRECISION )

Converts chrono time point structure to text.

This is Kea implementation for converting time point to strings.

Parameters
ttime point value to convert to text
fsecs_precisionnumber of digits of precision for fractional seconds. Zero omits the value.
Returns
a string representing time

Definition at line 19 of file chrono_time_utils.cc.

References MAX_FSECS_PRECISION.

Referenced by isc::stats::Observation::getJSON().

◆ cStringDhcpSpace()

template<DhcpSpace D>
char const * isc::util::cStringDhcpSpace ( )

Provides the C string representation of the DHCP space.

Template Parameters
DDHCP space
Returns
"4" or "6"

Referenced by formatDhcpSpace().

◆ cStringDhcpSpace< DHCPv4 >()

template<>
char const * isc::util::cStringDhcpSpace< DHCPv4 > ( )

Definition at line 15 of file dhcp_space.cc.

◆ cStringDhcpSpace< DHCPv6 >()

template<>
char const * isc::util::cStringDhcpSpace< DHCPv6 > ( )

Definition at line 20 of file dhcp_space.cc.

◆ durationToText() [1/2]

std::string isc::util::durationToText ( boost::posix_time::time_duration dur,
size_t fsecs_precision = MAX_FSECS_PRECISION )

Converts StatsDuration to text.

This is Kea equivalent of boost::posix_time::to_simple_string(time_duration). See ptimeToText for explanation why we chose our own implementation.

Parameters
durduration value to convert to text
fsecs_precisionnumber of digits of precision for fractional seconds. Default is given by boost::posix_time::time_duration::num_fractional_digits(). Zero omits the value.
Returns
a string representing time

Definition at line 25 of file boost_time_utils.cc.

References MAX_FSECS_PRECISION.

Referenced by isc::stats::Observation::getJSON(), and ptimeToText().

◆ durationToText() [2/2]

template<typename Duration >
std::string isc::util::durationToText ( Duration dur,
size_t fsecs_precision = MAX_FSECS_PRECISION )

Converts StatsDuration to text.

See clockToText for explanation why we chose our own implementation.

Template Parameters
Durationduration type instance for instance std::chrono::system_clock::duration.
Parameters
durduration value to convert to text
fsecs_precisionnumber of digits of precision for fractional seconds. Zero omits the value.
Returns
a string representing time

Definition at line 55 of file chrono_time_utils.cc.

References MAX_FSECS_PRECISION.

◆ durationToText< steady_clock::duration >()

template std::string isc::util::durationToText< steady_clock::duration > ( steady_clock::duration dur,
size_t fsecs_precision )

◆ durationToText< system_clock::duration >()

template std::string isc::util::durationToText< system_clock::duration > ( system_clock::duration dur,
size_t fsecs_precision )

◆ equalValues()

template<typename T >
bool isc::util::equalValues ( const T & ptr1,
const T & ptr2 )
inline

This function checks if two pointers are non-null and values are equal.

This function performs the typical comparison of values encapsulated by the smart pointers, with checking if the pointers are non-null.

Parameters
ptr1First pointer.
ptr2Second pointer.
Template Parameters
TPointer type, e.g. boost::shared_ptr, or boost::scoped_ptr.
Returns
true only if both pointers are non-null and the values which they point to are equal.

Definition at line 27 of file pointer_util.h.

Referenced by isc::dhcp::Lease4::belongsToClient(), isc::dhcp::Dhcpv6Srv::extendIA_NA(), isc::dhcp::Dhcpv6Srv::extendIA_PD(), and nullOrEqualValues().

◆ fillRandom()

template<typename Iterator >
void isc::util::fillRandom ( Iterator begin,
Iterator end )

Fill in specified range with a random data.

Make sure that random number generator is initialized properly. Otherwise you will get the same pseudo-random sequence after every start of your process. Calling srand() is enough. This method uses default rand(), which is usually a LCG pseudo-random number generator, so it is not suitable for security purposes. Please use cryptolink RNG if you are doing anything related with security.

PRNG initialization is left out of this function on purpose. It may be initialized to specific value on purpose, e.g. to repeat exactly the same sequence in a test.

Parameters
begin
end

Definition at line 52 of file range_utilities.h.

Referenced by isc::dhcp::DUIDFactory::createEN().

◆ formatDhcpSpace()

template<DhcpSpace D>
std::string isc::util::formatDhcpSpace ( char const *const format_string)

Replaces all occurrences of {} with 4 or 6 based on the templated DHCP space.

Template Parameters
DDHCP space
Returns
the formatted string

Definition at line 36 of file dhcp_space.h.

References cStringDhcpSpace().

+ Here is the call graph for this function:

◆ isRangeZero()

template<typename Iterator >
bool isc::util::isRangeZero ( Iterator begin,
Iterator end )

Checks if specified range in a container contains only zeros.

Parameters
beginbeginning of the range
endend of the range
Returns
true if there are only zeroes, false otherwise

Definition at line 29 of file range_utilities.h.

◆ nullOrEqualValues()

template<typename T >
bool isc::util::nullOrEqualValues ( const T & ptr1,
const T & ptr2 )
inline

This function checks if two pointers are both null or both are non-null and they point to equal values.

Parameters
ptr1First pointer.
ptr2Second pointer.
Template Parameters
TPointer type, e.g. boost::shared_ptr, or boost::scoped_ptr.
Returns
true if both pointers are null or if they are both non-null and the values pointed to are equal.

Definition at line 42 of file pointer_util.h.

References equalValues().

Referenced by isc::dhcp::Lease4::operator==(), and isc::dhcp::Lease6::operator==().

+ Here is the call graph for this function:

◆ operator<<() [1/3]

std::ostream & isc::util::operator<< ( std::ostream & os,
const CSVRow & row )

Overrides standard output stream operator for CSVRow object.

The resulting string of characters is the same as the one returned by CSVRow::render function.

Parameters
osOutput stream.
rowObject representing a CSV file row.

Definition at line 100 of file csv_file.cc.

References isc::util::CSVRow::render().

+ Here is the call graph for this function:

◆ operator<<() [2/3]

std::ostream & isc::util::operator<< ( std::ostream & os,
const LabeledValue & vlp )

Dumps the label to ostream.

Definition at line 51 of file labeled_value.cc.

References isc::util::LabeledValue::getLabel().

+ Here is the call graph for this function:

◆ operator<<() [3/3]

template<typename T >
std::ostream & isc::util::operator<< ( std::ostream & os,
const Optional< T > & optional_value )

Inserts an optional value to a stream.

This function overloads the global operator<< to behave as in ostream::operator<< but applied to Optional objects.

Parameters
osA std::ostream object to which the value is inserted.
optional_valueAn Optional object to be inserted into a stream.
Template Parameters
Typeof the value encapsulated by the Optional object.
Returns
A reference to the stream after insertion.

Definition at line 191 of file optional.h.

References isc::util::Optional< T >::get().

+ Here is the call graph for this function:

◆ ptimeToText()

std::string isc::util::ptimeToText ( boost::posix_time::ptime t,
size_t fsecs_precision = MAX_FSECS_PRECISION )

Converts ptime structure to text.

This is Kea implementation for converting ptime to strings. It's a functional equivalent of boost::posix_time::to_simple_string. We do not use it, though, because it would introduce unclear dependency on boost_time_date library. First, we try to avoid depending on boost libraries (we tend to use only the headers). Second, this dependency is system specific, i.e. it is required on Ubuntu and FreeBSD, but doesn't seem to be needed on OS X. Since the functionality needed is minor, we decided to reimplement it on our own, rather than introduce extra dependencies. This explanation also applies to durationToText.

Parameters
tptime value to convert to text
fsecs_precisionnumber of digits of precision for fractional seconds. Default is given by boost::posix_time::time_duration::num_fractional_digits(). Zero omits the value.
Returns
a string representing time

Definition at line 14 of file boost_time_utils.cc.

References durationToText().

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::createResultSet(), isc::ha::CommunicationState::getReport(), isc::perfmon::PerfMonMgr::perfmonGetAllDurationsHandler(), isc::ha::HAService::processStatusGet(), isc::perfmon::PerfMonMgr::reportAlarm(), isc::perfmon::MonitoredDuration::toElement(), and isc::perfmon::MonitoredDuration::toValueRow().

+ Here is the call graph for this function:

◆ readUint()

template<typename uint_t >
uint_t isc::util::readUint ( void const *const buffer,
size_t const length )

Read an unsigned integer from given buffer.

Template Parameters
uint_tData type of the unsigned integer.
Parameters
bufferData buffer at least two bytes long of which the first bytes are assumed to represent an unsigned integer in network-byte order.
lengthLength of the data buffer.
Returns
Value of the integer.

Definition at line 27 of file io.h.

References isc_throw.

Referenced by readUint16(), readUint32(), and readUint64().

◆ readUint16()

◆ readUint32()

◆ readUint64()

uint64_t isc::util::readUint64 ( void const *const buffer,
size_t const length )
inline

uint16_t wrapper over readUint.

Definition at line 88 of file io.h.

References readUint().

Referenced by isc::dhcp::Option6Auth::unpack().

+ Here is the call graph for this function:

◆ timeFromText32()

uint32_t isc::util::timeFromText32 ( const std::string & time_txt)

Convert textual DNSSEC time to integer, 32-bit version.

This version is the same as timeFromText64() except that the return value is wrapped around to an unsigned 32-bit integer, simply dropping the upper 32 bits.

Parameters
time_txtTextual time in the form of YYYYMMDDHHmmSS
Returns
Seconds since epoch corresponding to time_txt as uint_32

Definition at line 188 of file time_utils.cc.

References timeFromText64().

+ Here is the call graph for this function:

◆ timeFromText64()

uint64_t isc::util::timeFromText64 ( const std::string & time_txt)

Convert textual DNSSEC time to integer, 64-bit version.

The textual form must only consist of digits and be in the form of YYYYMMDDHHmmSS, where:

  • YYYY must be between 1970 and 9999
  • MM must be between 01 and 12
  • DD must be between 01 and 31 and must be a valid day for the month represented in 'MM'. For example, if MM is 04, DD cannot be 31. DD can be 29 when MM is 02 only when YYYY is a leap year.
  • HH must be between 00 and 23
  • mm must be between 00 and 59
  • SS must be between 00 and 60

For all fields the range includes the begin and end values. Note that 60 is allowed for 'SS', intending a leap second, although in real operation it's unlikely to be specified.

If the given text is valid, this function converts it to an unsigned 64-bit number of seconds since epoch (1 January 1970 00:00:00) and returns the converted value. 64 bits are sufficient to represent all possible values for the valid format uniquely, so there is no overflow.

Note
RFC4034 also defines the textual form of an unsigned decimal integer for the corresponding time in seconds. This function doesn't support this form, and if given it throws an exception of class InvalidTime.
Parameters
time_txtTextual time in the form of YYYYMMDDHHmmSS
Returns
Seconds since epoch corresponding to time_txt
Exceptions
InvalidTimeThe given textual representation is invalid.

Definition at line 149 of file time_utils.cc.

References isc_throw.

Referenced by isc::dhcp_ddns::NameChangeRequest::setLeaseExpiresOn(), and timeFromText32().

◆ timeToText32()

std::string isc::util::timeToText32 ( uint32_t value)

Convert integral DNSSEC time to textual form, 32-bit version.

This version is the same as timeToText64(), but the time value is expected to be the lower 32 bits of the full 64-bit value. These two will be different on and after a certain point of time in year 2106, so this function internally resolves the ambiguity using the current system time at the time of function call; it first identifies the range of [N*2^32 - 2^31, N*2^32 + 2^31) that contains the current time, and interprets value in the context of that range. It then applies the same process as timeToText64().

There is one important exception in this processing, however. Until 19 Jan 2038 03:14:08 (2^31 seconds since epoch), this range would contain time before epoch. In order to ensure the returned value is also a valid input to timeFromText, this function uses a special range [0, 2^32) until that time. As a result, all upper half of the 32-bit values are treated as a future time. For example, 2^32-1 (the highest value in 32-bit unsigned integers) will be converted to "21060207062815", instead of "19691231235959".

Parameters
valueSeconds since epoch to be converted.
Returns
Textual representation of value in the form of YYYYMMDDHHmmSS.

Definition at line 133 of file time_utils.cc.

References isc::util::detail::getTimeWrapper(), and timeToText64().

+ Here is the call graph for this function:

◆ timeToText64()

std::string isc::util::timeToText64 ( uint64_t value)

Convert integral DNSSEC time to textual form, 64-bit version.

This function takes an integer that would be seconds since epoch and converts it in the form of YYYYMMDDHHmmSS. For example, if value is 0, it returns "19700101000000". If the value corresponds to a point of time on and after year 10,000, which cannot be represented in the YYYY... form, an exception of class InvalidTime will be thrown.

Parameters
valueSeconds since epoch to be converted.
Returns
Textual representation of value in the form of YYYYMMDDHHmmSS.
Exceptions
InvalidTimeThe given time specifies on or after year 10,000.
OtherA standard exception, if resource allocation for the returned text fails.

Definition at line 85 of file time_utils.cc.

References isc_throw.

Referenced by isc::dhcp_ddns::NameChangeRequest::getLeaseExpiresOnStr(), and timeToText32().

◆ writeUint()

template<typename uint_t >
uint8_t * isc::util::writeUint ( uint_t const value,
void *const buffer,
size_t const length )

Write the given unsigned integer to the given buffer.

Template Parameters
uint_tData type of the unsigned integer.
Parameters
valueValue to convert.
bufferData buffer at least two bytes long into which the unsigned integer value is written in network-byte order.
lengthLength of the data buffer.
Returns
pointer to the next byte after stored value

Definition at line 56 of file io.h.

References isc_throw.

Referenced by writeUint16(), writeUint32(), and writeUint64().

◆ writeUint16()

uint8_t * isc::util::writeUint16 ( uint16_t const value,
void *const buffer,
size_t const length )
inline

uint16_t wrapper over writeUint.

Definition at line 94 of file io.h.

References writeUint().

Referenced by isc::dhcp::DUIDFactory::createEN(), isc::dhcp::DUIDFactory::createLL(), isc::dhcp::DUIDFactory::createLLT(), isc::dhcp::Option::setUint16(), isc::dhcp::OptionDataTypeUtil::writeInt(), isc::dhcp::OptionDataTypeUtil::writePsid(), isc::dhcp::OptionDataTypeUtil::writeTuple(), and isc::dhcp::OptionDataTypeUtil::writeTuple().

+ Here is the call graph for this function:

◆ writeUint32()

uint8_t * isc::util::writeUint32 ( uint32_t const value,
void *const buffer,
size_t const length )
inline

uint32_t wrapper over writeUint.

Definition at line 100 of file io.h.

References writeUint().

Referenced by isc::dhcp::DUIDFactory::createEN(), isc::dhcp::DUIDFactory::createLLT(), isc::dhcp::Option::setUint32(), and isc::dhcp::OptionDataTypeUtil::writeInt().

+ Here is the call graph for this function:

◆ writeUint64()

uint8_t * isc::util::writeUint64 ( uint64_t const value,
void *const buffer,
size_t const length )
inline

uint64_t wrapper over writeUint.

Definition at line 106 of file io.h.

References writeUint().

+ Here is the call graph for this function:

Variable Documentation

◆ MAX_FSECS_PRECISION

const size_t isc::util::MAX_FSECS_PRECISION =boost::posix_time::time_duration::num_fractional_digits()

The number of digits of fractional seconds supplied by the underlying class, boost::posix_time.

The number of digits of fractional seconds supplied by the underlying class, std::chrono::time_point.

Typically 6 = microseconds.

Definition at line 18 of file boost_time_utils.h.

Referenced by clockToText(), durationToText(), and durationToText().