1NetPacket::Ethernet(3)User Contributed Perl DocumentationNetPacket::Ethernet(3)
2
3
4

NAME

6       NetPacket::Ethernet - Assemble and disassemble ethernet packets.
7

VERSION

9       version 1.7.2
10

SYNOPSIS

12         use NetPacket::Ethernet;
13
14         $eth_obj = NetPacket::Ethernet->decode($raw_pkt);
15         $eth_pkt = NetPacket::Ethernet->encode(params...);   # Not implemented
16         $eth_data = NetPacket::Ethernet::strip($raw_pkt);
17

DESCRIPTION

19       "NetPacket::Ethernet" provides a set of routines for assembling and
20       disassembling packets using the Ethernet protocol.
21
22   Methods
23       "NetPacket::Ethernet->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::Ethernet->encode(param => value)"
30           Return an ethernet packet encoded with the instance data specified.
31           Not implemented.
32
33   Functions
34       "NetPacket::Ethernet::strip([RAW PACKET])"
35           Return the encapsulated data (or payload) contained in the ethernet
36           packet.  This data is suitable to be used as input for other
37           "NetPacket::*" modules.
38
39           This function is equivalent to creating an object using the
40           decode() constructor and returning the "data" field of that object.
41
42   Instance data
43       The instance data for the "NetPacket::Ethernet" object consists of the
44       following fields.
45
46       src_mac
47           The source MAC address for the ethernet packet as a hex string.
48
49       dest_mac
50           The destination MAC address for the ethernet packet as a hex
51           string.
52
53       type
54           The protocol type for the ethernet packet.
55
56       data
57           The payload for the ethernet packet.
58
59   Exports
60       default
61           none
62
63       exportable
64           ETH_TYPE_IP ETH_TYPE_ARP ETH_TYPE_APPLETALK ETH_TYPE_SNMP
65           ETH_TYPE_IPv6 ETH_TYPE_PPP
66
67       tags
68           The following tags group together related exportable items.
69
70           ":types"
71               ETH_TYPE_IP ETH_TYPE_ARP ETH_TYPE_APPLETALK ETH_TYPE_SNMP
72               ETH_TYPE_IPv6 ETH_TYPE_PPP
73
74           ":strip"
75               Import the strip function "eth_strip" which is an alias for
76               "NetPacket::Ethernet::strip"
77
78           ":ALL"
79               All the above exportable items.
80

EXAMPLE

82       The following script dumps ethernet frames by mac address and protocol
83       to standard output.
84
85         #!/usr/bin/perl -w
86
87         use strict;
88         use Net::PcapUtils;
89         use NetPacket::Ethernet;
90
91         sub process_pkt {
92             my($arg, $hdr, $pkt) = @_;
93
94             my $eth_obj = NetPacket::Ethernet->decode($pkt);
95             print("$eth_obj->{src_mac}:$eth_obj->{dest_mac} $eth_obj->{type}\n");
96         }
97
98         Net::PcapUtils::loop(\&process_pkt);
99

TODO

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

AUTHOR

117       Tim Potter <tpot@samba.org>
118
119
120
121perl v5.36.0                      2023-01-20            NetPacket::Ethernet(3)
Impressum