Skip Menu |

This queue is for tickets about the Net-sFlow CPAN distribution.

Report information
The Basics
Id: 101412
Status: new
Priority: 0/
Queue: Net-sFlow

People
Owner: Nobody in particular
Requestors: ACFEREN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: MAC addresses being formatted incorrectly
The MAC addresses ETHERNETFRAMEDATA: EtherSrcMac, EtherDestMac COUNTERLAG: dot3adAggPortActorSystemID dot3adAggPortPartnerOperSystemID Are unpacked as 2 4-byte unsigned integers (so far so good) After unpacking they are formatted as hex. The hex for the MAC should be bytes 0-3 of the first integer and bytes 0-1 of the second integer, but isn't. I've attached a short test script that shows the issue.
Subject: MAC_test.pl
#!/usr/bin/perl use strict; use warnings; my ( $N1, $N2 ); $N1 = pack( 'H*', '01020304' ); for my $N ( '05060000', '05060708', '00000708' ) { print "N2 = $N:\n"; $N2 = pack( 'H*', $N ); fmt_macs( $N1, $N2 ); } sub fmt_macs { my ( $N1, $N2 ) = @_; my $MAC = $N1 . $N2; print "MAC (new):", unpack( 'H12', $MAC ), "\n"; ( $N1, $N2 ) = unpack( 'N2', $N1 . $N2 ); print "MAC (old):", sprintf( "%08x%04x", $N1, $N2 ), "\n"; } __END__ # Local Variables: *** # mode:CPerl *** # cperl-indent-level:2 *** # perl-indent-level:2 *** # tab-width: 2 *** # indent-tabs-mode: t *** # End: *** # # vim: ts=2 sw=2 noexpandtab
On Thu Jan 08 12:48:00 2015, ACFEREN wrote: [ snip ] Show quoted text
> I've attached a short test script that shows the issue.
I probably should have included the output too. (new) marks what I expect to see (old) shows the current behavior. $ perl ~/MAC_test.pl N2 = 05060000: MAC (new):010203040506 MAC (old):010203045060000 N2 = 05060708: MAC (new):010203040506 MAC (old):010203045060708 N2 = 00000708: MAC (new):010203040000 MAC (old):010203040708 I've committed a patch on github and sent a pull request as well.