FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora/Linux Management Tools

 
 
LinkBack Thread Tools
 
Old 04-11-2008, 11:42 AM
"Richard W.M. Jones"
 
Default comparing MAC address is changed to case insensitive

On Fri, Apr 11, 2008 at 09:22:33AM +0900, Hiroyuki Kaguchi wrote:
> MAC address is case sensitive in "countMACaddr" method.
> This patch changes from case sensitive to case insensitive.

You also have to note that 1:2:3:4:5:6 is the same as
01:02:03:04:05:06. Comparing MAC addresses is hard :-)

There's some C code in libvirt (src/utils.c IIRC) which Jim Meyering
wrote that does a correct compare on MAC addresses. Should be easier
in Python 'coz you can split the string and compare each component
numerically.

Rich.

--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 04-21-2008, 09:40 AM
"Richard W.M. Jones"
 
Default comparing MAC address is changed to case insensitive

On Mon, Apr 21, 2008 at 05:02:30PM +0900, Hiroyuki Kaguchi wrote:
> diff -r 6462dfd3e606 -r 6ec83c2a5c36 virtinst/util.py
> --- a/virtinst/util.py Tue Apr 08 15:35:49 2008 -0400
> +++ b/virtinst/util.py Mon Apr 21 15:44:24 2008 +0900
> @@ -222,3 +222,22 @@
> str = str.replace("<", "&lt;")
> str = str.replace(">", "&gt;")
> return str
> +
> +def compareMAC(p, q):
> + """Compare two MAC addresses"""
> + pa = p.split(":")
> + qa = q.split(":")
> +
> + if len(pa) != len(qa):
> + if p > q:
> + return 1
> + else:
> + return -1
> +
> + for i in xrange(len(pa)):
> + n = int(pa[i], 0x10) - int(qa[i], 0x10)
> + if n > 0:
> + return 1
> + elif n < 0:
> + return -1
> + return 0

Looks good to me, although I don't have commit access so someone else
should also review this.

Rich.

--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 09:53 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org