9 |
|
|
10 |
use server; |
use server; |
11 |
use format; |
use format; |
12 |
|
use ip; |
13 |
|
|
14 |
our $debug = $server::debug; |
our $debug = $server::debug; |
15 |
|
|
80 |
} |
} |
81 |
sub next_ip($) { |
sub next_ip($) { |
82 |
my $mac = shift; |
my $mac = shift; |
83 |
|
$mac = format::mac($mac); |
84 |
|
|
85 |
my $p = Net::Ping->new; |
my $p = Net::Ping->new; |
86 |
|
|
104 |
|
|
105 |
sub save_ip_mac { |
sub save_ip_mac { |
106 |
my ($ip,$mac) = @_; |
my ($ip,$mac) = @_; |
107 |
|
$mac = format::mac($mac); |
108 |
|
|
109 |
mkdir ip_path($ip) unless -e ip_path($ip); |
mkdir ip_path($ip) unless -e ip_path($ip); |
110 |
|
|
116 |
|
|
117 |
sub ip_from_mac($) { |
sub ip_from_mac($) { |
118 |
my $mac = shift; |
my $mac = shift; |
119 |
|
$mac = format::mac($mac); |
|
$mac = lc $mac; |
|
|
$mac =~ s{:}{}g; |
|
120 |
|
|
121 |
my $mac_path = mac_path $mac; |
my $mac_path = mac_path $mac; |
122 |
return unless -e $mac_path; |
return unless -e $mac_path; |
150 |
symlink ip_path($new), mac_path($mac); |
symlink ip_path($new), mac_path($mac); |
151 |
} |
} |
152 |
|
|
153 |
|
sub all_ips { |
154 |
|
sort { ip::to_int($a) cmp ip::to_int($b) } |
155 |
|
map { |
156 |
|
my $ip = $_; |
157 |
|
$ip =~ s{^.+/ip/}{}; |
158 |
|
$ip; |
159 |
|
} glob("$server::conf/ip/*") |
160 |
|
} |
161 |
|
|
162 |
1; |
1; |