BIND 10 trac3177, updated. e43c23bc2d1006c2abb5dd7df7ed575cfce00451 [3177] Changes after review

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 7 10:27:11 UTC 2013


The branch, trac3177 has been updated
       via  e43c23bc2d1006c2abb5dd7df7ed575cfce00451 (commit)
      from  23c944640d1b697af40582f7999b40b05b17a44a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e43c23bc2d1006c2abb5dd7df7ed575cfce00451
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Mon Oct 7 12:26:54 2013 +0200

    [3177] Changes after review
    
     - removed unnecessary filename reference
     - setting Pkt6 fields is now done in a common function
     - methods return shared_ptr instead of raw pointer

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |    6 ++--
 src/bin/dhcp6/tests/dhcp6_test_utils.h    |   14 +++++++--
 src/bin/dhcp6/tests/wireshark.cc          |   46 +++++++++++++----------------
 3 files changed, 34 insertions(+), 32 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 024b589..c4a6ef9 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -2110,7 +2110,7 @@ TEST_F(Dhcpv6SrvTest, portsDirectTraffic) {
     NakedDhcpv6Srv srv(0);
 
     // Let's create a simple SOLICIT
-    Pkt6Ptr sol = Pkt6Ptr(captureSimpleSolicit());
+    Pkt6Ptr sol = captureSimpleSolicit();
 
     // Simulate that we have received that traffic
     srv.fakeReceive(sol);
@@ -2135,7 +2135,7 @@ TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) {
     NakedDhcpv6Srv srv(0);
 
     // Let's create a simple SOLICIT
-    Pkt6Ptr sol = Pkt6Ptr(captureRelayedSolicit());
+    Pkt6Ptr sol = captureRelayedSolicit();
 
     // Simulate that we have received that traffic
     srv.fakeReceive(sol);
@@ -2162,7 +2162,7 @@ TEST_F(Dhcpv6SrvTest, DISABLED_docsisTraffic) {
     NakedDhcpv6Srv srv(0);
 
     // Let's get a traffic capture from DOCSIS3.0 modem
-    Pkt6Ptr sol = Pkt6Ptr(captureDocsisRelayedSolicit());
+    Pkt6Ptr sol = captureDocsisRelayedSolicit();
 
     // Simulate that we have received that traffic
     srv.fakeReceive(sol);
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h
index 6035d26..939ae22 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.h
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h
@@ -396,9 +396,17 @@ public:
     // see wireshark.cc for descriptions
     // The descriptions are too large and too closely related to the
     // code, so it is kept in .cc rather than traditionally in .h
-    Pkt6* captureSimpleSolicit();
-    Pkt6* captureRelayedSolicit();
-    Pkt6* captureDocsisRelayedSolicit();
+    Pkt6Ptr captureSimpleSolicit();
+    Pkt6Ptr captureRelayedSolicit();
+    Pkt6Ptr captureDocsisRelayedSolicit();
+
+
+    /// @brief Auxiliary method that sets Pkt6 fields
+    ///
+    /// Used to reconstruct captured packets. Sets UDP ports, interface names,
+    /// and other fields to some believable values.
+    /// @param pkt packet that will have its fields set
+    void captureSetDefaultFields(const Pkt6Ptr& pkt);
 
     ~Dhcpv6SrvTest() {
         CfgMgr::instance().deleteSubnets6();
diff --git a/src/bin/dhcp6/tests/wireshark.cc b/src/bin/dhcp6/tests/wireshark.cc
index 1daeeac..2f59030 100644
--- a/src/bin/dhcp6/tests/wireshark.cc
+++ b/src/bin/dhcp6/tests/wireshark.cc
@@ -39,9 +39,18 @@ using namespace std;
 namespace isc {
 namespace test {
 
+void Dhcpv6SrvTest::captureSetDefaultFields(const Pkt6Ptr& pkt) {
+    pkt->setRemotePort(546);
+    pkt->setRemoteAddr(IOAddress("fe80::1"));
+    pkt->setLocalPort(0);
+    pkt->setLocalAddr(IOAddress("ff02::1:2"));
+    pkt->setIndex(2);
+    pkt->setIface("eth0");
+}
+
 // This function returns buffer for very simple Solicit
-Pkt6* isc::test::Dhcpv6SrvTest::captureSimpleSolicit() {
-    Pkt6* pkt;
+Pkt6Ptr Dhcpv6SrvTest::captureSimpleSolicit() {
+    Pkt6Ptr pkt;
     uint8_t data[] = {
         1,  // type 1 = SOLICIT
         0xca, 0xfe, 0x01, // trans-id = 0xcafe01
@@ -55,18 +64,13 @@ Pkt6* isc::test::Dhcpv6SrvTest::captureSimpleSolicit() {
         0, 0, 0, 0  // T2 = 0
     };
 
-    pkt = new Pkt6(data, sizeof(data));
-    pkt->setRemotePort(546);
-    pkt->setRemoteAddr(IOAddress("fe80::1"));
-    pkt->setLocalPort(0);
-    pkt->setLocalAddr(IOAddress("ff02::1:2"));
-    pkt->setIndex(2);
-    pkt->setIface("eth0");
+    pkt.reset(new Pkt6(data, sizeof(data)));
+    captureSetDefaultFields(pkt);
 
     return (pkt);
 }
 
-Pkt6* isc::test::Dhcpv6SrvTest::captureRelayedSolicit() {
+Pkt6Ptr Dhcpv6SrvTest::captureRelayedSolicit() {
 
     // This is a very simple relayed SOLICIT message:
     // RELAY-FORW
@@ -89,19 +93,14 @@ Pkt6* isc::test::Dhcpv6SrvTest::captureRelayedSolicit() {
     // to be OptionBuffer format)
     isc::util::encode::decodeHex(hex_string, bin);
 
-    Pkt6* pkt = new Pkt6(&bin[0], bin.size());
-    pkt->setRemotePort(547);
-    pkt->setRemoteAddr(IOAddress("fe80::1234"));
-    pkt->setLocalPort(547);
-    pkt->setLocalAddr(IOAddress("ff05::1:3"));
-    pkt->setIndex(2);
-    pkt->setIface("eth0");
+    Pkt6Ptr pkt(new Pkt6(&bin[0], bin.size()));
+    captureSetDefaultFields(pkt);
+
     return (pkt);
 }
 
 /// returns a buffer with relayed SOLICIT (from DOCSIS3.0 cable modem)
-/// see dhcp6_relay_forw-virginmedia.pcap
-Pkt6* isc::test::Dhcpv6SrvTest::captureDocsisRelayedSolicit() {
+Pkt6Ptr isc::test::Dhcpv6SrvTest::captureDocsisRelayedSolicit() {
 
     // This is an actual DOCSIS packet
     // RELAY-FORW (12) 
@@ -156,13 +155,8 @@ Pkt6* isc::test::Dhcpv6SrvTest::captureDocsisRelayedSolicit() {
     // to be OptionBuffer format)
     isc::util::encode::decodeHex(hex_string, bin);
 
-    Pkt6* pkt = new Pkt6(&bin[0], bin.size());
-    pkt->setRemotePort(547);
-    pkt->setRemoteAddr(IOAddress("fe80::1234"));
-    pkt->setLocalPort(547);
-    pkt->setLocalAddr(IOAddress("ff05::1:3"));
-    pkt->setIndex(2);
-    pkt->setIface("eth0");
+    Pkt6Ptr pkt(new Pkt6(&bin[0], bin.size()));
+    captureSetDefaultFields(pkt);
     return (pkt);
 }
 



More information about the bind10-changes mailing list