Kea  2.3.9
rdatafields.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2015 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 RDATAFIELDS_H
8 #define RDATAFIELDS_H 1
9 
10 #include <stdint.h>
11 
12 #include <cstddef>
13 
14 namespace isc {
15 namespace util {
16 class OutputBuffer;
17 }
18 namespace dns {
19 class AbstractMessageRenderer;
20 
21 namespace rdata {
22 class Rdata;
23 
83 
151 class RdataFields {
152 public:
159  enum Type {
163  };
164 
206  struct FieldSpec {
207  FieldSpec(Type type_param, uint16_t len_param) :
208  type(type_param), len(len_param)
209  {}
211  uint16_t len;
212  };
213 
220 
221 private:
222  RdataFields(const RdataFields& source);
223  RdataFields& operator=(const RdataFields& source);
224 
225 public:
247  RdataFields(const Rdata& rdata);
248 
295  RdataFields(const void* fields, const unsigned int fields_length,
296  const void* data, const size_t data_length);
297 
299  ~RdataFields();
301 
305 
306  unsigned int getDataLength() const { return (data_length_); }
311 
317  const void* getData() const { return (data_); }
318 
323  unsigned int getFieldSpecDataSize() const { return (nfields_ *
324  sizeof (*fields_)); }
325 
331  unsigned int getFieldCount() const { return (nfields_); }
332 
353  const void* getFieldSpecData() const {
354  return (fields_);
355  }
356 
371  FieldSpec getFieldSpec(const unsigned int field_id) const;
373 
377 
378  void toWire(AbstractMessageRenderer& renderer) const;
390 
398  void toWire(isc::util::OutputBuffer& buffer) const;
400 
401 private:
402  const FieldSpec* fields_;
403  unsigned int nfields_;
404  const uint8_t* data_;
405  size_t data_length_;
406 
407  // hide further details within the implementation and don't create vectors
408  // every time we don't need them.
409  struct RdataFieldsDetail;
410  RdataFieldsDetail* detail_;
411 };
412 }
413 }
414 }
415 #endif // RDATAFIELDS_H
416 
417 // Local Variables:
418 // mode: c++
419 // End:
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
A low-level, RR type-independent representation of DNS RDATA.
Definition: rdatafields.h:151
~RdataFields()
The destructor.
Definition: rdatafields.cc:178
FieldSpec getFieldSpec(const unsigned int field_id) const
Return the specification of the field identified by the given index.
Definition: rdatafields.cc:183
const void * getFieldSpecData() const
Return a pointer to a sequence of FieldSpec for the RdataFields.
Definition: rdatafields.h:353
unsigned int getFieldSpecDataSize() const
Return the number of bytes the buffer returned by getFieldSpecData() will occupy.
Definition: rdatafields.h:323
unsigned int getFieldCount() const
Return the number of specs fields.
Definition: rdatafields.h:331
const void * getData() const
Return a pointer to the RDATA encoded in the RdataFields.
Definition: rdatafields.h:317
Type
Types of RdataFields fields.
Definition: rdatafields.h:159
@ INCOMPRESSIBLE_NAME
A domain name that shouldn't be compressed.
Definition: rdatafields.h:162
@ COMPRESSIBLE_NAME
A domain name subject to name compression.
Definition: rdatafields.h:161
unsigned int getDataLength() const
Return the length of the entire RDATA encoded in the RdataFields in bytes.
Definition: rdatafields.h:310
void toWire(AbstractMessageRenderer &renderer) const
Render the RdataFields in the wire format with name compression.
Definition: rdatafields.cc:191
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-lfc.
Structure that specifies a single RdataFields field.
Definition: rdatafields.h:206
Type type
The type of the field.
Definition: rdatafields.h:210
FieldSpec(Type type_param, uint16_t len_param)
Definition: rdatafields.h:207
uint16_t len
The length of the field in bytes.
Definition: rdatafields.h:211