14#include <boost/functional/hash.hpp> 
   29                  "Null pointer passed to LabelSequence constructor");
 
   33    const uint8_t* bp = 
reinterpret_cast<const uint8_t*
>(buf);
 
   35    const uint8_t offsets_len = *bp++;
 
   40                  "Bad offsets len in serialized LabelSequence data: " 
   41                  << 
static_cast<unsigned int>(offsets_len));
 
   45    last_label_ = offsets_len - 1;
 
   47    data_ = bp + offsets_len;
 
   51    const uint8_t* dp = data_;
 
   52    for (
size_t cur_offset = 0; cur_offset < offsets_len; ++cur_offset) {
 
   55                      "Broken offset or name data in serialized " 
   56                      "LabelSequence data");
 
 
   67    std::memcpy(buf, 
data, data_len);
 
   71                                  src.offsets_[src.first_label_];
 
   75    last_label_ = src.last_label_ - src.first_label_;
 
 
   84    return (&data_[offsets_[first_label_]]);
 
 
   89    const size_t last_label_len = data_[offsets_[last_label_]] + 1;
 
   90    return (offsets_[last_label_] - offsets_[first_label_] + last_label_len);
 
 
  103isOutOfRange(
const uint8_t* bp, 
const uint8_t* ep,
 
  104             const uint8_t* buf, 
size_t buf_len) {
 
  105    return (bp >= buf + buf_len || 
 
  113    if (expected_size > buf_len) {
 
  122    uint8_t* bp = 
reinterpret_cast<uint8_t*
>(buf);
 
  124    if (!isOutOfRange(offsets_, offsets_ + offsets_len, bp, buf_len) ||
 
  125        !isOutOfRange(data_, data_ + ndata_len, bp, buf_len)) {
 
  130    for (
size_t i = 0; i < offsets_len; ++i) {
 
  131        *bp++ = offsets_[first_label_ + i] - offsets_[first_label_];
 
  133    std::memcpy(bp, &data_[offsets_[first_label_]], ndata_len);
 
  137                     static_cast<ssize_t
>(expected_size));
 
 
  142    size_t len, other_len;
 
  144    const uint8_t* other_data = other.
getData(&other_len);
 
  146    if (len != other_len) {
 
  149    if (case_sensitive) {
 
  150        return (std::memcmp(
data, other_data, len) == 0);
 
  156    for (
size_t i = 0; i < len; ++i) {
 
  157        const uint8_t ch = 
data[i];
 
  158        const uint8_t other_ch = other_data[i];
 
 
  169                       bool case_sensitive)
 const {
 
  174    unsigned int nlabels = 0;
 
  177    const int ldiff = 
static_cast<int>(l1) - 
static_cast<int>(l2);
 
  178    unsigned int l = (ldiff < 0) ? l1 : l2;
 
  184        size_t pos1 = offsets_[l1 + first_label_];
 
  185        size_t pos2 = other.offsets_[l2 + other.first_label_];
 
  186        unsigned int count1 = data_[pos1++];
 
  187        unsigned int count2 = other.data_[pos2++];
 
  193        const int cdiff = 
static_cast<int>(count1) - 
static_cast<int>(count2);
 
  194        unsigned int count = (cdiff < 0) ? count1 : count2;
 
  197            const uint8_t label1 = data_[pos1];
 
  198            const uint8_t label2 = other.data_[pos2];
 
  201            if (case_sensitive) {
 
  202                chdiff = 
static_cast<int>(label1) - 
static_cast<int>(label2);
 
  204                chdiff = 
static_cast<int>(
 
  232    } 
else if (ldiff > 0) {
 
 
  260    return (data_[offsets_[last_label_]] == 0);
 
 
  266    const uint8_t* s = 
getData(&length);
 
  273        const uint8_t c = *s++;
 
  274        boost::hash_combine(hash_val, case_sensitive ? c :
 
 
  283    const uint8_t* np = &data_[offsets_[first_label_]];
 
  296    while (np != np_end) {
 
  304            if (!omit_final_dot || result.empty()) {
 
  305                result.push_back(
'.');
 
  313            if (!result.empty()) {
 
  315                result.push_back(
'.');
 
  318            while (count-- > 0) {
 
  319                const uint8_t c = *np++;
 
 
  337    const uint8_t* np = &data_[offsets_[first_label_]];
 
  350    while (np != np_end) {
 
  358            if (!omit_final_dot || result.empty()) {
 
  359                result.push_back(
'.');
 
  367            if (!result.empty()) {
 
  369                result.push_back(
'.');
 
  372            while (count-- > 0) {
 
  373                const uint8_t c = *np++;
 
  384                    result.push_back(
'\\');
 
  388                    if (c > 0x20 && c < 0x7f) {
 
  393                        result.push_back(0x5c);
 
  394                        result.push_back(0x30 + ((c / 100) % 10));
 
  395                        result.push_back(0x30 + ((c / 10) % 10));
 
  396                        result.push_back(0x30 + (c % 10));
 
  401            isc_throw(BadLabelType, 
"unknown label type in name data");
 
  421    size_t label_count = last_label_ + 1;
 
  424    size_t data_pos = offsets_[last_label_] + data_[offsets_[last_label_]] + 1;
 
  438                  "extend() called with unrelated buffer");
 
  443                  "extend() would exceed maximum number of labels");
 
  447                  "extend() would exceed maximum wire length");
 
  451    std::memmove(&buf[data_pos], 
data, data_len);
 
  453    for (
size_t i = 0; i < append_label_count; ++i) {
 
  456            labels.offsets_[i + labels.first_label_] -
 
  457            labels.offsets_[labels.first_label_];
 
  459    last_label_ = label_count + append_label_count - 1;
 
 
  464    os << label_sequence.
toText();
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
A standard DNS module exception that is thrown if the name parser encounters an obsolete or incomplet...
Light-weight Accessor to Name data.
std::string toRawText(bool omit_final_dot) const
Convert the LabelSequence to a string without escape sequences.
static const size_t MAX_SERIALIZED_LENGTH
Max possible size of serialized image generated by serialize.
size_t getHash(bool case_sensitive) const
Calculate a simple hash for the label sequence.
void serialize(void *buf, size_t buf_len) const
Serialize the LabelSequence object in to a buffer.
NameComparisonResult compare(const LabelSequence &other, bool case_sensitive=false) const
Compares two label sequences.
bool isAbsolute() const
Checks whether the label sequence is absolute.
std::string toText() const
Convert the LabelSequence to a string.
LabelSequence(const Name &name)
Constructs a LabelSequence for the given name.
bool equals(const LabelSequence &other, bool case_sensitive=false) const
Compares two label sequences for equality.
size_t getLabelCount() const
Returns the current number of labels for this LabelSequence.
size_t getSerializedLength() const
Return the size of serialized image of the LabelSequence.
void stripLeft(size_t i)
Remove labels from the front of this LabelSequence.
const uint8_t * getData(size_t *len) const
Return the wire-format data for this LabelSequence.
void stripRight(size_t i)
Remove labels from the end of this LabelSequence.
size_t getDataLength() const
Return the length of the wire-format data of this LabelSequence.
void extend(const LabelSequence &labels, uint8_t buf[MAX_SERIALIZED_LENGTH])
Extend this LabelSequence with the given labelsequence.
This is a supplemental class used only as a return value of Name::compare() and LabelSequence::compar...
static const size_t MAX_LABELLEN
Max allowable length of labels of a domain name.
static const size_t MAX_WIRE
Max allowable length of domain names.
static const size_t MAX_LABELS
Max allowable labels of domain names.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
const uint8_t maptolower[]
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Defines the logger used by the top-level component of kea-lfc.