NetPacket::USBMon(3)

πŸ’– NetPacket::USBMon πŸ’–

okay bestie, so this is NetPacket::USBMon β€” a lil Perl module from the User Contributed Perl Documentation corner of the world. It assembles and disassembles USB packets that got captured through the Linux USBMon interface. yes. USB. packets. we're going low-level today and honestly? iconic behavior. πŸ¦‹

✨ NAME ✨

NetPacket::USBMon β€” assemble and disassemble USB packets captured via the Linux USBMon interface. that's it, that's the whole job, and she does it flawlessly πŸ’…

🌸 VERSION 🌸

version 1.8.0 β€” she's grown up, she's thriving

πŸŽ€ SYNOPSIS πŸŽ€

the whole vibe in four lines, no notes:

use NetPacket::USBMon;

$usb = NetPacket::USBMon->decode($raw_pkt);

like... that's literally it. import it, decode your raw packet, boom. main character energy ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

so NetPacket::USBMon is a NetPacket decoder for USB packets captured via the Linux USBMon interface. it takes your raw captured bytes and hands you back a cute lil object you can actually read. no cap. 🫢

🧚 Methods

  • NetPacket::USBMon->decode([RAW PACKET]) β€” decode a USB packet. that's the one job, and she ate πŸ”₯

πŸ’œ Instance data

the instance data for the NetPacket::UDP object (yes, the docs really do say UDP there, we don't make the rules, we just vibe with them πŸ™ˆ) consists of the following fields:

  • id β€” an in-kernel address of the USB Request Block (URB). it stays the same for the transaction submission and the completion.
heads up bestie: this might get truncated when you're reading a 64-bit capture with a 32-bit file. 😭
  • type β€” the URB type. one character: 'S', 'C' or 'E', which correspond to the constants USB_TYPE_SUBMISSION, USB_TYPE_CALLBACK or USB_TYPE_ERROR.
  • xfer_type β€” the transfer type. one of USB_XFER_TYPE_ISO, USB_XFER_TYPE_INTR, USB_XFER_TYPE_CONTROL or USB_XFER_TYPE_BULK.
  • ep β€” endpoint identification, and she's got layers:
    • num β€” endpoint number.
    • dir β€” transfer direction. either "IN" or "OUT".
  • devnum β€” device address.
  • busnum β€” bus number.
  • flag_setup β€” indicates whether setup is present and makes sense.
  • flag_data β€” indicates whether data is present and makes sense.
  • ts_sec β€” timestamp seconds since epoch. subject to truncation with 32-bit Perl, which should be totally fine until 2038 β€” so, like, future-us problem ⏳
  • ts_usec β€” timestamp microseconds.
  • status β€” URB status. it's a negative errno, so if it's being dramatic, that's why πŸ’€
  • length β€” length of data (submitted or actual).
  • len_cap β€” delivered length.
  • setup β€” only present for packets with setup_flag turned on. some contents are dependent on the actual request type. the squad:
    • bmRequestType
    • bRequest
    • wValue
    • wIndex
    • wLength
  • iso β€” only present for isochronous transfers. the duo:
    • error_count
    • numdesc
  • interval β€” isochronous packet response rate.
  • start_frame β€” only applicable to isochronous transfers.
  • xfer_flags β€” a copy of the URB's transfer_flags.
  • ndesc β€” actual number of isochronous descriptors.
  • data β€” the packet payload. the actual goods πŸ“¦

🌈 Exports

  • default β€” none. sorry bestie, she gives you nothing for free on import 😌
  • exportable β€” the full treasure chest:

USB_TYPE_SUBMISSION, USB_TYPE_CALLBACK, USB_TYPE_ERROR, USB_XFER_TYPE_ISO, USB_XFER_TYPE_INTR, USB_XFER_TYPE_CONTROL, USB_XFER_TYPE_BULK, USB_FLAG_SETUP_IRRELEVANT, USB_FLAG_SETUP_RELEVANT, USB_FLAG_DATA_ERROR, USB_FLAG_DATA_INCOMING, USB_FLAG_DATA_OUTGOING, USB_FLAG_DATA_PRESENT, USB_TYPE_VENDOR

  • tags β€” the following tags group together related exportable items. it's giving curated playlists fr fr 🎧
    • :types β€” USB_TYPE_SUBMISSION, USB_TYPE_CALLBACK, USB_TYPE_ERROR
    • :xfer_types β€” USB_XFER_TYPE_ISO, USB_XFER_TYPE_INTR, USB_XFER_TYPE_CONTROL, USB_XFER_TYPE_BULK
    • :setup_flags β€” USB_FLAG_SETUP_IRRELEVANT, USB_FLAG_SETUP_RELEVANT
    • :data_flags β€” USB_FLAG_DATA_ERROR, USB_FLAG_DATA_INCOMING, USB_FLAG_DATA_OUTGOING, USB_FLAG_DATA_PRESENT
    • :setup_types β€” USB_TYPE_VENDOR
    • :ALL β€” all the above exportable items. the whole buffet, no crumbs left πŸ“

Copyright (c) 2013 Lubomir Rintel.

this module is free software. you can redistribute it and/or modify it under the same terms as Perl itself. so go forth and remix, bestie πŸ’–

🌟 AUTHOR 🌟

Lubomir Rintel <lkundrak@v3.sk>


and that's the whole page!! shoutout to perl v5.42.0 for stamping this on 2026-02-05 and shoutout to you for reading all the way down here. you're doing amazing sweetie πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from