提交 92a1e14b 编写于 作者: R Richard W.M. Jones

virMacAddrCompare for comparing MAC addresses

	* src/util.c, src/util.h, src/libvirt_sym.version: Added
	  virMacAddrCompare utility function for comparing MAC
	  addresses.
	* src/virsh.c, src/xm_internal.c: Use virMacAddrCompare
	  to compare addresses.  (Shigeki Sakamoto and Richard Jones).
上级 fa4ab332
Wed Feb 27 16:11:00 UTC 2008 Richard W.M. Jones <rjones@redhat.com>
virMacAddrCompare for comparing MAC addresses
* src/util.c, src/util.h, src/libvirt_sym.version: Added
virMacAddrCompare utility function for comparing MAC
addresses.
* src/virsh.c, src/xm_internal.c: Use virMacAddrCompare
to compare addresses. (Shigeki Sakamoto and Richard Jones).
Wed Feb 27 15:39:10 CET 2008 Jim Meyering <meyering@redhat.com>
Avoid "make distcheck" failure.
......
......@@ -54,7 +54,6 @@ extern "C" {
#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
/* If configured with --enable-debug=yes then library calls
* are printed to stderr for debugging.
*/
......
......@@ -185,5 +185,7 @@
__virBufferAdd;
__virBufferAddChar;
__virMacAddrCompare;
local: *;
};
......@@ -654,6 +654,16 @@ virParseNumber(const char **str)
return (ret);
}
/* Use this function when comparing two MAC addresses. It deals with
* string case compare and will eventually be extended to understand
* that 01:02:03:04:05:06 is the same as 1:2:3:4:5:6.
*/
int
__virMacAddrCompare (const char *mac1, const char *mac2)
{
return strcasecmp (mac1, mac2);
}
/*
* Local variables:
* indent-tabs-mode: nil
......
......@@ -79,8 +79,10 @@ int __virStrToLong_ull(char const *s,
unsigned long long *result);
#define virStrToLong_ull(s,e,b,r) __virStrToLong_ull((s),(e),(b),(r))
int __virMacAddrCompare (const char *mac1, const char *mac2);
#define virMacAddrCompare(mac1,mac2) __virMacAddrCompare((mac1),(mac2))
void virSkipSpaces(const char **str);
int virParseNumber(const char **str);
#endif /* __VIR_UTIL_H__ */
......@@ -4742,7 +4742,7 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE && xmlStrEqual(cur->name, BAD_CAST "mac")) {
tmp_mac = xmlGetProp(cur, BAD_CAST "address");
diff_mac = xmlStrcasecmp(tmp_mac, BAD_CAST mac);
diff_mac = virMacAddrCompare ((char *) tmp_mac, mac);
xmlFree(tmp_mac);
if (!diff_mac) {
goto hit;
......
......@@ -53,6 +53,7 @@
#include "xml.h"
#include "buf.h"
#include "uuid.h"
#include "util.h"
static int xenXMConfigSetString(virConfPtr conf, const char *setting,
const char *str);
......@@ -2813,7 +2814,7 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
key = nextkey;
}
if (!(strcmp(dommac, (const char *) mac))) {
if (virMacAddrCompare (dommac, (const char *) mac) == 0) {
if (autoassign) {
free(mac);
mac = NULL;
......@@ -3088,7 +3089,7 @@ xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
mac = nextmac;
}
if (!(strcmp(dommac, (const char *) key)))
if (virMacAddrCompare (dommac, (const char *) key) == 0)
break;
}
skip:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册