Network/Icmp.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Network/Http.pm ↑ Summary Network/Linux/Iptables.pm »
1 #
2 # $Id$
3 #
4 # network::icmp Brik
5 #
6 package Metabrik::Network::Icmp;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Network::Frame);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable ping redirect doubleredirect mitm) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
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 my $self = shift;
31  
32 return {
33 attributes_default => {
34 device => defined($self->global) && $self->global->device || 'eth0',
35 },
36 };
37 }
38  
39 sub ping {
40 my $self = shift;
41 my ($target) = @_;
42  
43 $self->brik_help_run_undef_arg('ping', $target) or return;
44  
45 my $ipv4 = $self->ipv4;
46 $ipv4->dst($target);
47 $ipv4->protocol(0x01); # ICMPv4
48  
49 my $icmpv4 = $self->icmpv4;
50  
51 my $echo1 = $self->echo_icmpv4;
52 $echo1->identifier(1);
53 my $echo2 = $self->echo_icmpv4;
54 $echo2->identifier(2);
55 my $echo3 = $self->echo_icmpv4;
56 $echo3->identifier(3);
57  
58 my $frame1 = $self->frame([ $ipv4, $icmpv4, $echo1 ]);
59 my $frame2 = $self->frame([ $ipv4, $icmpv4, $echo2 ]);
60 my $frame3 = $self->frame([ $ipv4, $icmpv4, $echo3 ]);
61  
62 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 for my $f ($frame1, $frame2, $frame3) {
66 my $r = $nw->fnsend_reply($f)
67 or return $self->log->error("ping: network::write fnsend_reply failed");
68 if (defined($r)) {
69 print $r->print."\n";
70 }
71 sleep(1);
72 }
73  
74 return 1;
75 }
76  
77 sub half_poison {
78 my $self = shift;
79  
80 $self->log->info("TODO");
81  
82 return 1;
83 }
84  
85 sub full_poison {
86 my $self = shift;
87  
88 $self->log->info("TODO");
89  
90 return 1;
91 }
92  
93 1;
94  
95 __END__
« Network/Http.pm ↑ Summary Network/Linux/Iptables.pm »