summaryrefslogtreecommitdiff
path: root/net/icmp.h
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-25 20:46:52 +0200
committerMiguel <m.i@gmx.at>2018-09-25 20:46:52 +0200
commitb58e7bc7cb8ce4fc6f824761ac8ef3920e7dfcc1 (patch)
treed760847e65ac231e5a18a9051af15eac12ff071d /net/icmp.h
parent112ca29a3bb2ab38693943ed33ee51f4fd7d2d81 (diff)
working on icmp ping reply
Diffstat (limited to 'net/icmp.h')
-rw-r--r--net/icmp.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/net/icmp.h b/net/icmp.h
new file mode 100644
index 0000000..c2c5e8f
--- /dev/null
+++ b/net/icmp.h
@@ -0,0 +1,28 @@
+//http://www.saminiir.com/lets-code-tcp-ip-stack-2-ipv4-icmpv4/
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "netdev.h"
+
+struct icmp_v4 {
+ uint8_t type; // purpose 0-echo reply, 3- unreachable, 8- echo request, etc...
+ uint8_t code; // reason (type=3,code=0 net unreachable, etc..)
+ uint16_t csum; // checksum (Same as in ipv4 header)
+ uint8_t data[]; // payload (example icmp_v4_echo)
+} __attribute__((packed));
+
+// payload
+struct icmp_v4_echo {
+ uint16_t id; // set by sender
+ uint16_t seq; // starting at 0
+ uint8_t data[]; // optinal (example timestamp)
+} __attribute__((packed));
+
+struct icmp_v4_dst_unreachable {
+ uint8_t unused;
+ uint8_t len; // lenght of original datagramm
+ uint16_t var; // depends on icmp code
+ uint8_t data[];
+} __attribute__((packed));
+
+bool icmp_incoming(struct netdev *dev,struct icmp_v4 *data, uint32_t count_bytes);