Kea  1.9.9-git
isc::dns::rdata::RdataFields::FieldSpec Struct Reference

Structure that specifies a single RdataFields field. More...

#include <rdatafields.h>

Public Member Functions

 FieldSpec (Type type_param, uint16_t len_param)
 

Public Attributes

uint16_t len
 The length of the field in bytes. More...
 
Type type
 The type of the field. More...
 

Detailed Description

Structure that specifies a single RdataFields field.

This is a straightforward pair of the type and length of a single RdataFields field.

In some cases an application may want to do deeper inspection of some RdataFields field(s). For example, an application may want to construct a Name object for each domain name field of an RDATA and use it for some special purpose. The FieldSpec structure provides necessary parameters to get access to a specific RdataFields field.

The following code snippet implements the above example scenario:

// assume "fields" is of type RdataFields
size_t offset = 0;
for (int i = 0; i < fields.getFieldCount(); ++i) {
const FieldSpec spec = fields.getFieldSpec(i);
if (spec.type == RdataFields::COMPRESSIBLE_NAME ||
InputBuffer ibuffer(fields.getData() + offset, spec.len);
Name name(ibuffer);
// do something with name
}
offset += spec.len;
}

Note that the offset is not included in FieldSpec. This is because such deeper inspection would be a relatively rare operation while it is desirable to keep this structure as small as possible for the purpose of space efficiency. Also, if and when an application wants to look into a specific field, it would be quite likely that the application iterates over all fields and does something special for selected fields like the above example. In that case the application can easily and efficiently identify the necessary offset, again, as shown in the above code example.

Todo:
We might find that 16bits per field is generally too much and squeeze the two bit type into it as well, having 14bit length (in the rare case of having too long field, it could be split into multiple ones). That would save 2 bytes per item (one for the type, one for padding).

Definition at line 206 of file rdatafields.h.

Constructor & Destructor Documentation

isc::dns::rdata::RdataFields::FieldSpec::FieldSpec ( Type  type_param,
uint16_t  len_param 
)
inline

Definition at line 207 of file rdatafields.h.

Member Data Documentation

uint16_t isc::dns::rdata::RdataFields::FieldSpec::len

The length of the field in bytes.

Definition at line 211 of file rdatafields.h.

Referenced by isc::dns::rdata::RdataFields::RdataFields(), and isc::dns::rdata::RdataFields::toWire().

Type isc::dns::rdata::RdataFields::FieldSpec::type

The type of the field.

Definition at line 210 of file rdatafields.h.


The documentation for this struct was generated from the following file: