line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
7
|
|
|
7
|
|
50
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
216
|
|
3
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
296
|
|
4
|
|
|
|
|
|
|
package Net::PcapWriter::UDP; |
5
|
7
|
|
|
7
|
|
51
|
use fields qw(flow l2prefix pktmpl writer); |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
44
|
|
6
|
7
|
|
|
7
|
|
548
|
use Net::PcapWriter::IP; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
504
|
|
7
|
7
|
|
|
7
|
|
43
|
use Socket qw(AF_INET IPPROTO_UDP); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1570
|
|
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
|
|
|
|
|
5542
|
[ $src,$dst,$sport,$dport ], |
15
|
|
|
|
|
|
|
[ $dst,$src,$dport,$sport ], |
16
|
|
|
|
|
|
|
]; |
17
|
2
|
|
|
|
|
6
|
$self->{writer} = $writer; |
18
|
2
|
|
|
|
|
10
|
$self->{l2prefix} = $self->{writer}->layer2prefix($src); |
19
|
|
|
|
|
|
|
$self->{pktmpl} = [ |
20
|
2
|
|
|
|
|
10
|
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
|
26
|
my ($self,$dir,$data,$timestamp) = @_; |
28
|
4
|
|
|
|
|
10
|
my $flow = $self->{flow}[$dir]; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
17
|
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
|
|
|
|
|
16
|
$self->{l2prefix} . $self->{pktmpl}[$dir]($udp), |
39
|
|
|
|
|
|
|
$timestamp |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|