struct iphdr* iphdr = NULL; struct icmphdr* recv_icmphdr = NULL; // we got an IP packet - verify that it contains an ICMP message. iphdr = (struct iphdr*)rbuf; if (iphdr->protocol != IPPROTO_ICMP) { fprintf(stderr, "Expected ICMP packet, got %u\n", iphdr->protocol); exit(1); }Originally written by guy keren