File: icmp-echo.pl

package info (click to toggle)
libnet-frame-layer-icmpv6-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 188 kB
  • sloc: perl: 1,083; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
use strict;
use warnings;

use Net::Frame::Simple;
use Net::Frame::Layer::ETH qw(:consts);
use Net::Frame::Layer::IPv6 qw(:consts);
use Net::Frame::Layer::ICMPv6;
use Net::Frame::Layer::ICMPv6::Echo;

my $eth = Net::Frame::Layer::ETH->new(type => NF_ETH_TYPE_IPv6);

my $ip = Net::Frame::Layer::IPv6->new(nextHeader => NF_IPv6_PROTOCOL_ICMPv6);

my $icmp = Net::Frame::Layer::ICMPv6->new;
my $echo = Net::Frame::Layer::ICMPv6::Echo->new(payload => 'test');

my $oSimple = Net::Frame::Simple->new(
   layers => [ $eth, $ip, $icmp, $echo, ],
);
print $oSimple->print."\n";
print unpack('H*', $oSimple->raw)."\n";

my $oSimple2 = Net::Frame::Simple->new(
   raw        => $oSimple->raw,
   firstLayer => 'ETH',
);
print $oSimple2->print."\n";
print unpack('H*', $oSimple2->raw)."\n";