line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ISC::DHCPd::Config::OptionCode; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::OptionCode - Optionspace config param data |
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 one of the |
13
|
|
|
|
|
|
|
lines below, dependent on L</quoted>. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
option $prefix_attribute_value.$name_attribute_value \ |
16
|
|
|
|
|
|
|
code $code_attribute_value = $value_attribute_value; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
option $prefix_attribute_value.$name_attribute_value \ |
19
|
|
|
|
|
|
|
code $code_attribute_value = "$value_attribute_value"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This used to be under OptionSpace, but they can actually be seperated in |
22
|
|
|
|
|
|
|
dhcpd.conf files, which means they need to be parsed seperately. This |
23
|
|
|
|
|
|
|
actually makes the parsing easier because they're treated as individual lines. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
There is no real difference between these and normal options, but I'm leaving |
26
|
|
|
|
|
|
|
them seperate in the parser to keep things easy. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config> for synopsis. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
24
|
|
|
24
|
|
21940
|
use Moose; |
|
24
|
|
|
|
|
64
|
|
|
24
|
|
|
|
|
230
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
with 'Net::ISC::DHCPd::Config::Role'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 prefix |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Human readable prefix of this option. This is the parent of the option. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has prefix => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => 'Str', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 name |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Human readable name of this option, without parent name prefix |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has name => ( |
59
|
|
|
|
|
|
|
is => 'ro', |
60
|
|
|
|
|
|
|
isa => 'Str', |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 code |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Computer readable code for this option. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has code => ( |
70
|
|
|
|
|
|
|
is => 'ro', |
71
|
|
|
|
|
|
|
isa => 'Int', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 value |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Value of the option, as a string. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has value => ( |
81
|
|
|
|
|
|
|
is => 'ro', |
82
|
|
|
|
|
|
|
isa => 'Str', |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 quoted |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This flag tells if the option value should be quoted or not. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has quoted => ( |
92
|
|
|
|
|
|
|
is => 'ro', |
93
|
|
|
|
|
|
|
isa => 'Bool', |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 regex |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/regex>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
sub regex { |
102
|
73
|
|
|
73
|
1
|
575
|
qr{^\s* option \s+ (\S+) \s+ code \s+ (\d+) \s+ = \s+ (.*) ;}x; |
103
|
|
|
|
|
|
|
} |
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
|
15
|
|
|
15
|
1
|
32
|
my $name = shift; |
115
|
15
|
|
|
|
|
28
|
my $code = shift; |
116
|
15
|
|
|
|
|
34
|
my $value = shift; |
117
|
15
|
|
|
|
|
34
|
my %values; |
118
|
15
|
|
|
|
|
25
|
my $quoted = 0; |
119
|
15
|
100
|
|
|
|
83
|
if ($name =~ /(\S+)\.(\S+)/) { |
120
|
10
|
|
|
|
|
26
|
$name = $2; |
121
|
10
|
|
|
|
|
34
|
$values{prefix} = $1; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
15
|
50
|
|
|
|
75
|
$quoted = 1 if($value =~ s/^"(.*)"$/$1/g); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return { |
127
|
15
|
|
|
|
|
114
|
%values, |
128
|
|
|
|
|
|
|
name => $name, |
129
|
|
|
|
|
|
|
code => $code, |
130
|
|
|
|
|
|
|
value => $value, |
131
|
|
|
|
|
|
|
quoted => $quoted, |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 generate |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/generate>. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub generate { |
142
|
6
|
|
|
6
|
1
|
13
|
my $self = shift; |
143
|
|
|
|
|
|
|
|
144
|
6
|
100
|
|
|
|
212
|
if (defined($self->prefix)) { |
145
|
3
|
|
|
|
|
121
|
return sprintf('option %s.%s code %i = %s;', |
146
|
|
|
|
|
|
|
$self->prefix, |
147
|
|
|
|
|
|
|
$self->name, |
148
|
|
|
|
|
|
|
$self->code, |
149
|
|
|
|
|
|
|
$self->value, |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} else { |
152
|
3
|
|
|
|
|
115
|
return sprintf('option %s code %i = %s;', |
153
|
|
|
|
|
|
|
$self->name, |
154
|
|
|
|
|
|
|
$self->code, |
155
|
|
|
|
|
|
|
$self->value, |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd>. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |