|
@@ -406,7 +406,7 @@ TEST_F(Pkt6Test, unpackVendorMalformed) {
|
|
orig.push_back(3);
|
|
orig.push_back(3);
|
|
orig.push_back(4);
|
|
orig.push_back(4);
|
|
orig.push_back(1); // suboption type=0x101
|
|
orig.push_back(1); // suboption type=0x101
|
|
- orig.push_back(1);
|
|
|
|
|
|
+ orig.push_back(1);
|
|
orig.push_back(0); // suboption length=3
|
|
orig.push_back(0); // suboption length=3
|
|
orig.push_back(3);
|
|
orig.push_back(3);
|
|
orig.push_back(102); // data="foo"
|
|
orig.push_back(102); // data="foo"
|
|
@@ -428,7 +428,7 @@ TEST_F(Pkt6Test, unpackVendorMalformed) {
|
|
shortv[len_index] = 20;
|
|
shortv[len_index] = 20;
|
|
Pkt6Ptr too_short_vendor_pkt(new Pkt6(&shortv[0], shortv.size()));
|
|
Pkt6Ptr too_short_vendor_pkt(new Pkt6(&shortv[0], shortv.size()));
|
|
EXPECT_NO_THROW(too_short_vendor_pkt->unpack());
|
|
EXPECT_NO_THROW(too_short_vendor_pkt->unpack());
|
|
-
|
|
|
|
|
|
+
|
|
// Truncated option header is not accepted
|
|
// Truncated option header is not accepted
|
|
vector<uint8_t> shorth = orig;
|
|
vector<uint8_t> shorth = orig;
|
|
shorth.resize(orig.size() - 4);
|
|
shorth.resize(orig.size() - 4);
|
|
@@ -996,10 +996,17 @@ TEST_F(Pkt6Test, getMAC) {
|
|
// Let's check if setting IPv6 address improves the situation.
|
|
// Let's check if setting IPv6 address improves the situation.
|
|
IOAddress linklocal_eui64("fe80::204:06ff:fe08:0a0c");
|
|
IOAddress linklocal_eui64("fe80::204:06ff:fe08:0a0c");
|
|
pkt.setRemoteAddr(linklocal_eui64);
|
|
pkt.setRemoteAddr(linklocal_eui64);
|
|
- EXPECT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
|
|
- EXPECT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL));
|
|
|
|
- EXPECT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL |
|
|
|
|
- HWAddr::HWADDR_SOURCE_RAW));
|
|
|
|
|
|
+ HWAddrPtr mac;
|
|
|
|
+ ASSERT_TRUE(mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, mac->source_);
|
|
|
|
+
|
|
|
|
+ ASSERT_TRUE(mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, mac->source_);
|
|
|
|
+
|
|
|
|
+ ASSERT_TRUE(mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL |
|
|
|
|
+ HWAddr::HWADDR_SOURCE_RAW));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, mac->source_);
|
|
|
|
+
|
|
pkt.setRemoteAddr(IOAddress("::"));
|
|
pkt.setRemoteAddr(IOAddress("::"));
|
|
|
|
|
|
// Let's invent a MAC
|
|
// Let's invent a MAC
|
|
@@ -1011,10 +1018,15 @@ TEST_F(Pkt6Test, getMAC) {
|
|
pkt.setRemoteHWAddr(dummy_hwaddr);
|
|
pkt.setRemoteHWAddr(dummy_hwaddr);
|
|
|
|
|
|
// Now we should be able to get something
|
|
// Now we should be able to get something
|
|
- ASSERT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
|
|
|
|
+ ASSERT_TRUE(mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_RAW, mac->source_);
|
|
|
|
+
|
|
ASSERT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_RAW));
|
|
ASSERT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_RAW));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_RAW, mac->source_);
|
|
|
|
+
|
|
EXPECT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL |
|
|
EXPECT_TRUE(pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL |
|
|
HWAddr::HWADDR_SOURCE_RAW));
|
|
HWAddr::HWADDR_SOURCE_RAW));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_RAW, mac->source_);
|
|
|
|
|
|
// Check that the returned MAC is indeed the expected one
|
|
// Check that the returned MAC is indeed the expected one
|
|
ASSERT_TRUE(*dummy_hwaddr == *pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
ASSERT_TRUE(*dummy_hwaddr == *pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
|
|
@@ -1050,6 +1062,7 @@ TEST_F(Pkt6Test, getMACFromIPv6LinkLocal_direct) {
|
|
pkt.setRemoteAddr(linklocal_eui64);
|
|
pkt.setRemoteAddr(linklocal_eui64);
|
|
HWAddrPtr found = pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL);
|
|
HWAddrPtr found = pkt.getMAC(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL);
|
|
ASSERT_TRUE(found);
|
|
ASSERT_TRUE(found);
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, found->source_);
|
|
|
|
|
|
stringstream tmp;
|
|
stringstream tmp;
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " f0:04:06:08:0a:0c";
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " f0:04:06:08:0a:0c";
|
|
@@ -1097,6 +1110,7 @@ TEST_F(Pkt6Test, getMACFromIPv6LinkLocal_singleRelay) {
|
|
stringstream tmp;
|
|
stringstream tmp;
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " f0:04:06:08:0a:0c";
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " f0:04:06:08:0a:0c";
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, found->source_);
|
|
}
|
|
}
|
|
|
|
|
|
// Test checks whether getMACFromIPv6LinkLocal() returns the hardware (MAC)
|
|
// Test checks whether getMACFromIPv6LinkLocal() returns the hardware (MAC)
|
|
@@ -1151,6 +1165,7 @@ TEST_F(Pkt6Test, getMACFromIPv6LinkLocal_multiRelay) {
|
|
stringstream tmp;
|
|
stringstream tmp;
|
|
tmp << "hwtype=" << iface->getHWType() << " 00:00:00:00:00:01";
|
|
tmp << "hwtype=" << iface->getHWType() << " 00:00:00:00:00:01";
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, found->source_);
|
|
}
|
|
}
|
|
|
|
|
|
// Test checks whether getMACFromIPv6RelayOpt() returns the hardware (MAC)
|
|
// Test checks whether getMACFromIPv6RelayOpt() returns the hardware (MAC)
|
|
@@ -1184,6 +1199,7 @@ TEST_F(Pkt6Test, getMACFromIPv6RelayOpt_singleRelay) {
|
|
stringstream tmp;
|
|
stringstream tmp;
|
|
tmp << "hwtype=1 0a:1b:0b:01:ca:fe";
|
|
tmp << "hwtype=1 0a:1b:0b:01:ca:fe";
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION, found->source_);
|
|
}
|
|
}
|
|
|
|
|
|
// Test checks whether getMACFromIPv6RelayOpt() returns the hardware (MAC)
|
|
// Test checks whether getMACFromIPv6RelayOpt() returns the hardware (MAC)
|
|
@@ -1232,6 +1248,7 @@ TEST_F(Pkt6Test, getMACFromIPv6RelayOpt_multipleRelay) {
|
|
stringstream tmp;
|
|
stringstream tmp;
|
|
tmp << "hwtype=1 fa:30:0b:fa:c0:fe";
|
|
tmp << "hwtype=1 fa:30:0b:fa:c0:fe";
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
EXPECT_EQ(tmp.str(), found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION,found->source_);
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(Pkt6Test, getMACFromDUID) {
|
|
TEST_F(Pkt6Test, getMACFromDUID) {
|
|
@@ -1271,6 +1288,7 @@ TEST_F(Pkt6Test, getMACFromDUID) {
|
|
HWAddrPtr mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_DUID);
|
|
HWAddrPtr mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_DUID);
|
|
ASSERT_TRUE(mac);
|
|
ASSERT_TRUE(mac);
|
|
EXPECT_EQ("hwtype=7 0a:0b:0c:0d:0e:0f:10", mac->toText(true));
|
|
EXPECT_EQ("hwtype=7 0a:0b:0c:0d:0e:0f:10", mac->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_DUID, mac->source_);
|
|
|
|
|
|
// Let's test DUID-LL. This should work.
|
|
// Let's test DUID-LL. This should work.
|
|
ASSERT_TRUE(pkt.delOption(D6O_CLIENTID));
|
|
ASSERT_TRUE(pkt.delOption(D6O_CLIENTID));
|
|
@@ -1278,6 +1296,7 @@ TEST_F(Pkt6Test, getMACFromDUID) {
|
|
mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_DUID);
|
|
mac = pkt.getMAC(HWAddr::HWADDR_SOURCE_DUID);
|
|
ASSERT_TRUE(mac);
|
|
ASSERT_TRUE(mac);
|
|
EXPECT_EQ("hwtype=11 0a:0b:0c:0d:0e", mac->toText(true));
|
|
EXPECT_EQ("hwtype=11 0a:0b:0c:0d:0e", mac->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_DUID, mac->source_);
|
|
|
|
|
|
// Finally, let's try DUID-EN. This should fail, as EN type does not
|
|
// Finally, let's try DUID-EN. This should fail, as EN type does not
|
|
// contain any MAC address information.
|
|
// contain any MAC address information.
|
|
@@ -1303,6 +1322,7 @@ TEST_F(Pkt6Test, getMAC_DOCSIS_Modem) {
|
|
|
|
|
|
// Let's check the info.
|
|
// Let's check the info.
|
|
EXPECT_EQ("hwtype=1 10:0d:7f:00:07:88", found->toText(true));
|
|
EXPECT_EQ("hwtype=1 10:0d:7f:00:07:88", found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_DOCSIS_MODEM, found->source_);
|
|
|
|
|
|
// Now let's remove the option
|
|
// Now let's remove the option
|
|
OptionVendorPtr vendor = boost::dynamic_pointer_cast<
|
|
OptionVendorPtr vendor = boost::dynamic_pointer_cast<
|
|
@@ -1331,6 +1351,7 @@ TEST_F(Pkt6Test, getMAC_DOCSIS_CMTS) {
|
|
|
|
|
|
// Let's check the info.
|
|
// Let's check the info.
|
|
EXPECT_EQ("hwtype=1 20:e5:2a:b8:15:14", found->toText(true));
|
|
EXPECT_EQ("hwtype=1 20:e5:2a:b8:15:14", found->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_DOCSIS_CMTS, found->source_);
|
|
|
|
|
|
// Now let's remove the suboption 1026 that is inserted by the
|
|
// Now let's remove the suboption 1026 that is inserted by the
|
|
// relay.
|
|
// relay.
|
|
@@ -1393,6 +1414,7 @@ TEST_F(Pkt6Test, getMACFromRemoteIdRelayOption) {
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " 0a:0b:0c:0d:0e:0f";
|
|
tmp << "hwtype=" << (int)iface->getHWType() << " 0a:0b:0c:0d:0e:0f";
|
|
|
|
|
|
EXPECT_EQ(tmp.str(), mac->toText(true));
|
|
EXPECT_EQ(tmp.str(), mac->toText(true));
|
|
|
|
+ EXPECT_EQ(HWAddr::HWADDR_SOURCE_REMOTE_ID, mac->source_);
|
|
}
|
|
}
|
|
|
|
|
|
// This test verifies that a solicit that passed through two relays is parsed
|
|
// This test verifies that a solicit that passed through two relays is parsed
|