summaryrefslogtreecommitdiff
path: root/net/ipv4.c
blob: b7e6a53b557de46bc9158f6175cbddf67998d37e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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,hdr);
    }

    return true;
}