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

NAME

6       NetPacket::IP - Assemble and disassemble IP (Internet Protocol)
7       packets.
8

VERSION

10       version 1.7.2
11

SYNOPSIS

13         use NetPacket::IP;
14
15         $ip_obj = NetPacket::IP->decode($raw_pkt);
16         $ip_pkt = NetPacket::IP->encode($ip_obj);
17         $ip_data = NetPacket::IP::strip($raw_pkt);
18

DESCRIPTION

20       "NetPacket::IP" provides a set of routines for assembling and
21       disassembling packets using IP (Internet Protocol).
22
23   Methods
24       "NetPacket::IP->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::IP->encode()"
31           Return an IP packet encoded with the instance data specified. This
32           will infer the total length of the packet automatically from the
33           payload length and also adjust the checksum.
34
35   Functions
36       "NetPacket::IP::strip([RAW PACKET])"
37           Return the encapsulated data (or payload) contained in the IP
38           packet.  This data is suitable to be used as input for other
39           "NetPacket::*" modules.
40
41           This function is equivalent to creating an object using the
42           decode() constructor and returning the "data" field of that object.
43
44   Instance data
45       The instance data for the "NetPacket::IP" object consists of the
46       following fields.
47
48       ver The IP version number of this packet.
49
50       hlen
51           The IP header length of this packet.
52
53       flags
54           The IP header flags for this packet.
55
56       foffset
57           The IP fragment offset for this packet.
58
59       tos The type-of-service for this IP packet.
60
61       len The length (including length of header) in bytes for this packet.
62
63       id  The identification (sequence) number for this IP packet.
64
65       ttl The time-to-live value for this packet.
66
67       proto
68           The IP protocol number for this packet.
69
70       cksum
71           The IP checksum value for this packet.
72
73       src_ip
74           The source IP address for this packet in dotted-quad notation.
75
76       dest_ip
77           The destination IP address for this packet in dotted-quad notation.
78
79       options
80           Any IP options for this packet.
81
82       data
83           The encapsulated data (payload) for this IP packet.
84
85   Exports
86       default
87           none
88
89       exportable
90           IP_PROTO_IP IP_PROTO_ICMP IP_PROTO_IGMP IP_PROTO_IPIP IP_PROTO_TCP
91           IP_PROTO_UDP IP_VERSION_IPv4
92
93       tags
94           The following tags group together related exportable items.
95
96           ":protos"
97               IP_PROTO_IP IP_PROTO_ICMP IP_PROTO_IGMP IP_PROTO_IPIP
98               IP_PROTO_TCP IP_PROTO_UDP
99
100           ":versions"
101               IP_VERSION_IPv4
102
103           ":strip"
104               Import the strip function "ip_strip".
105
106           ":ALL"
107               All the above exportable items.
108

EXAMPLE

110       The following script dumps IP frames by IP address and protocol to
111       standard output.
112
113         #!/usr/bin/perl -w
114
115         use strict;
116         use Net::PcapUtils;
117         use NetPacket::Ethernet qw(:strip);
118         use NetPacket::IP;
119
120         sub process_pkt {
121             my ($user, $hdr, $pkt) = @_;
122
123             my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
124             print("$ip_obj->{src_ip}:$ip_obj->{dest_ip} $ip_obj->{proto}\n");
125         }
126
127         Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip');
128

TODO

130       IP option decoding - currently stored in binary form.
131       Assembly of received fragments
132
134       Copyright (c) 2001 Tim Potter and Stephanie Wehner.
135
136       Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the
137       participants in the CRC for Advanced Computational Systems ('ACSys').
138
139       This module is free software.  You can redistribute it and/or modify it
140       under the terms of the Artistic License 2.0.
141
142       This program is distributed in the hope that it will be useful, but
143       without any warranty; without even the implied warranty of
144       merchantability or fitness for a particular purpose.
145

AUTHOR

147       Tim Potter <tpot@samba.org>
148
149       Stephanie Wehner <atrak@itsx.com>
150
151
152
153perl v5.38.0                      2023-07-21                  NetPacket::IP(3)
Impressum