18 #include <arpa/inet.h> 31 :
Option(V6, type), addrs_(addrs) {
46 return (cloneInternal<Option6AddrLst>());
71 for (AddressContainer::const_iterator addr=
addrs_.begin();
72 addr!=
addrs_.end(); ++addr) {
75 <<
" is not an IPv6 address");
79 buf.
writeData(&addr->toBytes()[0], V6ADDRESS_LEN);
85 if ((distance(begin, end) % V6ADDRESS_LEN) != 0) {
87 <<
" malformed: len=" << distance(begin, end)
88 <<
" is not divisible by 16.");
90 while (begin != end) {
92 begin += V6ADDRESS_LEN;
100 for (AddressContainer::const_iterator addr =
addrs_.begin();
101 addr !=
addrs_.end(); ++addr) {
102 output <<
" " << *addr;
104 return (output.str());
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
boost::shared_ptr< Option > OptionPtr
virtual std::string toText(int indent=0) const
Returns string representation of the option.
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6)
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header) ...
std::vector< isc::asiolink::IOAddress > AddressContainer
a container for (IPv6) addresses
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...
static IOAddress fromBytes(short family, const uint8_t *data)
Creates an address from over wire data.
void setAddress(const isc::asiolink::IOAddress &addr)
Sets a single address.
std::string headerToText(const int indent=0, const std::string &type_name="") const
Returns option header in the textual format.
bool isV6() const
Convenience function to check for an IPv6 address.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received data.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Option6AddrLst(uint16_t type, const AddressContainer &addrs)
Constructor used during option generation.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Defines the logger used by the top-level component of kea-lfc.
void pack(isc::util::OutputBuffer &buf, bool check=true) const
Assembles on-wire form of this option.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order...
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
void setAddresses(const AddressContainer &addrs)
Sets list of addresses.
uint16_t type_
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
The IOAddress class represents an IP addresses (version agnostic)
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header