From owner-freebsd-hackers Wed Sep 2 17:54:42 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA10885 for freebsd-hackers-outgoing; Wed, 2 Sep 1998 17:54:42 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA10880 for ; Wed, 2 Sep 1998 17:54:40 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id RAA03916; Wed, 2 Sep 1998 17:53:37 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma003914; Wed Sep 2 17:53:33 1998 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id RAA20948; Wed, 2 Sep 1998 17:53:33 -0700 (PDT) From: Archie Cobbs Message-Id: <199809030053.RAA20948@bubba.whistle.com> Subject: Re: bcmp abuse in networking code ? In-Reply-To: <199809021506.RAA10910@labinfo.iet.unipi.it> from Luigi Rizzo at "Sep 2, 98 05:06:30 pm" To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Date: Wed, 2 Sep 1998 17:53:33 -0700 (PDT) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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