Date: Wed, 2 Sep 1998 17:53:33 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Cc: hackers@FreeBSD.ORG Subject: Re: bcmp abuse in networking code ? Message-ID: <199809030053.RAA20948@bubba.whistle.com> In-Reply-To: <199809021506.RAA10910@labinfo.iet.unipi.it> from Luigi Rizzo at "Sep 2, 98 05:06:30 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo writes: > poking around in /sys/net and /sys/netinet, i frequently see bcmp() being > used to compare ethernet addresses (but not only those). In some cases, > even against the ethernet broadcast address. > > In my revised bridge code i have the following macros > > #define ETH_MATCH(a,b) ( \ > ((unsigned short *)(a))[2] == ((unsigned short *)(b))[2] && \ > *((unsigned int *)(a)) == *((unsigned int *)(b)) ) > #define IS_ETHER_BROADCAST(a) ( \ > *((unsigned int *)(a)) == 0xffffffff && \ > ((unsigned short *)(a))[2] == 0xffff ) Cool...! A minor nit, though: use u_int16_t and u_int32_t instead. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809030053.RAA20948>