line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# network::icmp Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Network::Icmp; |
7
|
1
|
|
|
1
|
|
693
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use base qw(Metabrik::Network::Frame); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
509
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable ping redirect doubleredirect mitm) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
commands => { |
19
|
|
|
|
|
|
|
ping => [ qw(ipv4_address) ], |
20
|
|
|
|
|
|
|
half_poison => [ ], |
21
|
|
|
|
|
|
|
full_poison => [ ], |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
require_modules => { |
24
|
|
|
|
|
|
|
'Metabrik::Network::Write' => [ ], |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub brik_use_properties { |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return { |
33
|
0
|
|
0
|
|
|
|
attributes_default => { |
34
|
|
|
|
|
|
|
device => defined($self->global) && $self->global->device || 'eth0', |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub ping { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
my ($target) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('ping', $target) or return; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $ipv4 = $self->ipv4; |
46
|
0
|
|
|
|
|
|
$ipv4->dst($target); |
47
|
0
|
|
|
|
|
|
$ipv4->protocol(0x01); # ICMPv4 |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $icmpv4 = $self->icmpv4; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $echo1 = $self->echo_icmpv4; |
52
|
0
|
|
|
|
|
|
$echo1->identifier(1); |
53
|
0
|
|
|
|
|
|
my $echo2 = $self->echo_icmpv4; |
54
|
0
|
|
|
|
|
|
$echo2->identifier(2); |
55
|
0
|
|
|
|
|
|
my $echo3 = $self->echo_icmpv4; |
56
|
0
|
|
|
|
|
|
$echo3->identifier(3); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $frame1 = $self->frame([ $ipv4, $icmpv4, $echo1 ]); |
59
|
0
|
|
|
|
|
|
my $frame2 = $self->frame([ $ipv4, $icmpv4, $echo2 ]); |
60
|
0
|
|
|
|
|
|
my $frame3 = $self->frame([ $ipv4, $icmpv4, $echo3 ]); |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
my $nw = Metabrik::Network::Write->new_from_brik_init($self) or return; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# We must use different Net::Frame::Simple objects so recv() method will work |
65
|
0
|
|
|
|
|
|
for my $f ($frame1, $frame2, $frame3) { |
66
|
0
|
0
|
|
|
|
|
my $r = $nw->fnsend_reply($f) |
67
|
|
|
|
|
|
|
or return $self->log->error("ping: network::write fnsend_reply failed"); |
68
|
0
|
0
|
|
|
|
|
if (defined($r)) { |
69
|
0
|
|
|
|
|
|
print $r->print."\n"; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
sleep(1); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub half_poison { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->log->info("TODO"); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub full_poison { |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->log->info("TODO"); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |