31 uint8_t prefix_len, uint32_t pref, uint32_t
valid)
35 if (prefix_len > 128) {
37 <<
" is not a valid prefix length. "
38 <<
"Allowed range is 0..128");
41 if (first_address !=
addr_) {
43 <<
" exceeds prefix/prefix-len pair: " << first_address
44 <<
"/" <<
static_cast<uint32_t
>(prefix_len_));
49 OptionBuffer::const_iterator begin,
50 OptionBuffer::const_iterator end,
54 unpack(begin, end, rec_level);
86 OptionBuffer::const_iterator end) {
91 OptionBuffer::const_iterator end,
98 begin +=
sizeof(uint32_t);
101 begin +=
sizeof(uint32_t);
103 prefix_len_ = *begin;
104 begin +=
sizeof(uint8_t);
108 mask(begin, begin + V6ADDRESS_LEN, prefix_len_, address_with_mask);
110 begin += V6ADDRESS_LEN;
117 std::stringstream output;
119 <<
"prefix=" <<
addr_ <<
"/" <<
static_cast<int>(prefix_len_)
121 <<
", valid-lft=" <<
valid_;
124 return (output.str());
133 length += it.second->len();
139Option6IAPrefix::mask(OptionBuffer::const_iterator begin,
140 OptionBuffer::const_iterator end,
143 output_address.resize(16, 0);
145 std::copy(begin, end, output_address.begin());
146 }
else if (
len > 0) {
149 std::copy(begin, begin +
static_cast<uint8_t
>(
len/8), output_address.begin());
158 output_address[
len/8] = (*(begin +
len/8) & (0xFF << (8 - (
len % 8))));
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...
The IOAddress class represents an IP addresses (version agnostic).
static IOAddress fromBytes(short family, const uint8_t *data)
Creates an address from over wire data.
unsigned int valid_
contains valid-lifetime timer (in seconds)
Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress &addr, uint32_t preferred, uint32_t valid)
Constructor, used for options constructed (during transmission).
isc::asiolink::IOAddress addr_
contains an IPv6 address
unsigned int preferred_
contains preferred-lifetime timer (in seconds)
static const size_t OPTION6_IAPREFIX_LEN
length of the fixed part of the IAPREFIX option
virtual std::string toText(int indent=0) const
Returns string representation of the option.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
Option6IAPrefix(uint16_t type, const isc::asiolink::IOAddress &addr, uint8_t prefix_length, uint32_t preferred, uint32_t valid)
Constructor, used for options constructed (during transmission).
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
virtual uint16_t len() const
returns data length (data length + DHCPv4/DHCPv6 option header)
void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes option in wire-format.
uint16_t type_
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
std::string headerToText(const int indent=0, const std::string &type_name="") const
Returns option header in the textual format.
std::string suboptionsToText(const int indent=0) const
Returns collection of suboptions in the textual format.
void setEncapsulatedSpace(const std::string &encapsulated_space)
Sets the name of the option space encapsulated by this option.
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6).
void packOptions(isc::util::OutputBuffer &buf, bool check=true) const
Store sub options in a buffer.
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header
virtual bool valid() const
returns if option is valid (e.g.
OptionCollection options_
collection for storing suboptions
void unpackOptions(const OptionBuffer &buf, size_t rec_level=0)
Builds a collection of sub options from the buffer.
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
IOAddress firstAddrInPrefix(const IOAddress &prefix, uint8_t len)
This code is based on similar code from the Dibbler project.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< Option > OptionPtr
uint32_t readUint32(void const *const buffer, size_t const length)
uint32_t wrapper over readUint.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP6_OPTION_SPACE