€•ÇÏŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ/translations/zh_CN/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/zh_TW/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/it_IT/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ja_JP/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ko_KR/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/pt_BR/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/sp_SP/usb/usbmon”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒusbmon”h]”hŒusbmon”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ8/var/lib/git/docbuild/linux/Documentation/usb/usbmon.rst”h´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ Introduction”h]”hŒ Introduction”…”�”}”(hhÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhËh²hh³hÊh´KubhŒ paragraph”“”)�”}”(hXnThe name "usbmon" in lowercase refers to a facility in kernel which is used to collect traces of I/O on the USB bus. This function is analogous to a packet socket used by network monitoring tools such as tcpdump(1) or Ethereal. Similarly, it is expected that a tool such as usbdump or USBMon (with uppercase letters) is used to examine raw traces produced by usbmon.”h]”hXrThe name “usbmonâ€� in lowercase refers to a facility in kernel which is used to collect traces of I/O on the USB bus. This function is analogous to a packet socket used by network monitoring tools such as tcpdump(1) or Ethereal. Similarly, it is expected that a tool such as usbdump or USBMon (with uppercase letters) is used to examine raw traces produced by usbmon.”…”�”}”(hhÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhÝ)�”}”(hŒòThe usbmon reports requests made by peripheral-specific drivers to Host Controller Drivers (HCD). So, if HCD is buggy, the traces reported by usbmon may not correspond to bus transactions precisely. This is the same situation as with tcpdump.”h]”hŒòThe usbmon reports requests made by peripheral-specific drivers to Host Controller Drivers (HCD). So, if HCD is buggy, the traces reported by usbmon may not correspond to bus transactions precisely. This is the same situation as with tcpdump.”…”�”}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhÝ)�”}”(hŒØTwo APIs are currently implemented: "text" and "binary". The binary API is available through a character device in /dev namespace and is an ABI. The text API is deprecated since 2.6.35, but available for convenience.”h]”hŒàTwo APIs are currently implemented: “textâ€� and “binaryâ€�. The binary API is available through a character device in /dev namespace and is an ABI. The text API is deprecated since 2.6.35, but available for convenience.”…”�”}”(hhúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ,How to use usbmon to collect raw text traces”h]”hŒ,How to use usbmon to collect raw text traces”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KubhÝ)�”}”(hX!Unlike the packet socket, usbmon has an interface which provides traces in a text format. This is used for two purposes. First, it serves as a common trace exchange format for tools while more sophisticated formats are finalized. Second, humans can read it in case tools are not available.”h]”hX!Unlike the packet socket, usbmon has an interface which provides traces in a text format. This is used for two purposes. First, it serves as a common trace exchange format for tools while more sophisticated formats are finalized. Second, humans can read it in case tools are not available.”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²hubhÝ)�”}”(hŒ5To collect a raw text trace, execute following steps.”h]”hŒ5To collect a raw text trace, execute following steps.”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hjh²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ 1. Prepare”h]”hŒ 1. Prepare”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj=h²hh³hÊh´K#ubhÝ)�”}”(hŒ³Mount debugfs (it has to be enabled in your kernel configuration), and load the usbmon module (if built as module). The second step is skipped if usbmon is built into the kernel::”h]”hŒ²Mount debugfs (it has to be enabled in your kernel configuration), and load the usbmon module (if built as module). The second step is skipped if usbmon is built into the kernel:”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K%hj=h²hubhŒ literal_block”“”)�”}”(hŒD# mount -t debugfs none_debugs /sys/kernel/debug # modprobe usbmon #”h]”hŒD# mount -t debugfs none_debugs /sys/kernel/debug # modprobe usbmon #”…”�”}”hj^sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j\h³hÊh´K)hj=h²hubhÝ)�”}”(hŒ%Verify that bus sockets are present::”h]”hŒ$Verify that bus sockets are present:”…”�”}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K-hj=h²hubj])�”}”(hŒZ# ls /sys/kernel/debug/usb/usbmon 0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u #”h]”hŒZ# ls /sys/kernel/debug/usb/usbmon 0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u #”…”�”}”hj|sbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´K/hj=h²hubhÝ)�”}”(hŒÞNow you can choose to either use the socket '0u' (to capture packets on all buses), and skip to step #3, or find the bus used by your device with step #2. This allows to filter away annoying devices that talk continuously.”h]”hŒâNow you can choose to either use the socket ‘0u’ (to capture packets on all buses), and skip to step #3, or find the bus used by your device with step #2. This allows to filter away annoying devices that talk continuously.”…”�”}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K3hj=h²hubeh}”(h]”Œprepare”ah ]”h"]”Œ 1. prepare”ah$]”h&]”uh1hµhjh²hh³hÊh´K#ubh¶)�”}”(hhh]”(h»)�”}”(hŒ02. Find which bus connects to the desired device”h]”hŒ02. Find which bus connects to the desired device”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´K8ubhÝ)�”}”(hXRun "cat /sys/kernel/debug/usb/devices", and find the T-line which corresponds to the device. Usually you do it by looking for the vendor string. If you have many similar devices, unplug one and compare the two /sys/kernel/debug/usb/devices outputs. The T-line will have a bus number.”h]”hX Run “cat /sys/kernel/debug/usb/devicesâ€�, and find the T-line which corresponds to the device. Usually you do it by looking for the vendor string. If you have many similar devices, unplug one and compare the two /sys/kernel/debug/usb/devices outputs. The T-line will have a bus number.”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K:hj h²hubhÝ)�”}”(hŒ Example::”h]”hŒExample:”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K?hj h²hubj])�”}”(hŒÔT: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=0557 ProdID=2004 Rev= 1.00 S: Manufacturer=ATEN S: Product=UC100KM V2.00”h]”hŒÔT: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=0557 ProdID=2004 Rev= 1.00 S: Manufacturer=ATEN S: Product=UC100KM V2.00”…”�”}”hjÍsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KAhj h²hubhÝ)�”}”(hŒŒ"Bus=03" means it's bus 3. Alternatively, you can look at the output from "lsusb" and get the bus number from the appropriate line. Example:”h]”hŒ–“Bus=03â€� means it’s bus 3. Alternatively, you can look at the output from “lsusbâ€� and get the bus number from the appropriate line. Example:”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KGhj h²hubhÝ)�”}”(hŒ3Bus 003 Device 002: ID 0557:2004 ATEN UC100KM V2.00”h]”hŒ3Bus 003 Device 002: ID 0557:2004 ATEN UC100KM V2.00”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KJhj h²hubeh}”(h]”Œ-find-which-bus-connects-to-the-desired-device”ah ]”h"]”Œ02. find which bus connects to the desired device”ah$]”h&]”uh1hµhjh²hh³hÊh´K8ubh¶)�”}”(hhh]”(h»)�”}”(hŒ3. Start 'cat'”h]”hŒ3. Start ‘cat’”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÿh²hh³hÊh´KMubj])�”}”(hŒ6# cat /sys/kernel/debug/usb/usbmon/3u > /tmp/1.mon.out”h]”hŒ6# cat /sys/kernel/debug/usb/usbmon/3u > /tmp/1.mon.out”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KQhjÿh²hubhÝ)�”}”(hŒDto listen on a single bus, otherwise, to listen on all buses, type::”h]”hŒCto listen on a single bus, otherwise, to listen on all buses, type:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KShjÿh²hubj])�”}”(hŒ6# cat /sys/kernel/debug/usb/usbmon/0u > /tmp/1.mon.out”h]”hŒ6# cat /sys/kernel/debug/usb/usbmon/0u > /tmp/1.mon.out”…”�”}”hj,sbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KUhjÿh²hubhÝ)�”}”(hŒ¤This process will read until it is killed. Naturally, the output can be redirected to a desirable location. This is preferred, because it is going to be quite long.”h]”hŒ¤This process will read until it is killed. Naturally, the output can be redirected to a desirable location. This is preferred, because it is going to be quite long.”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KWhjÿh²hubeh}”(h]”Œ start-cat”ah ]”h"]”Œ3. start 'cat'”ah$]”h&]”uh1hµhjh²hh³hÊh´KMubh¶)�”}”(hhh]”(h»)�”}”(hŒ/4. Perform the desired operation on the USB bus”h]”hŒ/4. Perform the desired operation on the USB bus”…”�”}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjPh²hh³hÊh´K\ubhÝ)�”}”(hŒpThis is where you do something that creates the traffic: plug in a flash key, copy files, control a webcam, etc.”h]”hŒpThis is where you do something that creates the traffic: plug in a flash key, copy files, control a webcam, etc.”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K^hjPh²hubeh}”(h]”Œ,perform-the-desired-operation-on-the-usb-bus”ah ]”h"]”Œ/4. perform the desired operation on the usb bus”ah$]”h&]”uh1hµhjh²hh³hÊh´K\ubh¶)�”}”(hhh]”(h»)�”}”(hŒ 5. Kill cat”h]”hŒ 5. Kill cat”…”�”}”(hjzh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjwh²hh³hÊh´KbubhÝ)�”}”(hŒ8Usually it's done with a keyboard interrupt (Control-C).”h]”hŒ:Usually it’s done with a keyboard interrupt (Control-C).”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kdhjwh²hubhÝ)�”}”(hŒ×At this point the output file (/tmp/1.mon.out in this example) can be saved, sent by e-mail, or inspected with a text editor. In the last case make sure that the file size is not excessive for your favourite editor.”h]”hŒ×At this point the output file (/tmp/1.mon.out in this example) can be saved, sent by e-mail, or inspected with a text editor. In the last case make sure that the file size is not excessive for your favourite editor.”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kfhjwh²hubeh}”(h]”Œkill-cat”ah ]”h"]”Œ 5. kill cat”ah$]”h&]”uh1hµhjh²hh³hÊh´Kbubeh}”(h]”Œ,how-to-use-usbmon-to-collect-raw-text-traces”ah ]”h"]”Œ,how to use usbmon to collect raw text traces”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒRaw text data format”h]”hŒRaw text data format”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj´h²hh³hÊh´KkubhÝ)�”}”(hX/Two formats are supported currently: the original, or '1t' format, and the '1u' format. The '1t' format is deprecated in kernel 2.6.21. The '1u' format adds a few fields, such as ISO frame descriptors, interval, etc. It produces slightly longer lines, but otherwise is a perfect superset of '1t' format.”h]”hXCTwo formats are supported currently: the original, or ‘1t’ format, and the ‘1u’ format. The ‘1t’ format is deprecated in kernel 2.6.21. The ‘1u’ format adds a few fields, such as ISO frame descriptors, interval, etc. It produces slightly longer lines, but otherwise is a perfect superset of ‘1t’ format.”…”�”}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kmhj´h²hubhÝ)�”}”(hŒÊIf it is desired to recognize one from the other in a program, look at the "address" word (see below), where '1u' format adds a bus number. If 2 colons are present, it's the '1t' format, otherwise '1u'.”h]”hŒÜIf it is desired to recognize one from the other in a program, look at the “addressâ€� word (see below), where ‘1u’ format adds a bus number. If 2 colons are present, it’s the ‘1t’ format, otherwise ‘1u’.”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kshj´h²hubhÝ)�”}”(hX'Any text format data consists of a stream of events, such as URB submission, URB callback, submission error. Every event is a text line, which consists of whitespace separated words. The number or position of words may depend on the event type, but there is a set of words, common for all types.”h]”hX'Any text format data consists of a stream of events, such as URB submission, URB callback, submission error. Every event is a text line, which consists of whitespace separated words. The number or position of words may depend on the event type, but there is a set of words, common for all types.”…”�”}”(hjáh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kwhj´h²hubhÝ)�”}”(hŒ.Here is the list of words, from left to right:”h]”hŒ.Here is the list of words, from left to right:”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K|hj´h²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒºURB Tag. This is used to identify URBs, and is normally an in-kernel address of the URB structure in hexadecimal, but can be a sequence number or any other unique string, within reason. ”h]”hÝ)�”}”(hŒ¹URB Tag. This is used to identify URBs, and is normally an in-kernel address of the URB structure in hexadecimal, but can be a sequence number or any other unique string, within reason.”h]”hŒ¹URB Tag. This is used to identify URBs, and is normally an in-kernel address of the URB structure in hexadecimal, but can be a sequence number or any other unique string, within reason.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K~hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hŒÆTimestamp in microseconds, a decimal number. The timestamp's resolution depends on available clock, and so it can be much worse than a microsecond (if the implementation uses jiffies, for example). ”h]”hÝ)�”}”(hŒÅTimestamp in microseconds, a decimal number. The timestamp's resolution depends on available clock, and so it can be much worse than a microsecond (if the implementation uses jiffies, for example).”h]”hŒÇTimestamp in microseconds, a decimal number. The timestamp’s resolution depends on available clock, and so it can be much worse than a microsecond (if the implementation uses jiffies, for example).”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K‚hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hŒ�Event Type. This type refers to the format of the event, not URB type. Available types are: S - submission, C - callback, E - submission error. ”h]”hÝ)�”}”(hŒ�Event Type. This type refers to the format of the event, not URB type. Available types are: S - submission, C - callback, E - submission error.”h]”hŒ�Event Type. This type refers to the format of the event, not URB type. Available types are: S - submission, C - callback, E - submission error.”…”�”}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K†hj4ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hX@"Address" word (formerly a "pipe"). It consists of four fields, separated by colons: URB type and direction, Bus number, Device address, Endpoint number. Type and direction are encoded with two bytes in the following manner: == == ============================= Ci Co Control input and output Zi Zo Isochronous input and output Ii Io Interrupt input and output Bi Bo Bulk input and output == == ============================= Bus number, Device address, and Endpoint are decimal numbers, but they may have leading zeros, for the sake of human readers. ”h]”(hÝ)�”}”(hŒà"Address" word (formerly a "pipe"). It consists of four fields, separated by colons: URB type and direction, Bus number, Device address, Endpoint number. Type and direction are encoded with two bytes in the following manner:”h]”hŒè“Addressâ€� word (formerly a “pipeâ€�). It consists of four fields, separated by colons: URB type and direction, Bus number, Device address, Endpoint number. Type and direction are encoded with two bytes in the following manner:”…”�”}”(hjPh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K‰hjLubhŒ block_quote”“”)�”}”(hŒÓ== == ============================= Ci Co Control input and output Zi Zo Isochronous input and output Ii Io Interrupt input and output Bi Bo Bulk input and output == == ============================= ”h]”hŒtable”“”)�”}”(hhh]”hŒtgroup”“”)�”}”(hhh]”(hŒcolspec”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jnhjkubjo)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jnhjkubjo)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jnhjkubhŒtbody”“”)�”}”(hhh]”(hŒrow”“”)�”}”(hhh]”(hŒentry”“”)�”}”(hhh]”hÝ)�”}”(hŒCi”h]”hŒCi”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŽhjšubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj•ubj™)�”}”(hhh]”hÝ)�”}”(hŒCo”h]”hŒCo”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŽhj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj•ubj™)�”}”(hhh]”hÝ)�”}”(hŒControl input and output”h]”hŒControl input and output”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŽhjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj•ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hj�ubj”)�”}”(hhh]”(j™)�”}”(hhh]”hÝ)�”}”(hŒZi”h]”hŒZi”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hjèubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjåubj™)�”}”(hhh]”hÝ)�”}”(hŒZo”h]”hŒZo”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hjÿubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjåubj™)�”}”(hhh]”hÝ)�”}”(hŒIsochronous input and output”h]”hŒIsochronous input and output”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjåubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hj�ubj”)�”}”(hhh]”(j™)�”}”(hhh]”hÝ)�”}”(hŒIi”h]”hŒIi”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hj6ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj3ubj™)�”}”(hhh]”hÝ)�”}”(hŒIo”h]”hŒIo”…”�”}”(hjPh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hjMubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj3ubj™)�”}”(hhh]”hÝ)�”}”(hŒInterrupt input and output”h]”hŒInterrupt input and output”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K�hjdubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj3ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hj�ubj”)�”}”(hhh]”(j™)�”}”(hhh]”hÝ)�”}”(hŒBi”h]”hŒBi”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K‘hj„ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj�ubj™)�”}”(hhh]”hÝ)�”}”(hŒBo”h]”hŒBo”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K‘hj›ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj�ubj™)�”}”(hhh]”hÝ)�”}”(hŒBulk input and output”h]”hŒBulk input and output”…”�”}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K‘hj²ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jŽhjkubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1jihjfubah}”(h]”h ]”h"]”h$]”h&]”uh1jdhj`ubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´K�hjLubhÝ)�”}”(hŒ}Bus number, Device address, and Endpoint are decimal numbers, but they may have leading zeros, for the sake of human readers.”h]”hŒ}Bus number, Device address, and Endpoint are decimal numbers, but they may have leading zeros, for the sake of human readers.”…”�”}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K”hjLubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hX-URB Status word. This is either a letter, or several numbers separated by colons: URB status, interval, start frame, and error count. Unlike the "address" word, all fields save the status are optional. Interval is printed only for interrupt and isochronous URBs. Start frame is printed only for isochronous URBs. Error count is printed only for isochronous callback events. The status field is a decimal number, sometimes negative, which represents a "status" field of the URB. This field makes no sense for submissions, but is present anyway to help scripts with parsing. When an error occurs, the field contains the error code. In case of a submission of a Control packet, this field contains a Setup Tag instead of an group of numbers. It is easy to tell whether the Setup Tag is present because it is never a number. Thus if scripts find a set of numbers in this word, they proceed to read Data Length (except for isochronous URBs). If they find something else, like a letter, they read the setup packet before reading the Data Length or isochronous descriptors. ”h]”(hÝ)�”}”(hXuURB Status word. This is either a letter, or several numbers separated by colons: URB status, interval, start frame, and error count. Unlike the "address" word, all fields save the status are optional. Interval is printed only for interrupt and isochronous URBs. Start frame is printed only for isochronous URBs. Error count is printed only for isochronous callback events.”h]”hXyURB Status word. This is either a letter, or several numbers separated by colons: URB status, interval, start frame, and error count. Unlike the “addressâ€� word, all fields save the status are optional. Interval is printed only for interrupt and isochronous URBs. Start frame is printed only for isochronous URBs. Error count is printed only for isochronous callback events.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K—hjüubhÝ)�”}”(hŒÿThe status field is a decimal number, sometimes negative, which represents a "status" field of the URB. This field makes no sense for submissions, but is present anyway to help scripts with parsing. When an error occurs, the field contains the error code.”h]”hXThe status field is a decimal number, sometimes negative, which represents a “statusâ€� field of the URB. This field makes no sense for submissions, but is present anyway to help scripts with parsing. When an error occurs, the field contains the error code.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KžhjüubhÝ)�”}”(hX´In case of a submission of a Control packet, this field contains a Setup Tag instead of an group of numbers. It is easy to tell whether the Setup Tag is present because it is never a number. Thus if scripts find a set of numbers in this word, they proceed to read Data Length (except for isochronous URBs). If they find something else, like a letter, they read the setup packet before reading the Data Length or isochronous descriptors.”h]”hX´In case of a submission of a Control packet, this field contains a Setup Tag instead of an group of numbers. It is easy to tell whether the Setup Tag is present because it is never a number. Thus if scripts find a set of numbers in this word, they proceed to read Data Length (except for isochronous URBs). If they find something else, like a letter, they read the setup packet before reading the Data Length or isochronous descriptors.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K£hjüubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hX+Setup packet, if present, consists of 5 words: one of each for bmRequestType, bRequest, wValue, wIndex, wLength, as specified by the USB Specification 2.0. These words are safe to decode if Setup Tag was 's'. Otherwise, the setup packet was present, but not captured, and the fields contain filler. ”h]”hÝ)�”}”(hX*Setup packet, if present, consists of 5 words: one of each for bmRequestType, bRequest, wValue, wIndex, wLength, as specified by the USB Specification 2.0. These words are safe to decode if Setup Tag was 's'. Otherwise, the setup packet was present, but not captured, and the fields contain filler.”h]”hX.Setup packet, if present, consists of 5 words: one of each for bmRequestType, bRequest, wValue, wIndex, wLength, as specified by the USB Specification 2.0. These words are safe to decode if Setup Tag was ‘s’. Otherwise, the setup packet was present, but not captured, and the fields contain filler.”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kªhj0ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hX�Number of isochronous frame descriptors and descriptors themselves. If an Isochronous transfer event has a set of descriptors, a total number of them in an URB is printed first, then a word per descriptor, up to a total of 5. The word consists of 3 colon-separated decimal numbers for status, offset, and length respectively. For submissions, initial length is reported. For callbacks, actual length is reported. ”h]”hÝ)�”}”(hXœNumber of isochronous frame descriptors and descriptors themselves. If an Isochronous transfer event has a set of descriptors, a total number of them in an URB is printed first, then a word per descriptor, up to a total of 5. The word consists of 3 colon-separated decimal numbers for status, offset, and length respectively. For submissions, initial length is reported. For callbacks, actual length is reported.”h]”hXœNumber of isochronous frame descriptors and descriptors themselves. If an Isochronous transfer event has a set of descriptors, a total number of them in an URB is printed first, then a word per descriptor, up to a total of 5. The word consists of 3 colon-separated decimal numbers for status, offset, and length respectively. For submissions, initial length is reported. For callbacks, actual length is reported.”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¯hjHubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hŒfData Length. For submissions, this is the requested length. For callbacks, this is the actual length. ”h]”hÝ)�”}”(hŒeData Length. For submissions, this is the requested length. For callbacks, this is the actual length.”h]”hŒeData Length. For submissions, this is the requested length. For callbacks, this is the actual length.”…”�”}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¶hj`ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hŒ�Data tag. The usbmon may not always capture data, even if length is nonzero. The data words are present only if this tag is '='. ”h]”hÝ)�”}”(hŒ€Data tag. The usbmon may not always capture data, even if length is nonzero. The data words are present only if this tag is '='.”h]”hŒ„Data tag. The usbmon may not always capture data, even if length is nonzero. The data words are present only if this tag is ‘=’.”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¹hjxubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubj)�”}”(hXxData words follow, in big endian hexadecimal format. Notice that they are not machine words, but really just a byte stream split into words to make it easier to read. Thus, the last word may contain from one to four bytes. The length of collected data is limited and can be less than the data length reported in the Data Length word. In the case of an Isochronous input (Zi) completion where the received data is sparse in the buffer, the length of the collected data can be greater than the Data Length value (because Data Length counts only the bytes that were received whereas the Data words contain the entire transfer buffer). ”h]”hÝ)�”}”(hXwData words follow, in big endian hexadecimal format. Notice that they are not machine words, but really just a byte stream split into words to make it easier to read. Thus, the last word may contain from one to four bytes. The length of collected data is limited and can be less than the data length reported in the Data Length word. In the case of an Isochronous input (Zi) completion where the received data is sparse in the buffer, the length of the collected data can be greater than the Data Length value (because Data Length counts only the bytes that were received whereas the Data words contain the entire transfer buffer).”h]”hXwData words follow, in big endian hexadecimal format. Notice that they are not machine words, but really just a byte stream split into words to make it easier to read. Thus, the last word may contain from one to four bytes. The length of collected data is limited and can be less than the data length reported in the Data Length word. In the case of an Isochronous input (Zi) completion where the received data is sparse in the buffer, the length of the collected data can be greater than the Data Length value (because Data Length counts only the bytes that were received whereas the Data words contain the entire transfer buffer).”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¼hj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jýh³hÊh´K~hj´h²hubhÝ)�”}”(hŒ Examples:”h]”hŒ Examples:”…”�”}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÆhj´h²hubhÝ)�”}”(hŒ0An input control transfer to get a port status::”h]”hŒ/An input control transfer to get a port status:”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÈhj´h²hubj])�”}”(hŒkd5ea89a0 3575914555 S Ci:1:001:0 s a3 00 0000 0003 0004 4 < d5ea89a0 3575914560 C Ci:1:001:0 0 4 = 01050000”h]”hŒkd5ea89a0 3575914555 S Ci:1:001:0 s a3 00 0000 0003 0004 4 < d5ea89a0 3575914560 C Ci:1:001:0 0 4 = 01050000”…”�”}”hjÌsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KÊhj´h²hubhÝ)�”}”(hŒzAn output bulk transfer to send a SCSI command 0x28 (READ_10) in a 31-byte Bulk wrapper to a storage device at address 5::”h]”hŒyAn output bulk transfer to send a SCSI command 0x28 (READ_10) in a 31-byte Bulk wrapper to a storage device at address 5:”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÍhj´h²hubj])�”}”(hŒ˜dd65f0e8 4128379752 S Bo:1:005:2 -115 31 = 55534243 ad000000 00800000 80010a28 20000000 20000040 00000000 000000 dd65f0e8 4128379808 C Bo:1:005:2 0 31 >”h]”hŒ˜dd65f0e8 4128379752 S Bo:1:005:2 -115 31 = 55534243 ad000000 00800000 80010a28 20000000 20000040 00000000 000000 dd65f0e8 4128379808 C Bo:1:005:2 0 31 >”…”�”}”hjèsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KÐhj´h²hubeh}”(h]”Œraw-text-data-format”ah ]”h"]”Œraw text data format”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kkubh¶)�”}”(hhh]”(h»)�”}”(hŒRaw binary format and API”h]”hŒRaw binary format and API”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjþh²hh³hÊh´KÔubhÝ)�”}”(hŒÙThe overall architecture of the API is about the same as the one above, only the events are delivered in binary format. Each event is sent in the following structure (its name is made up, so that we can refer to it)::”h]”hŒØThe overall architecture of the API is about the same as the one above, only the events are delivered in binary format. Each event is sent in the following structure (its name is made up, so that we can refer to it):”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÖhjþh²hubj])�”}”(hX’struct usbmon_packet { u64 id; /* 0: URB ID - from submission to callback */ unsigned char type; /* 8: Same as text; extensible. */ unsigned char xfer_type; /* ISO (0), Intr, Control, Bulk (3) */ unsigned char epnum; /* Endpoint number and transfer direction */ unsigned char devnum; /* Device address */ u16 busnum; /* 12: Bus number */ char flag_setup; /* 14: Same as text */ char flag_data; /* 15: Same as text; Binary zero is OK. */ s64 ts_sec; /* 16: gettimeofday */ s32 ts_usec; /* 24: gettimeofday */ int status; /* 28: */ unsigned int length; /* 32: Length of data (submitted or actual) */ unsigned int len_cap; /* 36: Delivered length */ union { /* 40: */ unsigned char setup[SETUP_LEN]; /* Only for Control S-type */ struct iso_rec { /* Only for ISO */ int error_count; int numdesc; } iso; } s; int interval; /* 48: Only for Interrupt and ISO */ int start_frame; /* 52: For ISO */ unsigned int xfer_flags; /* 56: copy of URB's transfer_flags */ unsigned int ndesc; /* 60: Actual number of ISO descriptors */ }; /* 64 total length */”h]”hX’struct usbmon_packet { u64 id; /* 0: URB ID - from submission to callback */ unsigned char type; /* 8: Same as text; extensible. */ unsigned char xfer_type; /* ISO (0), Intr, Control, Bulk (3) */ unsigned char epnum; /* Endpoint number and transfer direction */ unsigned char devnum; /* Device address */ u16 busnum; /* 12: Bus number */ char flag_setup; /* 14: Same as text */ char flag_data; /* 15: Same as text; Binary zero is OK. */ s64 ts_sec; /* 16: gettimeofday */ s32 ts_usec; /* 24: gettimeofday */ int status; /* 28: */ unsigned int length; /* 32: Length of data (submitted or actual) */ unsigned int len_cap; /* 36: Delivered length */ union { /* 40: */ unsigned char setup[SETUP_LEN]; /* Only for Control S-type */ struct iso_rec { /* Only for ISO */ int error_count; int numdesc; } iso; } s; int interval; /* 48: Only for Interrupt and ISO */ int start_frame; /* 52: For ISO */ unsigned int xfer_flags; /* 56: copy of URB's transfer_flags */ unsigned int ndesc; /* 60: Actual number of ISO descriptors */ }; /* 64 total length */”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´KÚhjþh²hubhÝ)�”}”(hŒÍThese events can be received from a character device by reading with read(2), with an ioctl(2), or by accessing the buffer with mmap. However, read(2) only returns first 48 bytes for compatibility reasons.”h]”hŒÍThese events can be received from a character device by reading with read(2), with an ioctl(2), or by accessing the buffer with mmap. However, read(2) only returns first 48 bytes for compatibility reasons.”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kõhjþh²hubhÝ)�”}”(hŒÔThe character device is usually called /dev/usbmonN, where N is the USB bus number. Number zero (/dev/usbmon0) is special and means "all buses". Note that specific naming policy is set by your Linux distribution.”h]”hŒØThe character device is usually called /dev/usbmonN, where N is the USB bus number. Number zero (/dev/usbmon0) is special and means “all busesâ€�. Note that specific naming policy is set by your Linux distribution.”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kùhjþh²hubhÝ)�”}”(hŒŸIf you create /dev/usbmon0 by hand, make sure that it is owned by root and has mode 0600. Otherwise, unprivileged users will be able to snoop keyboard traffic.”h]”hŒŸIf you create /dev/usbmon0 by hand, make sure that it is owned by root and has mode 0600. Otherwise, unprivileged users will be able to snoop keyboard traffic.”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kýhjþh²hubhÝ)�”}”(hŒAThe following ioctl calls are available, with MON_IOC_MAGIC 0x92:”h]”hŒAThe following ioctl calls are available, with MON_IOC_MAGIC 0x92:”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjþh²hubj_)�”}”(hŒ3MON_IOCQ_URB_LEN, defined as _IO(MON_IOC_MAGIC, 1) ”h]”hÝ)�”}”(hŒ2MON_IOCQ_URB_LEN, defined as _IO(MON_IOC_MAGIC, 1)”h]”hŒ2MON_IOCQ_URB_LEN, defined as _IO(MON_IOC_MAGIC, 1)”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjcubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´Mhjþh²hubhÝ)�”}”(hŒ²This call returns the length of data in the next event. Note that majority of events contain no data, so if this call returns zero, it does not mean that no events are available.”h]”hŒ²This call returns the length of data in the next event. Note that majority of events contain no data, so if this call returns zero, it does not mean that no events are available.”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjþh²hubj_)�”}”(hŒHMON_IOCG_STATS, defined as _IOR(MON_IOC_MAGIC, 3, struct mon_bin_stats) ”h]”hÝ)�”}”(hŒGMON_IOCG_STATS, defined as _IOR(MON_IOC_MAGIC, 3, struct mon_bin_stats)”h]”hŒGMON_IOCG_STATS, defined as _IOR(MON_IOC_MAGIC, 3, struct mon_bin_stats)”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M hj‰ubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´M hjþh²hubhÝ)�”}”(hŒ6The argument is a pointer to the following structure::”h]”hŒ5The argument is a pointer to the following structure:”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M hjþh²hubj])�”}”(hŒ>struct mon_bin_stats { u32 queued; u32 dropped; };”h]”hŒ>struct mon_bin_stats { u32 queued; u32 dropped; };”…”�”}”hj¯sbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´M hjþh²hubhÝ)�”}”(hŒ“The member "queued" refers to the number of events currently queued in the buffer (and not to the number of events processed since the last reset).”h]”hŒ—The member “queuedâ€� refers to the number of events currently queued in the buffer (and not to the number of events processed since the last reset).”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjþh²hubhÝ)�”}”(hŒXThe member "dropped" is the number of events lost since the last call to MON_IOCG_STATS.”h]”hŒ\The member “droppedâ€� is the number of events lost since the last call to MON_IOCG_STATS.”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjþh²hubj_)�”}”(hŒ5MON_IOCT_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 4) ”h]”hÝ)�”}”(hŒ4MON_IOCT_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 4)”h]”hŒ4MON_IOCT_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 4)”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MhjÙubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´Mhjþh²hubhÝ)�”}”(hŒßThis call sets the buffer size. The argument is the size in bytes. The size may be rounded down to the next chunk (or page). If the requested size is out of [unspecified] bounds for this kernel, the call fails with -EINVAL.”h]”hŒßThis call sets the buffer size. The argument is the size in bytes. The size may be rounded down to the next chunk (or page). If the requested size is out of [unspecified] bounds for this kernel, the call fails with -EINVAL.”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjþh²hubj_)�”}”(hŒ5MON_IOCQ_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 5) ”h]”hÝ)�”}”(hŒ4MON_IOCQ_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 5)”h]”hŒ4MON_IOCQ_RING_SIZE, defined as _IO(MON_IOC_MAGIC, 5)”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mhjÿubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´Mhjþh²hubhÝ)�”}”(hŒ:This call returns the current size of the buffer in bytes.”h]”hŒ:This call returns the current size of the buffer in bytes.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M!hjþh²hubj_)�”}”(hŒŠMON_IOCX_GET, defined as _IOW(MON_IOC_MAGIC, 6, struct mon_get_arg) MON_IOCX_GETX, defined as _IOW(MON_IOC_MAGIC, 10, struct mon_get_arg) ”h]”hÝ)�”}”(hŒ‰MON_IOCX_GET, defined as _IOW(MON_IOC_MAGIC, 6, struct mon_get_arg) MON_IOCX_GETX, defined as _IOW(MON_IOC_MAGIC, 10, struct mon_get_arg)”h]”hŒ‰MON_IOCX_GET, defined as _IOW(MON_IOC_MAGIC, 6, struct mon_get_arg) MON_IOCX_GETX, defined as _IOW(MON_IOC_MAGIC, 10, struct mon_get_arg)”…”�”}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M#hj%ubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´M#hjþh²hubhÝ)�”}”(hŒœThese calls wait for events to arrive if none were in the kernel buffer, then return the first event. The argument is a pointer to the following structure::”h]”hŒ›These calls wait for events to arrive if none were in the kernel buffer, then return the first event. The argument is a pointer to the following structure:”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M&hjþh²hubj])�”}”(hŒ‹struct mon_get_arg { struct usbmon_packet *hdr; void *data; size_t alloc; /* Length of data (can be zero) */ };”h]”hŒ‹struct mon_get_arg { struct usbmon_packet *hdr; void *data; size_t alloc; /* Length of data (can be zero) */ };”…”�”}”hjKsbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´M*hjþh²hubhÝ)�”}”(hŒÛBefore the call, hdr, data, and alloc should be filled. Upon return, the area pointed by hdr contains the next event structure, and the data buffer contains the data, if any. The event is removed from the kernel buffer.”h]”hŒÛBefore the call, hdr, data, and alloc should be filled. Upon return, the area pointed by hdr contains the next event structure, and the data buffer contains the data, if any. The event is removed from the kernel buffer.”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M0hjþh²hubhÝ)�”}”(hŒLThe MON_IOCX_GET copies 48 bytes to hdr area, MON_IOCX_GETX copies 64 bytes.”h]”hŒLThe MON_IOCX_GET copies 48 bytes to hdr area, MON_IOCX_GETX copies 64 bytes.”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M4hjþh²hubj_)�”}”(hŒKMON_IOCX_MFETCH, defined as _IOWR(MON_IOC_MAGIC, 7, struct mon_mfetch_arg) ”h]”hÝ)�”}”(hŒJMON_IOCX_MFETCH, defined as _IOWR(MON_IOC_MAGIC, 7, struct mon_mfetch_arg)”h]”hŒJMON_IOCX_MFETCH, defined as _IOWR(MON_IOC_MAGIC, 7, struct mon_mfetch_arg)”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M6hjuubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´M6hjþh²hubhÝ)�”}”(hŒŠThis ioctl is primarily used when the application accesses the buffer with mmap(2). Its argument is a pointer to the following structure::”h]”hŒ‰This ioctl is primarily used when the application accesses the buffer with mmap(2). Its argument is a pointer to the following structure:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M8hjþh²hubj])�”}”(hŒâstruct mon_mfetch_arg { uint32_t *offvec; /* Vector of events fetched */ uint32_t nfetch; /* Number of events to fetch (out: fetched) */ uint32_t nflush; /* Number of events to flush */ };”h]”hŒâstruct mon_mfetch_arg { uint32_t *offvec; /* Vector of events fetched */ uint32_t nfetch; /* Number of events to fetch (out: fetched) */ uint32_t nflush; /* Number of events to flush */ };”…”�”}”hj›sbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´M;hjþh²hubhÝ)�”}”(hŒThe ioctl operates in 3 stages.”h]”hŒThe ioctl operates in 3 stages.”…”�”}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MAhjþh²hubhÝ)�”}”(hŒ‡First, it removes and discards up to nflush events from the kernel buffer. The actual number of events discarded is returned in nflush.”h]”hŒ‡First, it removes and discards up to nflush events from the kernel buffer. The actual number of events discarded is returned in nflush.”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MChjþh²hubhÝ)�”}”(hŒmSecond, it waits for an event to be present in the buffer, unless the pseudo- device is open with O_NONBLOCK.”h]”hŒmSecond, it waits for an event to be present in the buffer, unless the pseudo- device is open with O_NONBLOCK.”…”�”}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MFhjþh²hubhÝ)�”}”(hŒœThird, it extracts up to nfetch offsets into the mmap buffer, and stores them into the offvec. The actual number of event offsets is stored into the nfetch.”h]”hŒœThird, it extracts up to nfetch offsets into the mmap buffer, and stores them into the offvec. The actual number of event offsets is stored into the nfetch.”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MIhjþh²hubj_)�”}”(hŒ2MON_IOCH_MFLUSH, defined as _IO(MON_IOC_MAGIC, 8) ”h]”hÝ)�”}”(hŒ1MON_IOCH_MFLUSH, defined as _IO(MON_IOC_MAGIC, 8)”h]”hŒ1MON_IOCH_MFLUSH, defined as _IO(MON_IOC_MAGIC, 8)”…”�”}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MMhjáubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´MMhjþh²hubhÝ)�”}”(hXThis call removes a number of events from the kernel buffer. Its argument is the number of events to remove. If the buffer contains fewer events than requested, all events present are removed, and no error is reported. This works when no events are available too.”h]”hXThis call removes a number of events from the kernel buffer. Its argument is the number of events to remove. If the buffer contains fewer events than requested, all events present are removed, and no error is reported. This works when no events are available too.”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MOhjþh²hubj_)�”}”(hŒFIONBIO ”h]”hÝ)�”}”(hŒFIONBIO”h]”hŒFIONBIO”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MThjubah}”(h]”h ]”h"]”h$]”h&]”uh1j^h³hÊh´MThjþh²hubhÝ)�”}”(hŒFThe ioctl FIONBIO may be implemented in the future, if there's a need.”h]”hŒHThe ioctl FIONBIO may be implemented in the future, if there’s a need.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MVhjþh²hubhÝ)�”}”(hŒ‰In addition to ioctl(2) and read(2), the special file of binary API can be polled with select(2) and poll(2). But lseek(2) does not work.”h]”hŒ‰In addition to ioctl(2) and read(2), the special file of binary API can be polled with select(2) and poll(2). But lseek(2) does not work.”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MXhjþh²hubjþ)�”}”(hhh]”j)�”}”(hŒ=Memory-mapped access of the kernel buffer for the binary API ”h]”hÝ)�”}”(hŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj;h²hh³hÊh´Nubah}”(h]”h ]”h"]”h$]”h&]”j®Œ*”uh1jýh³hÊh´M[hjþh²hubhÝ)�”}”(hŒThe basic idea is simple:”h]”hŒThe basic idea is simple:”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M]hjþh²hubhÝ)�”}”(hŒ’To prepare, map the buffer by getting the current size, then using mmap(2). Then, execute a loop similar to the one written in pseudo-code below::”h]”hŒ‘To prepare, map the buffer by getting the current size, then using mmap(2). Then, execute a loop similar to the one written in pseudo-code below:”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M_hjþh²hubj])�”}”(hX?struct mon_mfetch_arg fetch; struct usbmon_packet *hdr; int nflush = 0; for (;;) { fetch.offvec = vec; // Has N 32-bit words fetch.nfetch = N; // Or less than N fetch.nflush = nflush; ioctl(fd, MON_IOCX_MFETCH, &fetch); // Process errors, too nflush = fetch.nfetch; // This many packets to flush when done for (i = 0; i < nflush; i++) { hdr = (struct ubsmon_packet *) &mmap_area[vec[i]]; if (hdr->type == '@') // Filler packet continue; caddr_t data = &mmap_area[vec[i]] + 64; process_packet(hdr, data); } }”h]”hX?struct mon_mfetch_arg fetch; struct usbmon_packet *hdr; int nflush = 0; for (;;) { fetch.offvec = vec; // Has N 32-bit words fetch.nfetch = N; // Or less than N fetch.nflush = nflush; ioctl(fd, MON_IOCX_MFETCH, &fetch); // Process errors, too nflush = fetch.nfetch; // This many packets to flush when done for (i = 0; i < nflush; i++) { hdr = (struct ubsmon_packet *) &mmap_area[vec[i]]; if (hdr->type == '@') // Filler packet continue; caddr_t data = &mmap_area[vec[i]] + 64; process_packet(hdr, data); } }”…”�”}”hjysbah}”(h]”h ]”h"]”h$]”h&]”jljmuh1j\h³hÊh´Mbhjþh²hubhÝ)�”}”(hŒ>Thus, the main idea is to execute only one ioctl per N events.”h]”hŒ>Thus, the main idea is to execute only one ioctl per N events.”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mthjþh²hubhÝ)�”}”(hŒ˜Although the buffer is circular, the returned headers and data do not cross the end of the buffer, so the above pseudo-code does not need any gathering.”h]”hŒ˜Although the buffer is circular, the returned headers and data do not cross the end of the buffer, so the above pseudo-code does not need any gathering.”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mvhjþh²hubeh}”(h]”Œraw-binary-format-and-api”ah ]”h"]”Œraw binary format and api”ah$]”h&]”uh1hµhh·h²hh³hÊh´KÔubeh}”(h]”Œusbmon”ah ]”h"]”Œusbmon”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”j˜Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jÕŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j°j­j j j±j®j�jšjüjùjMjJjtjqj©j¦jûjøj¨j¥uŒ nametypes”}”(j°‰j ‰j±‰j�‰jü‰jM‰jt‰j©‰jû‰j¨‰uh}”(j­h·j hËj®jjšj=jùj jJjÿjqjPj¦jwjøj´j¥jþuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.