srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/include/wireframe/net/ethernet.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/wireframe/net/ethernet.hpp')
-rw-r--r--include/wireframe/net/ethernet.hpp44
1 files changed, 0 insertions, 44 deletions
diff --git a/include/wireframe/net/ethernet.hpp b/include/wireframe/net/ethernet.hpp
deleted file mode 100644
index 2da4cc8..0000000
--- a/include/wireframe/net/ethernet.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-#include <algorithm>
-#include <array>
-#include <cstdint>
-#include <optional>
-#include <span>
-
-#include "wireframe/byteio.hpp"
-
-namespace wireframe::net {
-
-inline constexpr std::size_t kEthernetHeaderLen = 14;
-inline constexpr std::uint16_t kEthertypeIPv4 = 0x0800;
-inline constexpr std::uint16_t kEthertypeIPv6 = 0x86DD;
-inline constexpr std::uint16_t kEthertypeArp = 0x0806;
-
-struct MacAddress {
- std::array<unsigned char, 6> bytes;
-};
-
-struct EthernetHeader {
- MacAddress dst;
- MacAddress src;
- std::uint16_t ethertype;
-};
-
-struct EthernetFrame {
- EthernetHeader header;
- std::span<const unsigned char> payload;
-};
-
-inline std::optional<EthernetFrame> parse_ethernet(std::span<const unsigned char> bytes) {
- if (bytes.size() < kEthernetHeaderLen) return std::nullopt;
-
- EthernetHeader header{};
- std::copy_n(bytes.begin(), 6, header.dst.bytes.begin());
- std::copy_n(bytes.begin() + 6, 6, header.src.bytes.begin());
- header.ethertype = read_be16(bytes, 12);
-
- return EthernetFrame{header, bytes.subspan(kEthernetHeaderLen)};
-}
-
-} // namespace wireframe::net