提交 46b2cafb 编写于 作者: S Stefan Berger 提交者: Daniel Veillard

Implement virMacAddrIsBroadcastRaw

Add function for testing for Ethernet broadcast address
上级 7b9d55e6
......@@ -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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册