i am capturing packets in the network, and printing the packet values i have defined structures for ethernet ip and tcp, i am first printing the entire packet then but while printing the packet data according to the structure it skips the first 4 bytes of packet and prints the next as 6 bytes as destination address ans so on, why is it skipping the first 4 bytes ? due to this i get wrong results
    void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
    {
        int i,a[4],mul_value;
        struct classifier *ptr_fltr;
        ptr_fltr = (struct classifier*)(packet);
        int PacketLength = header->len;
        for(i = 0; i < PacketLength; i++)
        printf("%3X", packet[i]);
        printf("destination host");
        for(i = 0; i < 6; i++)
        printf("%3x",ptr_fltr->pktFltr.mac.ether_dhost[i]);
        printf("\n");
        printf("source host");
        for(i = 0; i < 6; i++)
        printf("%3x",ptr_fltr->pktFltr.mac.ether_shost[i]);
    .
    .
    .
    .
    }
these are the structures
        struct packet_filter
    {
        struct mac_filter mac;
        struct ip_filter ip;
        union {
            struct udp_filter proto;
        }protocol;
    }__attribute__((packed));
    struct mac_filter
    {
        u_char ether_dhost[ETHER_ADDR_LEN];
        u_char ether_shost[ETHER_ADDR_LEN];
        u_short ether_type;
    }__attribute__ ((packed));
    struct ip_filter
    {
        u_char ip_vhl;
        u_char ip_tos; /* type of service */
        u_short ip_len; /* total length */
        u_short ip_id; /* identification */
        u_short ip_off; /* fragment offset field */
        u_char ip_ttl; /* time to live */
        u_char ip_p; /* protocol */
        u_short ip_sum; /* checksum */
        struct in_addr ip_src; /* source and dest address */
        struct in_addr ip_dst; /* source and dest address */
    }__attribute__((packed));
struct node
    {
        int n; 
        struct classifier keys[M-1]; /*array of keys*/
        struct node *p[M]; 
    }__attribute__((packed));
output
    i have put some part of the o/p
    0 14 85 A5 1B  1  0 19 D1 A3  7 25  8  0 45 10  1 54 A6 CA 40  0 40  6 2D CC AC 1C  6 6E AC 1C  6 57  0 16 91 57 EA AB
    destination host 1b  1  0 19 d1 a3
    source host  7 25  8  0 45 10
but the destination host should be 0 14 85 A5 1B 1
 
     
     
    