summaryrefslogtreecommitdiff
path: root/src/user/app/ethdump/proto.h
diff options
context:
space:
mode:
authordzwdz2022-08-17 21:26:29 +0200
committerdzwdz2022-08-17 21:26:29 +0200
commit6ffb06af70faa5657f2c6091fe23500007e2bd44 (patch)
tree8228cdda29cda0c44ff6a09d5a76314fa9760ce9 /src/user/app/ethdump/proto.h
parent5abcc66cb6e83f02b5218802d3eca74c0d29bebf (diff)
user/ethdump: file per protocol, ethernet frame functions
Diffstat (limited to 'src/user/app/ethdump/proto.h')
-rw-r--r--src/user/app/ethdump/proto.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/user/app/ethdump/proto.h b/src/user/app/ethdump/proto.h
new file mode 100644
index 0000000..f47ca53
--- /dev/null
+++ b/src/user/app/ethdump/proto.h
@@ -0,0 +1,31 @@
+#pragma once
+#include <camellia/types.h>
+#include <stdint.h>
+
+typedef uint8_t mac_t[6];
+
+extern struct net_state {
+ mac_t mac;
+ uint32_t ip;
+
+ handle_t raw_h;
+} state;
+
+enum { /* ethertype */
+ ET_IPv4 = 0x800,
+ ET_ARP = 0x806,
+};
+
+struct ethernet {
+ const mac_t *src, *dst;
+ uint16_t type;
+};
+
+
+void arp_parse(const uint8_t *buf, size_t len);
+void icmp_parse(const uint8_t *buf, size_t len);
+void ipv4_parse(const uint8_t *buf, size_t len);
+
+void ether_parse(const uint8_t *buf, size_t len);
+uint8_t *ether_start(size_t len, struct ethernet ether);
+void ether_finish(uint8_t *pkt);