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

NAME

6       NetPacket::ARP - Assemble and disassemble ARP (Address Resolution
7       Protocol) packets.
8

VERSION

10       version 1.7.2
11

SYNOPSIS

13         use NetPacket::ARP;
14
15         $tcp_obj = NetPacket::ARP->decode($raw_pkt);
16         $tcp_pkt = NetPacket::ARP->encode(params...);   # Not implemented
17

DESCRIPTION

19       "NetPacket::ARP" provides a set of routines for assembling and
20       disassembling packets using ARP (Address Resolution Protocol).
21
22   Methods
23       "NetPacket::ARP->decode([RAW PACKET])"
24           Decode the raw packet data given and return an object containing
25           instance data.  This method will quite happily decode garbage
26           input.  It is the responsibility of the programmer to ensure valid
27           packet data is passed to this method.
28
29       "NetPacket::ARP->encode(param => value)"
30           Return a ARP packet encoded with the instance data specified.  Not
31           implemented.
32
33   Functions
34       "NetPacket::ARP::strip([RAW PACKET])"
35           Return the encapsulated data (or payload) contained in the TCP
36           packet.  Since no payload data is encapulated in an ARP packet
37           (only instance data), this function returns undef.
38
39   Instance data
40       The instance data for the "NetPacket::ARP" object consists of the
41       following fields.
42
43       htype
44           Hardware type.
45
46       proto
47           Protocol type.
48
49       hlen
50           Header length.
51
52       plen
53           Protocol length.
54
55       opcode
56           One of the following constants:
57
58           •   ARP_OPCODE_REQUEST
59
60           •   ARP_OPCODE_REPLY
61
62           •   RARP_OPCODE_REQUEST
63
64           •   RARP_OPCODE_REPLY
65
66       sha Source hardware address.
67
68       spa Source protocol address.
69
70       tha Target hardware address.
71
72       tpa Target protocol address.
73
74   Exports
75       default
76           none
77
78       exportable
79           none
80
81       tags
82           The following tags group together related exportable items.
83
84           ":ALL"
85               All the above exportable items.
86

EXAMPLE

88       Print out arp requests on the local network.
89
90         #!/usr/bin/perl -w
91
92         use Net::PcapUtils;
93         use NetPacket::Ethernet qw(:types);
94         use NetPacket::ARP;
95
96         sub process_pkt {
97           my ($arg, $hdr, $pkt) = @_;
98
99           my $eth_obj = NetPacket::Ethernet->decode($pkt);
100
101           if ($eth_obj->{type} == ETH_TYPE_ARP) {
102               my $arp_obj = NetPacket::ARP->decode($eth_obj->{data}, $eth_obj);
103               print("source hw addr=$arp_obj->{sha}, " .
104                     "dest hw addr=$arp_obj->{tha}\n");
105           }
106         }
107
108       Net::PcapUtils::loop(\&process_pkt);
109

TODO

111       Implement encode() function
112       Does this work for protocols other than IP?  Need to read RFC.
113       Example is a bit silly
114
116       Copyright (c) 2001 Tim Potter.
117
118       Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the
119       participants in the CRC for Advanced Computational Systems ('ACSys').
120
121       This module is free software.  You can redistribute it and/or modify it
122       under the terms of the Artistic License 2.0.
123
124       This program is distributed in the hope that it will be useful, but
125       without any warranty; without even the implied warranty of
126       merchantability or fitness for a particular purpose.
127

AUTHOR

129       Tim Potter <tpot@samba.org>
130
131
132
133perl v5.38.0                      2023-07-21                 NetPacket::ARP(3)
Impressum