From e35d6a4fde9a0671bc7d2527ff6b55b0ce1b4b1e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 21 Aug 2022 22:33:09 +0200 Subject: user: rename ethdump to netstack --- src/user/app/ethdump/icmp.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/user/app/ethdump/icmp.c (limited to 'src/user/app/ethdump/icmp.c') diff --git a/src/user/app/ethdump/icmp.c b/src/user/app/ethdump/icmp.c deleted file mode 100644 index 0c6a502..0000000 --- a/src/user/app/ethdump/icmp.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "proto.h" -#include "util.h" - -enum { - Type = 0, - Code = 1, - Checksum = 2, - Payload = 4, -}; - -void icmp_parse(const uint8_t *buf, size_t len, struct ipv4 ip) { - if (len < Payload) return; - uint8_t type = buf[Type]; - if (type == 8 && ip.dst == state.ip) { - /* echo reply */ - icmp_send(buf + Payload, len - Payload, (struct icmp){ - .type = 0, - .ip.dst = ip.src, - .ip.e.dst = ip.e.src, - }); - } -} - -void icmp_send(const void *payload, size_t len, struct icmp i) { - i.ip.proto = 1; - uint8_t *pkt = malloc(Payload + len); - pkt[Type] = i.type; - pkt[Code] = i.code; - memcpy(pkt + Payload, payload, len); - nput16(pkt + Checksum, 0); - nput16(pkt + Checksum, ip_checksum(pkt, Payload + len)); - ipv4_send(pkt, Payload + len, i.ip); - free(pkt); -} -- cgit v1.2.3