Peter Memishian wrote:
>  > /*
>  >   * Compare two Ethernet addresses - assumes that the two given
>  >   * pointers can be referenced as shorts.  On architectures
>  >   * where this is not the case, use bcmp instead.  Note that like
>  >   * bcmp, we return zero if they are the SAME.
>  >   */
>  > 
>  > #if defined(__sparc) || defined(__i386) || defined(__amd64)
>  > #define ether_cmp(a, b) (((short *)b)[2] != ((short *)a)[2] || \
>  >          ((short *)b)[1] != ((short *)a)[1] || \
>  >          ((short *)b)[0] != ((short *)a)[0])
>  > #else
>  > #define ether_cmp(a, b) (bcmp((caddr_t)a, (caddr_t)b, 6))
>  > #endif
> 
> As the comment you included states, the code is assuming that the
> passed-in Ethernet address is at least 2-byte aligned -- which makes some
> sense since that's going to tbe usual case with an Ethernet header.

That's not the way I interpret that comment.  The first sentence is
describing the first implementation (before the #else) which assumes
that the *architecture* allows accessing arbitrary addresses as shorts.
As originally written (both code and comment), ether_cmp was meant to be
usable on arbitrarily aligned memory, and when defined(__sparc) was
added, it was broken (or the interface was redefined with a new
restriction).

                                        -=] Mike [=-
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to