Kea 2.7.5
|
Represents DHCPv4 packet. More...
#include <pkt4.h>
Public Member Functions | |
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::IOAddress & | getCiaddr () 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::IOAddress & | getGiaddr () 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::IOAddress & | getSiaddr () const |
Returns siaddr field. | |
const OptionBuffer | getSname () const |
Returns sname field. | |
uint8_t | getType () const |
Returns DHCP message type (e.g. | |
const isc::asiolink::IOAddress & | getYiaddr () 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 | 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. | |
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 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. | |
Static Public Attributes | |
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 | |
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. | |
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 | |
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. | |
Additional Inherited Members | |
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. | |
Represents DHCPv4 packet.
This class represents a single DHCPv4 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 DHCPv4-specific methods, but it uses a lot of common operations from its base Pkt
class that is shared with Pkt6.
isc::dhcp::Pkt4::Pkt4 | ( | uint8_t | msg_type, |
uint32_t | transid ) |
Constructor, used in replying to a message.
msg_type | type of message (e.g. DHCPDISCOVER=1) |
transid | transaction-id |
Definition at line 32 of file pkt4.cc.
References file_, MAX_FILE_LEN, MAX_SNAME_LEN, setType(), and sname_.
isc::dhcp::Pkt4::Pkt4 | ( | const uint8_t * | data, |
size_t | len ) |
Constructor, used in message reception.
Creates new message. Pkt4 will copy data to bufferIn_ buffer on creation.
data | pointer to received data |
len | size of buffer to be allocated for this packet. |
Definition at line 43 of file pkt4.cc.
References DHCPV4_PKT_HDR_LEN, file_, isc_throw, len(), MAX_FILE_LEN, MAX_SNAME_LEN, and sname_.
|
virtual |
Add an option.
BadValue | if option with that type is already present. |
opt | option to be added |
Reimplemented from isc::dhcp::Pkt.
Definition at line 589 of file pkt4.cc.
References isc::dhcp::Pkt::addOption(), isc::dhcp::Pkt::getNonCopiedOption(), and isc_throw.
Referenced by setType().
|
protected |
converts DHCP message type to BOOTP op type
dhcpType | DHCP message type (e.g. DHCPDISCOVER) |
Definition at line 545 of file pkt4.cc.
References isc::dhcp::BOOTREPLY, isc::dhcp::BOOTREQUEST, isc::dhcp::DHCPACK, isc::dhcp::DHCPBULKLEASEQUERY, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEQUERY, isc::dhcp::DHCPLEASEQUERYDONE, isc::dhcp::DHCPLEASEUNASSIGNED, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::DHCPNAK, isc::dhcp::DHCPOFFER, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, and isc_throw.
|
inline |
|
inline |
Returns a reference to option codes which unpacking will be deferred.
Only options 43 and 224-254 are subject of deferred unpacking: when the packet unpacking is performed, each time such an option is found, it is unpacked as an unknown option and the code added in this list.
Definition at line 385 of file pkt4.h.
References deferred_options_.
|
inline |
Returns file field.
Note: This is 128 bytes long field. It doesn't have to be null-terminated. Do not use strlen() or similar on it.
Definition at line 280 of file pkt4.h.
References file_, and MAX_FILE_LEN.
|
inline |
|
inline |
uint8_t isc::dhcp::Pkt4::getHlen | ( | ) | const |
Returns hlen field.
Definition at line 580 of file pkt4.cc.
References hwaddr_, len(), and MAX_CHADDR_LEN.
|
inline |
uint8_t isc::dhcp::Pkt4::getHtype | ( | ) | const |
Returns htype field.
Definition at line 572 of file pkt4.cc.
References isc::dhcp::HTYPE_UNDEFINED, and hwaddr_.
|
inline |
returns hardware address information
Definition at line 324 of file pkt4.h.
References hwaddr_.
Referenced by isc::dhcp::TokenPkt4::evaluate().
std::string isc::dhcp::Pkt4::getHWAddrLabel | ( | ) | const |
Returns text representation of the hardware address.
Returns text representation of the hardware address (e.g. hwaddr=00:01:02:03:04:05). If there is no defined hardware address, it returns hwaddr=
(undefined).
Definition at line 605 of file pkt4.cc.
References hwaddr_.
|
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.
This method is exception safe.
Reimplemented from isc::dhcp::Pkt.
Definition at line 365 of file pkt4.cc.
References isc::dhcp::Pkt::getNonCopiedOption(), hwaddr_, makeLabel(), and isc::dhcp::Pkt::transid_.
|
inline |
Returns local HW address.
Definition at line 372 of file pkt4.h.
References local_hwaddr_.
|
inlineprotectedvirtual |
No-op.
This is a DHCPv4 version of the function that attempts to extract MAC address from the options inserted by a CMTS. It is currently not implemented for v4.
Implements isc::dhcp::Pkt.
|
inlineprotectedvirtual |
No-op.
This is a DHCPv4 version of the function that attempts to extract MAC address from the options inserted by a cable modem. It is currently not implemented for v4.
Implements isc::dhcp::Pkt.
|
inlineprotectedvirtual |
No-op.
This method returns hardware address extracted from DUID. Currently it is a no-op, even though there's RFC that defines how to use DUID in DHCPv4 (see RFC4361). We may implement it one day.
Implements isc::dhcp::Pkt.
|
inlineprotectedvirtual |
No-op.
This method returns hardware address extracted from an IPv6 relay agent. option. As there is no IPv4-equivalent, it always returns NULL. We need this stub implementation here, to keep all the get hardware address logic in the base class.
Implements isc::dhcp::Pkt.
|
inlineprotectedvirtual |
No-op.
This method returns hardware address extracted from remote-id relay option. Currently it is a no-op, it always returns NULL.
Implements isc::dhcp::Pkt.
|
inlineprotectedvirtual |
No-op.
This method returns hardware address generated from the IPv6 link-local address. As there is no IPv4-equivalent, it always returns NULL. We need this stub implementation here, to keep all the get hardware address logic in the base class.
Implements isc::dhcp::Pkt.
|
virtual |
Returns name of the DHCP message.
Implements isc::dhcp::Pkt.
Definition at line 357 of file pkt4.cc.
References getName(), and getType().
Referenced by isc::perfmon::DurationKey::getMessageTypeLabel(), getName(), isc::perfmon::DurationKeyParser::toElement(), toText(), and isc::perfmon::DurationKey::validateMessagePair().
|
static |
Returns name of the DHCP message for a given type number.
This method is exception safe. For messages without DHCP Message Type options, it returns UNKNOWN.
type | DHCPv4 message type which name should be returned. |
Definition at line 282 of file pkt4.cc.
References isc::dhcp::DHCPACK, isc::dhcp::DHCPBULKLEASEQUERY, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEQUERY, isc::dhcp::DHCPLEASEQUERYDONE, isc::dhcp::DHCPLEASEQUERYSTATUS, isc::dhcp::DHCPLEASEUNASSIGNED, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::DHCPNAK, isc::dhcp::DHCPOFFER, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, and isc::dhcp::DHCPTLS.
|
inline |
|
inline |
|
inline |
|
inline |
Returns sname field.
Note: This is 64 bytes long field. It doesn't have to be null-terminated. Do not use strlen() or similar on it.
Definition at line 265 of file pkt4.h.
References MAX_SNAME_LEN, and sname_.
|
virtual |
Returns DHCP message type (e.g.
1 = DHCPDISCOVER).
This method is exception safe. For packets without DHCP Message Type option, it returns DHCP_NOTYPE (0).
Implements isc::dhcp::Pkt.
Definition at line 234 of file pkt4.cc.
References isc::dhcp::DHCP_NOTYPE, isc::dhcp::DHO_DHCP_MESSAGE_TYPE, and isc::dhcp::Pkt::getNonCopiedOption().
Referenced by getName(), and toText().
|
inline |
|
inlinevirtual |
Checks if a DHCPv4 message has been transported over DHCPv6.
Reimplemented in isc::dhcp::Pkt4o6.
bool isc::dhcp::Pkt4::isRelayed | ( | ) | const |
Checks if a DHCPv4 message has been relayed.
This function returns a boolean value which indicates whether a DHCPv4 message has been relayed (if true is returned) or not (if false).
The message is considered relayed if the giaddr field is non-zero and non-broadcast.
Definition at line 600 of file pkt4.cc.
References giaddr_, isc::asiolink::IOAddress::isV4Bcast(), and isc::asiolink::IOAddress::isV4Zero().
|
virtual |
Returns the size of the required buffer to build the packet.
Returns the size of the required buffer to build the packet with the current set of packet options.
Implements isc::dhcp::Pkt.
Definition at line 59 of file pkt4.cc.
References DHCPV4_PKT_HDR_LEN, and isc::dhcp::Pkt::options_.
|
static |
|
static |
Returns text representation of the given packet identifiers.
hwaddr | - hardware address to include in the string, it may be NULL. |
client_id | - client id to include in the string, it may be NULL. to include in the string |
transid | - numeric transaction id to include in the string |
Definition at line 397 of file pkt4.cc.
References makeLabel().
Referenced by getLabel(), makeLabel(), and isc::dhcp::queueNCR().
|
virtual |
Prepares on-wire format of DHCPv4 packet.
Prepares on-wire format of message and all its options. Options must be stored in options_ field. Output buffer will be stored in buffer_out_. The buffer_out_ is cleared before writing to the buffer.
InvalidOperation | if packing fails |
Create a ManagedScopedOptionsCopyContainer to handle storing and restoration of copied options.
Implements isc::dhcp::Pkt.
Reimplemented in isc::dhcp::Pkt4o6.
Definition at line 71 of file pkt4.cc.
References isc::dhcp::Pkt::buffer_out_, ciaddr_, isc::util::OutputBuffer::clear(), isc::dhcp::DHO_END, file_, flags_, giaddr_, hops_, hwaddr_, isc_throw, MAX_CHADDR_LEN, MAX_FILE_LEN, MAX_SNAME_LEN, op_, isc::dhcp::Pkt::options_, isc::dhcp::LibDHCP::packOptions4(), secs_, siaddr_, sname_, isc::dhcp::LibDHCP::splitOptions4(), isc::asiolink::IOAddress::toUint32(), isc::dhcp::Pkt::transid_, isc::Exception::what(), isc::util::OutputBuffer::writeData(), isc::util::OutputBuffer::writeUint16(), isc::util::OutputBuffer::writeUint32(), isc::util::OutputBuffer::writeUint8(), and yiaddr_.
Referenced by isc::dhcp::Pkt4o6::pack().
|
inline |
void isc::dhcp::Pkt4::setFile | ( | const uint8_t * | file, |
size_t | file_len ) |
Sets file field.
file | value to be set |
file_len | length of the file buffer (up to MAX_FILE_LEN) |
Definition at line 526 of file pkt4.cc.
References file_, isc_throw, and MAX_FILE_LEN.
|
inline |
|
inline |
|
inline |
void isc::dhcp::Pkt4::setHWAddr | ( | const HWAddrPtr & | addr | ) |
void isc::dhcp::Pkt4::setHWAddr | ( | uint8_t | htype, |
uint8_t | hlen, | ||
const std::vector< uint8_t > & | mac_addr ) |
Sets hardware address.
Sets parameters of hardware address. hlen specifies length of mac_addr buffer. Content of mac_addr buffer will be copied to appropriate field.
Note: mac_addr must be a buffer of at least hlen bytes.
htype | hardware type (will be sent in htype field) |
hlen | hardware length (will be sent in hlen field) |
mac_addr | pointer to hardware address |
Definition at line 458 of file pkt4.cc.
References hwaddr_.
void isc::dhcp::Pkt4::setLocalHWAddr | ( | const HWAddrPtr & | addr | ) |
Sets local HW address.
Sets hardware address from an existing HWAddr structure. The local address is a source address for outgoing packet and destination address for incoming packet.
addr | structure representing HW address. |
BadValue | if addr is null |
Definition at line 499 of file pkt4.cc.
References isc_throw, and local_hwaddr_.
void isc::dhcp::Pkt4::setLocalHWAddr | ( | const uint8_t | htype, |
const uint8_t | hlen, | ||
const std::vector< uint8_t > & | mac_addr ) |
Sets local HW address.
Sets the source HW address for the outgoing packet or destination HW address for the incoming packet.
htype | hardware type (will be sent in htype field) |
hlen | hardware length (will be sent in hlen field) |
mac_addr | pointer to hardware address |
Definition at line 493 of file pkt4.cc.
References local_hwaddr_.
|
inline |
|
inline |
void isc::dhcp::Pkt4::setSname | ( | const uint8_t * | sname, |
size_t | sname_len ) |
Sets sname field.
sname | value to be set |
sname_len | length of the sname buffer (up to MAX_SNAME_LEN) |
Definition at line 508 of file pkt4.cc.
References isc_throw, MAX_SNAME_LEN, and sname_.
|
virtual |
Sets DHCP message type (e.g.
1 = DHCPDISCOVER).
type | message type to be set |
Implements isc::dhcp::Pkt.
Definition at line 251 of file pkt4.cc.
References addOption(), isc::dhcp::DHO_DHCP_MESSAGE_TYPE, isc::dhcp::Pkt::getNonCopiedOption(), and isc::dhcp::Option::V4.
Referenced by Pkt4().
|
inline |
|
virtual |
Returns text representation of the packet.
This function is useful mainly for debugging.
Implements isc::dhcp::Pkt.
Definition at line 420 of file pkt4.cc.
References isc::dhcp::DHCP_NOTYPE, getName(), getType(), isc::dhcp::Pkt::local_addr_, isc::dhcp::Pkt::local_port_, isc::dhcp::Pkt::options_, isc::dhcp::Pkt::remote_addr_, isc::dhcp::Pkt::remote_port_, and isc::dhcp::Pkt::transid_.
|
virtual |
Parses on-wire form of DHCPv4 packet.
Parses received packet, stored in on-wire format in bufferIn_.
Will create a collection of option objects that will be stored in options_ container.
Method with throw exception if packet parsing fails.
Implements isc::dhcp::Pkt.
Definition at line 151 of file pkt4.cc.
References ciaddr_, isc::dhcp::Pkt::data_, deferred_options_, DHCP4_OPTION_SPACE, DHCPV4_PKT_HDR_LEN, isc::dhcp::LibDHCP::extendVendorOptions4(), file_, flags_, giaddr_, hops_, hwaddr_, isc_throw, MAX_CHADDR_LEN, MAX_FILE_LEN, MAX_SNAME_LEN, op_, isc::dhcp::Pkt::options_, secs_, siaddr_, sname_, isc::dhcp::Pkt::transid_, isc::dhcp::LibDHCP::unpackOptions4(), and yiaddr_.
|
protected |
ciaddr field (32 bits): Client's IP address
Definition at line 534 of file pkt4.h.
Referenced by getCiaddr(), pack(), setCiaddr(), and unpack().
|
protected |
Definition at line 507 of file pkt4.h.
Referenced by getDeferredOptions(), and unpack().
|
static |
|
protected |
|
static |
Mask for the value of flags field in the DHCPv4 message to check whether client requested broadcast response.
Definition at line 54 of file pkt4.h.
Referenced by isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), and isc::dhcp::writeEthernetHeader().
|
protected |
flags
Definition at line 531 of file pkt4.h.
Referenced by getFlags(), pack(), setFlags(), and unpack().
|
protected |
giaddr field (32 bits): Gateway IP address
Definition at line 543 of file pkt4.h.
Referenced by getGiaddr(), isRelayed(), pack(), setGiaddr(), and unpack().
|
protected |
|
protected |
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)
Definition at line 522 of file pkt4.h.
Referenced by getHlen(), getHtype(), getHWAddr(), getHWAddrLabel(), getLabel(), pack(), setHWAddr(), setHWAddr(), and unpack().
|
protected |
local HW address (dst if receiving packet, src if sending packet)
Definition at line 504 of file pkt4.h.
Referenced by getLocalHWAddr(), setLocalHWAddr(), and setLocalHWAddr().
|
static |
|
static |
length of the FILE field in DHCPv4 message
Definition at line 47 of file pkt4.h.
Referenced by Pkt4(), Pkt4(), getFile(), isc::dhcp::Subnet4ConfigParser::initSubnet(), pack(), isc::dhcp::ClientClassDefParser::parse(), isc::dhcp::SharedNetwork4Parser::parse(), isc::dhcp::Host::setBootFileName(), setFile(), and unpack().
|
static |
length of the SNAME field in DHCPv4 message
Definition at line 44 of file pkt4.h.
Referenced by Pkt4(), Pkt4(), getSname(), isc::dhcp::Subnet4ConfigParser::initSubnet(), pack(), isc::dhcp::ClientClassDefParser::parse(), isc::dhcp::SharedNetwork4Parser::parse(), isc::dhcp::Host::setServerHostname(), setSname(), and unpack().
|
protected |
message operation code
Note: This is legacy BOOTP field. There's no need to manipulate it directly. Its value is set based on DHCP message type. Note that DHCPv4 protocol reuses BOOTP message format, so this field is kept due to BOOTP format. This is NOT DHCPv4 type (DHCPv4 message type is kept in message type option).
|
protected |
|
protected |
siaddr field (32 bits): next server IP address in boot process(e.g.TFTP)
Definition at line 540 of file pkt4.h.
Referenced by getSiaddr(), pack(), setSiaddr(), and unpack().
|
protected |
sname field (64 bytes)
Definition at line 546 of file pkt4.h.
Referenced by Pkt4(), Pkt4(), getSname(), pack(), setSname(), and unpack().
|
protected |
yiaddr field (32 bits): Client's IP address ("your"), set by server
Definition at line 537 of file pkt4.h.
Referenced by getYiaddr(), pack(), setYiaddr(), and unpack().