Kea 2.7.5
isc::perfdhcp::PerfPkt6 Class Reference

PerfPkt6 (DHCPv6 packet) More...

#include <perf_pkt6.h>

+ Inheritance diagram for isc::perfdhcp::PerfPkt6:

Public Types

typedef boost::shared_ptr< LocalizedOptionLocalizedOptionPtr
 Localized option pointer type.
 
- Public Types inherited from isc::dhcp::Pkt6
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

 PerfPkt6 (const uint8_t *buf, size_t len, size_t transid_offset=1, uint32_t transid=0)
 Constructor, used to create messages from packet template files.
 
size_t getTransidOffset () const
 Returns transaction id offset in packet buffer.
 
bool rawPack ()
 Prepares on-wire format from raw buffer.
 
bool rawUnpack ()
 Handles limited binary packet parsing for packets with custom offsets of options and transaction id.
 
void writeAt (size_t dest_pos, std::vector< uint8_t >::iterator first, std::vector< uint8_t >::iterator last)
 Replace contents of buffer with data.
 
template<typename T >
void writeValueAt (size_t dest_pos, T val)
 Replace contents of buffer with value.
 
- Public Member Functions inherited from isc::dhcp::Pkt6
 Pkt6 (const uint8_t *buf, uint32_t len, DHCPv6Proto proto=UDP)
 Constructor, used in message transmission.
 
 Pkt6 (uint8_t msg_type, uint32_t transid, DHCPv6Proto proto=UDP)
 Constructor, used in replying to a message.
 
void addRelayInfo (const RelayInfo &relay)
 add information about one traversed relay
 
void copyRelayInfo (const Pkt6Ptr &question)
 copies relay information from client's packet to server's response
 
OptionCollection getAllRelayOptions (const uint16_t option_code, const RelaySearchOrder &order)
 Return first instances of a specified option.
 
OptionPtr getAnyRelayOption (const uint16_t option_code, const RelaySearchOrder &order)
 Return first instance of a specified option.
 
DuidPtr getClientId () const
 Retrieves the DUID from the Client Identifier option.
 
virtual std::string getLabel () const
 Returns text representation of the primary packet identifiers.
 
const char * getName () const
 Returns name of the DHCPv6 message.
 
DHCPv6Proto getProto ()
 Returns protocol of this packet (UDP or TCP).
 
const isc::asiolink::IOAddressgetRelay6LinkAddress (uint8_t relay_level) const
 return the link address field from a relay option
 
const isc::asiolink::IOAddressgetRelay6PeerAddress (uint8_t relay_level) const
 return the peer address field from a relay option
 
OptionPtr getRelayOption (uint16_t option_code, uint8_t nesting_level)
 Returns option inserted by relay.
 
OptionCollection getRelayOptions (uint16_t option_code, uint8_t nesting_level)
 Returns options inserted by relay.
 
