Get the size of ARP packet
<p>I am currently decomposing a data packet into several headers. </p>

<p>Here's my current code :</p>

<pre><code>void analyse(struct pcap_pkthdr *header, const unsigned char *packet, int verbose) {


    // Define headers and payload
    const struct ether_header *ethernet = NULL;
    const struct ether_arp *arp = NULL;
    const struct ip *ip = NULL;
    const struct tcphdr *tcp = NULL;
    const char *payload = NULL;

    /* Ethernet header is the first data block of packet **/
    ethernet = ( struct ether_header* ) packet;

    // ARP packet following
    if( ntohs( ethernet-&gt;ether_type ) == ETHERTYPE_ARP ) {

        arp = ( struct ether_arp* ) ( packet + ETH_HLEN );

        // If the operation performed by the sender is a reply, we increment the ARP Response Counter
        if( ntohs(arp-&gt;ea_hdr.ar_op ) == 2 ) {

            arpResponsesCounter++;

        }

    } else { // IP packet following

        ip = ( struct ip* ) ( packet + ETH_HLEN );

    }

    // ARP header and IP header don't have the same size
    if( arp == NULL ) {

        u_int shift_size = (ip-&gt;ip_hl)*4;

    } else {


    }


}
</code></pre>

<p>According to <a href="http://unix.superglobalmegacorp.com/BSD4.4/newsrc/netinet/ip.h.html" rel="nofollow noreferrer">http://unix.superglobalmegacorp.com/BSD4.4/newsrc/netinet/ip.h.html</a> and <a href="http://unix.superglobalmegacorp.com/Net2/newsrc/netinet/if_ether.h.html" rel="nofollow noreferrer">http://unix.superglobalmegacorp.com/Net2/newsrc/netinet/if_ether.h.html</a> , the size of an IP header is given by <code>(ip-&gt;ip_hl)*4;</code> but I can't figure out how to get the size of an ARP header.
I need it to define properly the TCP header pointer. </p>

<p>Thanks</p>