1e64ac239SWeongyo Jeong.\" 2e64ac239SWeongyo Jeong.\" Copyright (c) 2010 Weongyo Jeong. 3e64ac239SWeongyo Jeong.\" All rights reserved. 4e64ac239SWeongyo Jeong.\" 5e64ac239SWeongyo Jeong.\" Redistribution and use in source and binary forms, with or without 6e64ac239SWeongyo Jeong.\" modification, are permitted provided that the following conditions 7e64ac239SWeongyo Jeong.\" are met: 8e64ac239SWeongyo Jeong.\" 1. Redistributions of source code must retain the above copyright 9e64ac239SWeongyo Jeong.\" notice, this list of conditions and the following disclaimer. 10e64ac239SWeongyo Jeong.\" 2. Redistributions in binary form must reproduce the above copyright 11e64ac239SWeongyo Jeong.\" notice, this list of conditions and the following disclaimer in the 12e64ac239SWeongyo Jeong.\" documentation and/or other materials provided with the distribution. 13e64ac239SWeongyo Jeong.\" 14e64ac239SWeongyo Jeong.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15e64ac239SWeongyo Jeong.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16e64ac239SWeongyo Jeong.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17e64ac239SWeongyo Jeong.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18e64ac239SWeongyo Jeong.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19e64ac239SWeongyo Jeong.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20e64ac239SWeongyo Jeong.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21e64ac239SWeongyo Jeong.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22e64ac239SWeongyo Jeong.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23e64ac239SWeongyo Jeong.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24e64ac239SWeongyo Jeong.\" SUCH DAMAGE. 25e64ac239SWeongyo Jeong.\" 26e64ac239SWeongyo Jeong.\" $FreeBSD$ 27e64ac239SWeongyo Jeong.\" 28*fa001545SHans Petter Selasky.Dd April 24, 2012 29a6d11f71SRuslan Ermilov.Dt USBDUMP 8 30e64ac239SWeongyo Jeong.Os 31e64ac239SWeongyo Jeong.Sh NAME 32e64ac239SWeongyo Jeong.Nm usbdump 33e64ac239SWeongyo Jeong.Nd "dump traffic on USB host controller" 34e64ac239SWeongyo Jeong.Sh SYNOPSIS 35e64ac239SWeongyo Jeong.Nm 36e64ac239SWeongyo Jeong.Op Fl i Ar ifname 37e64ac239SWeongyo Jeong.Op Fl r Ar file 38e64ac239SWeongyo Jeong.Op Fl s Ar snaplen 39e64ac239SWeongyo Jeong.Op Fl v 40e64ac239SWeongyo Jeong.Op Fl w Ar file 4179fcfd2eSHans Petter Selasky.Op Fl f Ar filter 42*fa001545SHans Petter Selasky.Op Fl b Ar file 43e64ac239SWeongyo Jeong.Sh DESCRIPTION 44e64ac239SWeongyo JeongThe 45e64ac239SWeongyo Jeong.Nm 4658ea8701SWeongyo Jeongutility provides a way to dump USB packets on host controllers. 47e64ac239SWeongyo Jeong.Pp 4858ea8701SWeongyo JeongThe following options are accepted: 49e64ac239SWeongyo Jeong.Bl -tag -width ".Fl f Ar file" 50*fa001545SHans Petter Selasky.It Fl b Ar file 51*fa001545SHans Petter SelaskyStore data part of the USB trace in binary format to the given 52*fa001545SHans Petter Selasky.Ar file . 53*fa001545SHans Petter SelaskyThis option also works with the -r and -f options. 54e64ac239SWeongyo Jeong.It Fl i Ar ifname 5558ea8701SWeongyo JeongListen on USB bus interface 5658ea8701SWeongyo Jeong.Ar ifname . 57e64ac239SWeongyo Jeong.It Fl r Ar file 5858ea8701SWeongyo JeongRead the raw packets from 5958ea8701SWeongyo Jeong.Ar file . 60*fa001545SHans Petter SelaskyThis option also works with the -f option. 61e64ac239SWeongyo Jeong.It Fl s Ar snaplen 6258ea8701SWeongyo JeongSnapshot 6358ea8701SWeongyo Jeong.Ar snaplen 6458ea8701SWeongyo Jeongbytes from each packet. 65e64ac239SWeongyo Jeong.It Fl v 66e64ac239SWeongyo JeongEnable debugging messages. 6758ea8701SWeongyo JeongWhen defined multiple times the verbosity level increases. 68e64ac239SWeongyo Jeong.It Fl w Ar file 6958ea8701SWeongyo JeongWrite the raw packets to 7058ea8701SWeongyo Jeong.Ar file . 71*fa001545SHans Petter SelaskyThis option also works with the -s and -v options. 7279fcfd2eSHans Petter Selasky.It Fl f Ar filter 7379fcfd2eSHans Petter SelaskyThe filter argument consists of either one or two numbers separated by a dot. 7479fcfd2eSHans Petter SelaskyThe first indicates the device unit number which should be traced. 7579fcfd2eSHans Petter SelaskyThe second number which is optional indicates the endpoint which should be traced. 7679fcfd2eSHans Petter SelaskyTo get all traffic for the control endpoint, two filters should be 7779fcfd2eSHans Petter Selaskycreated, one for endpoint 0 and one for endpoint 128. 7879fcfd2eSHans Petter SelaskyIf 128 is added to the endpoint number that means IN direction, else OUT direction is implied. 7979fcfd2eSHans Petter SelaskyA device unit or endpoint value of -1 means ignore this field. 8079fcfd2eSHans Petter SelaskyIf no filters are specified, all packets are passed through using the default -1,-1 filter. 8179fcfd2eSHans Petter SelaskyThis option can be specified multiple times. 82e64ac239SWeongyo Jeong.El 83e64ac239SWeongyo Jeong.Sh EXAMPLES 846b436e62SBenedict ReuschlingCapture the USB raw packets on usbus2: 85e64ac239SWeongyo Jeong.Pp 86e64ac239SWeongyo Jeong.Dl "usbdump -i usbus2 -s 256 -v" 87e64ac239SWeongyo Jeong.Pp 886b436e62SBenedict ReuschlingDump the USB raw packets of usbus2 into the file without packet 89e64ac239SWeongyo Jeongsize limit: 90e64ac239SWeongyo Jeong.Pp 91e64ac239SWeongyo Jeong.Dl "usbdump -i usbus2 -s 0 -w /tmp/dump_pkts" 92e64ac239SWeongyo Jeong.Pp 9379fcfd2eSHans Petter SelaskyDump the USB raw packets of usbus2, but only the control endpoint traffic 9479fcfd2eSHans Petter Selaskyof device unit number 3: 9579fcfd2eSHans Petter Selasky.Pp 9679fcfd2eSHans Petter Selasky.Dl "usbdump -i usbus2 -s 0 -f 3.0 -f 3.128 -w /tmp/dump_pkts" 9779fcfd2eSHans Petter Selasky.Pp 986b436e62SBenedict ReuschlingRead and display the USB raw packets from previous file: 99e64ac239SWeongyo Jeong.Pp 100e64ac239SWeongyo Jeong.Dl "usbdump -r /tmp/dump_pkts -v" 10158ea8701SWeongyo Jeong.Sh OUTPUT FORMAT 10258ea8701SWeongyo JeongThe output format of 10358ea8701SWeongyo Jeong.Nm 10458ea8701SWeongyo Jeongis as follows: 10558ea8701SWeongyo Jeong.Pp 10658ea8701SWeongyo Jeong.Dl "<time> <bus>.<addr> <ep> <xfertype> <S/D> (<frames>/<length>) <...>" 10758ea8701SWeongyo Jeong.Pp 10858ea8701SWeongyo JeongThe meaning of the output format elements is as follows: 10958ea8701SWeongyo Jeong.Bl -tag -width "<xfertype>" 11058ea8701SWeongyo Jeong.It <time> 11158ea8701SWeongyo JeongA timestamp preceding all output lines. 11258ea8701SWeongyo JeongThe timestamp has the format "hh:mm:ss.frac" and is as accurate as 11358ea8701SWeongyo Jeongthe kernel's clock. 11458ea8701SWeongyo Jeong.It <bus> 11558ea8701SWeongyo JeongThe USB host controller's bus unit number. 11658ea8701SWeongyo Jeong.It <addr> 11758ea8701SWeongyo JeongThe unique number of the USB device as allocated by the host controller driver. 11858ea8701SWeongyo Jeong.It <ep> 11958ea8701SWeongyo JeongThe USB endpoint address that indicates whether the address is 12058ea8701SWeongyo Jeong.Dv OUT 12158ea8701SWeongyo Jeongor 12258ea8701SWeongyo Jeong.Dv IN . 12358ea8701SWeongyo Jeong.It <xfertype> 12458ea8701SWeongyo JeongThe USB transfer type. 12558ea8701SWeongyo JeongCan be 12658ea8701SWeongyo Jeong.Dv CTRL , 12758ea8701SWeongyo Jeong.Dv ISOC , 12858ea8701SWeongyo Jeong.Dv BULK 12958ea8701SWeongyo Jeongor 13058ea8701SWeongyo Jeong.Dv INTR . 13158ea8701SWeongyo Jeong.It <S/D> 13258ea8701SWeongyo Jeong`S' indicates a USB submit. 13358ea8701SWeongyo Jeong`D' indicates a USB transfer done. 13458ea8701SWeongyo Jeong.It <frames> 13558ea8701SWeongyo JeongNumbers of frames in this packets. 13658ea8701SWeongyo JeongIf this is a USB submit, its value is 13758ea8701SWeongyo Jeong.Li xfer->nframes 13858ea8701SWeongyo Jeongwhich means how many frames are acceptable or registered to transfer. 13958ea8701SWeongyo JeongIf this is a USB done, 14058ea8701SWeongyo Jeong.Li xfer->aframes 14158ea8701SWeongyo Jeongis the actual number of frames. 14258ea8701SWeongyo Jeong.It <length> 14358ea8701SWeongyo JeongTotal packet size. 14458ea8701SWeongyo JeongIf this is a USB submit, its value is 14558ea8701SWeongyo Jeong.Li xfer->sumlen . 14658ea8701SWeongyo JeongIf this is a USB done, its value is 14758ea8701SWeongyo Jeong.Li xfer->actlen . 14858ea8701SWeongyo Jeong.It <...> 14958ea8701SWeongyo JeongOptional field used for printing an error string if the packet is from USB done. 15058ea8701SWeongyo Jeong.El 151e64ac239SWeongyo Jeong.Sh SEE ALSO 152e64ac239SWeongyo Jeong.Xr usbconfig 8 153e64ac239SWeongyo Jeong.Sh AUTHORS 154e64ac239SWeongyo Jeong.An Weongyo Jeong 15558ea8701SWeongyo Jeong.Aq weongyo@FreeBSD.org 156