line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DHCP::Info::Obj; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::DHCP::Info::Obj - Storage module for dhcp-information |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.01 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module contains methods that can access the data C<Net::DHCP::Info> |
14
|
|
|
|
|
|
|
has extracted. It inherits from C<NetAddr::IP>, so it provides all the methods |
15
|
|
|
|
|
|
|
from that package as well. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Net::DHCP::Info::Obj; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $ip = "127.0.0.1"; |
22
|
|
|
|
|
|
|
my $obj = Net::DHCP::Info::Obj->new($ip); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$obj->mac("aa:b:02:3d:0:01"); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
print $obj->mac; # prints the above mac |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
131
|
|
31
|
4
|
|
|
4
|
|
115
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
98
|
|
32
|
4
|
|
|
4
|
|
9594
|
use DateTime; |
|
4
|
|
|
|
|
1169078
|
|
|
4
|
|
|
|
|
1481
|
|
33
|
4
|
|
|
4
|
|
20928
|
use NetAddr::IP; |
|
4
|
|
|
|
|
263630
|
|
|
4
|
|
|
|
|
23
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our @ISA = qw/NetAddr::IP/; |
36
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
37
|
|
|
|
|
|
|
our $AUTOLOAD; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 binding |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns the dhcp leases binding. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 circuit_id |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns the dhcp leases circuit id. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 hostname |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns the client-hostname |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 mac |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the dhcp leases mac. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 range |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns a list of ranges in a subnet in this format: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
[$low_ip, $high_ip] |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 remote_id |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns the dhcp leases remote id. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 routers |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns a list of routers in a subnet. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
BEGIN { ## no critic # for strict |
74
|
4
|
|
|
4
|
|
15
|
my @keys = qw/ |
75
|
|
|
|
|
|
|
circuit_id binding ends hostname |
76
|
|
|
|
|
|
|
mac range remote_id routers starts |
77
|
|
|
|
|
|
|
/; |
78
|
|
|
|
|
|
|
|
79
|
4
|
|
|
4
|
|
733
|
no strict 'refs'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
331
|
|
80
|
|
|
|
|
|
|
|
81
|
4
|
|
|
|
|
10
|
for my $k (@keys) { |
82
|
|
|
|
|
|
|
*$k = sub { |
83
|
16
|
|
|
16
|
|
4624
|
my $self = shift; |
84
|
16
|
100
|
|
|
|
876
|
$self->{$k} = $_[0] if(defined $_[0]); |
85
|
16
|
|
|
|
|
110
|
$self->{$k}; |
86
|
|
|
|
|
|
|
} |
87
|
36
|
|
|
|
|
1220
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 add_range |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub add_range { |
95
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
96
|
1
|
|
|
|
|
3
|
my $range = shift; |
97
|
|
|
|
|
|
|
|
98
|
1
|
50
|
|
|
|
5
|
return unless(ref $range eq 'ARRAY'); |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
2
|
push @{ $self->{'range'} }, $range; |
|
1
|
|
|
|
|
27
|
|
101
|
1
|
|
|
|
|
6
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 starts |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 starts_datetime |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns the dhcp leases start time as string / DateTime object. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub starts_datetime { |
113
|
1
|
|
|
1
|
1
|
29
|
my $self = shift; |
114
|
1
|
|
|
|
|
5
|
return $self->_datetime($self->starts); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 ends |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 ends_datetime |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the dhcp leases end time as string / DateTime object. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub ends_datetime { |
126
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
127
|
0
|
|
|
|
|
0
|
return $self->_datetime($self->ends); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _datetime { |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
### init |
133
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
134
|
1
|
|
|
|
|
11
|
my @time = split m"[\s\:/]"mx, shift; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
14
|
return DateTime->new( |
137
|
|
|
|
|
|
|
year => $time[0], |
138
|
|
|
|
|
|
|
month => $time[1], |
139
|
|
|
|
|
|
|
day => $time[2], |
140
|
|
|
|
|
|
|
hour => $time[3], |
141
|
|
|
|
|
|
|
minute => $time[4], |
142
|
|
|
|
|
|
|
second => $time[5], |
143
|
|
|
|
|
|
|
time_zone => 'UTC', |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Jan Henning Thorsen, C<< <pm at flodhest.net> >> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Copyright 2007 Jan Henning Thorsen, all rights reserved. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
156
|
|
|
|
|
|
|
under the same terms as Perl itself. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |