line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnutella::Packet::Query;
|
2
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
66
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw/$VERSION $AUTOLOAD/;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
472
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = $VERSION = "0.1";
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Use AUTOHANDLER to supply generic attribute methods
|
9
|
|
|
|
|
|
|
#
|
10
|
|
|
|
|
|
|
sub AUTOLOAD {
|
11
|
0
|
|
|
0
|
|
|
my $self = shift;
|
12
|
0
|
|
|
|
|
|
my $attr = $AUTOLOAD;
|
13
|
0
|
|
|
|
|
|
$attr =~ s/.*:://;
|
14
|
0
|
0
|
|
|
|
|
return unless $attr =~ /[^A-Z]/; # skip DESTROY and all-cap methods
|
15
|
0
|
0
|
|
|
|
|
croak sprintf "invalid attribute method: %s->%s()", ref($self), $attr unless exists $self->{_attr}->{lc $attr};
|
16
|
0
|
0
|
|
|
|
|
$self->{_attr}->{lc $attr} = shift if @_;
|
17
|
0
|
|
|
|
|
|
return $self->{_attr}->{lc $attr};
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new {
|
21
|
0
|
|
|
0
|
0
|
|
my $proto = shift;
|
22
|
0
|
|
|
|
|
|
my %args = @_;
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $self = {
|
25
|
|
|
|
|
|
|
_attr => {
|
26
|
|
|
|
|
|
|
msgid => [],
|
27
|
|
|
|
|
|
|
ttl => 7,
|
28
|
|
|
|
|
|
|
hops => 1,
|
29
|
|
|
|
|
|
|
function => 128,
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
minspeed => 0,
|
32
|
|
|
|
|
|
|
query => "\x00",
|
33
|
|
|
|
|
|
|
},
|
34
|
|
|
|
|
|
|
};
|
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
bless $self, $proto;
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
foreach my $key (keys %args) {
|
39
|
0
|
|
|
|
|
|
my $lkey = lc $key;
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->$lkey($args{$key});
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub parse {
|
48
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
49
|
0
|
|
|
|
|
|
my $data = shift;
|
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $minspeed = unpack("S", substr($data, 0, 2, ''));
|
52
|
0
|
|
|
|
|
|
my $query = substr($data, 0, index($data, "\x00"), '');
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->minspeed($minspeed);
|
55
|
0
|
|
|
|
|
|
$self->query($query);
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub format {
|
59
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
60
|
0
|
|
|
|
|
|
my $data;
|
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$data .= pack("S", $self->minspeed);
|
63
|
0
|
|
|
|
|
|
$data .= $self->query;
|
64
|
0
|
0
|
|
|
|
|
$data .= $data =~ /\x00$/ ? "" : "\x00";
|
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return $data;
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1;
|