17 #include <boost/date_time/posix_time/posix_time.hpp>
18 #include <boost/shared_ptr.hpp>
39 template<
typename PktType>
56 pkt1->setCopyRetrievedOptions(
true);
59 pkt2->setCopyRetrievedOptions(
true);
68 pkts_.first->setCopyRetrievedOptions(
false);
71 pkts_.second->setCopyRetrievedOptions(
false);
78 std::pair<PktTypePtr, PktTypePtr> pkts_;
107 uint16_t remote_port);
122 Pkt(
const uint8_t* buf, uint32_t
len,
125 uint16_t remote_port);
144 virtual void pack() = 0;
160 virtual void unpack() = 0;
215 virtual std::string
toText()
const = 0;
227 virtual size_t len() = 0;
236 virtual uint8_t
getType()
const = 0;
245 virtual void setType(uint8_t type) = 0;
256 virtual const char*
getName()
const = 0;
291 bool required =
false);
554 const std::vector<uint8_t>& hw_addr);
791 virtual void setHWAddrMember(
const uint8_t htype,
const uint8_t hlen,
792 const std::vector<uint8_t>& hw_addr,
797 typedef boost::shared_ptr<isc::dhcp::Pkt>
PktPtr;
virtual HWAddrPtr getMACFromRemoteIdRelayOption()=0
Attempts to obtain MAC address from remote-id relay option.
isc::asiolink::IOAddress local_addr_
Local IP (v4 or v6) address.
HWAddrPtr getMACFromIPv6(const isc::asiolink::IOAddress &addr)
Attempts to convert IPv6 address into MAC.
int64_t ifindex_
Interface index.
const ClientClasses & getClasses(bool required=false) const
Returns the class set.
virtual ~Pkt()
Virtual destructor.
OptionBuffer data_
Unparsed data (in received packets).
A generic exception that is thrown when a function is not implemented.
virtual void pack()=0
Prepares on-wire format of DHCP (either v4 or v6) packet.
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.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
uint16_t getRemotePort() const
Returns remote port.
virtual size_t len()=0
Returns packet size in binary format.
uint16_t getLocalPort() const
Returns local UDP (and soon TCP) port.
virtual const char * getName() const =0
Returns name of the DHCP message.
uint32_t transid_
Transaction-id (32 bits for v4, 24 bits for v6)
Defines elements for storing the names of client classes.
Base class for classes representing DHCP messages.
boost::shared_ptr< Option > OptionPtr
virtual HWAddrPtr getMACFromDocsisModem()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself...
void setTransid(uint32_t transid)
Sets transaction-id value.
virtual void addOption(const OptionPtr &opt)
Adds an option to this packet.
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.
OptionPtr getNonCopiedOption(const uint16_t type) const
Returns the first option of specified type without copying.
bool indexSet() const
Checks if interface index has been set.
const isc::asiolink::IOAddress & getLocalAddr() const
Returns local IP address.
RAII object enabling copying options retrieved from the packet.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
virtual void setType(uint8_t type)=0
Sets message type (e.g.
void setRemoteAddr(const isc::asiolink::IOAddress &remote)
Sets remote IP address.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ClientClasses classes_
Classes this packet belongs to.
virtual HWAddrPtr getMACFromDocsisCMTS()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the CMTS (the relay agent) ...
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
virtual void unpack()=0
Parses on-wire form of DHCP (either v4 or v6) packet.
Base class for classes which need to be associated with a CalloutHandle object.
void setLocalAddr(const isc::asiolink::IOAddress &local)
Sets local IP address.
bool delOption(uint16_t type)
Attempts to delete first suboption of requested type.
void setRemotePort(uint16_t remote)
Sets remote UDP (and soon TCP) port.
void setLocalPort(uint16_t local)
Sets local UDP (and soon TCP) port.
void resetIndex()
Resets interface index to negative value.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
isc::util::OutputBuffer & getBuffer()
Returns reference to output buffer.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
HWAddrPtr getRemoteHWAddr() const
Returns the remote HW address obtained from raw sockets.
~ScopedEnableOptionsCopy()
Destructor.
void setTimestamp(boost::posix_time::ptime ×tamp)
Set packet timestamp.
bool copy_retrieved_options_
Indicates if a copy of the retrieved option should be returned when Pkt::getOption is called...
uint16_t remote_port_
remote TCP or UDP port
const boost::posix_time::ptime & getTimestamp() const
Returns packet timestamp.
void setRemoteHWAddr(const HWAddrPtr &hw_addr)
Sets remote hardware address.
ScopedEnableOptionsCopy(const PktTypePtr &pkt1, const PktTypePtr &pkt2=PktTypePtr())
Constructor.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void updateTimestamp()
Update packet timestamp.
uint16_t local_port_
local TDP or UDP port
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 std::string toText() const =0
Returns text representation of the packet.
virtual HWAddrPtr getMACFromDUID()=0
Attempts to obtain MAC address from DUID-LL or DUID-LLT.
uint32_t getTransid() const
Returns value of transaction-id field.
void setIndex(uint32_t ifindex)
Sets interface index.
isc::asiolink::IOAddress remote_addr_
Remote IP address.
OptionPtr getOption(const uint16_t type)
Returns the first option of specified type.
void repack()
Copies content of input buffer to output buffer.
uint32_t getIndex() const
Returns interface index.
std::string getIface() const
Returns interface name.
bool isCopyRetrievedOptions() const
Returns whether the copying of retrieved options is enabled.
const isc::asiolink::IOAddress & getRemoteAddr() const
Returns remote IP address.
std::string ClientClass
Defines a single class name.
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.
boost::shared_ptr< PktType > PktTypePtr
Pointer to an encapsulated packet.
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.
virtual std::string getLabel() const
Returns text representation primary packet identifiers.
boost::posix_time::ptime timestamp_
packet timestamp
virtual uint8_t getType() const =0
Returns message type (e.g.
HWAddrPtr getMAC(uint32_t hw_addr_src)
Returns MAC address.