Kea  2.1.7-git
isc::util Namespace Reference

Namespaces

 detail
 
 encode
 
 file
 
 io
 
 str
 
 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...
 
class  Filename
 Class to Manipulate Filenames. 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  InvalidBufferPosition
 A standard DNS module exception that is thrown if an out-of-range buffer operation is being performed. 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...
 
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. More...
 
typedef LabeledValuePtr EventPtr
 Define Event pointer. More...
 
typedef boost::shared_ptr< InputBufferInputBufferPtr
 Pointer-like types pointing to InputBuffer or OutputBuffer. More...
 
typedef std::map< unsigned int, LabeledValuePtrLabeledValueMap
 Defines a map of pointers to LabeledValues keyed by value. More...
 
typedef boost::shared_ptr< LabeledValueLabeledValuePtr
 Defines a shared pointer to a LabeledValue instance. More...
 
typedef boost::shared_ptr< OutputBufferOutputBufferPtr
 
typedef boost::shared_ptr< PIDFilePIDFilePtr
 Defines a shared pointer to a PIDFile. More...
 
typedef boost::shared_ptr< ReconnectCtlReconnectCtlPtr
 Pointer to an instance of ReconnectCtl. More...
 
typedef std::function< void()> StateHandler
 Defines a pointer to an instance method for handling a state. More...
 
typedef boost::shared_ptr< StateModelStateModelPtr
 Defines a pointer to a StateModel. More...
 
typedef boost::shared_ptr< StateStatePtr
 Defines a shared pointer to a State. More...
 
typedef boost::shared_ptr< std::thread > ThreadPtr
 Thread pointer type. More...
 
typedef boost::shared_ptr< VersionedColumnVersionedColumnPtr
 Defines a smart pointer to VersionedColumn. More...
 
typedef boost::shared_ptr< WatchedThreadWatchedThreadPtr
 Defines a pointer to a WatchedThread. More...
 
typedef boost::shared_ptr< WatchSocketWatchSocketPtr
 Defines a smart pointer to an instance of a WatchSocket. More...
 

Enumerations

enum  DhcpSpace { DHCPv4, DHCPv6 }
 
