1NetPacket::ICMP(3)    User Contributed Perl Documentation   NetPacket::ICMP(3)
2
3
4

NAME

6       NetPacket::ICMP - Assemble and disassemble ICMP (Internet Control
7       Message Protocol) packets.
8

VERSION

10       version 1.7.2
11

SYNOPSIS

13         use NetPacket::ICMP;
14
15         $icmp_obj = NetPacket::ICMP->decode($raw_pkt);
16         $icmp_pkt = NetPacket::ICMP->encode();
17         $icmp_data = NetPacket::ICMP::strip($raw_pkt);
18

DESCRIPTION

20       "NetPacket::ICMP" provides a set of routines for assembling and
21       disassembling packets using ICMP (Internet Control Message Protocol).
22
23   Methods
24       "NetPacket::ICMP->decode([RAW PACKET])"
25           Decode the raw packet data given and return an object containing
26           instance data.  This method will quite happily decode garbage
27           input.  It is the responsibility of the programmer to ensure valid
28           packet data is passed to this method.
29
30       "NetPacket::ICMP->encode()"
31           Return an ICMP packet encoded with the instance data specified.
32
33   Functions
34       "NetPacket::ICMP::strip([RAW PACKET])"
35           Return the encapsulated data (or payload) contained in the ICMP
36           packet.
37
38   Instance data
39       The instance data for the "NetPacket::ICMP" object consists of the
40       following fields.
41
42       type
43           The ICMP message type of this packet.
44
45       code
46           The ICMP message code of this packet.
47
48       cksum
49           The checksum for this packet.
50
51       data
52           The encapsulated data (payload) for this packet.
53
54   Exports
55       default
56           none
57
58       exportable
59           ICMP message types:
60               ICMP_ECHOREPLY ICMP_UNREACH ICMP_SOURCEQUENCH
61               ICMP_REDIRECT ICMP_ECHO ICMP_ROUTERADVERT
62               ICMP_ROUTERSOLICIT ICMP_TIMXCEED ICMP_PARAMPROB
63               ICMP_TSTAMP ICMP_TSTAMPREPLY ICMP_IREQ ICMP_IREQREPLY
64               ICMP_MASKREQ ICMP_MASKREPLY
65
66       tags
67           The following tags group together related exportable items.
68
69           ":types"
70                 ICMP_ECHOREPLY ICMP_UNREACH ICMP_SOURCEQUENCH
71                 ICMP_REDIRECT ICMP_ECHO ICMP_ROUTERADVERT
72                 ICMP_ROUTERSOLICIT ICMP_TIMXCEED ICMP_PARAMPROB
73                 ICMP_TSTAMP ICMP_TSTAMPREPLY ICMP_IREQ
74                 ICMP_IREQREPLY ICMP_MASKREQ ICMP_MASKREPLY
75
76           ":strip"
77               Import the strip function "icmp_strip".
78
79           ":ALL"
80               All the above exportable items.
81

EXAMPLE

83       The following example prints the ICMP type, code, and checksum fields.
84
85         #!/usr/bin/perl -w
86
87         use strict;
88         use Net::PcapUtils;
89         use NetPacket::Ethernet qw(:strip);
90         use NetPacket::IP qw(:strip);
91         use NetPacket::ICMP;
92
93         sub process_pkt {
94             my ($user, $hdr, $pkt) = @_;
95
96             my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
97             my $icmp_obj = NetPacket::ICMP->decode(ip_strip($ip_obj));
98
99             print("Type: $icmp_obj->{type}\n");
100             print("Code: $icmp_obj->{code}\n");
101             print("Checksum: $icmp_obj->{cksum}\n\n");
102         }
103
104         Net::PcapUtils::loop(\&process_pkt, FILTER => 'icmp');
105

TODO

107       Create constants
108
110       Copyright (c) 2001 Tim Potter and Stephanie Wehner.
111
112       Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the
113       participants in the CRC for Advanced Computational Systems ('ACSys').
114
115       This module is free software.  You can redistribute it and/or modify it
116       under the terms of the Artistic License 2.0.
117
118       This program is distributed in the hope that it will be useful, but
119       without any warranty; without even the implied warranty of
120       merchantability or fitness for a particular purpose.
121

AUTHOR

123       Tim Potter <tpot@samba.org>
124
125       Stephanie Wehner <atrak@itsx.com>
126
127
128
129perl v5.32.0                      2020-07-28                NetPacket::ICMP(3)
Impressum