From: Tomek Mrugalski Date: Wed, 22 Oct 2014 13:04:32 +0000 (+0200) Subject: [3486] DHCPv6 now processed vendor-class option properly. X-Git-Tag: trac3602_base~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62409cd9531b081943b8f3567f7b0dca36b18802;p=thirdparty%2Fkea.git [3486] DHCPv6 now processed vendor-class option properly. --- diff --git a/ChangeLog b/ChangeLog index 2d4a3e5af8..504829b72b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +8xx. [bug] tomek + DHCPv6 component now processes incoming vendor-class options + properly (packets are classified as VENDOR_CLASS_[content of the + vendor-class option]). + (Trac #3486, git tbd) + 848. [func] fdupont Added truncated HMAC support to TSIG, as per RFC 4635. (Trac #3593, git ae3a9cd1a0d2dc07b7092368149381d69bc2c61a) diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 8af74b42ac..7118c67085 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -2555,8 +2555,7 @@ void Dhcpv6Srv::classifyPacket(const Pkt6Ptr& pkt) { classes << VENDOR_CLASS_PREFIX << DOCSIS3_CLASS_EROUTER; } else { - classes << vclass->getTuple(0).getText(); - + classes << VENDOR_CLASS_PREFIX << vclass->getTuple(0).getText(); } // If there is no class identified, leave. diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index cac225fad5..dd3e94154e 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1849,6 +1850,37 @@ TEST_F(Dhcpv6SrvTest, clientClassify2) { EXPECT_TRUE(srv_.selectSubnet(sol)); } +// Tests whether a packet with custom vendor-class (not erouter or docsis) +// is classified properly. +TEST_F(Dhcpv6SrvTest, clientClassification3) { + NakedDhcpv6Srv srv(0); + + // Let's create a SOLICIT. + Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)); + sol->setRemoteAddr(IOAddress("2001:db8:1::3")); + sol->addOption(generateIA(D6O_IA_NA, 234, 1500, 3000)); + OptionPtr clientid = generateClientId(); + sol->addOption(clientid); + + // Now let's add a vendor-class with id=1234 and content "foo" + OptionVendorClassPtr vendor_class(new OptionVendorClass(Option::V6, 1234)); + OpaqueDataTuple tuple(OpaqueDataTuple::LENGTH_2_BYTES); + tuple = "foo"; + vendor_class->addTuple(tuple); + sol->addOption(vendor_class); + + // Now the server classifies the packet. + srv.classifyPacket(sol); + + // The packet should now belong to VENDOR_CLASS_foo. + EXPECT_TRUE(sol->inClass(srv.VENDOR_CLASS_PREFIX + "foo")); + + // It should not belong to "foo" + EXPECT_FALSE(sol->inClass("foo")); + +} + + // This test checks that the server will handle a Solicit with the Vendor Class // having a length of 4 (enterprise-id only). TEST_F(Dhcpv6SrvTest, cableLabsShortVendorClass) {