
On Thu, Aug 30, 2012 at 02:29:49PM -0400, Stefan Berger wrote:
Add function for testing for Ethernet broadcast address --- src/libvirt_private.syms | 1 + src/util/virmacaddr.c | 9 +++++++++ src/util/virmacaddr.h | 2 ++ 3 files changed, 12 insertions(+)
Index: libvirt-acl/src/util/virmacaddr.c =================================================================== --- libvirt-acl.orig/src/util/virmacaddr.c +++ libvirt-acl/src/util/virmacaddr.c @@ -30,6 +30,9 @@ #include "virmacaddr.h" #include "virrandom.h"
+static const unsigned char virMacAddrBroadcastAddrRaw[VIR_MAC_BUFLEN] = + { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + /* Compare two MAC addresses, ignoring differences in case, * as well as leading zeros. */ @@ -218,3 +221,9 @@ virMacAddrIsUnicast(const virMacAddrPtr { return !(mac->addr[0] & 1); } + +bool +virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]) +{ + return memcmp(virMacAddrBroadcastAddrRaw, s, sizeof(*s)) == 0; +} Index: libvirt-acl/src/util/virmacaddr.h =================================================================== --- libvirt-acl.orig/src/util/virmacaddr.h +++ libvirt-acl/src/util/virmacaddr.h @@ -52,4 +52,6 @@ int virMacAddrParse(const char* str, virMacAddrPtr addr) ATTRIBUTE_RETURN_CHECK; bool virMacAddrIsUnicast(const virMacAddrPtr addr); bool virMacAddrIsMulticast(const virMacAddrPtr addr); +bool virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]); +
Humpf, we really ought to add virMacAddrIsBroadcast instead, but I understand from patch 3/3 that you don't have the structure handy at that point (and doing a pointer cast to an inexistant structure would be ugly), so okay for the purpose of fixing that bug, but I would expect a followup patch with a proper bool virMacAddrIsBroadcast(const virMacAddrPtr addr); added too
#endif /* __VIR_MACADDR_H__ */ Index: libvirt-acl/src/libvirt_private.syms =================================================================== --- libvirt-acl.orig/src/libvirt_private.syms +++ libvirt-acl/src/libvirt_private.syms @@ -1329,6 +1329,7 @@ virMacAddrCompare; virMacAddrFormat; virMacAddrGenerate; virMacAddrGetRaw; +virMacAddrIsBroadcastRaw; virMacAddrIsMulticast; virMacAddrIsUnicast; virMacAddrParse;
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/