71 |
|
|
72 |
} |
} |
73 |
|
|
74 |
|
sub ip_from_mac { |
75 |
|
my $mac = shift; |
76 |
|
|
77 |
|
$mac = lc $mac; |
78 |
|
$mac =~ s{:}{}g; |
79 |
|
|
80 |
|
my $mac_path = "$server::conf/mac/$mac"; |
81 |
|
return unless -e $mac_path; |
82 |
|
|
83 |
|
my $ip; |
84 |
|
|
85 |
|
if ( -f $mac_path ) { |
86 |
|
$ip = read_file $mac_path; |
87 |
|
unlink $mac_path; |
88 |
|
symlink "$server::conf/ip/$ip", $mac_path; |
89 |
|
warn "I: upgrade to mac symlink $mac_path\n"; |
90 |
|
} elsif ( -l $mac_path ) { |
91 |
|
$ip = readlink $mac_path; |
92 |
|
$ip =~ s{^.+/([^/]+)$}{$1}; |
93 |
|
} else { |
94 |
|
die "$mac_path not file or symlink"; |
95 |
|
} |
96 |
|
|
97 |
|
return $ip; |
98 |
|
} |
99 |
|
|
100 |
1; |
1; |