diff options
Diffstat (limited to 'net/ipv4.c')
| -rw-r--r-- | net/ipv4.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/net/ipv4.c b/net/ipv4.c new file mode 100644 index 0000000..aa8502e --- /dev/null +++ b/net/ipv4.c @@ -0,0 +1,20 @@ +#include "inet.h" +#include "ipv4.h" +#include "eth.h" +#include "log.h" +#include "icmp.h" + +bool ipv4_incoming(struct netdev *dev,struct eth_hdr *hdr) +{ + struct ipv4_hdr *ipv4=hdr->payload; + klog("ipv4 incoming with checksum: 0x%04X",ntohs(ipv4->csum)); + ipv4->csum=0; + klog("expected checksum: 0x%04X",checksum(ipv4,ntohs(ipv4->len))); + klog("ipv4 header len=%d",ipv4->ihl); + if(ipv4->proto==IPV4_P_ICMP) + { + icmp_incoming(dev,((uint32_t *)ipv4)+ipv4->ihl,ntohs(ipv4->len)-ipv4->ihl*4); + } + + return true; +} |
