srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/include/wireframe/net/icmp.hpp
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-05-27 22:00:00 +0200
committersrdusr <[email protected]>2024-05-27 22:00:00 +0200
commitb565d7d9c47ca1ec5af0effd828431ee96027d60 (patch)
treefbe0c9c897e78f507443507354d5b1d8fb851099 /include/wireframe/net/icmp.hpp
parentfbedc55d5aa861c381701c9f913b34ee7ab57ec4 (diff)
downloadpacketeer-b565d7d9c47ca1ec5af0effd828431ee96027d60.tar.gz
packeteer-b565d7d9c47ca1ec5af0effd828431ee96027d60.zip
Rename project from wireframe to packeteer
Decided on the name after weighing alternatives in NAMES.md: packeteer (packet + -eer, "one who wields packets") fit the project's actual scope better than the wire/frame pun once it had grown into full L2-L7 dissection, reassembly, checksums, privilege dropping, and dual TUI/GUI frontends. No existing packet-capture project uses the name; the one real-world collision (Packeteer, Inc., a networking company acquired and folded into Blue Coat/Symantec by 2008) is long defunct. Mechanical rename throughout: CMake project/target names, the wireframe:: namespace and include/wireframe/ directory (git mv, history preserved), every #include path, CLI/GUI help text, and the project's own working directory. NAMES.md rewritten to record the decision instead of leaving stale self-referential etymology behind from the blind rename pass. Verified after every step: full rebuild (all four targets, no warnings) and the full test suite (128/128 cases, 366/366 assertions) both from a fresh reconfigure and again after the directory move.
Diffstat (limited to 'include/wireframe/net/icmp.hpp')
-rw-r--r--include/wireframe/net/icmp.hpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/include/wireframe/net/icmp.hpp b/include/wireframe/net/icmp.hpp
deleted file mode 100644
index af83916..0000000
--- a/include/wireframe/net/icmp.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <optional>
-#include <span>
-#include <string>
-
-#include "wireframe/byteio.hpp"
-
-// ICMPv4 (RFC 792) and ICMPv6 (RFC 4443) share the same first-4-byte
-// shape (Type, Code, Checksum) but a completely different type
-// namespace - the same numeric type means something different in each
-// - so they get separate parse functions and separate type-name
-// tables, sharing only the header struct shape. Neither protocol has
-// ports, so this doesn't fit L7Registry's port-keyed dispatch at all;
-// it's handled directly by protocol number in summarize.hpp instead.
-namespace wireframe::net {
-
-struct IcmpHeader {
- std::uint8_t type;
- std::uint8_t code;
- std::optional<std::uint16_t> identifier; // echo request/reply only
- std::optional<std::uint16_t> sequence; // echo request/reply only
-};
-
-inline std::optional<IcmpHeader> parse_icmpv4(std::span<const unsigned char> bytes) {
- if (bytes.size() < 4) return std::nullopt;
-
- IcmpHeader header{};
- header.type = bytes[0];
- header.code = bytes[1];
- if ((header.type == 8 || header.type == 0) && bytes.size() >= 8) { // echo request/reply
- header.identifier = read_be16(bytes, 4);
- header.sequence = read_be16(bytes, 6);
- }
- return header;
-}
-
-inline std::string icmpv4_type_name(std::uint8_t type) {
- switch (type) {
- case 0: return "Echo Reply";
- case 3: return "Destination Unreachable";
- case 4: return "Source Quench";
- case 5: return "Redirect";
- case 8: return "Echo Request";
- case 11: return "Time Exceeded";
- case 12: return "Parameter Problem";
- case 13: return "Timestamp Request";
- case 14: return "Timestamp Reply";
- default: return "type=" + std::to_string(type);
- }
-}
-
-inline std::optional<IcmpHeader> parse_icmpv6(std::span<const unsigned char> bytes) {
- if (bytes.size() < 4) return std::nullopt;
-
- IcmpHeader header{};
- header.type = bytes[0];
- header.code = bytes[1];
- if ((header.type == 128 || header.type == 129) && bytes.size() >= 8) { // echo request/reply
- header.identifier = read_be16(bytes, 4);
- header.sequence = read_be16(bytes, 6);
- }
- return header;
-}
-
-inline std::string icmpv6_type_name(std::uint8_t type) {
- switch (type) {
- case 1: return "Destination Unreachable";
- case 2: return "Packet Too Big";
- case 3: return "Time Exceeded";
- case 4: return "Parameter Problem";
- case 128: return "Echo Request";
- case 129: return "Echo Reply";
- case 133: return "Router Solicitation";
- case 134: return "Router Advertisement";
- case 135: return "Neighbor Solicitation";
- case 136: return "Neighbor Advertisement";
- case 137: return "Redirect";
- default: return "type=" + std::to_string(type);
- }
-}
-
-} // namespace wireframe::net