summaryrefslogtreecommitdiff
path: root/net/icmp.c
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.c
parent112ca29a3bb2ab38693943ed33ee51f4fd7d2d81 (diff)
working on icmp ping reply
Diffstat (limited to 'net/icmp.c')
-rw-r--r--net/icmp.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/icmp.c b/net/icmp.c
new file mode 100644
index 0000000..038e32a
--- /dev/null
+++ b/net/icmp.c
@@ -0,0 +1,21 @@
+#include "inet.h"
+#include "icmp.h"
+#include "log.h"
+
+bool icmp_incoming(struct netdev *dev,struct icmp_v4 *data, uint32_t count_bytes)
+{
+ klog ("icmp type=%d",data->type);
+ klog ("icmp code=%d",data->code);
+ klog ("icmp csum=0x%04x",ntohs(data->csum));
+ data->csum=0;
+ klog("expected checksum = 0x%04X",checksum(data,count_bytes));
+
+ if(data->type==ICMP_ECHO_REQUEST) // echo request
+ {
+ struct icmp_v4_echo *echo=data->data;
+ klog ("received echo request id=%d, seq=%d, data=%d ",ntohs(echo->id),ntohs(echo->seq),echo->data);
+// icmp_reply(); /// TODO watchout that this is the memory managed by the network card we are dealing with!!. fix this later.
+ }
+
+ return true;
+}