[PATCH V1 1/3] Implement virMacAddrIsBroadcastRaw

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]);
+
 #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;

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]