Hello, I had posted this code at the end of my discussion in ARP Lookups and at the time of posting the code worked flawlessly. Went to run it today and I'm getting:
Can't call method "opCode" on an undefined value at ./arp2.pl line 46.

If I step it back a level just to the ref of $r->ref->{ARP} there is nothing there. However if I go back and do a r->print or if I unpack the raw data, I can see the ARP layer plain as day. I supposed I could use ->print and regex my output, but the modules i'm using shouldn't require me to do that. Any ideas? Code Below:

#!/usr/bin/perl use Net::ARP; use Net::Netmask; use Net::Frame::Simple; use Net::Frame::Dump::Online; my $dev= "eth1"; $ifconf= `ifconfig $dev`; $ifconf=~ /\d+\.\d+\.\d+\.\d+/; $ipdec= $&; $ifconf=~ /Mask:\d+\.\d+\.\d+\.\d+/; $nmaskdec= $&; $nmaskdec=~s/Mask://; my $netblock= $ipdec . ":" . $nmaskdec ; $netmask=new Net::Netmask ($netblock); my @iprange = $netmask->enumerate; $arpDump=Net::Frame::Dump::Online->new( dev => $dev, filter => 'arp'); $arpDump->start; my %livehosts; my $reply; $counter=0; while ($counter<3){ for $ipts (@iprange){ Net::ARP::send_packet($dev,$ipdec,$ipts,"00:18:de:34:8e:7b","f +f:ff:ff:ff:ff:ff","request"); } until ($arpDump->timeout){ if ($next=$arpDump->next){ my $r=Net::Frame::Simple->newFromDump($next); $opc=$r->ref->{ARP}->opCode; next unless $opc == 2; $livehosts{$r->ref->{ARP}->srcIp}=$r->ref->{ARP}->src; } } $arpDump->timeoutReset; $counter++; } foreach $key (keys %livehosts){ print "IP Address $key is up with mac of $livehosts{$key} \n"; } $arpDump->stop;


UPDATE: Arg , what a total waste of time. I went and reloaded Net::Frame from CPAN and now it works fine. Sorry, folks.

In reply to Issue with Net::Frame packages by WalkingZero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.