Kea  2.1.7-git
isc::dhcp::Pkt6 Class Reference

Represents a DHCPv6 packet. More...

#include <pkt6.h>

+ Inheritance diagram for isc::dhcp::Pkt6:

Classes

struct  RelayInfo
 structure that describes a single relay information More...
 

Public Types

enum  DHCPv6Proto { UDP = 0, TCP = 1 }
 DHCPv6 transport protocol. More...
 
enum  RelaySearchOrder { RELAY_SEARCH_FROM_CLIENT = 1, RELAY_SEARCH_FROM_SERVER = 2, RELAY_GET_FIRST = 3, RELAY_GET_LAST = 4 }
 defines relay search pattern More...
 

Public Member Functions

 Pkt6 (uint8_t msg_type, uint32_t transid, DHCPv6Proto proto=UDP)
 Constructor, used in replying to a message. More...
 
 Pkt6 (const uint8_t *buf, uint32_t len, DHCPv6Proto proto=UDP)
 Constructor, used in message transmission. More...
 
void addRelayInfo (const RelayInfo &relay)
 add information about one traversed relay More...
 
void copyRelayInfo (const Pkt6Ptr &question)
 copies relay information from client's packet to server's response More...
 
OptionPtr getAnyRelayOption (const uint16_t option_code, const RelaySearchOrder &order)
 Return first instance of a specified option. More...
 
DuidPtr getClientId () const
 Retrieves the DUID from the Client Identifier option. More...
 
virtual std::string getLabel () const
 Returns text representation of the primary packet identifiers. More...
 
const char * getName () const
 Returns name of the DHCPv6 message. More...
 
isc::dhcp::OptionCollection getOptions (const uint16_t type)
 Returns all instances of specified type. More...
 
DHCPv6Proto getProto ()
 Returns protocol of this packet (UDP or TCP). More...
 
const isc::asiolink::IOAddressgetRelay6LinkAddress (uint8_t relay_level) const
 return the link address field from a relay option More...
 
const isc::asiolink::IOAddressgetRelay6PeerAddress (uint8_t relay_level) const
 return the peer address field from a relay option More...
 
OptionPtr getRelayOption (uint16_t option_code, uint8_t nesting_level)
 Returns option inserted by relay. More...
 
