Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpack data in LittleEndian format #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/NetPacket/USBMon.pm
Expand Up @@ -59,14 +59,14 @@ sub decode
my($id, $type, $xfer_type, $epnum, $devnum, $busnum, $flag_setup,
$flag_data, $ts_sec, $ts_usec, $status, $length, $len_cap,
$s, $interval, $start_frame, $xfer_flags, $ndesc, $rest) =
unpack('a8CCCCSCCa8liIIa8llLLa*', $packet);
unpack('a8CCCCS<CCa8l<i<I<I<a8l<l<L<L<a*', $packet);

# Try to grok quads. We may loose some address information with 32-bit
# Perl parsing 64-bit captures, or timestamp after 2038. Still the best
# we can do.
eval {
$id = unpack ('Q', $id);
$ts_sec = unpack ('Q', $ts_sec);
$id = unpack ('Q<', $id);
$ts_sec = unpack ('Q<', $ts_sec);
};
if ($@) {
($id) = unpack ('LL', $id);
Expand Down Expand Up @@ -109,7 +109,7 @@ sub decode

if ($setup->{bmRequestType} & USB_TYPE_VENDOR) {
($setup->{wValue}, $setup->{wIndex},
$setup->{wLength}) = unpack('S3', $rest);
$setup->{wLength}) = unpack('S<3', $rest);
} else {
# Unknown setup request;
$setup->{data} = $rest;
Expand All @@ -121,7 +121,7 @@ sub decode
# Isochronous descriptors
if ($self->{xfer_type} == USB_XFER_TYPE_ISO) {
my $iso = {};
($iso->{error_count}, $iso->{numdesc}) = unpack('ii', $s);
($iso->{error_count}, $iso->{numdesc}) = unpack('i<i<', $s);
$self->{iso} = $iso;
}

Expand Down