66 |
return $value; |
return $value; |
67 |
} |
} |
68 |
|
|
69 |
|
sub all_conf { |
70 |
|
my $ip = shift; |
71 |
|
my $path = ip_path $ip || return; |
72 |
|
my $conf; |
73 |
|
foreach my $file ( glob("$path/*") ) { |
74 |
|
my $name = $file; |
75 |
|
$name =~ s{^.+/([^/]+)$}{$1}; |
76 |
|
$conf->{ $name } = read_file $file; |
77 |
|
} |
78 |
|
return $conf; |
79 |
|
} |
80 |
sub next_ip($) { |
sub next_ip($) { |
81 |
my $mac = shift; |
my $mac = shift; |
82 |
|
|
103 |
sub save_ip_mac { |
sub save_ip_mac { |
104 |
my ($ip,$mac) = @_; |
my ($ip,$mac) = @_; |
105 |
|
|
106 |
mkdir ip_path($ip); |
mkdir ip_path($ip) unless -e ip_path($ip); |
107 |
|
|
108 |
my $mac_path = mac_path($mac); |
my $mac_path = mac_path($mac); |
109 |
unlink $mac_path if -e $mac_path; # XXX audit? |
unlink $mac_path if -l $mac_path; # XXX audit? |
110 |
symlink ip_path($ip), $mac_path; |
symlink ip_path($ip), $mac_path; |
111 |
write_file ip_path($ip,'mac'), $mac; |
write_file ip_path($ip,'mac'), $mac; |
112 |
} |
} |