mirror of https://gitee.com/openkylin/libvirt.git
Implement virMacAddrIsBroadcastRaw
Add function for testing for Ethernet broadcast address
This commit is contained in:
parent
7b9d55e629
commit
46b2cafb25
|
@ -1326,6 +1326,7 @@ virMacAddrCompare;
|
|||
virMacAddrFormat;
|
||||
virMacAddrGenerate;
|
||||
virMacAddrGetRaw;
|
||||
virMacAddrIsBroadcastRaw;
|
||||
virMacAddrIsMulticast;
|
||||
virMacAddrIsUnicast;
|
||||
virMacAddrParse;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in New Issue