line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Connection::Simple; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::Connection::Simple - Perl extension handling simple connection info within an application |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Net::Connection::Simple; |
10
|
|
|
|
|
|
|
my $c = Net::Connection::Simple->new(seenFirst => (time()-1800), seenLast => time()); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$c->protocols(Net::Protocol::Simple->new(protocol => tcp, layer => 4)); |
13
|
|
|
|
|
|
|
$c->protocols(Net::Protocol::Simple->new(protocol => 'ip', layer => 3)); |
14
|
|
|
|
|
|
|
$c->protocols(Net::Protocol::Simple->new(protocol => 'irc', layer => 7)); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$c->protocols({ |
17
|
|
|
|
|
|
|
1 => Net::Protocol::Simple->new(protocol => 6, layer => 4), |
18
|
|
|
|
|
|
|
2 => Net::Protocol::Simple->new(protocol => 'ip', layer => 3), |
19
|
|
|
|
|
|
|
3 => Net::Protocol::Simple->new(protocol => 'irc', layer => 7), |
20
|
|
|
|
|
|
|
}); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$c->protocols([ |
23
|
|
|
|
|
|
|
Net::Protocol::Simple->new(protocol => 6, layer => 4), |
24
|
|
|
|
|
|
|
Net::Protocol::Simple->new(protocol => 'ip', layer => 3), |
25
|
|
|
|
|
|
|
Net::Protocol::Simple->new(protocol => 'irc', layer => 7), |
26
|
|
|
|
|
|
|
]); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module created to handle simple information about connections. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
21843
|
use 5.008007; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
35
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
36
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
378
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Constructs the Connection object |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Accepts: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
protocols => [ARRAY|HASHREF|Net::Protocol::Simple] |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
0
|
|
|
0
|
1
|
|
my ($class,%data) = @_; |
54
|
0
|
|
|
|
|
|
my $self = {}; |
55
|
0
|
|
|
|
|
|
bless($self,$class); |
56
|
0
|
|
|
|
|
|
$self->protocols($data{protocols}); |
57
|
0
|
|
|
|
|
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 protocols |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns a HASHREF of the protocols composing the connection [See Net::Protocol::Simple] keyed by layer |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Accepts: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
HASHREF: |
67
|
|
|
|
|
|
|
{ $key => Net::Protocol::Simple(...), |
68
|
|
|
|
|
|
|
$key++ => Net::Protocol::Simple(...), |
69
|
|
|
|
|
|
|
$key++ => Net::Protocol::Simple(...), |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
ARRAY: |
73
|
|
|
|
|
|
|
[ |
74
|
|
|
|
|
|
|
Net::Protocol::Simple->new(...), |
75
|
|
|
|
|
|
|
Net::Protocol::Simple->new(...), |
76
|
|
|
|
|
|
|
Net::Protocol::Simple->new(...), |
77
|
|
|
|
|
|
|
] |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Net::Protocol::Simple: |
80
|
|
|
|
|
|
|
Net::Protocol::Simple->new(protocol => 6, layer => 4) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub protocols { |
85
|
0
|
|
|
0
|
1
|
|
my ($self,$v) = @_; |
86
|
0
|
0
|
|
|
|
|
if(defined($v)){ |
87
|
0
|
|
|
|
|
|
for(ref($v)){ |
88
|
0
|
0
|
|
|
|
|
if(/^HASH$/){ |
89
|
0
|
|
|
|
|
|
foreach my $x (keys %$v){ $self->protocols($v->{$x});} |
|
0
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
last; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
0
|
|
|
|
|
if(/^ARRAY$/){ |
93
|
0
|
|
|
|
|
|
foreach my $x (@{$v}) { $self->protocols($x); } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
last; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
0
|
|
|
|
|
if(/^Net::Protocol::Simple$/){ |
97
|
0
|
|
|
|
|
|
$self->{_protocols}->{$v->layer()} = $v; |
98
|
0
|
|
|
|
|
|
last; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
die('Protocols requires a Net::Protocol::Simple Obj to be passed!'); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
0
|
|
|
|
|
|
return $self->{_protocols}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |