32                    const size_t transid_offset,
 
   33                    const uint32_t transid,
 
   39     out_buffer.
writeData(&in_buffer[0], in_buffer.size());
 
   41     uint8_t transid_len = (universe == Option::V6) ? 3 : 4;
 
   43     if ((transid_offset + transid_len >= in_buffer.size()) ||
 
   44         (transid_offset == 0)) {
 
   45         cout << 
"Failed to build packet: provided transaction id offset: " 
   46              << transid_offset <<  
" is out of bounds (expected 1.." 
   47              << in_buffer.size()-1 << 
")." << endl;
 
   52         size_t offset_ptr = transid_offset;
 
   53         if (universe == Option::V4) {
 
   54             out_buffer.
writeUint8At(transid >> 24 & 0xFF, offset_ptr++);
 
   56         out_buffer.
writeUint8At(transid >> 16 & 0xFF, offset_ptr++);
 
   57         out_buffer.
writeUint8At(transid >> 8 & 0xFF, offset_ptr++);
 
   63         PktTransform::packOptions(in_buffer, options, out_buffer);
 
   65         cout << 
"Building packet failed: " << e.
what() << endl;
 
   75                      const size_t transid_offset,
 
   78     uint8_t transid_len = (universe == Option::V6) ? 3 : 4;
 
   81     if ((transid_offset + transid_len + 1 > in_buffer.size()) ||
 
   82         (transid_offset == 0)) {
 
   83         cout << 
"Failed to parse packet: provided transaction id offset: " 
   84              << transid_offset <<  
" is out of bounds (expected 1.." 
   85              << in_buffer.size()-1 << 
")." << endl;
 
   94     for (
int i = 0; i < transid_len; ++i, ++it) {
 
   97         transid += *it << (transid_len - i - 1) * 8;
 
  101         PktTransform::unpackOptions(in_buffer, options);
 
  103         ExchangeStats::malformed_pkts_++;
 
  104         cout << 
"Packet parsing failed: " << e.
what() << endl;
 
  112 PktTransform::packOptions(
const OptionBuffer& in_buffer,
 
  119         for (OptionCollection::const_iterator it = options.begin();
 
  120              it != options.end(); ++it) {
 
  122             boost::shared_ptr<LocalizedOption> option =
 
  124             if (option == NULL) {
 
  127             uint32_t offset = option->getOffset();
 
  129                 (offset + option->len() > in_buffer.size())) {
 
  131                           "option offset for option: " << option->getType()
 
  132                           << 
" is out of bounds (expected 1.." 
  133                           << in_buffer.size() - option->len() << 
")");
 
  143             const uint8_t *buf_data =
 
  144                 static_cast<const uint8_t*
>(buf.getData());
 
  145             for (
size_t i = 0; i < buf.getLength(); ++i) {
 
  156 PktTransform::unpackOptions(
const OptionBuffer& in_buffer,
 
  158     for (OptionCollection::const_iterator it = options.begin();
 
  159          it != options.end(); ++it) {
 
  161         boost::shared_ptr<LocalizedOption> option =
 
  162             boost::dynamic_pointer_cast<LocalizedOption>(it->second);
 
  163         if (option == NULL) {
 
  166         size_t opt_pos = option->getOffset();
 
  169                       "(Option position not specified)");
 
  170         } 
else if (opt_pos + option->getHeaderLen() > in_buffer.size()) {
 
  172                       "failed to unpack options from from raw buffer " 
  173                       "(Option position out of bounds)");
 
  176         size_t offset = opt_pos;
 
  177         size_t offset_step = 1;
 
  178         uint16_t opt_type = 0;
 
  179         if (option->getUniverse() == Option::V6) {
 
  182             opt_type = in_buffer[offset] * 256 + in_buffer[offset + 1];
 
  185             opt_type = in_buffer[offset];
 
  188         if (opt_type != option->getType()) {
 
  190                       "failed to unpack option from raw buffer " 
  191                       "(option type mismatch)");
 
  195         offset += offset_step;
 
  196         const uint16_t opt_len =
 
  197             (option->getUniverse() == Option::V6) ?
 
  198             in_buffer[offset] * 256 + in_buffer[offset + 1] :
 
  202         if (offset + option->getHeaderLen() + opt_len > in_buffer.size()) {
 
  204                       "failed to unpack option from raw buffer " 
  205                       "(option truncated)");
 
  209         offset += offset_step;
 
  210         option->setData(in_buffer.begin() + offset,
 
  211                         in_buffer.begin() + offset + opt_len);
 
  217                       dhcp::OptionBuffer::iterator first,
 
  218                       dhcp::OptionBuffer::iterator last) {
 
  219     memcpy(&in_buffer[dest_pos], &(*first), std::distance(first, last));
 
DHCP option at specific offset. 
 
Universe
defines option universe DHCPv4 or DHCPv6 
 
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code. 
 
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer. 
 
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments. 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
 
void clear()
Clear buffer content. 
 
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options. 
 
virtual const char * what() const 
Returns a C-style character string of the cause of the exception. 
 
The OutputBuffer class is a buffer abstraction for manipulating mutable data. 
 
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer 
 
This is a base class for exceptions thrown from the DNS library module. 
 
Defines the logger used by the top-level component of kea-dhcp-ddns. 
 
void writeUint8At(uint8_t data, size_t pos)
Write an unsigned 8-bit integer into the buffer.