Your patch would work, I can test it later. Memcpy could avoid the problem.
There is a drawback using memcpy because you should put memcpy() everywhere
in your codes, for everytime you access ip_src.s_addr or ip_src.d_addr

I do think my way to solve this problem is better, just like it is in the
kernel driver. A net card driver is general enough because you use the same
code under different architectures. And it is documented in the driver
source:

"Big- and Little-Endian byte order as well as 32- and 64-bit archs are
supported.  Weak-ordered memory and non-cache-coherent archs are supported."


On Sun, May 18, 2008 at 6:44 PM, Richard Andrews <[EMAIL PROTECTED]>
wrote:

> Hai - can you try this patch against original edge.c.
>
> Index: edge.c
> ===================================================================
> --- edge.c      (revision 3486)
> +++ edge.c      (working copy)
> @@ -608,9 +608,12 @@
>     if(ntohs(eh->ether_type) == 0x0800) {
>
>       /* Note: all elements of the_ip are in network order */
> -      struct ip *the_ip = (struct ip*)(decrypted_msg+sizeof(struct
> ether_header));
> +      struct ip the_ip; /* Make sure this struct is aligned for all
> platforms.
> */
> +      memcpy( &the_ip,
> +              (decrypted_msg+sizeof(struct ether_header)),
> +              sizeof(the_ip) );
>
> -      if(the_ip->ip_src.s_addr != device.ip_addr) {
> +      if(the_ip.ip_src.s_addr != device.ip_addr) {
>        /* This is a packet that needs to be routed */
>        traceEvent(TRACE_INFO, "Discarding routed packet");
>        return;
>
>
> --- Richard Andrews <[EMAIL PROTECTED]> wrote:
>
> > Hai - can you please create a new patch that modifies send_packet2net()
> such
> > that "the_ip" is a local variable (not a pointer) and the data is put
> into it
> > via memcpy. Something like:
> >
> >     struct ip the_ip;
> >     memcpy( &the_ip,
> >             decrypted_msg+sizeof(struct ether_header),
> >             sizeof(the_ip) );
>
>
>
>       Get the name you always wanted with the new y7mail email address.
> www.yahoo7.com.au/y7mail
>
>
_______________________________________________
Ntop-dev mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to