line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# PODNAME: Net::DHCP::Packet::Attributes |
3
|
|
|
|
|
|
|
# Author : D. Hamstead |
4
|
|
|
|
|
|
|
# Original Author: F. van Dun, S. Hadinger |
5
|
|
|
|
|
|
|
# ABSTRACT: Attribute methods for Net::DHCP::Packet |
6
|
11
|
|
|
11
|
|
38
|
use strict; |
|
11
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
245
|
|
7
|
11
|
|
|
11
|
|
31
|
use warnings; |
|
11
|
|
|
|
|
10
|
|
|
11
|
|
|
|
|
218
|
|
8
|
11
|
|
|
11
|
|
99
|
use 5.8.0; |
|
11
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Net::DHCP::Packet::Attributes; |
11
|
|
|
|
|
|
|
$Net::DHCP::Packet::Attributes::VERSION = '0.7_007'; # TRIAL |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$Net::DHCP::Packet::Attributes::VERSION = '0.7007';# standard module declaration |
14
|
|
|
|
|
|
|
our ( @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS ); |
15
|
11
|
|
|
11
|
|
35
|
use Exporter; |
|
11
|
|
|
|
|
10
|
|
|
11
|
|
|
|
|
723
|
|
16
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
@EXPORT = qw( ); |
18
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
19
|
|
|
|
|
|
|
comment op htype hlen hops xid secs flags ciaddr |
20
|
|
|
|
|
|
|
ciaddrRaw yiaddr yiaddrRaw siaddr siaddrRaw giaddr giaddrRaw |
21
|
|
|
|
|
|
|
chaddr chaddrRaw sname file isDhcp padding |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => \@EXPORT_OK ); |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
11
|
|
33
|
use Carp qw/ carp /; |
|
11
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
404
|
|
26
|
11
|
|
|
11
|
|
3570
|
use Net::DHCP::Packet::IPv4Utils qw( packinet unpackinet ); |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
6426
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#======================================================================= |
29
|
|
|
|
|
|
|
# comment attribute : enables transaction number identification |
30
|
|
|
|
|
|
|
sub comment { |
31
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
32
|
2
|
50
|
|
|
|
8
|
if (@_) { $self->{comment} = shift } |
|
0
|
|
|
|
|
0
|
|
33
|
2
|
|
|
|
|
11
|
return $self->{comment}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# op attribute |
37
|
|
|
|
|
|
|
sub op { |
38
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
39
|
3
|
100
|
|
|
|
9
|
if (@_) { $self->{op} = shift } |
|
1
|
|
|
|
|
1
|
|
40
|
3
|
|
|
|
|
7
|
return $self->{op}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# htype attribute |
44
|
|
|
|
|
|
|
sub htype { |
45
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
46
|
3
|
100
|
|
|
|
10
|
if (@_) { $self->{htype} = shift } |
|
1
|
|
|
|
|
1
|
|
47
|
3
|
|
|
|
|
8
|
return $self->{htype}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# hlen attribute |
51
|
|
|
|
|
|
|
sub hlen { |
52
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
53
|
3
|
100
|
|
|
|
12
|
if (@_) { $self->{hlen} = shift } |
|
1
|
|
|
|
|
2
|
|
54
|
3
|
50
|
|
|
|
7
|
if ( $self->{hlen} < 0 ) { |
55
|
0
|
|
|
|
|
0
|
carp( 'hlen must not be < 0 (currently ' . $self->{hlen} . ')' ); |
56
|
0
|
|
|
|
|
0
|
$self->{hlen} = 0; |
57
|
|
|
|
|
|
|
} |
58
|
3
|
50
|
|
|
|
7
|
if ( $self->{hlen} > 16 ) { |
59
|
0
|
|
|
|
|
0
|
carp( 'hlen must not be > 16 (currently ' . $self->{hlen} . ')' ); |
60
|
0
|
|
|
|
|
0
|
$self->{hlen} = 16; |
61
|
|
|
|
|
|
|
} |
62
|
3
|
|
|
|
|
8
|
return $self->{hlen}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# hops attribute |
66
|
|
|
|
|
|
|
sub hops { |
67
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
68
|
3
|
100
|
|
|
|
8
|
if (@_) { $self->{hops} = shift } |
|
1
|
|
|
|
|
2
|
|
69
|
3
|
|
|
|
|
7
|
return $self->{hops}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# xid attribute |
73
|
|
|
|
|
|
|
sub xid { |
74
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
75
|
3
|
100
|
|
|
|
9
|
if (@_) { $self->{xid} = shift } |
|
1
|
|
|
|
|
2
|
|
76
|
3
|
|
|
|
|
7
|
return $self->{xid}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# secs attribute |
80
|
|
|
|
|
|
|
sub secs { |
81
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
82
|
1
|
50
|
|
|
|
5
|
if (@_) { $self->{secs} = shift } |
|
0
|
|
|
|
|
0
|
|
83
|
1
|
|
|
|
|
3
|
return $self->{secs}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# flags attribute |
87
|
|
|
|
|
|
|
sub flags { |
88
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
89
|
2
|
100
|
|
|
|
5
|
if (@_) { $self->{flags} = shift } |
|
1
|
|
|
|
|
1
|
|
90
|
2
|
|
|
|
|
5
|
return $self->{flags}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# ciaddr attribute |
94
|
|
|
|
|
|
|
sub ciaddr { |
95
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
96
|
3
|
100
|
|
|
|
8
|
if (@_) { $self->{ciaddr} = packinet(shift) } |
|
1
|
|
|
|
|
4
|
|
97
|
3
|
|
|
|
|
10
|
return unpackinet( $self->{ciaddr} ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# ciaddr attribute, Raw version |
101
|
|
|
|
|
|
|
sub ciaddrRaw { |
102
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
103
|
2
|
50
|
|
|
|
8
|
if (@_) { $self->{ciaddr} = shift } |
|
0
|
|
|
|
|
0
|
|
104
|
2
|
|
|
|
|
6
|
return $self->{ciaddr}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# yiaddr attribute |
108
|
|
|
|
|
|
|
sub yiaddr { |
109
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
110
|
3
|
100
|
|
|
|
8
|
if (@_) { $self->{yiaddr} = packinet(shift) } |
|
1
|
|
|
|
|
2
|
|
111
|
3
|
|
|
|
|
9
|
return unpackinet( $self->{yiaddr} ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# yiaddr attribute, Raw version |
115
|
|
|
|
|
|
|
sub yiaddrRaw { |
116
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
117
|
2
|
50
|
|
|
|
6
|
if (@_) { $self->{yiaddr} = shift } |
|
0
|
|
|
|
|
0
|
|
118
|
2
|
|
|
|
|
6
|
return $self->{yiaddr}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# siaddr attribute |
122
|
|
|
|
|
|
|
sub siaddr { |
123
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
124
|
3
|
100
|
|
|
|
8
|
if (@_) { $self->{siaddr} = packinet(shift) } |
|
1
|
|
|
|
|
2
|
|
125
|
3
|
|
|
|
|
8
|
return unpackinet( $self->{siaddr} ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# siaddr attribute, Raw version |
129
|
|
|
|
|
|
|
sub siaddrRaw { |
130
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
131
|
2
|
50
|
|
|
|
7
|
if (@_) { $self->{siaddr} = shift } |
|
0
|
|
|
|
|
0
|
|
132
|
2
|
|
|
|
|
6
|
return $self->{siaddr}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# giaddr attribute |
136
|
|
|
|
|
|
|
sub giaddr { |
137
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
138
|
3
|
100
|
|
|
|
9
|
if (@_) { $self->{giaddr} = packinet(shift) } |
|
1
|
|
|
|
|
3
|
|
139
|
3
|
|
|
|
|
12
|
return unpackinet( $self->{giaddr} ); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# giaddr attribute, Raw version |
143
|
|
|
|
|
|
|
sub giaddrRaw { |
144
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
145
|
2
|
50
|
|
|
|
6
|
if (@_) { $self->{giaddr} = shift } |
|
0
|
|
|
|
|
0
|
|
146
|
2
|
|
|
|
|
6
|
return $self->{giaddr}; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# chaddr attribute |
150
|
|
|
|
|
|
|
sub chaddr { |
151
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
152
|
3
|
100
|
|
|
|
9
|
if (@_) { $self->{chaddr} = pack( 'H*', shift ) } |
|
1
|
|
|
|
|
40
|
|
153
|
3
|
|
|
|
|
16
|
return unpack( 'H*', $self->{chaddr} ); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# chaddr attribute, Raw version |
157
|
|
|
|
|
|
|
sub chaddrRaw { |
158
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
159
|
1
|
50
|
|
|
|
3
|
if (@_) { $self->{chaddr} = shift } |
|
0
|
|
|
|
|
0
|
|
160
|
1
|
|
|
|
|
3
|
return $self->{chaddr}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# sname attribute |
164
|
|
|
|
|
|
|
sub sname { |
165
|
11
|
|
|
11
|
|
46
|
use bytes; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
29
|
|
166
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
167
|
3
|
100
|
|
|
|
7
|
if (@_) { $self->{sname} = shift } |
|
1
|
|
|
|
|
2
|
|
168
|
3
|
100
|
|
|
|
8
|
if ( length( $self->{sname} ) > 63 ) { |
169
|
|
|
|
|
|
|
carp( sprintf q|'sname' must not be > 63 bytes, (currently %d)|, |
170
|
1
|
|
|
|
|
11
|
length( $self->{sname} )); |
171
|
1
|
|
|
|
|
349
|
$self->{sname} = substr( $self->{sname}, 0, 63 ); |
172
|
|
|
|
|
|
|
} |
173
|
3
|
|
|
|
|
12
|
return $self->{sname}; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# file attribute |
177
|
|
|
|
|
|
|
sub file { |
178
|
11
|
|
|
11
|
|
826
|
use bytes; |
|
11
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
26
|
|
179
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
180
|
3
|
100
|
|
|
|
10
|
if (@_) { $self->{file} = shift } |
|
1
|
|
|
|
|
3
|
|
181
|
3
|
100
|
|
|
|
11
|
if ( length( $self->{file} ) > 127 ) { |
182
|
|
|
|
|
|
|
carp( sprintf q|'file' must not be > 127 bytes, (currently %d)|, |
183
|
1
|
|
|
|
|
29
|
length( $self->{file} )); |
184
|
1
|
|
|
|
|
487
|
$self->{file} = substr( $self->{file}, 0, 127 ); |
185
|
|
|
|
|
|
|
} |
186
|
3
|
|
|
|
|
9
|
return $self->{file}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# is it DHCP or BOOTP |
190
|
|
|
|
|
|
|
# -> DHCP needs magic cookie and options |
191
|
|
|
|
|
|
|
sub isDhcp { |
192
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
193
|
2
|
50
|
|
|
|
7
|
if (@_) { $self->{isDhcp} = shift } |
|
0
|
|
|
|
|
0
|
|
194
|
2
|
|
|
|
|
6
|
return $self->{isDhcp}; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# padding attribute |
198
|
|
|
|
|
|
|
sub padding { |
199
|
4
|
|
|
4
|
1
|
14
|
my $self = shift; |
200
|
4
|
100
|
|
|
|
11
|
if (@_) { $self->{padding} = shift } |
|
2
|
|
|
|
|
4
|
|
201
|
4
|
|
|
|
|
10
|
return $self->{padding}; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#======================================================================= |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
__END__ |