summaryrefslogtreecommitdiff
path: root/net/ipv4.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/ipv4.h
parent112ca29a3bb2ab38693943ed33ee51f4fd7d2d81 (diff)
working on icmp ping reply
Diffstat (limited to 'net/ipv4.h')
-rw-r--r--net/ipv4.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/ipv4.h b/net/ipv4.h
new file mode 100644
index 0000000..e3cbc36
--- /dev/null
+++ b/net/ipv4.h
@@ -0,0 +1,25 @@
+// http://www.saminiir.com/lets-code-tcp-ip-stack-2-ipv4-icmpv4/
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "eth.h"
+#include "netdev.h"
+
+struct ipv4_hdr {
+ uint8_t ihl : 4; // 4bit / number of 32 bit words in header
+ uint8_t version : 4; // 4bit / 4 - ipv4
+ uint8_t tos; // type of service
+ uint16_t len; // total length of ip datagramm
+ uint16_t id; // index of datagram for fragmentation
+ uint16_t flags : 3; // various control flags
+ uint16_t frag_offset : 13; // fragment offset 0 - first
+ uint8_t ttl; // time to live - countdown decreased by each receiver
+ uint8_t proto; // payload protocol / 1-icmp, 16 - udp , 6 -tcp
+ uint16_t csum; // header checksum
+ uint32_t saddr; // source ip address
+ uint32_t daddr; // destination ip address
+} __attribute__((packed));
+
+uint16_t ipv4_checksum(void *addr, int count);
+bool ipv4_incoming(struct netdev *,struct eth_hdr *);
+uint16_t ipv4_checksum(void *addr, int count);