Hi,


> 
>       im programming in linux sockets, but i need a help in this
> lines:
> 
>               struct etherpacket
>      {
>      struct ethhdr eth;
>      struct iphdr  ip;
>      struct tcphdr tcp;
>      char buff[8193];
>      }ep;
>               
>               struct iphdr  *ip;
>      struct tcphdr *tcp;
> 
> ->    ip=(struct iphdr *)(((unsigned long)&ep.ip)-2);
> ->    tcp=(struct tcphdr *)(((unsigned long)&ep.tcp)-2);

-------------> The ethhdr is 14 bytes long. So, the next field 
                                ip of the struct etherpacket starts from the next
                                4 byte multiple. Thus we have a 2 byte 'gap' in the
                                structure. But, while reading the packet from the
                                net there is no question of any alignment and hence
                                the ip field would start immediately after the end 
                                of eth structure. So, the minus 2 from the &ep.ip.

                                Experts please correct me if I am wrong.


                                                                                       
 --gopi
> -
> To unsubscribe from this list: send the line "unsubscribe linux-net" in
> the body of a message to [EMAIL PROTECTED]
> 
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to