Implement virMacAddrIsBroadcastRaw

Add function for testing for Ethernet broadcast address
This commit is contained in:
Stefan Berger 2012-08-30 14:29:49 -04:00 committed by Daniel Veillard
parent 7b9d55e629
commit 46b2cafb25
3 changed files with 12 additions and 0 deletions

View File

@ -1326,6 +1326,7 @@ virMacAddrCompare;
virMacAddrFormat;
virMacAddrGenerate;
virMacAddrGetRaw;
virMacAddrIsBroadcastRaw;
virMacAddrIsMulticast;
virMacAddrIsUnicast;
virMacAddrParse;

View File

@ -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 mac)
{
return !(mac->addr[0] & 1);
}
bool
virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN])
{
return memcmp(virMacAddrBroadcastAddrRaw, s, sizeof(*s)) == 0;
}

View File

@ -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__ */