line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ISC::DHCPd::Config::Subnet; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Subnet - Subnet config parameter |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role> for methods and attributes without |
10
|
|
|
|
|
|
|
documentation. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
An instance from this class, comes from / will produce: |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
subnet $address_attribute_value \ |
15
|
|
|
|
|
|
|
netmask $address_attribute_value { |
16
|
|
|
|
|
|
|
$options_attribute_value |
17
|
|
|
|
|
|
|
$filename_attribute_value |
18
|
|
|
|
|
|
|
$range_attribute_value |
19
|
|
|
|
|
|
|
$pool_attribute_value |
20
|
|
|
|
|
|
|
$hosts_attribute_value |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config/SYNOPSIS>. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
25
|
|
|
25
|
|
18246
|
use Moose; |
|
25
|
|
|
|
|
61
|
|
|
25
|
|
|
|
|
192
|
|
30
|
25
|
|
|
25
|
|
150932
|
use NetAddr::IP; |
|
25
|
|
|
|
|
548689
|
|
|
25
|
|
|
|
|
133
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
with 'Net::ISC::DHCPd::Config::Role'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 children |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config/children>. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub children { |
41
|
77
|
|
|
77
|
1
|
589
|
return qw/ |
42
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Host |
43
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Pool |
44
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Range |
45
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Filename |
46
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Option |
47
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Class |
48
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::KeyValue |
49
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Block |
50
|
|
|
|
|
|
|
/; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
__PACKAGE__->create_children(__PACKAGE__->children()); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 options |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
A list of parsed L<Net::ISC::DHCPd::Config::Option> objects. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 ranges |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
A list of parsed L<Net::ISC::DHCPd::Config::Range> objects. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 hosts |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
A list of parsed L<Net::ISC::DHCPd::Config::Host> objects. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 filenames |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
A list of parsed L<Net::ISC::DHCPd::Config::Filename> objects. There can |
71
|
|
|
|
|
|
|
be only be one node in this list. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
before add_filename => sub { |
76
|
|
|
|
|
|
|
if(0 < int @{ $_[0]->filenames }) { |
77
|
|
|
|
|
|
|
confess 'Subnet cannot have more than one filename'; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 pools |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
A list of parsed L<Net::ISC::DHCPd::Config::Pool> objects. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 address |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This attribute holds an instance of L<NetAddr::IP>, and represents |
88
|
|
|
|
|
|
|
the ip address of this subnet. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has address => ( |
93
|
|
|
|
|
|
|
is => 'ro', |
94
|
|
|
|
|
|
|
isa => 'Object', |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 regex |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config/regex>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
our $regex = qr{^ \s* subnet \s+ (\S+) \s+ netmask \s+ (\S+) }x; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 captured_to_args |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/captured_to_args>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub captured_to_args { |
114
|
13
|
|
|
13
|
1
|
146
|
return { address => NetAddr::IP->new(@_) }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 generate |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/generate>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub generate { |
124
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
125
|
3
|
|
|
|
|
76
|
my $net = $self->address; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return( |
128
|
3
|
|
|
|
|
42
|
'subnet ' .$net->addr .' netmask ' .$net->mask .' {', |
129
|
|
|
|
|
|
|
$self->_generate_config_from_children, |
130
|
|
|
|
|
|
|
'}', |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
142
|
|
|
|
|
|
|
1; |