line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Tshark::Packet;
|
2
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.04';
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
415
|
use XML::Simple;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use base 'Net::Tshark::Field';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new
|
11
|
|
|
|
|
|
|
{
|
12
|
|
|
|
|
|
|
my ($class, $string) = @_;
|
13
|
|
|
|
|
|
|
return if !defined $string;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Parse the string as PDML (Packet Description Markup Language)
|
16
|
|
|
|
|
|
|
my $parsed_xml = XMLin($string, ForceArray => 1, KeyAttr => 0);
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Tie a new hash to this package so we can access parts of the parsed
|
19
|
|
|
|
|
|
|
# PDML using hash notation (e.g. $packet->{ip}). Note that the TIEHASH
|
20
|
|
|
|
|
|
|
# subroutine does the actual construction of the object.
|
21
|
|
|
|
|
|
|
my $self = $class->SUPER::new($parsed_xml);
|
22
|
|
|
|
|
|
|
return bless $self, $class;
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub received_time
|
26
|
|
|
|
|
|
|
{
|
27
|
|
|
|
|
|
|
my ($self) = @_;
|
28
|
|
|
|
|
|
|
return $self->{frame}->{time_relative};
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Avoid having to check for the defined-ness of fields by simply
|
32
|
|
|
|
|
|
|
# passing in an array of field names and returning undef if any
|
33
|
|
|
|
|
|
|
# are not defined
|
34
|
|
|
|
|
|
|
sub get
|
35
|
|
|
|
|
|
|
{
|
36
|
|
|
|
|
|
|
my ($self, @field_names) = @_;
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $value = $self;
|
39
|
|
|
|
|
|
|
foreach my $field_name (@field_names)
|
40
|
|
|
|
|
|
|
{
|
41
|
|
|
|
|
|
|
$value = $value->{$field_name};
|
42
|
|
|
|
|
|
|
last if !defined $value;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $value;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1;
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__
|