Kea 2.7.6
|
Represents a DHCPv6 packet. More...
#include <pkt6.h>
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 (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::IOAddress & | getRelay6LinkAddress (uint8_t relay_level) const |
return the link address field from a relay option | |
const isc::asiolink::IOAddress & | getRelay6PeerAddress (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 ×tamp=PktEvent::now()) |
Adds an event to the end of the event stack. | |
void | addPktEvent (const std::string &label, const struct timeval ×tamp) |
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 ClientClasses & | getAdditionalClasses () const |
Returns the additional class list. | |
isc::util::OutputBuffer & | getBuffer () |
Returns reference to output buffer. | |
const ClientClasses & | getClasses () const |
Returns the class set. | |
std::string | getIface () const |
Returns interface name. | |
int | getIndex () const |
Returns interface index. | |
const isc::asiolink::IOAddress & | getLocalAddr () 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::IOAddress & | getRemoteAddr () 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 SubClassRelationContainer & | getSubClassesRelations () 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 ×tamp=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 ×tamp) |
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. | |
Static Public Member Functions | |
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 | |
std::vector< RelayInfo > | relay_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 | |
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 | |
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 | |
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. | |
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.
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 |
isc::dhcp::Pkt6::Pkt6 | ( | uint8_t | msg_type, |
uint32_t | transid, | ||
DHCPv6Proto | proto = UDP ) |
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.
buf | pointer to a buffer of received packet content |
len | size of buffer of received packet content |
proto | protocol (usually UDP, but TCP will be supported eventually) |
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.
relay | structure with necessary relay information |
Definition at line 623 of file pkt6.cc.
References HOP_COUNT_LIMIT, isc_throw, and relay_info_.
Referenced by unpackRelayMsg().
|
protected |
Calculates overhead for all relays defined for this message.
Definition at line 354 of file pkt6.cc.
References directLen(), getRelayOverhead(), len(), and relay_info_.
Referenced by len(), and packUDP().
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.
question | client's packet |
Definition at line 872 of file pkt6.cc.
References D6O_INTERFACE_ID, D6O_RELAY_SOURCE_PORT, DHCPV6_RELAY_REPL, isc::db::info, isc::dhcp::Pkt6::RelayInfo::msg_type_, and relay_info_.
|
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.
Definition at line 366 of file pkt6.cc.
References DHCPV6_PKT_HDR_LEN, and isc::dhcp::Pkt::options_.
Referenced by calculateRelaySizes(), and len().
OptionCollection isc::dhcp::Pkt6::getAllRelayOptions | ( | const uint16_t | option_code, |
const RelaySearchOrder & | order ) |
Return first instances of a specified option.
When a client's packet traverses multiple relays, each passing relay may insert extra options. This method allows the specific instances of a given option to be obtained in the specified order (e.g. first closest to the client, first closest to the server, etc.) See RelaySearchOrder for a detailed description.
option_code | searched option |
order | option search order (see RelaySearchOrder) |
Definition at line 201 of file pkt6.cc.
References isc::dhcp::Pkt::copy_retrieved_options_, and relay_info_.
Referenced by getMACFromDocsisCMTS().
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.
option_code | searched option |
order | option search order (see RelaySearchOrder) |
Definition at line 138 of file pkt6.cc.
References getRelayOption(), and relay_info_.
Referenced by getMACFromIPv6RelayOpt(), and getMACFromRemoteIdRelayOption().
DuidPtr isc::dhcp::Pkt6::getClientId | ( | ) | const |
Retrieves the DUID from the Client Identifier option.
This method is exception safe.
Definition at line 765 of file pkt6.cc.
References D6O_CLIENTID, and isc::dhcp::Pkt::getNonCopiedOption().
Referenced by getLabel().
|
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.
Reimplemented from isc::dhcp::Pkt.
Definition at line 718 of file pkt6.cc.
References getClientId(), isc::dhcp::Pkt::getTransid(), and makeLabel().
|
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.
Implements isc::dhcp::Pkt.
Definition at line 973 of file pkt6.cc.
References D6O_VENDOR_OPTS, DOCSIS3_V6_CMTS_CM_MAC, getAllRelayOptions(), isc::dhcp::HTYPE_DOCSIS, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_CMTS, relay_info_, RELAY_SEARCH_FROM_CLIENT, and VENDOR_ID_CABLE_LABS.
|
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.
Implements isc::dhcp::Pkt.
Definition at line 945 of file pkt6.cc.
References D6O_VENDOR_OPTS, DOCSIS3_V6_DEVICE_ID, isc::dhcp::Pkt::getNonCopiedOptions(), isc::dhcp::HTYPE_DOCSIS, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_MODEM, and VENDOR_ID_CABLE_LABS.
|
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.
Implements isc::dhcp::Pkt.
Definition at line 639 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().
|
protectedvirtual |
Extract MAC/Hardware address from client link-layer address.
This method extracts the client's hardware address from the
Implements isc::dhcp::Pkt.
Definition at line 917 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_.
|
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.
Implements isc::dhcp::Pkt.
Definition at line 1007 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_.
|
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.
Implements isc::dhcp::Pkt.
Definition at line 906 of file pkt6.cc.
References isc::dhcp::Pkt::getMACFromIPv6(), relay_info_, and isc::dhcp::Pkt::remote_addr_.
|
virtual |
Returns name of the DHCPv6 message.
This method requires an object. There is also a static version, which requires one parameter (type).
Implements isc::dhcp::Pkt.
Definition at line 868 of file pkt6.cc.
References getName(), and getType().
Referenced by isc::perfmon::DurationKey::getMessageTypeLabel(), getName(), isc::perfmon::DurationKeyParser::toElement(), isc::dhcp::Pkt6::RelayInfo::toText(), toText(), and isc::perfmon::DurationKey::validateMessagePair().
|
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.
type | DHCPv6 message type which name should be returned. |
Definition at line 782 of file pkt6.cc.
References DHCPV6_ADVERTISE, DHCPV6_CONFIRM, DHCPV6_DECLINE, DHCPV6_DHCPV4_QUERY, DHCPV6_DHCPV4_RESPONSE, DHCPV6_INFORMATION_REQUEST, DHCPV6_LEASEQUERY, DHCPV6_LEASEQUERY_DATA, DHCPV6_LEASEQUERY_DONE, DHCPV6_LEASEQUERY_REPLY, DHCPV6_REBIND, DHCPV6_RECONFIGURE, DHCPV6_RELAY_FORW, DHCPV6_RELAY_REPL, DHCPV6_RELEASE, DHCPV6_RENEW, DHCPV6_REPLY, DHCPV6_REQUEST, and DHCPV6_SOLICIT.
|
protected |
Returns pointers to instances of specified option.
This is a variant of getAllRelayOptions 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.
option_code | Searched option. |
order | Option search order (see RelaySearchOrder). |
Definition at line 171 of file pkt6.cc.
References relay_info_.
|
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.
option_code | Searched option. |
order | Option search order (see RelaySearchOrder). |
Definition at line 106 of file pkt6.cc.
References getNonCopiedRelayOption(), and relay_info_.
|
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.
opt_type | Code of the requested option. |
relay_level | Nesting level as described for Pkt6::getRelayOption. |
Definition at line 241 of file pkt6.cc.
References isc_throw, isc::dhcp::Pkt::options_, and relay_info_.
Referenced by getNonCopiedAnyRelayOption().
|
protected |
Returns all option instances inserted by relay agent.
This is a variant of the Pkt6::getRelayOptions 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.
opt_type | Code of the requested option. |
relay_level | Nesting level as described for Pkt6::getRelayOption. |
Definition at line 280 of file pkt6.cc.
References isc_throw, and relay_info_.
|
inline |
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).
isc::OutOfRange | if relay level has an invalid value. |
relay_level | see description above |
Definition at line 324 of file pkt6.cc.
References isc_throw, and relay_info_.
Referenced by isc::dhcp::TokenRelay6Field::evaluate().
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).
isc::OutOfRange | if relay level has an invalid value. |
relay_level | see description above |
Definition at line 334 of file pkt6.cc.
References isc_throw, and relay_info_.
Referenced by isc::dhcp::TokenRelay6Field::evaluate().
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).
isc::OutOfRange | if nesting level has invalid value. |
option_code | code of the requested option |
nesting_level | see description above |
Definition at line 259 of file pkt6.cc.
References isc::dhcp::Pkt::copy_retrieved_options_, isc_throw, isc::dhcp::Pkt::options_, and relay_info_.
Referenced by getAnyRelayOption(), and isc::dhcp::TokenRelay6Option::getOption().
OptionCollection isc::dhcp::Pkt6::getRelayOptions | ( | uint16_t | option_code, |
uint8_t | nesting_level ) |
Returns options inserted by relay.
Returns options 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).
isc::OutOfRange | if nesting level has invalid value. |
option_code | code of the requested option |
nesting_level | see description above |
Definition at line 296 of file pkt6.cc.
References isc::dhcp::Pkt::copy_retrieved_options_, isc_throw, and relay_info_.
|
protected |
Calculates overhead introduced in specified relay.
It is used when calculating message size and packing message
relay | RelayInfo structure that holds information about relay |
Definition at line 343 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().
|
inlinevirtual |
Returns message type (e.g.
1 = SOLICIT).
Implements isc::dhcp::Pkt.
Definition at line 220 of file pkt6.h.
References msg_type_.
Referenced by isc::dhcp::TokenPkt6::evaluate(), and getName().
|
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.
Implements isc::dhcp::Pkt.
Definition at line 63 of file pkt6.cc.
References calculateRelaySizes(), directLen(), getRelayOverhead(), and relay_info_.
Referenced by calculateRelaySizes(), getMACFromRemoteIdRelayOption(), and getRelayOverhead().
Returns text representation of the given packet identifiers.
This variant of the method does not include transaction id.
duid | Pointer to the client identifier or NULL. |
hwaddr | Hardware address to include in the string or NULL. |
|
static |
Returns text representation of the given packet identifiers.
Pkt6::makeLabel
is called.duid | Pointer to the client identifier or NULL. |
transid | Numeric transaction id to include in the string. |
hwaddr | Hardware address to include in the string or NULL. |
Definition at line 691 of file pkt6.cc.
References makeLabel().
Referenced by getLabel(), makeLabel(), and isc::dhcp::queueNCR().
|
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.
BadValue | if 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 377 of file pkt6.cc.
References isc_throw, packTCP(), packUDP(), proto_, TCP, and UDP.
Referenced by packUDP().
|
protected |
|
protected |
Builds on wire packet for UDP transmission.
InvalidOperation | if packing fails |
Definition at line 391 of file pkt6.cc.
References isc::dhcp::Pkt::buffer_out_, calculateRelaySizes(), isc::util::OutputBuffer::clear(), D6O_RELAY_MSG, isc_throw, msg_type_, isc::dhcp::Pkt::options_, pack(), isc::dhcp::LibDHCP::packOptions6(), relay_info_, isc::dhcp::Pkt::transid_, isc::Exception::what(), isc::util::OutputBuffer::writeData(), isc::util::OutputBuffer::writeUint16(), and isc::util::OutputBuffer::writeUint8().
Referenced by pack().
|
inline |
|
inlinevirtual |
Sets message type (e.g.
1 = SOLICIT).
type | message type to be set |
Implements isc::dhcp::Pkt.
Definition at line 225 of file pkt6.h.
References msg_type_.
|
virtual |
Returns text representation of the packet.
This function is useful mainly for debugging.
Implements isc::dhcp::Pkt.
Definition at line 726 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_.
|
virtual |
Dispatch method that handles binary packet parsing.
This method calls appropriate dispatch function (unpackUDP or unpackTCP).
tbd |
Implements isc::dhcp::Pkt.
Definition at line 460 of file pkt6.cc.
References isc_throw, proto_, TCP, UDP, unpackTCP(), and unpackUDP().
|
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.
begin | start of the buffer |
end | end of the buffer |
tbd |
Definition at line 502 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().
|
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).
tbd |
Definition at line 546 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().
|
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.
tbd |
Definition at line 633 of file pkt6.cc.
References isc_throw.
Referenced by unpack().
|
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.
tbd |
Definition at line 472 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().
|
static |
specifies non-relayed DHCPv6 packet header length (over UDP)
Definition at line 47 of file pkt6.h.
Referenced by directLen().
|
static |
specifies relay DHCPv6 packet header length (over UDP)
Definition at line 50 of file pkt6.h.
Referenced by getRelayOverhead(), and unpackRelayMsg().
|
protected |
DHCPv6 message type.
Definition at line 620 of file pkt6.h.
Referenced by getType(), packUDP(), setType(), isc::dhcp::Pkt6::RelayInfo::toText(), toText(), unpackMsg(), and unpackUDP().
|
protected |
UDP (usually) or TCP (bulk leasequery or failover)
Definition at line 617 of file pkt6.h.
Referenced by getProto(), pack(), setProto(), and unpack().
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 473 of file pkt6.h.
Referenced by addRelayInfo(), calculateRelaySizes(), copyRelayInfo(), isc::dhcp::TokenRelay6Field::evaluate(), getAllRelayOptions(), getAnyRelayOption(), getMACFromDocsisCMTS(), getMACFromIPv6RelayOpt(), getMACFromRemoteIdRelayOption(), getMACFromSrcLinkLocalAddr(), getNonCopiedAllRelayOptions(), getNonCopiedAnyRelayOption(), getNonCopiedRelayOption(), getNonCopiedRelayOptions(), isc::dhcp::TokenRelay6Option::getOption(), getRelay6LinkAddress(), getRelay6PeerAddress(), getRelayOption(), getRelayOptions(), len(), packUDP(), and toText().