Commit 01dd8b4f authored by Francis Dupont's avatar Francis Dupont
Browse files

[4097a] Split classifyPacket into 2 parts as proposed

parent b66c0b8c
......@@ -2243,15 +2243,13 @@ Dhcpv4Srv::unpackOptions(const OptionBuffer& buf,
return (offset);
}
void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
string classes = "";
void Dhcpv4Srv::classifyByVendor(const Pkt4Ptr& pkt, std::string& classes) {
// Built-in vendor class processing
boost::shared_ptr<OptionString> vendor_class =
boost::dynamic_pointer_cast<OptionString>(pkt->getOption(DHO_VENDOR_CLASS_IDENTIFIER));
if (!vendor_class) {
goto vendor_class_done;
return;
}
// DOCSIS specific section
......@@ -2281,8 +2279,13 @@ void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
pkt->addClass(VENDOR_CLASS_PREFIX + vendor_class->getValue());
classes += VENDOR_CLASS_PREFIX + vendor_class->getValue();
}
}
void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
string classes = "";
vendor_class_done:
// First phase: built-in vendor class processing
classifyByVendor(pkt, classes);
// Run match expressions
// Note getClientClassDictionary() cannot be null
......
......@@ -707,10 +707,11 @@ protected:
/// @brief Assigns incoming packet to zero or more classes.
///
/// @note It is done in two phases: first the content of the
/// vendor-class-identifier option is used as a class. Second
/// classification match expressions are evaluated. The resulting
/// class will be stored in packet (see @ref isc::dhcp::Pkt4::classes_
/// and @ref isc::dhcp::Pkt4::inClass).
/// vendor-class-identifier option is used as a class, by
/// calling @ref classifyByVendor(). Second classification match
/// expressions are evaluated. The resulting class will be stored
/// in packet (see @ref isc::dhcp::Pkt4::classes_ and
/// @ref isc::dhcp::Pkt4::inClass).
///
/// @param pkt packet to be classified
void classifyPacket(const Pkt4Ptr& pkt);
......@@ -735,6 +736,14 @@ protected:
private:
/// @brief Assign class using vendor-class-identifier option
///
/// @note This is the first part of @ref classifyPacket
///
/// @param pkt packet to be classified
/// @param classes a reference to added class names for logging
void classifyByVendor(const Pkt4Ptr& pkt, std::string& classes);
/// @brief Constructs netmask option based on subnet4
/// @param subnet subnet for which the netmask will be calculated
///
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment