in reply to Of Net::Arp and Hashes

The error IS in the XS code. I added a printf() line to ARP.xs:
char * arp_lookup(dev, ip, mac) unsigned char *dev; unsigned char *ip; unsigned char *mac; CODE: char tmp[20]; printf("TMP(%d) IS %s\n", strlen(tmp), tmp); if(SOCK_TYPE == SOCK_RAW) { arp_lookup_bsd(dev,ip,tmp); } else { arp_lookup_linux(dev,ip,tmp); } mac = tmp; OUTPUT: mac
Then I ran this:
#!/usr/bin/perl use Net::ARP; my $mac = ""; Net::ARP::arp_lookup(eth1 => '172.18.0.1', $mac); print "mac=$mac\n"; Net::ARP::arp_lookup(eth1 => '172.18.0.1', $mac); print "mac=$mac\n";
I get this as output:
TMP(0) IS mac= TMP(8) IS pï¿ï¿½ï¿½ mac=00:0E:D7:80:37:20
The simple fix is change char tmp[20]; to char tmp[20] = "unknown";. I will be sending a bug report to the author.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: Of Net::Arp and Hashes
by cmilfo (Hermit) on Jan 13, 2006 at 19:18 UTC
      The author has already responded, fixed the bug (and an identical one in get_mac()), and uploaded a new version to CPAN.

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

        IMHO, still wrong. The C code returns a value to indicate error conditions, but the XS has no way to convey this to the perl module. I just think that this whole function of the module is ill-conceived.


        The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon