summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/tests/pkt6_unittest.cc
diff options
context:
space:
mode:
authorAndrei Pavel <andrei.pavel@qualitance.com>2017-08-17 19:54:15 +0200
committerAndrei Pavel <andrei.pavel@qualitance.com>2017-08-17 19:54:15 +0200
commita8f6403d1b44f62ebb3dd3085e401b46767003a0 (patch)
tree00df52bd413b27ed04097164021251f8e8ec6c80 /src/lib/dhcp/tests/pkt6_unittest.cc
parentRemoved duplicate include (diff)
parent[master] Added ChangeLog 1288 for trac 5315. (diff)
downloadkea-a8f6403d1b44f62ebb3dd3085e401b46767003a0.tar.xz
kea-a8f6403d1b44f62ebb3dd3085e401b46767003a0.zip
Merge branch 'isc-master' into config-h
Diffstat (limited to 'src/lib/dhcp/tests/pkt6_unittest.cc')
-rw-r--r--src/lib/dhcp/tests/pkt6_unittest.cc42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/lib/dhcp/tests/pkt6_unittest.cc b/src/lib/dhcp/tests/pkt6_unittest.cc
index 2ee4a2b034..f45b937c81 100644
--- a/src/lib/dhcp/tests/pkt6_unittest.cc
+++ b/src/lib/dhcp/tests/pkt6_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -986,7 +986,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) {
EXPECT_TRUE(opt->equals(relay3_opt1));
EXPECT_FALSE(opt == relay3_opt1);
// Test that option copy has replaced the original option within the
- // packet. We achive that by calling a variant of the method which
+ // packet. We achieve that by calling a variant of the method which
// retrieved non-copied option.
relay3_opt1 = msg->getNonCopiedAnyRelayOption(200, Pkt6::RELAY_SEARCH_FROM_CLIENT);
ASSERT_TRUE(relay3_opt1);
@@ -1049,6 +1049,38 @@ TEST_F(Pkt6Test, getAnyRelayOption) {
EXPECT_FALSE(opt);
}
+// Tests whether Pkt6::toText() properly prints out all parameters, including
+// relay options: remote-id, interface-id.
+TEST_F(Pkt6Test, toText) {
+
+ // This packet contains doubly relayed solicit. The inner-most
+ // relay-forward contains interface-id and remote-id. We will
+ // check that these are printed correctly.
+ Pkt6Ptr msg(capture2());
+ EXPECT_NO_THROW(msg->unpack());
+
+ ASSERT_EQ(2, msg->relay_info_.size());
+
+ string expected =
+ "localAddr=[ff05::1:3]:547 remoteAddr=[fe80::1234]:547\n"
+ "msgtype=1(SOLICIT), transid=0x6b4fe2\n"
+ "type=00001, len=00014: 00:01:00:01:18:b0:33:41:00:00:21:5c:18:a9\n"
+ "type=00003(IA_NA), len=00012: iaid=1, t1=4294967295, t2=4294967295\n"
+ "type=00006, len=00006: 23(uint16) 242(uint16) 243(uint16)\n"
+ "type=00008, len=00002: 0 (uint16)\n"
+ "2 relay(s):\n"
+ "relay[0]: msg-type=12(RELAY_FORWARD), hop-count=1,\n"
+ "link-address=2001:888:db8:1::, peer-address=fe80::200:21ff:fe5c:18a9, 2 option(s)\n"
+ "type=00018, len=00028: 49:53:41:4d:31:34:34:7c:32:39:39:7c:69:70:76:36:7c:6e:74:3a:76:70:3a:31:3a:31:31:30\n"
+ "type=00037, len=00018: 6527 (uint32) 0001000118B033410000215C18A9 (binary)\n"
+ "relay[1]: msg-type=12(RELAY_FORWARD), hop-count=0,\n"
+ "link-address=::, peer-address=fe80::200:21ff:fe5c:18a9, 2 option(s)\n"
+ "type=00018, len=00021: 49:53:41:4d:31:34:34:20:65:74:68:20:31:2f:31:2f:30:35:2f:30:31\n"
+ "type=00037, len=00004: 3561 (uint32) (binary)\n";
+
+ EXPECT_EQ(expected, msg->toText());
+}
+
// Tests whether a packet can be assigned to a class and later
// checked if it belongs to a given class
TEST_F(Pkt6Test, clientClasses) {
@@ -1084,7 +1116,7 @@ TEST_F(Pkt6Test, clientClasses) {
TEST_F(Pkt6Test, getMAC) {
Pkt6 pkt(DHCPV6_ADVERTISE, 1234);
- // DHCPv6 packet by default doens't have MAC address specified.
+ // DHCPv6 packet by default doesn't have MAC address specified.
EXPECT_FALSE(pkt.getMAC(HWAddr::HWADDR_SOURCE_ANY));
EXPECT_FALSE(pkt.getMAC(HWAddr::HWADDR_SOURCE_RAW));
@@ -1578,7 +1610,7 @@ TEST_F(Pkt6Test, getClientId) {
EXPECT_TRUE(duid->getDuid() == duid_vec);
}
-// This test verfies that it is possible to obtain the packet
+// This test verifies that it is possible to obtain the packet
// identifiers (DUID, HW Address, transaction id) in the textual
// format.
TEST_F(Pkt6Test, makeLabel) {
@@ -1657,7 +1689,7 @@ TEST_F(Pkt6Test, getLabelEmptyClientId) {
// Create a packet.
Pkt6 pkt(DHCPV6_SOLICIT, 0x2312);
- // Add empty client idenitifier option.
+ // Add empty client identifier option.
pkt.addOption(OptionPtr(new Option(Option::V6, D6O_CLIENTID)));
EXPECT_EQ("duid=[no info], tid=0x2312", pkt.getLabel());
}