Kea 2.5.8
isc::dhcp::Pkt4o6 Class Reference

Represents DHCPv4-over-DHCPv6 packet. More...

#include <pkt4o6.h>

+ Inheritance diagram for isc::dhcp::Pkt4o6:

Public Member Functions

 Pkt4o6 (const OptionBuffer &pkt4, const Pkt6Ptr &pkt6)
 Constructor, used in message reception.
 
 Pkt4o6 (const Pkt4Ptr &pkt4, const Pkt6Ptr &pkt6)
 Constructor, used in replying to a message.
 
Pkt6Ptr getPkt6 () const
 Returns encapsulating DHCPv6 message.
 
virtual bool isDhcp4o6 () const
 Checks if a DHCPv4 message has been transported over DHCPv6.
 
virtual void pack ()
 Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
 
virtual void setCopyRetrievedOptions (const bool copy)
 Overrides the Pkt::setCopyRetrievedOptions to also set the flag for encapsulated Pkt6 instance.
 
- Public Member Functions inherited from isc::dhcp::Pkt4
 Pkt4 (const uint8_t *data, size_t len)
 Constructor, used in message reception.
 
 Pkt4 (uint8_t msg_type, uint32_t transid)
 Constructor, used in replying to a message.
 
virtual void addOption (const OptionPtr &opt)
 Add an option.
 
const isc::asiolink::IOAddressgetCiaddr () const
 Returns ciaddr field.
 
std::list< uint16_t > & getDeferredOptions ()
 Returns a reference to option codes which unpacking will be deferred.
 
const OptionBuffer getFile () const
 Returns file field.
 
uint16_t getFlags () const
 Returns flags field.
 
const isc::asiolink::IOAddressgetGiaddr () const
 Returns giaddr field.
 
uint8_t getHlen () const
 Returns hlen field.
 
uint8_t getHops () const
 Returns hops field.
 
uint8_t getHtype () const
 Returns htype field.
 
HWAddrPtr getHWAddr () const
 returns hardware address information
 
std::string getHWAddrLabel () const
 Returns text representation of the hardware address.
 
std::string getLabel () const
 Returns text representation of the primary packet identifiers.
 
HWAddrPtr getLocalHWAddr () const
 Returns local HW address.
 
const char * getName () const
 Returns name of the DHCP message.
 
uint8_t getOp () const
 Returns op field.
 
uint16_t getSecs () const
 Returns secs field.
 
const isc::asiolink::IOAddressgetSiaddr () const
 Returns siaddr field.
 
const OptionBuffer getSname () const
 Returns sname field.
 
uint8_t getType () const
 Returns DHCP message type (e.g.
 
const isc::asiolink::IOAddressgetYiaddr () const
 Returns yiaddr field.
 
virtual bool isDhcp4o6 () const
 Checks if a DHCPv4 message has been transported over DHCPv6.
 
bool isRelayed () const
 Checks if a DHCPv4 message has been relayed.
 
size_t len ()
 Returns the size of the required buffer to build the packet.
 
virtual void pack ()
 Prepares on-wire format of DHCPv4 packet.
 
void setCiaddr (const isc::asiolink::IOAddress &ciaddr)
 Sets ciaddr field.
 
void setFile (const uint8_t *file, size_t file_len)
 Sets file field.
 
void setFlags (uint16_t flags)
 Sets flags field.
 
void setGiaddr (const isc::asiolink::IOAddress &giaddr)
 Sets giaddr field.
 
void setHops (uint8_t hops)
 Sets hops field.
 
void setHWAddr (const HWAddrPtr &addr)
 Sets hardware address.
 
void setHWAddr (uint8_t htype, uint8_t hlen, const std::vector< uint8_t > &mac_addr)
 Sets hardware address.
 
void setLocalHWAddr (const HWAddrPtr &addr)
 Sets local HW address.
 
void setLocalHWAddr (const uint8_t htype, const uint8_t hlen, const std::vector< uint8_t > &mac_addr)
 Sets local HW address.
 
void setSecs (uint16_t secs)
 Sets secs field.
 
void setSiaddr (const isc::asiolink::IOAddress &siaddr)
 Sets siaddr field.
 
void setSname (const uint8_t *sname, size_t sname_len)
 Sets sname field.
 
void setType (uint8_t type)
 Sets DHCP message type (e.g.
 
void setYiaddr (const isc::asiolink::IOAddress &yiaddr)
 Sets yiaddr field.
 
std::string toText () const
 Returns text representation of the packet.
 
virtual void unpack ()
 Parses on-wire form of DHCPv4 packet.
 
- Public Member Functions inherited from isc::dhcp::Pkt
virtual ~Pkt ()
 Virtual destructor.
 
void addClass (const isc::dhcp::ClientClass &client_class, bool required=false)
 Adds a specified class to the packet.
 
virtual void addOption (const OptionPtr &opt)
 Adds an option to this packet.
 
void addPktEvent (const std::string &label, const boost::posix_time::ptime &timestamp=PktEvent::now())
 Adds an event to the end of the event stack.
 
void addPktEvent (const std::string &label, const struct timeval &timestamp)
 Adds an event to the end of the event stack with the timestamp specified as a struct timeval.
 
void addSubClass (const isc::dhcp::ClientClass &class_def, const isc::dhcp::ClientClass &subclass)
 Adds a specified subclass to the packet.
 
void clearPktEvents ()
 Discards contents of the packet event stack.
 
OptionCollection cloneOptions ()
 Clones all options so that they can be safely modified.
 
bool delOption (uint16_t type)
 Attempts to delete first suboption of requested type.
 
std::string dumpPktEvents (bool verbose=false) const
 Creates a dump of the stack contents to a string for logging.
 
isc::util::OutputBuffergetBuffer ()
 Returns reference to output buffer.
 
const ClientClassesgetClasses (bool required=false) const
 Returns the class set.
 
std::string getIface () const
 Returns interface name.
 
int getIndex () const
 Returns interface index.
 
virtual std::string getLabel () const
 Returns text representation primary packet identifiers.
 
const isc::asiolink::IOAddressgetLocalAddr () const
 Returns local IP address.
 
uint16_t getLocalPort () const
 Returns local UDP (and soon TCP) port.
 
HWAddrPtr getMAC (uint32_t hw_addr_src)
 Returns MAC address.
 
virtual const char * getName () const =0
 Returns name of the DHCP message.
 
OptionPtr getOption (const uint16_t type)
 Returns the first option of specified type.
 
isc::dhcp::OptionCollection getOptions (const uint16_t type)
 Returns all instances of specified type.
 
const std::list< PktEvent > & getPktEvents ()
 Fetches the current event stack contents.
 
boost::posix_time::ptime getPktEventTime (const std::string &label) const
 Fetches the timestamp for a given event in the stack.
 
const isc::asiolink::IOAddressgetRemoteAddr () const
 Returns remote IP address.
 
HWAddrPtr getRemoteHWAddr () const
 Returns the remote HW address obtained from raw sockets.
 
uint16_t getRemotePort () const
 Returns remote port.
 
const SubClassRelationContainergetSubClassesRelations () const
 Returns the class set including template classes associated with subclasses.
 
const boost::posix_time::ptime & getTimestamp () const
 Returns packet timestamp.
 
uint32_t getTransid () const
 Returns value of transaction-id field.
 
virtual uint8_t getType () const =0
 Returns message type (e.g.
 
bool inClass (const isc::dhcp::ClientClass &client_class)
 Checks whether a client belongs to a given class.
 
bool indexSet () const
 Checks if interface index has been set.
 
bool isCopyRetrievedOptions () const
 Returns whether the copying of retrieved options is enabled.
 
virtual size_t len ()=0
 Returns packet size in binary format.
 
virtual void pack ()=0
 Prepares on-wire format of DHCP (either v4 or v6) packet.
 
void repack ()
 Copies content of input buffer to output buffer.
 
void resetIndex ()
 Resets interface index to negative value.
 
virtual void setCopyRetrievedOptions (const bool copy)
 Controls whether the option retrieved by the Pkt::getOption should be copied before being returned.
 
void setIface (const std::string &iface)
 Sets interface name.
 
void setIndex (const unsigned int ifindex)
 Sets interface index.
 
void setLocalAddr (const isc::asiolink::IOAddress &local)
 Sets local IP address.
 
void setLocalPort (uint16_t local)
 Sets local UDP (and soon TCP) port.
 
void setPktEvent (const std::string &label, const boost::posix_time::ptime &timestamp=PktEvent::now())
 Updates (or adds) an event in the event stack.
 
void setRemoteAddr (const isc::asiolink::IOAddress &remote)
 Sets remote IP address.
 
void setRemoteHWAddr (const HWAddrPtr &hw_addr)
 Sets remote hardware address.
 
void setRemoteHWAddr (const uint8_t htype, const uint8_t hlen, const std::vector< uint8_t > &hw_addr)
 Sets remote hardware address.
 
void setRemotePort (uint16_t remote)
 Sets remote UDP (and soon TCP) port.
 
void setTimestamp (boost::posix_time::ptime &timestamp)
 Set socket receive timestamp.
 
void setTransid (uint32_t transid)
 Sets transaction-id value.
 
virtual void setType (uint8_t type)=0
 Sets message type (e.g.
 
virtual std::string toText () const =0
 Returns text representation of the packet.
 
virtual void unpack ()=0
 Parses on-wire form of DHCP (either v4 or v6) packet.
 
void updateTimestamp ()
 Update packet timestamp.
 
- Public Member Functions inherited from isc::hooks::CalloutHandleAssociate
 CalloutHandleAssociate ()
 Constructor.
 
CalloutHandlePtr getCalloutHandle ()
 Returns callout handle.
 
void resetCalloutHandle ()
 Reset callout handle.
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::Pkt4
static const char * getName (const uint8_t type)
 Returns name of the DHCP message for a given type number.
 
static std::string makeLabel (const HWAddrPtr &hwaddr, const ClientIdPtr &client_id)
 Returns text representation of the given packet identifiers.
 
static std::string makeLabel (const HWAddrPtr &hwaddr, const ClientIdPtr &client_id, const uint32_t transid)
 Returns text representation of the given packet identifiers.
 
- Public Attributes inherited from isc::dhcp::Pkt
ClientClasses classes_
 Classes this packet belongs to.
 
OptionBuffer data_
 Unparsed data (in received packets).
 
isc::dhcp::OptionCollection options_
 Collection of options present in this message.
 
ClientClasses required_classes_
 Classes which are required to be evaluated.
 
SubClassRelationContainer subclasses_
 SubClasses this packet belongs to.
 
- Static Public Attributes inherited from isc::dhcp::Pkt4
static const size_t DHCPV4_PKT_HDR_LEN = 236
 specifies DHCPv4 packet header length (fixed part)
 
static const uint16_t FLAG_BROADCAST_MASK = 0x8000
 Mask for the value of flags field in the DHCPv4 message to check whether client requested broadcast response.
 
static const size_t MAX_CHADDR_LEN = 16
 length of the CHADDR field in DHCPv4 message
 
static const size_t MAX_FILE_LEN = 128
 length of the FILE field in DHCPv4 message
 
static const size_t MAX_SNAME_LEN = 64
 length of the SNAME field in DHCPv4 message
 
- Protected Member Functions inherited from isc::dhcp::Pkt4
uint8_t DHCPTypeToBootpType (uint8_t dhcpType)
 converts DHCP message type to BOOTP op type
 
virtual HWAddrPtr getMACFromDocsisCMTS ()
 No-op.
 
virtual HWAddrPtr getMACFromDocsisModem ()
 No-op.
 
virtual HWAddrPtr getMACFromDUID ()
 No-op.
 
virtual HWAddrPtr getMACFromIPv6RelayOpt ()
 No-op.
 
virtual HWAddrPtr getMACFromRemoteIdRelayOption ()
 No-op.
 
virtual HWAddrPtr getMACFromSrcLinkLocalAddr ()
 No-op.
 
- Protected Member Functions inherited from isc::dhcp::Pkt
 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.
 
 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.
 
virtual HWAddrPtr getMACFromDocsisCMTS ()=0
 Attempts to extract MAC/Hardware address from DOCSIS options inserted by the CMTS (the relay agent)
 
virtual HWAddrPtr getMACFromDocsisModem ()=0
 Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself.
 
virtual HWAddrPtr getMACFromDUID ()=0
 Attempts to obtain MAC address from DUID-LL or DUID-LLT.
 
HWAddrPtr getMACFromIPv6 (const isc::asiolink::IOAddress &addr)
 Attempts to convert IPv6 address into MAC.
 
virtual HWAddrPtr getMACFromIPv6RelayOpt ()=0
 Attempts to obtain MAC address from relay option client-linklayer-addr.
 
virtual HWAddrPtr getMACFromRemoteIdRelayOption ()=0
 Attempts to obtain MAC address from remote-id relay option.
 
virtual HWAddrPtr getMACFromSrcLinkLocalAddr ()=0
 Attempts to obtain MAC address from source link-local IPv6 address.
 
OptionPtr getNonCopiedOption (const uint16_t type) const
 Returns the first option of specified type without copying.
 
OptionCollection getNonCopiedOptions (const uint16_t opt_type) const
 Returns all option instances of specified type without copying.
 
- Protected Attributes inherited from isc::dhcp::Pkt4
isc::asiolink::IOAddress ciaddr_
 ciaddr field (32 bits): Client's IP address
 
std::list< uint16_t > deferred_options_
 
uint8_t file_ [MAX_FILE_LEN]
 file field (128 bytes)
 
uint16_t flags_
 flags
 
isc::asiolink::IOAddress giaddr_
 giaddr field (32 bits): Gateway IP address
 
uint8_t hops_
 Number of relay agents traversed.
 
HWAddrPtr hwaddr_
 link-layer address and hardware information represents 3 fields: htype (hardware type, 1 byte), hlen (length of the hardware address, up to 16) and chaddr (hardware address field, 16 bytes)
 
HWAddrPtr local_hwaddr_
 local HW address (dst if receiving packet, src if sending packet)
 
uint8_t op_
 message operation code
 
uint16_t secs_
 elapsed (number of seconds since beginning of transmission)
 
isc::asiolink::IOAddress siaddr_
 siaddr field (32 bits): next server IP address in boot process(e.g.TFTP)
 
uint8_t sname_ [MAX_SNAME_LEN]
 sname field (64 bytes)
 
isc::asiolink::IOAddress yiaddr_
 yiaddr field (32 bits): Client's IP address ("your"), set by server
 
- Protected Attributes inherited from isc::dhcp::Pkt
isc::util::OutputBuffer buffer_out_
 Output buffer (used during message transmission)
 
bool copy_retrieved_options_
 Indicates if a copy of the retrieved option should be returned when Pkt::getOption is called.
 
std::string iface_
 Name of the network interface the packet was received/to be sent over.
 
unsigned int ifindex_
 Interface index.
 
isc::asiolink::IOAddress local_addr_
 Local IP (v4 or v6) address.
 
uint16_t local_port_
 local TDP or UDP port
 
isc::asiolink::IOAddress remote_addr_
 Remote IP address.
 
HWAddrPtr remote_hwaddr_
 
uint16_t remote_port_
 remote TCP or UDP port
 
boost::posix_time::ptime timestamp_
 packet timestamp
 
uint32_t transid_
 Transaction-id (32 bits for v4, 24 bits for v6)
 
- Protected Attributes inherited from isc::hooks::CalloutHandleAssociate
CalloutHandlePtr callout_handle_
 Callout handle stored.
 

Detailed Description

Represents DHCPv4-over-DHCPv6 packet.

This class derives from Pkt4 in order to be handled by the DHCPv4 server code. It includes a shared pointer to the DHCPv6 message too.

This is an implementation of the DHCPv4-query/response DHCPv6 messages defined in RFC 7341 (http://ietf.org/rfc/rfc7341.txt). See also https://gitlab.isc.org/isc-projects/kea/wikis/designs/dhcpv4o6-design for design discussions.

Definition at line 30 of file pkt4o6.h.

Constructor & Destructor Documentation

◆ Pkt4o6() [1/2]

isc::dhcp::Pkt4o6::Pkt4o6 ( const OptionBuffer pkt4,
const Pkt6Ptr pkt6 
)

Constructor, used in message reception.

Parameters
pkt4Content of the DHCPv4-message option
pkt6encapsulating unpacked DHCPv6 message the DHCPv4 message option will be removed

Definition at line 23 of file pkt4o6.cc.

References D6O_DHCPV4_MSG, isc::dhcp::Pkt::setIface(), isc::dhcp::Pkt::setIndex(), and isc::dhcp::Pkt::setRemoteAddr().

+ Here is the call graph for this function:

◆ Pkt4o6() [2/2]

isc::dhcp::Pkt4o6::Pkt4o6 ( const Pkt4Ptr pkt4,
const Pkt6Ptr pkt6 
)

Constructor, used in replying to a message.

Parameters
pkt4DHCPv4 message
pkt6DHCPv6 message

Definition at line 32 of file pkt4o6.cc.

Member Function Documentation

◆ getPkt6()

Pkt6Ptr isc::dhcp::Pkt4o6::getPkt6 ( ) const
inline

Returns encapsulating DHCPv6 message.

Definition at line 47 of file pkt4o6.h.

◆ isDhcp4o6()

virtual bool isc::dhcp::Pkt4o6::isDhcp4o6 ( ) const
inlinevirtual

Checks if a DHCPv4 message has been transported over DHCPv6.

Returns
Boolean value which indicates whether the message is transported over DHCPv6 (true) or native DHCPv4 (false)

Reimplemented from isc::dhcp::Pkt4.

Definition at line 60 of file pkt4o6.h.

◆ pack()

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

Prepares on-wire format of DHCPv4-over-DHCPv6 packet.

Calls pack() on both DHCPv4 and DHCPv6 parts Inserts the DHCPv4-message option Pkt4::pack and Pkt6::pack

Reimplemented from isc::dhcp::Pkt4.

Definition at line 36 of file pkt4o6.cc.

References D6O_DHCPV4_MSG, isc::dhcp::Pkt::getBuffer(), isc::util::OutputBuffer::getVector(), isc::dhcp::Pkt4::pack(), and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ setCopyRetrievedOptions()

void isc::dhcp::Pkt4o6::setCopyRetrievedOptions ( const bool  copy)
virtual

Overrides the Pkt::setCopyRetrievedOptions to also set the flag for encapsulated Pkt6 instance.

When the flag is set for the instance of the Pkt4o6 the encapsulated Pkt6, retrieved with Pkt4o6::getPkt6, will inherit this setting.

Parameters
copyIndicates if the options should be copied when retrieved (if true), or not copied (if false).

Reimplemented from isc::dhcp::Pkt.

Definition at line 49 of file pkt4o6.cc.

References isc::data::copy(), and isc::dhcp::Pkt::setCopyRetrievedOptions().

+ Here is the call graph for this function:

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