.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "ARP 3pm" .TH ARP 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME ARP \- Perl extension for creating ARP packets .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 7 \& use Net::ARP; \& Net::ARP::send_packet(\*(Aqlo\*(Aq, # Device \& \*(Aq127.0.0.1\*(Aq, # Source IP \& \*(Aq127.0.0.1\*(Aq, # Destination IP \& \*(Aqaa:bb:cc:aa:bb:cc\*(Aq, # Source MAC \& \*(Aqaa:bb:cc:aa:bb:cc\*(Aq, # Destinaton MAC \& \*(Aqreply\*(Aq); # ARP operation .Ve .PP \&\f(CW$mac\fR = Net::ARP::get_mac("enp3s0f1"); .PP print "$mac\en"; .PP \&\f(CW$mac\fR = Net::ARP::arp_lookup($dev,"192.168.1.1"); .PP print "192.168.1.1 has got mac \f(CW$mac\fR\en"; .SS IMPORTANT .IX Subsection "IMPORTANT" Version 1.0 will break with the API of PRE\-1.0 versions, because the return value of \fBarp_lookup()\fR and \fBget_mac()\fR will no longer be passed as parameter, but returned! I hope this decision is ok as long as we get a cleaner and more perlish API. .SS DESCRIPTION .IX Subsection "DESCRIPTION" This module can be used to create and send ARP packets and to get the mac address of an ethernet interface or ip address. .IP \fBsend_packet()\fR 4 .IX Item "send_packet()" .Vb 6 \& Net::ARP::send_packet(\*(Aqlo\*(Aq, # Device \& \*(Aq127.0.0.1\*(Aq, # Source IP \& \*(Aq127.0.0.1\*(Aq, # Destination IP \& \*(Aqaa:bb:cc:aa:bb:cc\*(Aq, # Source MAC \& \*(Aqaa:bb:cc:aa:bb:cc\*(Aq, # Destinaton MAC \& \*(Aqreply\*(Aq); # ARP operation \& \& I think this is self documentating. \& ARP operation can be one of the following values: \& request, reply, revrequest, revreply, invrequest, invreply. .Ve .IP \fBget_mac()\fR 4 .IX Item "get_mac()" .Vb 1 \& $mac = Net::ARP::get_mac("enp3s0f1"); \& \& This gets the MAC address of the enp3s0f1 interface and stores \& it in the variable $mac. The return value is "unknown" if \& the mac cannot be looked up. .Ve .IP \fBarp_lookup()\fR 4 .IX Item "arp_lookup()" .Vb 1 \& $mac = Net::ARP::arp_lookup($dev,"192.168.1.1"); \& \& This looks up the MAC address for the ip address 192.168.1.1 \& and stores it in the variable $mac. The return value is \& "unknown" if the mac cannot be looked up. .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 1 \& man \-a arp .Ve .SH AUTHOR .IX Header "AUTHOR" .Vb 2 \& Bastian Ballmann [ balle@codekid.net ] \& http://www.codekid.net .Ve .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2004\-2022 by Bastian Ballmann .PP License: GPLv2