line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
7
|
|
|
7
|
|
34
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
188
|
|
3
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
314
|
|
4
|
|
|
|
|
|
|
package Net::PcapWriter::UDP; |
5
|
7
|
|
|
7
|
|
35
|
use fields qw(flow l2prefix pktmpl writer); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
40
|
|
6
|
7
|
|
|
7
|
|
470
|
use Net::PcapWriter::IP; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
438
|
|
7
|
7
|
|
|
7
|
|
33
|
use Socket qw(AF_INET IPPROTO_UDP); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
1973
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
0
|
6
|
my ($class,$writer,$src,$sport,$dst,$dport) = @_; |
11
|
2
|
|
|
|
|
10
|
my $self = fields::new($class); |
12
|
|
|
|
|
|
|
$self->{flow} = [ |
13
|
|
|
|
|
|
|
# src, dst, sport, dport |
14
|
2
|
|
|
|
|
7437
|
[ $src,$dst,$sport,$dport ], |
15
|
|
|
|
|
|
|
[ $dst,$src,$dport,$sport ], |
16
|
|
|
|
|
|
|
]; |
17
|
2
|
|
|
|
|
7
|
$self->{writer} = $writer; |
18
|
2
|
|
|
|
|
11
|
$self->{l2prefix} = $self->{writer}->layer2prefix($src); |
19
|
|
|
|
|
|
|
$self->{pktmpl} = [ |
20
|
2
|
|
|
|
|
12
|
ip_packet( undef, $src, $dst, IPPROTO_UDP, 6), |
21
|
|
|
|
|
|
|
ip_packet( undef, $dst, $src, IPPROTO_UDP, 6), |
22
|
|
|
|
|
|
|
]; |
23
|
2
|
|
|
|
|
10
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub write { |
27
|
4
|
|
|
4
|
0
|
23
|
my ($self,$dir,$data,$timestamp) = @_; |
28
|
4
|
|
|
|
|
9
|
my $flow = $self->{flow}[$dir]; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
14
|
my $udp = pack("nnnna*", |
31
|
|
|
|
|
|
|
$flow->[2],$flow->[3], # sport,dport |
32
|
|
|
|
|
|
|
length($data)+8, |
33
|
|
|
|
|
|
|
0, # checksum |
34
|
|
|
|
|
|
|
$data # payload |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{writer}->packet( |
38
|
4
|
|
|
|
|
17
|
$self->{l2prefix} . $self->{pktmpl}[$dir]($udp), |
39
|
|
|
|
|
|
|
$timestamp |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|