23 local_addr_(local_addr),
24 remote_addr_(remote_addr),
25 local_port_(local_port),
26 remote_port_(remote_port),
28 copy_retrieved_options_(false)
38 local_addr_(local_addr),
39 remote_addr_(remote_addr),
40 local_port_(local_port),
41 remote_port_(remote_port),
43 copy_retrieved_options_(false)
51 memcpy(&
data_[0], buf, len);
57 options_.insert(std::pair<int, OptionPtr>(opt->getType(), opt));
62 OptionCollection::const_iterator x =
options_.find(type);
71 OptionCollection::iterator x =
options_.find(type);
74 OptionPtr option_copy = x->second->clone();
75 x->second = option_copy;
85 isc::dhcp::OptionCollection::iterator x =
options_.find(type);
106 if (!classes.
contains(client_class)) {
107 classes.
insert(client_class);
113 timestamp_ = boost::posix_time::microsec_clock::universal_time();
117 if (!
data_.empty()) {
124 const std::vector<uint8_t>& hw_addr) {
138 Pkt::setHWAddrMember(
const uint8_t htype,
const uint8_t,
139 const std::vector<uint8_t>& hw_addr,
142 storage.reset(
new HWAddr(hw_addr, htype));
157 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_RAW) {
169 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION) {
181 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_DUID) {
193 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL) {
205 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_REMOTE_ID) {
219 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_DOCSIS_CMTS) {
231 }
else if (hw_addr_src == HWAddr::HWADDR_SOURCE_DOCSIS_MODEM) {
247 std::vector<uint8_t> bin = addr.
toBytes();
250 if ((bin.size() == isc::asiolink::V6ADDRESS_LEN) &&
252 (bin[0] == 0xfe) && (bin[1] == 0x80) &&
255 ((bin[8] & 3) == 2) &&
257 (bin[11] == 0xff) && (bin[12] == 0xfe)) {
260 bin.erase(bin.begin(), bin.begin() + 8);
263 bin.erase(bin.begin() + 3, bin.begin() + 5);
274 hwtype = iface->getHWType();
277 mac.reset(
new HWAddr(bin, hwtype));
virtual HWAddrPtr getMACFromRemoteIdRelayOption()=0
Attempts to obtain MAC address from remote-id relay option.
IfacePtr getIface(int ifindex)
Returns interface specified interface index.
HWAddrPtr getMACFromIPv6(const isc::asiolink::IOAddress &addr)
Attempts to convert IPv6 address into MAC.
OptionBuffer data_
Unparsed data (in received packets).
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.
std::string iface_
Name of the network interface the packet was received/to be sent over.
bool inClass(const isc::dhcp::ClientClass &client_class)
Checks whether a client belongs to a given class.
static const uint32_t HWADDR_SOURCE_DOCSIS_MODEM
A cable modem (acting as DHCP client) that supports DOCSIS standard can insert DOCSIS options that co...
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
boost::shared_ptr< Option > OptionPtr
virtual HWAddrPtr getMACFromDocsisModem()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself...
virtual void addOption(const OptionPtr &opt)
Adds an option to this packet.
OptionPtr getNonCopiedOption(const uint16_t type) const
Returns the first option of specified type without copying.
static const uint32_t HWADDR_SOURCE_REMOTE_ID
A relay can insert remote-id.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
Get it from RFC6939 option.
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
ClientClasses classes_
Classes this packet belongs to.
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
virtual HWAddrPtr getMACFromDocsisCMTS()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the CMTS (the relay agent) ...
bool delOption(uint16_t type)
Attempts to delete first suboption of requested type.
HWAddrPtr getRemoteHWAddr() const
Returns the remote HW address obtained from raw sockets.
bool copy_retrieved_options_
Indicates if a copy of the retrieved option should be returned when Pkt::getOption is called...
static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL
Extracted from IPv6 link-local address.
static const uint32_t HWADDR_SOURCE_DOCSIS_CMTS
A CMTS (acting as DHCP relay agent) that supports DOCSIS standard can insert DOCSIS options that cont...
void setRemoteHWAddr(const HWAddrPtr &hw_addr)
Sets remote hardware address.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void updateTimestamp()
Update packet timestamp.
virtual HWAddrPtr getMACFromIPv6RelayOpt()=0
Attempts to obtain MAC address from relay option client-linklayer-addr.
void addClass(const isc::dhcp::ClientClass &client_class, bool required=false)
Adds packet to a specified class.
virtual HWAddrPtr getMACFromDUID()=0
Attempts to obtain MAC address from DUID-LL or DUID-LLT.
static const uint32_t HWADDR_SOURCE_RAW
Obtained first hand from raw socket (100% reliable).
OptionPtr getOption(const uint16_t type)
Returns the first option of specified type.
void repack()
Copies content of input buffer to output buffer.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
Hardware type that represents information from DHCPv4 packet.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
void insert(const ClientClass &class_name)
Insert an element.
bool empty() const
Check if classes is empty.
isc::util::OutputBuffer buffer_out_
Output buffer (used during message transmission)
virtual HWAddrPtr getMACFromSrcLinkLocalAddr()=0
Attempts to obtain MAC address from source link-local IPv6 address.
The IOAddress class represents an IP addresses (version agnostic)
ClientClasses required_classes_
Classes which are required to be evaluated.
isc::dhcp::OptionCollection options_
Collection of options present in this message.
Container for storing client class names.
static const uint32_t HWADDR_SOURCE_DUID
Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client can send fake DUID)...
boost::posix_time::ptime timestamp_
packet timestamp
HWAddrPtr getMAC(uint32_t hw_addr_src)
Returns MAC address.