17 #include <boost/date_time/posix_time/posix_time.hpp>
18 #include <boost/shared_ptr.hpp>
30 constexpr
unsigned int UNSET_IFINDEX = std::numeric_limits<unsigned int>::max();
45 template<
typename PktType>
62 pkt1->setCopyRetrievedOptions(
true);
65 pkt2->setCopyRetrievedOptions(
true);
74 pkts_.first->setCopyRetrievedOptions(
false);
77 pkts_.second->setCopyRetrievedOptions(
false);
84 std::pair<PktTypePtr, PktTypePtr> pkts_;
113 uint16_t remote_port);
128 Pkt(
const uint8_t* buf, uint32_t
len,
131 uint16_t remote_port);
295 bool required =
false);
608 const std::vector<uint8_t>& hw_addr);
853 virtual void setHWAddrMember(
const uint8_t htype,
const uint8_t hlen,
854 const std::vector<uint8_t>& hw_addr,
859 typedef boost::shared_ptr<isc::dhcp::Pkt>
PktPtr;
883 options_ = opt->getMutableOptions();
892 option_->getMutableOptions() = options_;
917 template<
typename PktType>
933 pkt_.options_ = options_;
Defines elements for storing the names of client classes.
A generic exception that is thrown when a function is not implemented.
The IOAddress class represents an IP addresses (version agnostic)
Container for storing client class names.
Base class for classes representing DHCP messages.
bool delOption(uint16_t type)
Attempts to delete first suboption of requested type.
virtual HWAddrPtr getMACFromDocsisModem()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the modem itself.
virtual uint8_t getType() const =0
Returns message type (e.g.
isc::dhcp::OptionCollection getOptions(const uint16_t type)
Returns all instances of specified type.
isc::asiolink::IOAddress remote_addr_
Remote IP address.
virtual HWAddrPtr getMACFromDocsisCMTS()=0
Attempts to extract MAC/Hardware address from DOCSIS options inserted by the CMTS (the relay agent)
virtual void setType(uint8_t type)=0
Sets message type (e.g.
ClientClasses required_classes_
Classes which are required to be evaluated.
const SubClassRelationContainer & getSubClassesRelations() const
Returns the class set including template classes associated with subclasses.
bool isCopyRetrievedOptions() const
Returns whether the copying of retrieved options is enabled.
uint16_t local_port_
local TDP or UDP port
int getIndex() const
Returns interface index.
const ClientClasses & getClasses(bool required=false) const
Returns the class set.
void resetIndex()
Resets interface index to negative value.
uint32_t transid_
Transaction-id (32 bits for v4, 24 bits for v6)
void repack()
Copies content of input buffer to output buffer.
isc::asiolink::IOAddress local_addr_
Local IP (v4 or v6) address.
virtual void pack()=0
Prepares on-wire format of DHCP (either v4 or v6) packet.
const isc::asiolink::IOAddress & getLocalAddr() const
Returns local IP address.
const boost::posix_time::ptime & getTimestamp() const
Returns packet timestamp.
virtual HWAddrPtr getMACFromRemoteIdRelayOption()=0
Attempts to obtain MAC address from remote-id relay option.
virtual void unpack()=0
Parses on-wire form of DHCP (either v4 or v6) packet.
OptionBuffer data_
Unparsed data (in received packets).
HWAddrPtr getRemoteHWAddr() const
Returns the remote HW address obtained from raw sockets.
virtual HWAddrPtr getMACFromSrcLinkLocalAddr()=0
Attempts to obtain MAC address from source link-local IPv6 address.
ClientClasses classes_
Classes this packet belongs to.
virtual size_t len()=0
Returns packet size in binary format.
void setIface(const std::string &iface)
Sets interface name.
virtual const char * getName() const =0
Returns name of the DHCP message.
bool indexSet() const
Checks if interface index has been set.
uint16_t getLocalPort() const
Returns local UDP (and soon TCP) port.
void setLocalPort(uint16_t local)
Sets local UDP (and soon TCP) port.
uint16_t remote_port_
remote TCP or UDP port
void setIndex(const unsigned int ifindex)
Sets interface index.
uint32_t getTransid() const
Returns value of transaction-id field.
isc::dhcp::OptionCollection options_
Collection of options present in this message.
isc::util::OutputBuffer buffer_out_
Output buffer (used during message transmission)
std::string getIface() const
Returns interface name.
virtual HWAddrPtr getMACFromDUID()=0
Attempts to obtain MAC address from DUID-LL or DUID-LLT.
virtual void setCopyRetrievedOptions(const bool copy)
Controls whether the option retrieved by the Pkt::getOption should be copied before being returned.
SubClassRelationContainer subclasses_
SubClasses this packet belongs to.
OptionCollection getNonCopiedOptions(const uint16_t opt_type) const
Returns all option instances of specified type without copying.
void setTimestamp(boost::posix_time::ptime ×tamp)
Set packet timestamp.
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.
uint16_t getRemotePort() const
Returns remote port.
OptionPtr getOption(const uint16_t type)
Returns the first option of specified type.
void setRemoteHWAddr(const HWAddrPtr &hw_addr)
Sets remote hardware address.
void addSubClass(const isc::dhcp::ClientClass &class_def, const isc::dhcp::ClientClass &subclass)
Adds a specified subclass to the packet.
bool inClass(const isc::dhcp::ClientClass &client_class)
Checks whether a client belongs to a given class.
virtual HWAddrPtr getMACFromIPv6RelayOpt()=0
Attempts to obtain MAC address from relay option client-linklayer-addr.
unsigned int ifindex_
Interface index.
boost::posix_time::ptime timestamp_
packet timestamp
void setTransid(uint32_t transid)
Sets transaction-id value.
HWAddrPtr getMAC(uint32_t hw_addr_src)
Returns MAC address.
virtual std::string toText() const =0
Returns text representation of the packet.
void updateTimestamp()
Update packet timestamp.
isc::util::OutputBuffer & getBuffer()
Returns reference to output buffer.
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.
void addClass(const isc::dhcp::ClientClass &client_class, bool required=false)
Adds a specified class to the packet.
OptionPtr getNonCopiedOption(const uint16_t type) const
Returns the first option of specified type without copying.
void setRemoteAddr(const isc::asiolink::IOAddress &remote)
Sets remote IP address.
const isc::asiolink::IOAddress & getRemoteAddr() const
Returns remote IP address.
HWAddrPtr getMACFromIPv6(const isc::asiolink::IOAddress &addr)
Attempts to convert IPv6 address into MAC.
void setLocalAddr(const isc::asiolink::IOAddress &local)
Sets local IP address.
void setRemotePort(uint16_t remote)
Sets remote UDP (and soon TCP) port.
virtual std::string getLabel() const
Returns text representation primary packet identifiers.
virtual void addOption(const OptionPtr &opt)
Adds an option to this packet.
virtual ~Pkt()
Virtual destructor.
RAII object enabling copying options retrieved from the packet.
ScopedEnableOptionsCopy(const PktTypePtr &pkt1, const PktTypePtr &pkt2=PktTypePtr())
Constructor.
boost::shared_ptr< PktType > PktTypePtr
Pointer to an encapsulated packet.
~ScopedEnableOptionsCopy()
Destructor.
RAII object enabling duplication of the stored options and restoring the original options on destruct...
~ScopedPktOptionsCopy()
Destructor.
ScopedPktOptionsCopy(PktType &pkt)
Constructor.
RAII object enabling duplication of the stored options and restoring the original options on destruct...
ScopedSubOptionsCopy(const OptionPtr &opt)
Constructor.
~ScopedSubOptionsCopy()
Destructor.
Base class for classes which need to be associated with a CalloutHandle object.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
std::string ClientClass
Defines a single class name.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
boost::multi_index_container< SubClassRelation, boost::multi_index::indexed_by< boost::multi_index::sequenced< boost::multi_index::tag< TemplateClassSequenceTag > >, boost::multi_index::hashed_unique< boost::multi_index::tag< TemplateClassNameTag >, boost::multi_index::member< SubClassRelation, ClientClass, &SubClassRelation::class_def_ > > > > SubClassRelationContainer
the subclass multi-index.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
constexpr unsigned int UNSET_IFINDEX
A value used to signal that the interface index was not set.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-lfc.