Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 4d51121ee3aab1267d88f87bfa6cbc4e > files > 6

perl-Net-Packet-3.280.0-4.mga7.noarch.rpm

#!/usr/bin/perl
#
# $Id: arp-reply.pl 1640 2009-11-09 17:58:27Z gomor $
#
use strict;
use warnings;

use Getopt::Std;
my %opts;
getopts('m:M:i:a:d:v', \%opts);

die "Usage: $0 -i dstIp -a isAtMac [-M srcMac] [-m dstMac] ".
    "(or will broadcast) [-d device] [-v]\n"
   unless $opts{i} && $opts{a};

use Net::Packet;

$Env->dev($opts{d}) if $opts{d};
$Env->mac($opts{M}) if $opts{M};
$Env->debug(3)      if $opts{v};
$Env->noFrameAutoDump(1);

my $eth = Net::Packet::ETH->new(
   type => NP_ETH_TYPE_ARP,
);
$eth->dst($opts{m}) if $opts{m};

my $arp = Net::Packet::ARP->new(
   opCode => NP_ARP_OPCODE_REPLY,
   src    => $opts{a},
   srcIp  => $opts{i},
   dstIp  => $opts{i},
);
$arp->dst($opts{m}) if $opts{m};

my $frame = Net::Packet::Frame->new(l2 => $eth, l3 => $arp);

print "Sending:\n";
print $frame->l2->print, "\n";
print $frame->l3->print, "\n";

$frame->send;