virtual uint8_t getType () const
 Returns message type (e.g. More...
 
virtual size_t len ()
 Returns length of the packet. More...
 
virtual void pack ()
 Prepares on-wire format. More...
 
void setProto (DHCPv6Proto proto=UDP)
 Sets protocol of this packet. More...
 
virtual void setType (uint8_t type)
 Sets message type (e.g. More...
 
virtual std::string toText () const
 Returns text representation of the packet. More...
 
virtual void unpack ()
 Dispatch method that handles binary packet parsing. More...
 
- Public Member Functions inherited from isc::dhcp::Pkt
virtual ~Pkt ()
 Virtual destructor. More...
 
void addClass (const isc::dhcp::ClientClass &client_class, bool required=false)
 Adds packet to a specified class. More...
 
virtual void addOption (const OptionPtr &opt)
 Adds an option to this packet. More...
 
bool delOption (uint16_t type)
 Attempts to delete first suboption of requested type. More...
 
isc::util::OutputBuffergetBuffer ()
 Returns reference to output buffer. More...
 
const ClientClassesgetClasses (bool required=false) const
 Returns the class set. More...
 
std::string getIface () const
 Returns interface name. More...
 
int getIndex () const
 Returns interface index. More...
 
const isc::asiolink::IOAddressgetLocalAddr () const
 Returns local IP address. More...
 
uint16_t getLocalPort () const
 Returns local UDP (and soon TCP) port. More...
 
HWAddrPtr getMAC (uint32_t hw_addr_src)
 Returns MAC address. More...
 
OptionPtr getOption (const uint16_t type)
 Returns the first option of specified type. More...
 
const isc::asiolink::IOAddressgetRemoteAddr () const
 Returns remote IP address. More...
 
HWAddrPtr getRemoteHWAddr () const
 Returns the remote HW address obtained from raw sockets. More...
 
uint16_t getRemotePort () const
 Returns remote port. More...
 
const boost::posix_time::ptime & getTimestamp () const
 Returns packet timestamp. More...
 
uint32_t getTransid () const
 Returns value of transaction-id field. More...
 
bool inClass (const isc::dhcp::ClientClass &client_class)
 Checks whether a client belongs to a given class. More...
 
bool indexSet () const
 Checks if interface index has been set. More...
 
bool isCopyRetrievedOptions () const
 Returns whether the copying of retrieved options is enabled. More...
 
void repack ()
 Copies content of input buffer to output buffer. More...
 
void resetIndex ()
 Resets interface index to negative value. More...
 
virtual void setCopyRetrievedOptions (const bool copy)
 Controls whether the option retrieved by the Pkt::getOption should be copied before being returned. More...
 
void setIface (const std::string &iface)
 Sets interface name. More...
 
void setIndex (int ifindex)
 Sets interface index. More...
 
void setLocalAddr (const isc::asiolink::IOAddress &local)
 Sets local IP address. More...
 
void setLocalPort (uint16_t local)
 Sets local UDP (and soon TCP) port. More...
 
void setRemoteAddr (const isc::asiolink::IOAddress &remote)
 Sets remote IP address. More...
 
void setRemoteHWAddr (const HWAddrPtr &hw_addr)
 Sets remote hardware address. More...
 
void setRemoteHWAddr (const uint8_t htype, const uint8_t hlen, const std::vector< uint8_t > &hw_addr)
 Sets remote hardware address. More...
 
void setRemotePort (uint16_t remote)
 Sets remote UDP (and soon TCP) port. More...
 
void setTimestamp (boost::posix_time::ptime &timestamp)
 Set packet timestamp. More...
 
void setTransid (uint32_t transid)
 Sets transaction-id value. More...
 
void updateTimestamp ()
 Update packet timestamp. More...
 
- Public Member Functions inherited from isc::hooks::CalloutHandleAssociate
 CalloutHandleAssociate ()
 Constructor. More...
 
CalloutHandlePtr getCalloutHandle ()
 Returns callout handle. More...
 

Static Public Member Functions

static const char * getName (const uint8_t type)
 Returns name of the DHCPv6 message for a given type number. More...
 
static std::string makeLabel (const DuidPtr duid, const uint32_t transid, const HWAddrPtr &hwaddr)
 Returns text representation of the given packet identifiers. More...
 
static std::string makeLabel (const DuidPtr duid, const HWAddrPtr &hwaddr)
 Returns text representation of the given packet identifiers. More...
 

Public Attributes

std::vector< RelayInforelay_info_
 Relay information. More...
 
- Public Attributes inherited from isc::dhcp::Pkt
ClientClasses classes_
 Classes this packet belongs to. More...
 
OptionBuffer data_
 Unparsed data (in received packets). More...
 
isc::dhcp::OptionCollection options_
 Collection of options present in this message. More...
 
ClientClasses required_classes_
 Classes which are required to be evaluated. More...
 

Static Public Attributes

static const size_t DHCPV6_PKT_HDR_LEN = 4
 specifies non-relayed DHCPv6 packet header length (over UDP) More...
 
static const size_t DHCPV6_RELAY_HDR_LEN = 34
 specifies relay DHCPv6 packet header length (over UDP) More...
 

Protected Member Functions

uint16_t calculateRelaySizes ()
 Calculates overhead for all relays defined for this message. More...
 
uint16_t directLen () const
 Calculates size of the message as if it was not relayed at all. More...
 
virtual HWAddrPtr getMACFromDocsisCMTS ()
 Attempts to extract MAC/Hardware address from DOCSIS options. More...
 
virtual HWAddrPtr getMACFromDocsisModem ()
 Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself. More...
 
virtual HWAddrPtr getMACFromDUID ()
 Extract MAC/Hardware address from client-id. More...
 
virtual HWAddrPtr getMACFromIPv6RelayOpt ()
 Extract MAC/Hardware address from client link-layer address. More...
 
virtual HWAddrPtr getMACFromRemoteIdRelayOption ()
 Attempts to obtain MAC address from remote-id relay option. More...
 
virtual HWAddrPtr getMACFromSrcLinkLocalAddr ()
 Attempts to generate MAC/Hardware address from IPv6 link-local address. More...
 
OptionPtr getNonCopiedAnyRelayOption (const uint16_t option_code, const RelaySearchOrder &order) const
 Returns pointer to an instance of specified option. More...
 
OptionCollection getNonCopiedOptions (const uint16_t opt_type) const
 Returns all option instances of specified type without copying. More...
 
OptionPtr getNonCopiedRelayOption (const uint16_t opt_type, const uint8_t relay_level) const
 Returns pointer to an option inserted by relay agent. More...
 
uint16_t getRelayOverhead (const RelayInfo &relay) const
 Calculates overhead introduced in specified relay. More...
 
void packTCP ()
 Builds on wire packet for TCP transmission. More...
 
void packUDP ()
 Builds on wire packet for UDP transmission. More...
 
void unpackMsg (OptionBuffer::const_iterator begin, OptionBuffer::const_iterator end)
 Unpacks direct (non-relayed) message. More...
 
void unpackRelayMsg ()
 Unpacks relayed message (RELAY-FORW or RELAY-REPL). More...
 
void unpackTCP ()
 Parses on-wire form of TCP DHCPv6 packet. More...
 
void unpackUDP ()
 Parses on-wire form of UDP DHCPv6 packet. More...
 
- Protected Member Functions inherited from isc::dhcp::Pkt
 Pkt (uint32_t transid, const isc::asiolink::IOAddress &local_addr, const isc::asiolink::IOAddress &remote_addr, uint16_t local_port, uint16_t remote_port)
 Constructor. More...
 
 Pkt (const uint8_t *buf, uint32_t len, const isc::asiolink::IOAddress &local_addr, const isc::asiolink::IOAddress &remote_addr, uint16_t local_port, uint16_t remote_port)
 Constructor. More...
 
HWAddrPtr getMACFromIPv6 (const isc::asiolink::IOAddress &addr)
 Attempts to convert IPv6 address into MAC. More...
 
OptionPtr getNonCopiedOption (const uint16_t type) const
 Returns the first option of specified type without copying. More...
 

Protected Attributes

uint8_t msg_type_
 DHCPv6 message type. More...
 
DHCPv6Proto proto_
 UDP (usually) or TCP (bulk leasequery or failover) More...
 
- Protected Attributes inherited from isc::dhcp::Pkt
isc::util::OutputBuffer buffer_out_
 Output buffer (used during message transmission) More...
 
bool copy_retrieved_options_
 Indicates if a copy of the retrieved option should be returned when Pkt::getOption is called. More...
 
std::string iface_
 Name of the network interface the packet was received/to be sent over. More...
 
int64_t ifindex_
 Interface index. More...
 
isc::asiolink::IOAddress local_addr_
 Local IP (v4 or v6) address. More...
 
uint16_t local_port_
 local TDP or UDP port More...
 
isc::asiolink::IOAddress remote_addr_
 Remote IP address. More...
 
HWAddrPtr remote_hwaddr_
 
uint16_t remote_port_
 remote TCP or UDP port More...
 
boost::posix_time::ptime timestamp_
 packet timestamp More...
 
uint32_t transid_
 Transaction-id (32 bits for v4, 24 bits for v6) More...
 
- Protected Attributes inherited from isc::hooks::CalloutHandleAssociate
CalloutHandlePtr callout_handle_
 Callout handle stored. More...
 

Detailed Description

Represents a DHCPv6 packet.

This class represents a single DHCPv6 packet. It handles both incoming and transmitted packets, parsing incoming options, options handling (add, get, remove), on-wire assembly, sanity checks and other operations. This specific class has several DHCPv6-specific methods, but it uses a lot of common operations from its base Pkt class that is shared with Pkt4.

This class also handles relayed packets. For example, a RELAY-FORW message with a SOLICIT inside will be represented as SOLICIT and the RELAY-FORW layers will be stored in relay_info_ vector.

Definition at line 44 of file pkt6.h.

Member Enumeration Documentation

◆ DHCPv6Proto

DHCPv6 transport protocol.

Enumerator
UDP 
TCP 

Definition at line 53 of file pkt6.h.

◆ RelaySearchOrder

defines relay search pattern

Defines order in which options are searched in a message that passed through multiple relays. RELAY_SEACH_FROM_CLIENT will start search from the relay that was the closest to the client (i.e. innermost in the encapsulated message, which also means this was the first relay that forwarded packet received by the server and this will be the last relay that will handle the response that server sent towards the client.). RELAY_SEARCH_FROM_SERVER is the opposite. This will be the relay closest to the server (i.e. outermost in the encapsulated message, which also means it was the last relay that relayed the received message and will be the first one to process server's response). RELAY_GET_FIRST will try to get option from the first relay only (closest to the client), RELAY_GET_LAST will try to get option form the last relay (closest to the server).

Enumerator
RELAY_SEARCH_FROM_CLIENT 
RELAY_SEARCH_FROM_SERVER 
RELAY_GET_FIRST 
RELAY_GET_LAST 

Definition at line 74 of file pkt6.h.

Constructor & Destructor Documentation

◆ Pkt6() [1/2]

isc::dhcp::Pkt6::Pkt6 ( uint8_t  msg_type,
uint32_t  transid,
DHCPv6Proto  proto = UDP 
)

Constructor, used in replying to a message.

Parameters
msg_typetype of message (SOLICIT=1, ADVERTISE=2, ...)
transidtransaction-id
protoprotocol (TCP or UDP)

Definition at line 58 of file pkt6.cc.

◆ Pkt6() [2/2]

isc::dhcp::Pkt6::Pkt6 ( const uint8_t *  buf,
uint32_t  len,
DHCPv6Proto  proto = UDP 
)

Constructor, used in message transmission.

Creates new message. Transaction-id will randomized.

Parameters
bufpointer to a buffer of received packet content
lensize of buffer of received packet content
protoprotocol (usually UDP, but TCP will be supported eventually)

Definition at line 53 of file pkt6.cc.

Member Function Documentation

◆ addRelayInfo()

void isc::dhcp::Pkt6::addRelayInfo ( const RelayInfo relay)

add information about one traversed relay

This adds information about one traversed relay, i.e. one relay-forw or relay-repl level of encapsulation.

Parameters
relaystructure with necessary relay information
Todo:
: Implement type checks here (e.g. we could receive relay-forw in relay-repl)

Definition at line 512 of file pkt6.cc.

References HOP_COUNT_LIMIT, isc_throw, and relay_info_.

Referenced by setType(), and unpackRelayMsg().

◆ calculateRelaySizes()

uint16_t isc::dhcp::Pkt6::calculateRelaySizes ( )
protected

Calculates overhead for all relays defined for this message.

Returns
number of bytes needed to store all relay information

Definition at line 241 of file pkt6.cc.

References directLen(), getRelayOverhead(), len(), and relay_info_.

Referenced by len(), and packUDP().

+ Here is the call graph for this function:

◆ copyRelayInfo()

void isc::dhcp::Pkt6::copyRelayInfo ( const Pkt6Ptr question)

copies relay information from client's packet to server's response

This information is not simply copied over. Some parameter are removed, msg_type_is updated (RELAY-FORW => RELAY-REPL), etc.

Parameters
questionclient's packet
Todo:
: Implement support for ERO (Echo Request Option, RFC4994)

Definition at line 774 of file pkt6.cc.

References D6O_INTERFACE_ID, D6O_RELAY_SOURCE_PORT, DHCPV6_RELAY_REPL, isc::dhcp::Pkt6::RelayInfo::hop_count_, isc::db::info, isc::dhcp::Pkt6::RelayInfo::linkaddr_, isc::dhcp::Pkt6::RelayInfo::msg_type_, isc::dhcp::Pkt6::RelayInfo::options_, isc::dhcp::Pkt6::RelayInfo::peeraddr_, and relay_info_.

Referenced by setType().

◆ directLen()

uint16_t isc::dhcp::Pkt6::directLen ( ) const
protected

Calculates size of the message as if it was not relayed at all.

This is equal to len() if the message was not relayed.

Returns
number of bytes required to store the message

Definition at line 253 of file pkt6.cc.

References DHCPV6_PKT_HDR_LEN, and isc::dhcp::Pkt::options_.

Referenced by calculateRelaySizes(), and len().

◆ getAnyRelayOption()

OptionPtr isc::dhcp::Pkt6::getAnyRelayOption ( const uint16_t  option_code,
const RelaySearchOrder order 
)

Return first instance of a specified option.

When a client's packet traverses multiple relays, each passing relay may insert extra options. This method allows the specific instance of a given option to be obtained (e.g. closest to the client, closest to the server, etc.) See RelaySearchOrder for a detailed description.

Parameters
option_codesearched option
orderoption search order (see RelaySearchOrder)
Returns
option pointer (or NULL if no option matches specified criteria)

Definition at line 139 of file pkt6.cc.

References getRelayOption(), and relay_info_.

Referenced by getMACFromDocsisCMTS(), getMACFromIPv6RelayOpt(), getMACFromRemoteIdRelayOption(), and setType().

+ Here is the call graph for this function:

◆ getClientId()

DuidPtr isc::dhcp::Pkt6::getClientId ( ) const

Retrieves the DUID from the Client Identifier option.

This method is exception safe.

Returns
Pointer to the DUID or NULL if the option doesn't exist.

Definition at line 648 of file pkt6.cc.

References D6O_CLIENTID, and isc::dhcp::Pkt::getNonCopiedOption().

Referenced by getLabel(), and setType().

+ Here is the call graph for this function:

◆ getLabel()

std::string isc::dhcp::Pkt6::getLabel ( ) const
virtual

Returns text representation of the primary packet identifiers.

This method is intended to be used to provide a consistent way to identify packets within log statements. It is an instance-level wrapper around static makeLabel(). See this method for string content.

Note
Currently this method doesn't include the HW address in the returned text.
Returns
string with text representation
Todo:
Do not print HW address as it is unclear how it should be retrieved if there is no access to user configuration which specifies the order of various techniques to be used to retrieve it.

Reimplemented from isc::dhcp::Pkt.

Definition at line 611 of file pkt6.cc.

References getClientId(), isc::dhcp::Pkt::getTransid(), and makeLabel().

Referenced by setProto().

+ Here is the call graph for this function:

◆ getMACFromDocsisCMTS()

HWAddrPtr isc::dhcp::Pkt6::getMACFromDocsisCMTS ( )
protectedvirtual

Attempts to extract MAC/Hardware address from DOCSIS options.

The DHCPv6 mechanism extracts that information from DOCSIS option (vendor-specific info, vendor-id=4491, suboption 1026). Note that in a DOCSIS capable network, the MAC address information is provided several times. The first is specified by the modem itself. The second is added by the CMTS, which acts as a relay agent. This method attempts to extract the latter. See getMACFromDocsisModem for a similar method that extracts from the modem (client) options.

Returns
hardware address (if DOCSIS suboption 1026 is present)

Implements isc::dhcp::Pkt.

Definition at line 869 of file pkt6.cc.

References D6O_VENDOR_OPTS, DOCSIS3_V6_CMTS_CM_MAC, getAnyRelayOption(), isc::dhcp::Option::getOption(), isc::dhcp::HTYPE_DOCSIS, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_CMTS, relay_info_, RELAY_SEARCH_FROM_CLIENT, and VENDOR_ID_CABLE_LABS.

+ Here is the call graph for this function:

◆ getMACFromDocsisModem()

HWAddrPtr isc::dhcp::Pkt6::getMACFromDocsisModem ( )
protectedvirtual

Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself.

The mechanism extracts that information from DOCSIS option (vendor-specific info, vendor-id=4491, suboption 36). Note that in a DOCSIS capable network, the MAC address information is provided several times. The first is specified by the modem itself. The second is added by the CMTS, which acts as a relay agent. This method attempts to extract the former. See getMACFromDocsisCMTS for a similar method that extracts from the CMTS (relay) options.

Returns
hardware address (if DOCSIS suboption 36 is present)

Implements isc::dhcp::Pkt.

Definition at line 847 of file pkt6.cc.

References D6O_VENDOR_OPTS, DOCSIS3_V6_DEVICE_ID, isc::dhcp::Pkt::getNonCopiedOption(), isc::dhcp::Option::getOption(), isc::dhcp::HTYPE_DOCSIS, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_MODEM, and VENDOR_ID_CABLE_LABS.

+ Here is the call graph for this function:

◆ getMACFromDUID()

HWAddrPtr isc::dhcp::Pkt6::getMACFromDUID ( )
protectedvirtual

Extract MAC/Hardware address from client-id.

This method attempts to extract MAC/Hardware address from DUID sent as client-id. This method may fail, as only DUID-LLT and DUID-LL are based on link-layer addresses. Client may use other valid DUID types and this method will fail.

Returns
Hardware address (or NULL)

Implements isc::dhcp::Pkt.

Definition at line 528 of file pkt6.cc.

References D6O_CLIENTID, isc::dhcp::DUID::DUID_LL, isc::dhcp::DUID::DUID_LLT, isc::dhcp::Pkt::getNonCopiedOption(), isc::dhcp::HWAddr::HWADDR_SOURCE_DUID, and isc::util::readUint16().

+ Here is the call graph for this function:

◆ getMACFromIPv6RelayOpt()

HWAddrPtr isc::dhcp::Pkt6::getMACFromIPv6RelayOpt ( )
protectedvirtual

Extract MAC/Hardware address from client link-layer address.

This method extracts the client's hardware address from the

Returns
Hardware address (or NULL)

Implements isc::dhcp::Pkt.

Definition at line 819 of file pkt6.cc.

References D6O_CLIENT_LINKLAYER_ADDR, getAnyRelayOption(), isc::dhcp::HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION, RELAY_GET_FIRST, and relay_info_.

+ Here is the call graph for this function:

◆ getMACFromRemoteIdRelayOption()

HWAddrPtr isc::dhcp::Pkt6::getMACFromRemoteIdRelayOption ( )
protectedvirtual

Attempts to obtain MAC address from remote-id relay option.

This method is called from getMAC(HWADDR_SOURCE_REMOTE_ID) and should not be called directly. It will attempt to extract MAC address information from remote-id option inserted by a relay agent closest to the client. If this method fails, it will return NULL.

Returns
hardware address (or NULL)

Implements isc::dhcp::Pkt.

Definition at line 896 of file pkt6.cc.

References D6O_REMOTE_ID, getAnyRelayOption(), isc::dhcp::IfaceMgr::getIface(), isc::dhcp::HWAddr::HWADDR_SOURCE_REMOTE_ID, isc::dhcp::Pkt::iface_, isc::dhcp::IfaceMgr::instance(), len(), isc::dhcp::HWAddr::MAX_HWADDR_LEN, RELAY_GET_FIRST, and relay_info_.

+ Here is the call graph for this function:

◆ getMACFromSrcLinkLocalAddr()

HWAddrPtr isc::dhcp::Pkt6::getMACFromSrcLinkLocalAddr ( )
protectedvirtual

Attempts to generate MAC/Hardware address from IPv6 link-local address.

This method uses source IPv6 address for direct messages and the peeraddr or the first relay that saw that packet. It may fail if the address is not link-local or does not use EUI-64 identifier.

Returns
Hardware address (or NULL)

Implements isc::dhcp::Pkt.

Definition at line 808 of file pkt6.cc.

References isc::dhcp::Pkt::getMACFromIPv6(), relay_info_, and isc::dhcp::Pkt::remote_addr_.

+ Here is the call graph for this function:

◆ getName() [1/2]

const char * isc::dhcp::Pkt6::getName ( const uint8_t  type)
static

Returns name of the DHCPv6 message for a given type number.

As the operation of the method does not depend on any server state, it is declared static. There is also non-static getName() method that works on Pkt6 objects.

Parameters
typeDHCPv6 message type which name should be returned.
Returns
Pointer to "const" string containing the message name. If the message type is unknown the "UNKNOWN" is returned. The caller must not release the returned pointer.

Definition at line 692 of file pkt6.cc.

References DHCPV6_ADVERTISE, DHCPV6_CONFIRM, DHCPV6_DECLINE, DHCPV6_DHCPV4_QUERY, DHCPV6_DHCPV4_RESPONSE, DHCPV6_INFORMATION_REQUEST, DHCPV6_LEASEQUERY, DHCPV6_LEASEQUERY_REPLY, DHCPV6_REBIND, DHCPV6_RECONFIGURE, DHCPV6_RELAY_FORW, DHCPV6_RELAY_REPL, DHCPV6_RELEASE, DHCPV6_RENEW, DHCPV6_REPLY, DHCPV6_REQUEST, and DHCPV6_SOLICIT.

◆ getName() [2/2]

const char * isc::dhcp::Pkt6::getName ( ) const
virtual

Returns name of the DHCPv6 message.

This method requires an object. There is also a static version, which requires one parameter (type).

Returns
Pointer to "const" string containing the message name. If the message type is unknown the "UNKNOWN" is returned. The caller must not release the returned pointer.

Implements isc::dhcp::Pkt.

Definition at line 770 of file pkt6.cc.

References getType().

Referenced by setType(), isc::dhcp::Pkt6::RelayInfo::toText(), and toText().

+ Here is the call graph for this function:

◆ getNonCopiedAnyRelayOption()

OptionPtr isc::dhcp::Pkt6::getNonCopiedAnyRelayOption ( const uint16_t  option_code,
const RelaySearchOrder order 
) const
protected

Returns pointer to an instance of specified option.

This is a variant of getAnyRelayOption but it never copies an option returned. This method should be only used by the Pkt6 class and derived classes. Any external callers should use getAnyRelayOption which copies the option before returning it when the Pkt::copy_retrieved_options_ flag is set to true.

Parameters
option_codeSearched option.
orderOption search order (see RelaySearchOrder).
Returns
Option pointer or NULL, if no option matches specified criteria.

Definition at line 107 of file pkt6.cc.

References getNonCopiedRelayOption(), and relay_info_.

Referenced by setType().

+ Here is the call graph for this function:

◆ getNonCopiedOptions()

isc::dhcp::OptionCollection isc::dhcp::Pkt6::getNonCopiedOptions ( const uint16_t  opt_type) const
protected

Returns all option instances of specified type without copying.

This is a variant of getOptions method, which returns a collection of options without copying them. This method should be only used by the Pkt6 class and derived classes. Any external callers should use getOptions which copies option instances before returning them when the Pkt::copy_retrieved_options_ flag is set to true.

Parameters
opt_typeOption code.
Returns
Collection of options found.

Definition at line 665 of file pkt6.cc.

References isc::dhcp::Pkt::options_.

Referenced by setType().

◆ getNonCopiedRelayOption()

OptionPtr isc::dhcp::Pkt6::getNonCopiedRelayOption ( const uint16_t  opt_type,
const uint8_t  relay_level 
) const
protected

Returns pointer to an option inserted by relay agent.

This is a variant of the Pkt6::getRelayOption function which never copies an option returned. This method should be only used by the Pkt6 class and derived classes. Any external callers should use getRelayOption which copies the option before returning it when the Pkt::copy_retrieved_options_ flag is set to true.

Parameters
opt_typeCode of the requested option.
relay_levelNesting level as described for Pkt6::getRelayOption.
Returns
Pointer to the option or NULL if such option doesn't exist.

Definition at line 172 of file pkt6.cc.

References isc_throw, isc::dhcp::Pkt::options_, and relay_info_.

Referenced by getNonCopiedAnyRelayOption(), and setType().

◆ getOptions()

isc::dhcp::OptionCollection isc::dhcp::Pkt6::getOptions ( const uint16_t  type)

Returns all instances of specified type.

Returns all instances of options of the specified type. DHCPv6 protocol allows (and uses frequently) multiple instances.

Parameters
typeoption type we are looking for
Returns
instance of option collection with requested options

Definition at line 672 of file pkt6.cc.

References isc::dhcp::Pkt::copy_retrieved_options_, and isc::dhcp::Pkt::options_.

Referenced by setType().

◆ getProto()

DHCPv6Proto isc::dhcp::Pkt6::getProto ( )
inline

Returns protocol of this packet (UDP or TCP).

Returns
protocol type

Definition at line 149 of file pkt6.h.

References proto_.

◆ getRelay6LinkAddress()

const isc::asiolink::IOAddress & isc::dhcp::Pkt6::getRelay6LinkAddress ( uint8_t  relay_level) const

return the link address field from a relay option

As with Pkt6::getRelayOption this returns information from the specified relay scope. The relay_level specifies which relay scope is to be used. 0 is the outermost encapsulation (relay closest to the server). pkt->relay_info_.size() -1 is the innermost encapsulation (relay closest to the client).

Exceptions
isc::OutOfRangeif relay level has an invalid value.
Parameters
relay_levelsee description above
Returns
pointer to the link address field

Definition at line 211 of file pkt6.cc.

References isc_throw, and relay_info_.

Referenced by isc::dhcp::TokenRelay6Field::evaluate(), and setType().

◆ getRelay6PeerAddress()

const isc::asiolink::IOAddress & isc::dhcp::Pkt6::getRelay6PeerAddress ( uint8_t  relay_level) const

return the peer address field from a relay option

As with Pkt6::getRelayOption this returns information from the specified relay scope. The relay_level specifies which relay scope is to be used. 0 is the outermost encapsulation (relay closest to the server). pkt->relay_info_.size() -1 is the innermost encapsulation (relay closest to the client).

Exceptions
isc::OutOfRangeif relay level has an invalid value.
Parameters
relay_levelsee description above
Returns
pointer to the peer address field

Definition at line 221 of file pkt6.cc.

References isc_throw, and relay_info_.

Referenced by isc::dhcp::TokenRelay6Field::evaluate(), and setType().

◆ getRelayOption()

OptionPtr isc::dhcp::Pkt6::getRelayOption ( uint16_t  option_code,
uint8_t  nesting_level 
)

Returns option inserted by relay.

Returns an option from specified relay scope (inserted by a given relay if this is received packet or to be decapsulated by a given relay if this is a transmitted packet). nesting_level specifies which relay scope is to be used. 0 is the outermost encapsulation (relay closest to the server). pkt->relay_info_.size() - 1 is the innermost encapsulation (relay closest to the client).

Exceptions
isc::OutOfRangeif nesting level has invalid value.
Parameters
option_codecode of the requested option
nesting_levelsee description above
Returns
pointer to the option (or NULL if there is no such option)

Definition at line 190 of file pkt6.cc.

References isc::dhcp::Pkt::copy_retrieved_options_, isc_throw, isc::dhcp::Pkt::options_, and relay_info_.

Referenced by getAnyRelayOption(), isc::dhcp::TokenRelay6Option::getOption(), and setType().

◆ getRelayOverhead()

uint16_t isc::dhcp::Pkt6::getRelayOverhead ( const RelayInfo relay) const
protected

Calculates overhead introduced in specified relay.

It is used when calculating message size and packing message

Parameters
relayRelayInfo structure that holds information about relay
Returns
number of bytes needed to store relay information

Definition at line 230 of file pkt6.cc.

References DHCPV6_RELAY_HDR_LEN, len(), isc::dhcp::Option::OPTION6_HDR_LEN, and isc::dhcp::Pkt6::RelayInfo::options_.

Referenced by calculateRelaySizes(), and len().

+ Here is the call graph for this function:

◆ getType()

virtual uint8_t isc::dhcp::Pkt6::getType ( ) const
inlinevirtual

Returns message type (e.g.

1 = SOLICIT).

Returns
message type

Implements isc::dhcp::Pkt.

Definition at line 220 of file pkt6.h.

References isc::dhcp::Pkt6::RelayInfo::msg_type_.

Referenced by isc::dhcp::TokenPkt6::evaluate(), and getName().

◆ len()

size_t isc::dhcp::Pkt6::len ( )
virtual

Returns length of the packet.

This function returns size required to hold this packet. It includes DHCPv6 header and all options stored in options_ field.

Note: It does not return proper length of incoming packets before they are unpacked.

Returns
number of bytes required to assemble this packet

Implements isc::dhcp::Pkt.

Definition at line 63 of file pkt6.cc.

References calculateRelaySizes(), directLen(), getRelayOverhead(), RELAY_GET_FIRST, RELAY_GET_LAST, relay_info_, RELAY_SEARCH_FROM_CLIENT, and RELAY_SEARCH_FROM_SERVER.

Referenced by calculateRelaySizes(), getMACFromRemoteIdRelayOption(), getRelayOverhead(), and setProto().

+ Here is the call graph for this function:

◆ makeLabel() [1/2]

std::string isc::dhcp::Pkt6::makeLabel ( const DuidPtr  duid,
const uint32_t  transid,
const HWAddrPtr hwaddr 
)
static

Returns text representation of the given packet identifiers.

Note
The parameters are ordered from the one that should be available almost at all times, to the one that is optional. This allows for providing default values for the parameters that may not be available in some places in the code where Pkt6::makeLabel is called.
Parameters
duidPointer to the client identifier or NULL.
transidNumeric transaction id to include in the string.
hwaddrHardware address to include in the string or NULL.
Returns
String with text representation of the packet identifiers.

Definition at line 580 of file pkt6.cc.

Referenced by getLabel(), isc::dhcp::queueNCR(), isc::dhcp::AllocEngine::reclaimExpiredLeases4(), and setProto().

◆ makeLabel() [2/2]

std::string isc::dhcp::Pkt6::makeLabel ( const DuidPtr  duid,
const HWAddrPtr hwaddr 
)
static

Returns text representation of the given packet identifiers.

This variant of the method does not include transaction id.

Parameters
duidPointer to the client identifier or NULL.
hwaddrHardware address to include in the string or NULL.
Returns
String with text representation of the packet identifiers.

Definition at line 593 of file pkt6.cc.

◆ pack()

void isc::dhcp::Pkt6::pack ( )
virtual

Prepares on-wire format.

Prepares on-wire format of message and all its options. Options must be stored in options_ field. Output buffer will be stored in data_. Length will be set in data_len_. The output buffer is cleared before new data is written to it.

Exceptions
BadValueif packet protocol is invalid, InvalidOperation if packing fails, or NotImplemented if protocol is TCP (IPv6 over TCP is not yet supported).

Implements isc::dhcp::Pkt.

Definition at line 265 of file pkt6.cc.

References isc_throw, packTCP(), packUDP(), proto_, TCP, and UDP.

Referenced by packUDP().

+ Here is the call graph for this function:

◆ packTCP()

void isc::dhcp::Pkt6::packTCP ( )
protected

Builds on wire packet for TCP transmission.

Todo:
This function is not implemented yet.
Exceptions
NotImplemented,IPv6over TCP is not yet supported.

TODO Implement this function.

Definition at line 342 of file pkt6.cc.

References isc_throw.

Referenced by pack().

◆ packUDP()

void isc::dhcp::Pkt6::packUDP ( )
protected

◆ setProto()

void isc::dhcp::Pkt6::setProto ( DHCPv6Proto  proto = UDP)
inline

Sets protocol of this packet.

Parameters
protoprotocol (UDP or TCP)

Definition at line 156 of file pkt6.h.

References getLabel(), len(), makeLabel(), proto_, and isc::dhcp::Pkt6::RelayInfo::toText().

+ Here is the call graph for this function:

◆ setType()

virtual void isc::dhcp::Pkt6::setType ( uint8_t  type)
inlinevirtual

Sets message type (e.g.

1 = SOLICIT).

Parameters
typemessage type to be set

Implements isc::dhcp::Pkt.

Definition at line 225 of file pkt6.h.

References addRelayInfo(), copyRelayInfo(), getAnyRelayOption(), getClientId(), getName(), getNonCopiedAnyRelayOption(), getNonCopiedOptions(), getNonCopiedRelayOption(), getOptions(), getRelay6LinkAddress(), getRelay6PeerAddress(), getRelayOption(), and isc::dhcp::Pkt6::RelayInfo::msg_type_.

+ Here is the call graph for this function:

◆ toText()

std::string isc::dhcp::Pkt6::toText ( ) const
virtual

Returns text representation of the packet.

This function is useful mainly for debugging.

Returns
string with text representation

Implements isc::dhcp::Pkt.

Definition at line 619 of file pkt6.cc.

References getName(), isc::dhcp::Pkt::local_addr_, isc::dhcp::Pkt::local_port_, msg_type_, isc::dhcp::Pkt::options_, relay_info_, isc::dhcp::Pkt::remote_addr_, isc::dhcp::Pkt::remote_port_, and isc::dhcp::Pkt::transid_.

+ Here is the call graph for this function:

◆ unpack()

void isc::dhcp::Pkt6::unpack ( )
virtual

Dispatch method that handles binary packet parsing.

This method calls appropriate dispatch function (unpackUDP or unpackTCP).

Exceptions
tbd

Implements isc::dhcp::Pkt.

Definition at line 349 of file pkt6.cc.

References isc_throw, proto_, TCP, UDP, unpackTCP(), and unpackUDP().

+ Here is the call graph for this function:

◆ unpackMsg()

void isc::dhcp::Pkt6::unpackMsg ( OptionBuffer::const_iterator  begin,
OptionBuffer::const_iterator  end 
)
protected

Unpacks direct (non-relayed) message.

This method unpacks specified buffer range as a direct (e.g. solicit or request) message. This method is called from unpackUDP() when received message is detected to be direct.

Parameters
beginstart of the buffer
endend of the buffer
Exceptions
tbd

Definition at line 391 of file pkt6.cc.

References isc::dhcp::Pkt::data_, DHCP6_OPTION_SPACE, isc_throw, msg_type_, isc::dhcp::Pkt::options_, isc::dhcp::Pkt::transid_, and isc::dhcp::LibDHCP::unpackOptions6().

Referenced by unpackRelayMsg(), and unpackUDP().

+ Here is the call graph for this function:

◆ unpackRelayMsg()

void isc::dhcp::Pkt6::unpackRelayMsg ( )
protected

Unpacks relayed message (RELAY-FORW or RELAY-REPL).

This method is called from unpackUDP() when received message is detected to be relay-message. It goes iteratively over all relays (if there are multiple encapsulation levels).

Exceptions
tbd
Todo:
: check that each option appears at most once
Todo:
: implement ERO (Echo Request Option, RFC 4994) here
Todo:
: log here that there are additional unparsed bytes

Definition at line 435 of file pkt6.cc.

References addRelayInfo(), isc::dhcp::Pkt::data_, DHCP6_OPTION_SPACE, DHCPV6_RELAY_FORW, DHCPV6_RELAY_HDR_LEN, DHCPV6_RELAY_REPL, isc::asiolink::IOAddress::fromBytes(), isc::dhcp::Pkt6::RelayInfo::hop_count_, isc_throw, isc::dhcp::Pkt6::RelayInfo::linkaddr_, isc::dhcp::Pkt6::RelayInfo::msg_type_, isc::dhcp::Pkt6::RelayInfo::options_, isc::dhcp::Pkt6::RelayInfo::peeraddr_, unpackMsg(), and isc::dhcp::LibDHCP::unpackOptions6().

Referenced by unpackUDP().

+ Here is the call graph for this function:

◆ unpackTCP()

void isc::dhcp::Pkt6::unpackTCP ( )
protected

Parses on-wire form of TCP DHCPv6 packet.

Parses received packet, stored in on-wire format in data_. data_len_ must be set to indicate data length. Will create a collection of option objects that will be stored in options_ container.

Todo:
This function is not implemented yet.
Exceptions
tbd

Definition at line 522 of file pkt6.cc.

References isc_throw.

Referenced by unpack().

◆ unpackUDP()

void isc::dhcp::Pkt6::unpackUDP ( )
protected

Parses on-wire form of UDP DHCPv6 packet.

Parses received packet, stored in on-wire format in data_. data_len_ must be set to indicate data length. Will create a collection of option objects that will be stored in options_ container.

Exceptions
tbd

Definition at line 361 of file pkt6.cc.

References isc::dhcp::Pkt::data_, DHCPV6_ADVERTISE, DHCPV6_CONFIRM, DHCPV6_DECLINE, DHCPV6_DHCPV4_QUERY, DHCPV6_DHCPV4_RESPONSE, DHCPV6_INFORMATION_REQUEST, DHCPV6_REBIND, DHCPV6_RECONFIGURE, DHCPV6_RELAY_FORW, DHCPV6_RELAY_REPL, DHCPV6_RENEW, DHCPV6_REPLY, DHCPV6_REQUEST, DHCPV6_SOLICIT, isc_throw, msg_type_, unpackMsg(), and unpackRelayMsg().

Referenced by unpack().

+ Here is the call graph for this function:

Member Data Documentation

◆ DHCPV6_PKT_HDR_LEN

const size_t isc::dhcp::Pkt6::DHCPV6_PKT_HDR_LEN = 4
static

specifies non-relayed DHCPv6 packet header length (over UDP)

Definition at line 47 of file pkt6.h.

Referenced by directLen().

◆ DHCPV6_RELAY_HDR_LEN

const size_t isc::dhcp::Pkt6::DHCPV6_RELAY_HDR_LEN = 34
static

specifies relay DHCPv6 packet header length (over UDP)

Definition at line 50 of file pkt6.h.

Referenced by getRelayOverhead(), and unpackRelayMsg().

◆ msg_type_

uint8_t isc::dhcp::Pkt6::msg_type_
protected

DHCPv6 message type.

Definition at line 583 of file pkt6.h.

Referenced by packUDP(), toText(), unpackMsg(), and unpackUDP().

◆ proto_

DHCPv6Proto isc::dhcp::Pkt6::proto_
protected

UDP (usually) or TCP (bulk leasequery or failover)

Definition at line 580 of file pkt6.h.

Referenced by getProto(), pack(), setProto(), and unpack().

◆ relay_info_

std::vector<RelayInfo> isc::dhcp::Pkt6::relay_info_

Relay information.

This is a public field. Otherwise we hit one of the two problems: we return reference to an internal field (and that reference could be potentially used past Pkt6 object lifetime causing badness) or we return a copy (which is inefficient and also causes any updates to be impossible). Therefore public field is considered the best (or least bad) solution.

This vector is arranged in the order packet is encapsulated, i.e. relay[0] was the outermost encapsulation (relay closest to the server), relay[last] was the innermost encapsulation (relay closest to the client).

Definition at line 436 of file pkt6.h.

Referenced by addRelayInfo(), calculateRelaySizes(), copyRelayInfo(), isc::dhcp::TokenRelay6Field::evaluate(), getAnyRelayOption(), getMACFromDocsisCMTS(), getMACFromIPv6RelayOpt(), getMACFromRemoteIdRelayOption(), getMACFromSrcLinkLocalAddr(), getNonCopiedAnyRelayOption(), getNonCopiedRelayOption(), isc::dhcp::TokenRelay6Option::getOption(), getRelay6LinkAddress(), getRelay6PeerAddress(), getRelayOption(), len(), packUDP(), and toText().


The documentation for this class was generated from the following files: