+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.
#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.
*/
__virBufferAdd;
__virBufferAddChar;
+ __virMacAddrCompare;
+
local: *;
};
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
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__ */
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;
#include "xml.h"
#include "buf.h"
#include "uuid.h"
+#include "util.h"
static int xenXMConfigSetString(virConfPtr conf, const char *setting,
const char *str);
key = nextkey;
}
- if (!(strcmp(dommac, (const char *) mac))) {
+ if (virMacAddrCompare (dommac, (const char *) mac) == 0) {
if (autoassign) {
free(mac);
mac = NULL;
mac = nextmac;
}
- if (!(strcmp(dommac, (const char *) key)))
+ if (virMacAddrCompare (dommac, (const char *) key) == 0)
break;
}
skip: