mirror of https://gitee.com/openkylin/libvirt.git
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).
This commit is contained in:
parent
fa4ab3325b
commit
92a1e14b0b
|
@ -1,3 +1,12 @@
|
||||||
|
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>
|
Wed Feb 27 15:39:10 CET 2008 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
Avoid "make distcheck" failure.
|
Avoid "make distcheck" failure.
|
||||||
|
|
|
@ -54,7 +54,6 @@ extern "C" {
|
||||||
#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
|
#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
|
||||||
#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
|
#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
|
||||||
|
|
||||||
|
|
||||||
/* If configured with --enable-debug=yes then library calls
|
/* If configured with --enable-debug=yes then library calls
|
||||||
* are printed to stderr for debugging.
|
* are printed to stderr for debugging.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -185,5 +185,7 @@
|
||||||
__virBufferAdd;
|
__virBufferAdd;
|
||||||
__virBufferAddChar;
|
__virBufferAddChar;
|
||||||
|
|
||||||
|
__virMacAddrCompare;
|
||||||
|
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|
10
src/util.c
10
src/util.c
|
@ -654,6 +654,16 @@ virParseNumber(const char **str)
|
||||||
return (ret);
|
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:
|
* Local variables:
|
||||||
* indent-tabs-mode: nil
|
* indent-tabs-mode: nil
|
||||||
|
|
|
@ -79,8 +79,10 @@ int __virStrToLong_ull(char const *s,
|
||||||
unsigned long long *result);
|
unsigned long long *result);
|
||||||
#define virStrToLong_ull(s,e,b,r) __virStrToLong_ull((s),(e),(b),(r))
|
#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);
|
void virSkipSpaces(const char **str);
|
||||||
int virParseNumber(const char **str);
|
int virParseNumber(const char **str);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __VIR_UTIL_H__ */
|
#endif /* __VIR_UTIL_H__ */
|
||||||
|
|
|
@ -4742,7 +4742,7 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (cur->type == XML_ELEMENT_NODE && xmlStrEqual(cur->name, BAD_CAST "mac")) {
|
if (cur->type == XML_ELEMENT_NODE && xmlStrEqual(cur->name, BAD_CAST "mac")) {
|
||||||
tmp_mac = xmlGetProp(cur, BAD_CAST "address");
|
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);
|
xmlFree(tmp_mac);
|
||||||
if (!diff_mac) {
|
if (!diff_mac) {
|
||||||
goto hit;
|
goto hit;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
#include "buf.h"
|
#include "buf.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static int xenXMConfigSetString(virConfPtr conf, const char *setting,
|
static int xenXMConfigSetString(virConfPtr conf, const char *setting,
|
||||||
const char *str);
|
const char *str);
|
||||||
|
@ -2813,7 +2814,7 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
|
||||||
key = nextkey;
|
key = nextkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(strcmp(dommac, (const char *) mac))) {
|
if (virMacAddrCompare (dommac, (const char *) mac) == 0) {
|
||||||
if (autoassign) {
|
if (autoassign) {
|
||||||
free(mac);
|
free(mac);
|
||||||
mac = NULL;
|
mac = NULL;
|
||||||
|
@ -3088,7 +3089,7 @@ xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
|
||||||
mac = nextmac;
|
mac = nextmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(strcmp(dommac, (const char *) key)))
|
if (virMacAddrCompare (dommac, (const char *) key) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
skip:
|
skip:
|
||||||
|
|
Loading…
Reference in New Issue