From: Francis Dupont Date: Fri, 20 Nov 2015 22:18:21 +0000 (+0100) Subject: [4097a] Split classifyPacket into 2 parts as proposed X-Git-Tag: trac4204fd_base~2^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01dd8b4fa3a036e94c418f72aca415ae1e294c87;p=thirdparty%2Fkea.git [4097a] Split classifyPacket into 2 parts as proposed --- diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 6ae81ff634..322ad01e29 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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 vendor_class = boost::dynamic_pointer_cast(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 diff --git a/src/bin/dhcp4/dhcp4_srv.h b/src/bin/dhcp4/dhcp4_srv.h index e86fde12aa..d5f5c39fc3 100644 --- a/src/bin/dhcp4/dhcp4_srv.h +++ b/src/bin/dhcp4/dhcp4_srv.h @@ -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 ///