virtual uint8_t getType () const
 Returns message type (e.g.
 
virtual size_t len ()
 Returns length of the packet.
 
virtual void pack ()
 Prepares on-wire format.
 
void setProto (DHCPv6Proto proto=UDP)
 Sets protocol of this packet.
 
virtual void setType (uint8_t type)
 Sets message type (e.g.
 
virtual std::string toText () const
 Returns text representation of the packet.
 
virtual void unpack ()
 Dispatch method that handles binary packet parsing.
 
- Public Member Functions inherited from isc::dhcp::Pkt
virtual ~Pkt ()
 Virtual destructor.
 
void addAdditionalClass (const isc::dhcp::ClientClass &client_class)
 Adds a specified class to the packet's additional class list.
 
void addClass (const isc::dhcp::ClientClass &client_class)
 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.
 
const ClientClassesgetAdditionalClasses () const
 Returns the additional class list.
 
isc::util::OutputBuffergetBuffer ()
 Returns reference to output buffer.
 
const ClientClassesgetClasses () const
 Returns the class set.
 
std::string getIface () const
 Returns interface name.
 
int getIndex () const
 Returns interface index.
 
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.
 
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.
 
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.
 
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.
 
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::Pkt6
static const char * getName (const uint8_t type)
 Returns name of the DHCPv6 message for a given type number.
 
static std::string makeLabel (const DuidPtr duid, const HWAddrPtr &hwaddr)
 Returns text representation of the given packet identifiers.
 
static std::string makeLabel (const DuidPtr duid, const uint32_t transid, const HWAddrPtr &hwaddr)
 Returns text representation of the given packet identifiers.
 
- Public Attributes inherited from isc::dhcp::Pkt6
std::vector< RelayInforelay_info_
 Relay information.
 
- Public Attributes inherited from isc::dhcp::Pkt
ClientClasses additional_classes_
 Classes to be evaluated during additional class evaluation.
 
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.
 
SubClassRelationContainer subclasses_
 SubClasses this packet belongs to.
 
- Static Public Attributes inherited from isc::dhcp::Pkt6
static const size_t DHCPV6_PKT_HDR_LEN = 4
 specifies non-relayed DHCPv6 packet header length (over UDP)
 
static const size_t DHCPV6_RELAY_HDR_LEN = 34
 specifies relay DHCPv6 packet header length (over UDP)
 
- Protected Member Functions inherited from isc::dhcp::Pkt6
uint16_t calculateRelaySizes ()
 Calculates overhead for all relays defined for this message.
 
uint16_t directLen () const
 Calculates size of the message as if it was not relayed at all.
 
virtual HWAddrPtr getMACFromDocsisCMTS ()
 Attempts to extract MAC/Hardware address from DOCSIS options.
 
virtual HWAddrPtr getMACFromDocsisModem ()
 Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself.
 
virtual HWAddrPtr getMACFromDUID ()
 Extract MAC/Hardware address from client-id.
 
virtual HWAddrPtr getMACFromIPv6RelayOpt ()
 Extract MAC/Hardware address from client link-layer address.
 
virtual HWAddrPtr getMACFromRemoteIdRelayOption ()
 Attempts to obtain MAC address from remote-id relay option.
 
virtual HWAddrPtr getMACFromSrcLinkLocalAddr ()
 Attempts to generate MAC/Hardware address from IPv6 link-local address.
 
OptionCollection getNonCopiedAllRelayOptions (const uint16_t option_code, const RelaySearchOrder &order) const
 Returns pointers to instances of specified option.
 
OptionPtr getNonCopiedAnyRelayOption (const uint16_t option_code, const RelaySearchOrder &order) const
 Returns pointer to an instance of specified option.
 
OptionPtr getNonCopiedRelayOption (const uint16_t opt_type, const uint8_t relay_level) const
 Returns pointer to an option inserted by relay agent.
 
OptionCollection getNonCopiedRelayOptions (const uint16_t opt_type, const uint8_t relay_level) const
 Returns all option instances inserted by relay agent.
 
uint16_t getRelayOverhead (const RelayInfo &relay) const
 Calculates overhead introduced in specified relay.
 
void packTCP ()
 Builds on wire packet for TCP transmission.
 
void packUDP ()
 Builds on wire packet for UDP transmission.
 
void unpackMsg (OptionBuffer::const_iterator begin, OptionBuffer::const_iterator end)
 Unpacks direct (non-relayed) message.
 
void unpackRelayMsg ()
 Unpacks relayed message (RELAY-FORW or RELAY-REPL).
 
void unpackTCP ()
 Parses on-wire form of TCP DHCPv6 packet.
 
void unpackUDP ()
 Parses on-wire form of UDP DHCPv6 packet.
 
- 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.
 
HWAddrPtr getMACFromIPv6 (const isc::asiolink::IOAddress &addr)
 Attempts to convert IPv6 address into MAC.
 
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::Pkt6
uint8_t msg_type_
 DHCPv6 message type.
 
DHCPv6Proto proto_
 UDP (usually) or TCP (bulk leasequery or failover)
 
- 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

PerfPkt6 (DHCPv6 packet)

This class extends the functionality of isc::dhcp::Pkt6 by adding the ability to specify an options offset in the DHCP message and so override the options' contents. This is particularly useful when we create a packet object using a template file (i.e. do not build it dynamically). The client class should read the data from the template file and pass it to this class as a buffer.

The contents of such packet can be later partially replaced: in particular, selected options and the transaction ID can be altered. (The transaction ID and its offset in the template file is passed via the constructor.)

In order to replace the contents of options, the client class has to create a collection of LocalizedOption by adding them using dhcp::Pkt6::addOption.

Note
If you don't use template files, simply use constructors inherited from parent class and the isc::dhcp::Option type instead.

Definition at line 41 of file perf_pkt6.h.

Member Typedef Documentation

◆ LocalizedOptionPtr

Localized option pointer type.

Definition at line 45 of file perf_pkt6.h.

Constructor & Destructor Documentation

◆ PerfPkt6()

isc::perfdhcp::PerfPkt6::PerfPkt6 ( const uint8_t * buf,
size_t len,
size_t transid_offset = 1,
uint32_t transid = 0 )

Constructor, used to create messages from packet template files.

Creates a new DHCPv6 message using the provided buffer. The transaction ID and its offset are specified via this constructor. The transaction ID is stored in outgoing message when client class calls PerfPkt6::rawPack. Transaction id offset value is used for incoming and outgoing messages to identify transaction ID field's position in incoming and outgoing messages.

Parameters
bufbuffer holding contents of the message (this can be directly read from template file).
lenlength of the data in the buffer.
transid_offsettransaction id offset in a message.
transidtransaction id to be stored in outgoing message.

Definition at line 25 of file perf_pkt6.cc.

References isc::dhcp::Pkt::setTransid().

+ Here is the call graph for this function:

Member Function Documentation

◆ getTransidOffset()

size_t isc::perfdhcp::PerfPkt6::getTransidOffset ( ) const
inline

Returns transaction id offset in packet buffer.

Returns
Transaction ID offset in the packet buffer.

Definition at line 71 of file perf_pkt6.h.

Referenced by rawPack(), and rawUnpack().

◆ rawPack()

bool isc::perfdhcp::PerfPkt6::rawPack ( )

Prepares on-wire format from raw buffer.

The method copies the buffer provided in constructor to the output buffer and replaces the transaction ID and selected options with new data.

Note
Use this method to prepare an on-wire DHCPv6 message when you use template packets that require replacement of selected options' contents before sending.
Returns
false ID pack operation failed.

Definition at line 35 of file perf_pkt6.cc.

References isc::dhcp::Pkt::buffer_out_, isc::dhcp::Pkt::data_, isc::dhcp::Pkt::getTransid(), getTransidOffset(), isc::dhcp::Pkt::options_, isc::perfdhcp::PktTransform::pack(), and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ rawUnpack()

bool isc::perfdhcp::PerfPkt6::rawUnpack ( )

Handles limited binary packet parsing for packets with custom offsets of options and transaction id.

This method handles the parsing of packets that have custom offsets of options or transaction ID. Use isc::dhcp::Pkt4::addOption to specify which options to parse. Options should be of the isc::perfdhcp::LocalizedOption type with offset values provided. Each added option will be updated with actual data read from the binary packet buffer.

Returns
false if unpack operation failed.

Definition at line 45 of file perf_pkt6.cc.

References isc::dhcp::Pkt::data_, isc::dhcp::Pkt::getTransid(), getTransidOffset(), isc::dhcp::Pkt::options_, isc::dhcp::Pkt::setTransid(), isc::perfdhcp::PktTransform::unpack(), and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ writeAt()

void isc::perfdhcp::PerfPkt6::writeAt ( size_t dest_pos,
std::vector< uint8_t >::iterator first,
std::vector< uint8_t >::iterator last )

Replace contents of buffer with data.

Function replaces part of the buffer with data from vector.

Parameters
dest_posposition in buffer where data is replaced.
firstbeginning of data range in source vector.
lastend of data range in source vector.

Definition at line 59 of file perf_pkt6.cc.

References isc::dhcp::Pkt::data_, and isc::perfdhcp::PktTransform::writeAt().

+ Here is the call graph for this function:

◆ writeValueAt()

template<typename T >
void isc::perfdhcp::PerfPkt6::writeValueAt ( size_t dest_pos,
T val )
inline

Replace contents of buffer with value.

Function replaces part of buffer with value.

Parameters
dest_posposition in buffer where value is to be written.
valvalue to be written.

Definition at line 118 of file perf_pkt6.h.

References isc::dhcp::Pkt::data_.


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