BIND 10 trac2902, updated. 454afa9877926214539d135f239035706bbec035 [2902] Defined constant replacing ETHERTYPE_IP.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 22 18:07:48 UTC 2013


The branch, trac2902 has been updated
       via  454afa9877926214539d135f239035706bbec035 (commit)
      from  32931752aee5c1c61bf6758a3ad34a77eec04064 (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 454afa9877926214539d135f239035706bbec035
Author: Marcin Siodelski <marcin at isc.org>
Date:   Wed May 22 20:07:12 2013 +0200

    [2902] Defined constant replacing ETHERTYPE_IP.
    
    The ETHERTYPE_IP is defined in different header files on different OSes.
    Since it is just a single constant that is needed, it is not practical
    to locate the proper header file in configure.ac to pull single constant.

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

Summary of changes:
 src/lib/dhcp/protocol_util.cc                |    3 +--
 src/lib/dhcp/protocol_util.h                 |    8 ++++++++
 src/lib/dhcp/tests/protocol_util_unittest.cc |    2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/protocol_util.cc b/src/lib/dhcp/protocol_util.cc
index a57311d..d93f8c4 100644
--- a/src/lib/dhcp/protocol_util.cc
+++ b/src/lib/dhcp/protocol_util.cc
@@ -16,7 +16,6 @@
 #include <dhcp/dhcp6.h>
 #include <dhcp/protocol_util.h>
 #include <boost/static_assert.hpp>
-#include <net/ethernet.h>
 // in_systm.h is required on some some BSD systems
 // complaining that n_time is undefined but used
 // in ip.h.
@@ -162,7 +161,7 @@ writeEthernetHeader(const Pkt4Ptr& pkt, OutputBuffer& out_buf) {
     }
 
     // Type IP.
-    out_buf.writeUint16(ETHERTYPE_IP);
+    out_buf.writeUint16(ETHERNET_TYPE_IP);
 }
 
 void
diff --git a/src/lib/dhcp/protocol_util.h b/src/lib/dhcp/protocol_util.h
index 582938e..b3f8085 100644
--- a/src/lib/dhcp/protocol_util.h
+++ b/src/lib/dhcp/protocol_util.h
@@ -38,6 +38,14 @@ static const size_t ETHERNET_HEADER_LEN = 14;
 /// Offset of the 2-byte word in the Ethernet packet which
 /// holds the type of the protocol it encapsulates.
 static const size_t ETHERNET_PACKET_TYPE_OFFSET = 12;
+/// This value is held in the Ethertype field of Ethernet frame
+/// and indicates that an IP packet is encapsulated with this
+/// frame. In the standard headers, there is an ETHERTYPE_IP,
+/// constant which serves the same purpose. However, it is more
+/// convenient to have our constant because we avoid
+/// inclusion of additional headers, which have different names
+/// and locations on different OSes.
+static const uint16_t ETHERNET_TYPE_IP = 0x0800;
 
 /// Minimal IPv4 header length.
 static const size_t MIN_IP_HEADER_LEN = 20;
diff --git a/src/lib/dhcp/tests/protocol_util_unittest.cc b/src/lib/dhcp/tests/protocol_util_unittest.cc
index 61bb6f6..eee98e6 100644
--- a/src/lib/dhcp/tests/protocol_util_unittest.cc
+++ b/src/lib/dhcp/tests/protocol_util_unittest.cc
@@ -85,7 +85,7 @@ TEST(ProtocolUtilTest, decodeEthernetHeader) {
     OutputBuffer buf(1);
     buf.writeData(dest_hw_addr, sizeof(dest_hw_addr));
     buf.writeData(src_hw_addr, sizeof(src_hw_addr));
-    buf.writeUint16(0x800);
+    buf.writeUint16(ETHERNET_TYPE_IP);
     // Append dummy data. We will later check that this data is not
     // removed or corrupted when reading the ethernet header.
     buf.writeUint32(0x01020304);



More information about the bind10-changes mailing list