mirror of
https://git.proxmox.com/git/pve-common
synced 2025-04-30 23:46:22 +00:00
add PVE::Tools::random_ether_addr()
This commit is contained in:
parent
67799787db
commit
a413a515c5
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
RELEASE=2.0
|
RELEASE=2.0
|
||||||
|
|
||||||
VERSION=1.0
|
VERSION=1.0
|
||||||
PKGREL=5
|
PKGREL=6
|
||||||
|
|
||||||
PACKAGE=libpve-common-perl
|
PACKAGE=libpve-common-perl
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ use Fcntl qw(:DEFAULT :flock);
|
|||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
use URI::Escape;
|
use URI::Escape;
|
||||||
use Encode;
|
use Encode;
|
||||||
|
use Digest::SHA1;
|
||||||
|
|
||||||
our @EXPORT_OK = qw(
|
our @EXPORT_OK = qw(
|
||||||
lock_file
|
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;
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -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
|
libpve-common-perl (1.0-5) unstable; urgency=low
|
||||||
|
|
||||||
* cleanups (prepare for beta release)
|
* cleanups (prepare for beta release)
|
||||||
|
2
debian/control
vendored
2
debian/control
vendored
@ -7,6 +7,6 @@ Standards-Version: 3.8.4
|
|||||||
|
|
||||||
Package: libpve-common-perl
|
Package: libpve-common-perl
|
||||||
Architecture: all
|
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
|
Description: Proxmox VE base library
|
||||||
This package contains the base library used by other Proxmox VE components.
|
This package contains the base library used by other Proxmox VE components.
|
||||||
|
Loading…
Reference in New Issue
Block a user