enum  OnFailAction { OnFailAction::STOP_RETRY_EXIT, OnFailAction::SERVE_RETRY_EXIT, OnFailAction::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. More...
 
std::string clockToText (std::chrono::system_clock::time_point t, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts chrono time point structure to text. More...
 
template<DhcpSpace D>
char const * cStringDhcpSpace ()
 Provides the C string representation of the DHCP space. More...
 
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. More...
 
template<typename Duration >
std::string durationToText (Duration dur, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts StatsDuration to text. More...
 
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. More...
 
template<typename Iterator >
void fillRandom (Iterator begin, Iterator end)
 Fill in specified range with a random data. More...
 
template<DhcpSpace D>
std::string formatDhcpSpace (char const *const format_string)
 Replaces all occurences of {} with 4 or 6 based on the templated DHCP space. More...
 
template<typename Iterator >
bool isRangeZero (Iterator begin, Iterator end)
 Checks if specified range in a container contains only zeros. More...
 
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. More...
 
std::ostream & operator<< (std::ostream &os, const LabeledValue &vlp)
 Dumps the label to ostream. More...
 
std::ostream & operator<< (std::ostream &os, const CSVRow &row)
 Overrides standard output stream operator for CSVRow object. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Optional< T > &optional_value)
 Inserts an optional value to a stream. More...
 
std::string ptimeToText (boost::posix_time::ptime t, size_t fsecs_precision=MAX_FSECS_PRECISION)
 Converts ptime structure to text. More...
 
uint16_t readUint16 (const void *buffer, size_t length)
 Read Unsigned 16-Bit Integer from Buffer. More...
 
uint32_t readUint32 (const uint8_t *buffer, size_t length)
 Read Unsigned 32-Bit Integer from Buffer. More...
 
uint64_t readUint64 (const uint8_t *buffer, size_t length)
 Read Unsigned 64-Bit Integer from Buffer. More...
 
uint8_t * writeUint16 (uint16_t value, void *buffer, size_t length)
 Write Unsigned 16-Bit Integer to Buffer. More...
 
uint8_t * writeUint32 (uint32_t value, uint8_t *buffer, size_t length)
 Write Unsigned 32-Bit Integer to Buffer. More...
 
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. More...
 
string timeToText32 (const uint32_t value)
 Convert integral DNSSEC time to textual form, 32-bit version. More...
 
uint64_t timeFromText64 (const std::string &time_txt)
 Convert textual DNSSEC time to integer, 64-bit version. More...
 
uint32_t timeFromText32 (const std::string &time_txt)
 Convert textual DNSSEC time to integer, 32-bit version. More...
 

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. More...
 

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

Pointer-like types pointing to InputBuffer or OutputBuffer.

These types are expected to be used as an argument in asynchronous callback functions. The internal reference-counting will ensure that that ongoing state information will not be lost if the object that originated the asynchronous call falls out of scope.

Definition at line 602 of file buffer.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

Definition at line 603 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.

◆ 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

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"

◆ 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.

References isc::cryptolink::random().

+ Here is the call graph for this function:

◆ formatDhcpSpace()

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

Replaces all occurences 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.

◆ 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.

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

◆ 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 LabeledValue vlp 
)

Dumps the label to ostream.

Definition at line 51 of file labeled_value.cc.

References isc::util::LabeledValue::getLabel(), and isc::util::LabeledValueSet::UNDEFINED_LABEL.

+ Here is the call graph for this function:

◆ operator<<() [2/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_throw, and isc::util::CSVRow::render().

Referenced by isc::dns::RRset::getRRsig(), isc::dns::RRClass::NONE(), isc::dns::Question::operator!=(), isc::util::CSVRow::operator!=(), isc::dns::RRTTL::operator>(), isc::dns::Name::ROOT_NAME(), and isc::dns::RRType::URI().

+ 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 192 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(), and isc::ha::CommunicationState::logFormatClockSkew().

+ Here is the call graph for this function:

◆ readUint16()

uint16_t isc::util::readUint16 ( const void *  buffer,
size_t  length 
)
inline

◆ readUint32()

uint32_t isc::util::readUint32 ( const uint8_t *  buffer,
size_t  length 
)
inline

Read Unsigned 32-Bit Integer from Buffer.

Parameters
bufferData buffer at least four bytes long of which the first four bytes are assumed to represent a 32-bit integer in network-byte order.
lengthLength of the data buffer.
Returns
Value of 32-bit unsigned integer

Definition at line 79 of file io_utilities.h.

References isc_throw.

Referenced by isc::dhcp::DUIDFactory::createEN(), isc::dhcp::DUIDFactory::createLLT(), isc::dhcp::Option::getUint32(), isc::dhcp::OptionDataTypeUtil::readInt(), isc::dhcp::Option6IA::unpack(), isc::dhcp::OptionVendor::unpack(), isc::dhcp::OptionVendorClass::unpack(), isc::dhcp::Option6IAPrefix::unpack(), isc::dhcp::OptionInt< T >::unpack(), and isc::dhcp::OptionIntArray< T >::unpack().

◆ readUint64()

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

Read Unsigned 64-Bit Integer from Buffer.

Parameters
bufferData buffer at least four bytes long of which the first four bytes are assumed to represent a 64-bit integer in network-byte order.
lengthLength of the data buffer.
Returns
Value of 64-bit unsigned integer

Definition at line 105 of file io_utilities.h.

References isc_throw.

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

◆ 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.

Definition at line 196 of file time_utilities.cc.

References timeFromText64().

Referenced by isc::util::InvalidTime::InvalidTime().

+ 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.
Exceptions
InvalidTimeThe given textual representation is invalid.
Parameters
time_txtTextual time in the form of YYYYMMDDHHmmSS
Returns
Seconds since epoch corresponding to time_txt

Definition at line 154 of file time_utilities.cc.

References isc_throw.

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

◆ timeToText32()

std::string isc::util::timeToText32 ( const 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".

Definition at line 122 of file time_utilities.cc.

References isc::util::detail::gettimeWrapper(), isc_throw, and timeToText64().

Referenced by isc::util::InvalidTime::InvalidTime().

+ 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.

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

Definition at line 50 of file time_utilities.cc.

References isc_throw.

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

◆ writeUint16()

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

Write Unsigned 16-Bit Integer to Buffer.

This is essentially a copy of isc::util::OutputBuffer::writeUint16. It should really be moved into a separate library.

Parameters
value16-bit value to convert
bufferData buffer at least two bytes long into which the 16-bit value is written in network-byte order.
lengthLength of the data buffer.
Returns
pointer to the next byte after stored value

Definition at line 55 of file io_utilities.h.

References isc_throw.

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

◆ writeUint32()

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

Write Unsigned 32-Bit Integer to Buffer.

Parameters
value32-bit value to convert
bufferData buffer at least four bytes long into which the 32-bit value is written in network-byte order.
lengthLength of the data buffer.
Returns
pointer to the next byte after stored value

Definition at line 136 of file io_utilities.h.

References isc_throw.

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

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(), and durationToText().