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;
175 return (buffer_out_);
185 virtual void addOption(
const OptionPtr& opt);
195 bool delOption(uint16_t type);
217 virtual std::string toText()
const = 0;
229 virtual size_t len() = 0;
238 virtual uint8_t getType()
const = 0;
247 virtual void setType(uint8_t type) = 0;
258 virtual const char* getName()
const = 0;
289 bool required =
false);
310 return (!required ? classes_ : required_classes_);
323 return (subclasses_);
349 OptionPtr getNonCopiedOption(
const uint16_t type)
const;
377 OptionPtr getOption(
const uint16_t type);
413 copy_retrieved_options_ =
copy;
422 return (copy_retrieved_options_);
431 void updateTimestamp();
448 timestamp_ = timestamp;
463 remote_addr_ = remote;
470 return (remote_addr_);
484 return (local_addr_);
504 return (local_port_);
514 remote_port_ = remote;
521 return (remote_port_);
547 return (ifindex_ >= 0);
581 void setRemoteHWAddr(
const HWAddrPtr& hw_addr);
601 void setRemoteHWAddr(
const uint8_t htype,
const uint8_t hlen,
602 const std::vector<uint8_t>& hw_addr);
608 return (remote_hwaddr_);
693 virtual HWAddrPtr getMACFromSrcLinkLocalAddr() = 0;
709 virtual HWAddrPtr getMACFromIPv6RelayOpt() = 0;
737 virtual HWAddrPtr getMACFromRemoteIdRelayOption() = 0;
766 virtual HWAddrPtr getMACFromDocsisModem() = 0;
779 virtual HWAddrPtr getMACFromDocsisCMTS() = 0;
847 virtual void setHWAddrMember(
const uint8_t htype,
const uint8_t hlen,
848 const std::vector<uint8_t>& hw_addr,
853 typedef boost::shared_ptr<isc::dhcp::Pkt>
PktPtr;
877 options_ = opt->getMutableOptions();
886 option_->getMutableOptions() = options_;
911 template<
typename PktType>
927 pkt_.options_ = options_;
isc::asiolink::IOAddress local_addr_
Local IP (v4 or v6) address.
int64_t ifindex_
Interface index.
virtual ~Pkt()
Virtual destructor.
OptionBuffer data_
Unparsed data (in received packets).
A generic exception that is thrown when a function is not implemented.
const ClientClasses & getClasses(bool required=false) const
Returns the class set.
std::string iface_
Name of the network interface the packet was received/to be sent over.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
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.
virtual std::string getLabel() const
Returns text representation primary packet identifiers.
boost::shared_ptr< Option > OptionPtr
void setTransid(uint32_t transid)
Sets transaction-id value.
uint16_t getRemotePort() const
Returns remote port.
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.
RAII object enabling copying options retrieved from the packet.
std::string getIface() const
Returns interface name.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
~ScopedPktOptionsCopy()
Destructor.
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.
const boost::posix_time::ptime & getTimestamp() const
Returns packet timestamp.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Base class for classes which need to be associated with a CalloutHandle object.
const SubClassRelationContainer & getSubClassesRelations() const
Returns the class set including template classes associated with subclasses.
ScopedSubOptionsCopy(const OptionPtr &opt)
Constructor.
void setLocalAddr(const isc::asiolink::IOAddress &local)
Sets local IP address.
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 setIndex(int ifindex)
Sets interface index.
SubClassRelationContainer subclasses_
SubClasses this packet belongs to.
void resetIndex()
Resets interface index to negative value.
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.
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.
RAII object enabling duplication of the stored options and restoring the original options on destruct...
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
~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 isc::asiolink::IOAddress & getRemoteAddr() const
Returns remote IP address.
ScopedEnableOptionsCopy(const PktTypePtr &pkt1, const PktTypePtr &pkt2=PktTypePtr())
Constructor.
Defines the logger used by the top-level component of kea-lfc.
~ScopedSubOptionsCopy()
Destructor.
uint16_t local_port_
local TDP or UDP port
uint16_t getLocalPort() const
Returns local UDP (and soon TCP) port.
bool isCopyRetrievedOptions() const
Returns whether the copying of retrieved options is enabled.
isc::asiolink::IOAddress remote_addr_
Remote IP address.
int getIndex() const
Returns interface index.
ScopedPktOptionsCopy(PktType &pkt)
Constructor.
std::string ClientClass
Defines a single class name.
isc::util::OutputBuffer buffer_out_
Output buffer (used during message transmission)
boost::shared_ptr< PktType > PktTypePtr
Pointer to an encapsulated packet.
The IOAddress class represents an IP addresses (version agnostic)
const isc::asiolink::IOAddress & getLocalAddr() const
Returns local IP address.
HWAddrPtr getRemoteHWAddr() const
Returns the remote HW address obtained from raw sockets.
RAII object enabling duplication of the stored options and restoring the original options on destruct...
ClientClasses required_classes_
Classes which are required to be evaluated.
uint32_t getTransid() const
Returns value of transaction-id field.
isc::dhcp::OptionCollection options_
Collection of options present in this message.
Container for storing client class names.
boost::posix_time::ptime timestamp_
packet timestamp
bool indexSet() const
Checks if interface index has been set.