#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.
}
// Type IP.
- out_buf.writeUint16(ETHERTYPE_IP);
+ out_buf.writeUint16(ETHERNET_TYPE_IP);
}
void
/// 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;
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);