]> git.proxmox.com Git - pve-common.git/commitdiff
add PVE::Tools::random_ether_addr()
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 5 Oct 2011 07:21:52 +0000 (09:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 5 Oct 2011 07:21:52 +0000 (09:21 +0200)
Makefile
data/PVE/Tools.pm
debian/changelog
debian/control

index feb0d19f829243832a7f26eff9c456a5c5174a4f..7f077835dda557397fe89f2b2e2e2b096d03a4a1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.0
 
 VERSION=1.0
 RELEASE=2.0
 
 VERSION=1.0
-PKGREL=5
+PKGREL=6
 
 PACKAGE=libpve-common-perl
 
 
 PACKAGE=libpve-common-perl
 
index d80524013b040b3f0e2b1acdc028a4191484ed2f..5e8e7bf46460c1abfa5fd199e3bcca14c5176cbe 100644 (file)
@@ -12,6 +12,7 @@ use Fcntl qw(:DEFAULT :flock);
 use base 'Exporter';
 use URI::Escape;
 use Encode;
 use base 'Exporter';
 use URI::Escape;
 use Encode;
+use Digest::SHA1;
 
 our @EXPORT_OK = qw(
 lock_file 
 
 our @EXPORT_OK = qw(
 lock_file 
@@ -635,5 +636,27 @@ sub decode_text {
     return Encode::decode("utf8", uri_unescape($data));
 }
 
     return Encode::decode("utf8", uri_unescape($data));
 }
 
+sub random_ether_addr {
+
+    my $rand = Digest::SHA1::sha1_hex(rand(), time());
+
+    my $mac = '';
+    for (my $i = 0; $i < 6; $i++) {
+       my $ss = hex(substr($rand, $i*2, 2));
+       if (!$i) {
+           $ss &= 0xfe; # clear multicast
+           $ss |= 2; # set local id
+       }
+       $ss = sprintf("%02X", $ss);
+
+       if (!$i) {
+           $mac .= "$ss";
+       } else {
+           $mac .= ":$ss";
+       }
+    }
+
+    return $mac;
+}
 
 1;
 
 1;
index 9610fe3b1b871502cdc1f2eaee0b539842c895af..b612dd6a78034c7f94725af1f8e617db50c4342d 100644 (file)
@@ -1,3 +1,9 @@
+libpve-common-perl (1.0-6) unstable; urgency=low
+
+  * add PVE::Tools::random_ether_addr()
+
+ -- Proxmox Support Team <support@proxmox.com>  Wed, 05 Oct 2011 09:19:39 +0200
+
 libpve-common-perl (1.0-5) unstable; urgency=low
 
   * cleanups (prepare for beta release)
 libpve-common-perl (1.0-5) unstable; urgency=low
 
   * cleanups (prepare for beta release)
index b2bb71ffb784f22e6d565920f6d265bc9af11f4e..9d7b69528bac5484af17c46ec62a4c563b13e7cb 100644 (file)
@@ -7,6 +7,6 @@ Standards-Version: 3.8.4
 
 Package: libpve-common-perl
 Architecture: all
 
 Package: libpve-common-perl
 Architecture: all
-Depends: ${perl:Depends} ${misc:Depends}, libdevel-cycle-perl, libwww-perl, libjson-perl, liblinux-inotify2-perl, libio-stringy-perl, liburi-perl
+Depends: ${perl:Depends} ${misc:Depends}, libdevel-cycle-perl, libwww-perl, libjson-perl, liblinux-inotify2-perl, libio-stringy-perl, liburi-perl, libdigest-sha1-perl
 Description: Proxmox VE base library
  This package contains the base library used by other Proxmox VE components.
 Description: Proxmox VE base library
  This package contains the base library used by other Proxmox VE components.