Kea 2.5.8
isc::dns::rdata::generic::detail Namespace Reference

Classes

class  TXTLikeImpl
 rdata::TXTLikeImpl class represents the TXT-like RDATA for TXT and SPF types. More...
 

Typedefs

typedef std::vector< uint8_t > CharString
 Type for DNS character string.
 
typedef std::vector< uint8_t > CharStringData
 Type for DNS character string without the length prefix.
 

Functions

size_t bufferToCharString (isc::util::InputBuffer &buffer, size_t rdata_len, CharString &target)
 Convert a buffer containing a character-string to CharString.
 
std::string charStringDataToString (const CharStringData &char_string)
 Convert a CharStringData into a textual DNS character-string.
 
std::string charStringToString (const CharString &char_string)
 Convert a CharString into a textual DNS character-string.
 
int compareCharStringDatas (const CharStringData &self, const CharStringData &other)
 Compare two CharStringData objects.
 
int compareCharStrings (const CharString &self, const CharString &other)
 Compare two CharString objects.
 
Name createNameFromLexer (MasterLexer &lexer, const Name *origin)
 Construct a Name object using a master lexer and optional origin.
 
void stringToCharString (const MasterToken::StringRegion &str_region, CharString &result)
 Convert a DNS character-string into corresponding binary data.
 
void stringToCharStringData (const MasterToken::StringRegion &str_region, CharStringData &result)
 Convert a DNS character-string into corresponding binary data.
 

Typedef Documentation

◆ CharString

typedef std::vector<uint8_t> isc::dns::rdata::generic::detail::CharString

Type for DNS character string.

A character string can contain any unsigned 8-bit value, so this cannot be the bare char basis.

Definition at line 27 of file char_string.h.

◆ CharStringData

Type for DNS character string without the length prefix.

Definition at line 30 of file char_string.h.

Function Documentation

◆ bufferToCharString()

size_t isc::dns::rdata::generic::detail::bufferToCharString ( isc::util::InputBuffer buffer,
size_t  rdata_len,
CharString target 
)

Convert a buffer containing a character-string to CharString.

This method reads one character-string from the given buffer (in wire format) and places the result in the given CharString object. Since this is expected to be used in message parsing, the exception it raises is of that type.

On success, the buffer position is advanced to the end of the char-string, and the number of bytes read is returned.

Parameters
bufferThe buffer to read from.
rdata_lenThe total size of the rr's rdata currently being read (used for integrity checks in the wire data)
targetThe CharString where the result will be stored. Any existing data in the target will be overwritten.
Exceptions
DNSMessageFORMERRIf the available data is not enough to read the character-string, or if the character-string length is out of bounds
Returns
The number of bytes read

Definition at line 235 of file char_string.cc.

References isc::util::InputBuffer::getLength(), isc::util::InputBuffer::getPosition(), isc_throw, isc::util::InputBuffer::readData(), and isc::util::InputBuffer::readUint8().

+ Here is the call graph for this function:

◆ charStringDataToString()

std::string isc::dns::rdata::generic::detail::charStringDataToString ( const CharStringData char_string)

Convert a CharStringData into a textual DNS character-string.

Reverse of stringToCharStringData(). See stringToCharString() vs. stringToCharStringData().

Parameters
char_stringThe CharStringData to convert.
Returns
A string representation of char_string.

Definition at line 148 of file char_string.cc.

◆ charStringToString()

std::string isc::dns::rdata::generic::detail::charStringToString ( const CharString char_string)

Convert a CharString into a textual DNS character-string.

This method converts a binary 8-bit representation of a DNS character string into a textual string representation, escaping any special characters in the process. For example, characters like double-quotes, semi-colon and backspace are prefixed with backspace character, and characters not in the printable range of [0x20, 0x7e] (inclusive) are converted to the \xxx 3-digit decimal representation.

Parameters
char_stringThe CharString to convert.
Returns
A string representation of char_string.

Definition at line 121 of file char_string.cc.

Referenced by isc::dns::rdata::generic::detail::TXTLikeImpl< Type, typeCode >::toText().

◆ compareCharStringDatas()

int isc::dns::rdata::generic::detail::compareCharStringDatas ( const CharStringData self,
const CharStringData other 
)

Compare two CharStringData objects.

Parameters
selfThe CharStringData field to compare
otherThe CharStringData field to compare to
Returns
-1 if self would be sorted before other 1 if self would be sorted after other 0 if self and other are equal

Definition at line 206 of file char_string.cc.

◆ compareCharStrings()

int isc::dns::rdata::generic::detail::compareCharStrings ( const CharString self,
const CharString other 
)

Compare two CharString objects.

Parameters
selfThe CharString field to compare
otherThe CharString field to compare to
Returns
-1 if self would be sorted before other 1 if self would be sorted after other 0 if self and other are equal

Definition at line 169 of file char_string.cc.

◆ createNameFromLexer()

Name isc::dns::rdata::generic::detail::createNameFromLexer ( MasterLexer lexer,
const Name origin 
)
inline

Construct a Name object using a master lexer and optional origin.

This is a convenient shortcut of commonly used code pattern that would be used to build RDATA that contain a domain name field.

Note that this function throws an exception against invalid input. The (direct or indirect) caller's responsibility needs to expect and handle exceptions appropriately.

Exceptions
MasterLexer::LexerErrorThe next token from lexer is not string.
OtherExceptions from the Name class constructor if the next string token from the lexer does not represent a valid name.
Parameters
lexerA MasterLexer object. Its next token is expected to be a string that represent a domain name.
originIf non null, specifies the origin of the name to be constructed.
Returns
A new Name object that corresponds to the next string token of the lexer.

Definition at line 207 of file rdataclass.h.

References isc::dns::MasterToken::StringRegion::beg, isc::dns::MasterLexer::getNextToken(), isc::dns::MasterToken::getStringRegion(), isc::dns::MasterToken::StringRegion::len, and isc::dns::MasterToken::STRING.

+ Here is the call graph for this function:

◆ stringToCharString()

void isc::dns::rdata::generic::detail::stringToCharString ( const MasterToken::StringRegion str_region,
CharString result 
)

Convert a DNS character-string into corresponding binary data.

This helper function takes a string object that is expected to be a textual representation of a valid DNS character-string, and dumps the corresponding binary sequence in the given placeholder (passed via the result parameter). It handles escape notations of character-strings with a backslash ('\'), and checks the length restriction.

Exceptions
CharStringTooLongThe resulting binary data are too large for a valid character-string.
InvalidRdataTextOther syntax errors.

str_region A string that represents a character-string.

result A placeholder vector where the resulting data are to be stored. Expected to be empty, but it's not checked.

Definition at line 55 of file char_string.cc.

References isc::dns::MasterToken::StringRegion::beg, isc_throw, isc::dns::MasterToken::StringRegion::len, and isc::dns::rdata::MAX_CHARSTRING_LEN.

◆ stringToCharStringData()

void isc::dns::rdata::generic::detail::stringToCharStringData ( const MasterToken::StringRegion str_region,
CharStringData result 
)

Convert a DNS character-string into corresponding binary data.

This method functions similar to stringToCharString() except it does not include the 1-octet length prefix in the result, and the result is not limited to MAX_CHARSTRING_LEN octets.

Exceptions
InvalidRdataTextUpon syntax errors.

str_region A string that represents a character-string.

result A placeholder vector where the resulting data are to be stored. Expected to be empty, but it's not checked.

Definition at line 92 of file char_string.cc.

References isc::dns::MasterToken::StringRegion::beg, isc_throw, and isc::dns::MasterToken::StringRegion::len.