Lines Matching +full:hi +full:- +full:speed

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
82 /* for -w option */
84 /* for -r option */
86 /* for -b option */
179 puf->unit = usb_filt_unit; in add_filter()
180 puf->endpoint = usb_filt_ep; in add_filter()
215 const int addr_off = (uintptr_t)&((struct usbpf_pkthdr *)0)->up_address; in make_filter()
216 const int addr_ep = (uintptr_t)&((struct usbpf_pkthdr *)0)->up_endpoint; in make_filter()
218 if (puf->unit != -1) { in make_filter()
219 if (puf->endpoint != -1) { in make_filter()
224 BPF_JMP | BPF_JEQ | BPF_K, (uint8_t)puf->unit, 0, 3); in make_filter()
230 BPF_JMP | BPF_JEQ | BPF_K, htobe32(puf->endpoint), 0, 1); in make_filter()
237 BPF_JMP | BPF_JEQ | BPF_K, (uint8_t)puf->unit, 0, 1); in make_filter()
241 if (puf->endpoint != -1) { in make_filter()
246 BPF_JMP | BPF_JEQ | BPF_K, htobe32(puf->endpoint), 0, 1); in make_filter()
259 pprog->bf_len = len; in make_filter()
260 pprog->bf_insns = dynamic_insn; in make_filter()
272 if ((puf->unit == -1 || puf->unit == unit) && in match_filter()
273 (puf->endpoint == -1 || puf->endpoint == endpoint)) in match_filter()
288 free(pprog->bf_insns); in free_filter()
315 usb_speedstr(uint8_t speed) in usb_speedstr() argument
317 if (speed >= USB_SPEED_MAX || speed_table[speed] == NULL) in usb_speedstr()
320 return (speed_table[speed]); in usb_speedstr()
382 uint8_t hi; in hexbyte() local
385 hi = temp >> 4; in hexbyte()
387 if (hi < 10) in hexbyte()
388 buf[0] = '0' + hi; in hexbyte()
390 buf[0] = 'A' + hi - 10; in hexbyte()
395 buf[1] = 'A' + lo - 10; in hexbyte()
415 hexbyte(linebuf + i + 1, ((line - region) >> 8) & 0xFF); in hexdump()
416 hexbyte(linebuf + i + 3, (line - region) & 0xFF); in hexdump()
426 linebuf[i] = '-'; in hexdump()
427 linebuf[i + 1] = '-'; in hexdump()
471 ptr_len -= USBPF_HDR_LEN; in print_apacket()
476 memcpy(&up_temp, ptr - USBPF_HDR_LEN, sizeof(up_temp)); in print_apacket()
483 up->up_totlen = le32toh(up->up_totlen); in print_apacket()
484 up->up_busunit = le32toh(up->up_busunit); in print_apacket()
485 up->up_flags = le32toh(up->up_flags); in print_apacket()
486 up->up_status = le32toh(up->up_status); in print_apacket()
487 up->up_error = le32toh(up->up_error); in print_apacket()
488 up->up_interval = le32toh(up->up_interval); in print_apacket()
489 up->up_frames = le32toh(up->up_frames); in print_apacket()
490 up->up_packet_size = le32toh(up->up_packet_size); in print_apacket()
491 up->up_packet_count = le32toh(up->up_packet_count); in print_apacket()
492 up->up_endpoint = le32toh(up->up_endpoint); in print_apacket()
494 if (!match_filter(up->up_address, up->up_endpoint)) in print_apacket()
497 tv.tv_sec = hdr->ts_sec; in print_apacket()
498 tv.tv_usec = hdr->ts_usec; in print_apacket()
504 printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n", in print_apacket()
506 (int)up->up_busunit, (int)up->up_address, in print_apacket()
507 (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE", in print_apacket()
508 usb_xferstr(up->up_xfertype), in print_apacket()
509 (unsigned int)up->up_endpoint, in print_apacket()
510 usb_speedstr(up->up_speed), in print_apacket()
511 (int)up->up_frames, in print_apacket()
512 (int)(up->up_totlen - USBPF_HDR_LEN - in print_apacket()
513 (USBPF_FRAME_HDR_LEN * up->up_frames)), in print_apacket()
514 (int)up->up_interval, in print_apacket()
515 (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "", in print_apacket()
516 (up->up_type == USBPF_XFERTAP_DONE) ? in print_apacket()
517 usb_errstr(up->up_error) : ""); in print_apacket()
521 for (x = 0; x != up->up_frames; x++) { in print_apacket()
528 ptr_len -= USBPF_FRAME_HDR_LEN; in print_apacket()
532 framelen = le32toh(uf->length); in print_apacket()
533 flags = le32toh(uf->flags); in print_apacket()
548 ptr_len -= tot_frame_len; in print_apacket()
557 ret = write(p->bfd, ptr, framelen); in print_apacket()
569 print_flags(up->up_flags); in print_apacket()
571 print_status(up->up_status); in print_apacket()
589 temp.ts_sec = htole32(hdr->bh_tstamp.tv_sec); in fix_packets()
590 temp.ts_usec = htole32(hdr->bh_tstamp.tv_usec); in fix_packets()
591 temp.caplen = htole32(hdr->bh_caplen); in fix_packets()
592 temp.datalen = htole32(hdr->bh_datalen); in fix_packets()
593 temp.hdrlen = hdr->bh_hdrlen; in fix_packets()
596 hdrlen = hdr->bh_hdrlen; in fix_packets()
597 caplen = hdr->bh_caplen; in fix_packets()
602 memset(ptr + sizeof(temp), 0, hdrlen - sizeof(temp)); in fix_packets()
627 temp.ts_sec = le32toh(hdr32->ts_sec); in print_packets()
628 temp.ts_usec = le32toh(hdr32->ts_usec); in print_packets()
629 temp.caplen = le32toh(hdr32->caplen); in print_packets()
630 temp.datalen = le32toh(hdr32->datalen); in print_packets()
631 temp.hdrlen = hdr32->hdrlen; in print_packets()
632 temp.align = hdr32->align; in print_packets()
653 ret = write(p->wfd, &len, sizeof(int)); in write_packets()
658 ret = write(p->wfd, data, datalen); in write_packets()
672 while ((ret = read(p->rfd, &datalen, sizeof(int))) == sizeof(int)) { in read_file()
677 ret = read(p->rfd, data, datalen); in read_file()
696 cc = read(p->fd, (uint8_t *)p->buffer, p->bufsize); in do_loop()
710 fix_packets(p->buffer, cc); in do_loop()
713 write_packets(p, p->buffer, cc); in do_loop()
714 print_packets(p->buffer, cc); in do_loop()
724 p->rfd = open(r_arg, O_RDONLY); in init_rfile()
725 if (p->rfd < 0) { in init_rfile()
729 ret = read(p->rfd, &uf, sizeof(uf)); in init_rfile()
758 p->wfd = open(w_arg, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); in init_wfile()
759 if (p->wfd < 0) { in init_wfile()
767 ret = write(p->wfd, (const void *)&uf, sizeof(uf)); in init_wfile()
778 #define FMT " %-14s %s\n" in usage()
780 fprintf(stderr, FMT, "-d [ugen]B", "Listen on bus, B"); in usage()
781 fprintf(stderr, FMT, "-d [ugen]B.D", "Listen on bus, B and device, D"); in usage()
782 fprintf(stderr, FMT, "-d [ugen]B.D.E", "Listen on bus, B, device, D, and endpoint E"); in usage()
783 fprintf(stderr, FMT, "-i <usbusX>", "Listen on this bus interface"); in usage()
784 fprintf(stderr, FMT, "-f <unit[.endpoint]>", "Specify a device and endpoint filter"); in usage()
785 fprintf(stderr, FMT, "-r <file>", "Read the raw packets from file"); in usage()
786 fprintf(stderr, FMT, "-s <snaplen>", "Snapshot bytes from each packet"); in usage()
787 fprintf(stderr, FMT, "-v", "Increase the verbose level"); in usage()
788 fprintf(stderr, FMT, "-b <file>", "Save raw version of all recorded data to file"); in usage()
789 fprintf(stderr, FMT, "-w <file>", "Write the raw packets to file"); in usage()
790 fprintf(stderr, FMT, "-h", "Display summary of command line options"); in usage()
802 /* check "hw.usb.no_pf" sysctl for 8- and 9- stable */ in check_usb_pf_sysctl()
832 optstring = "b:d:hi:r:s:uvw:f:"; in main()
833 while ((o = getopt(argc, argv, optstring)) != -1) { in main()
843 /* Must be same bus when using -d option. */ in main()
854 filt_ep = -1; in main()
872 filt_ep = -1; in main()
900 snapshot = -1; in main()
923 p->bfd = open(b_arg, O_CREAT | O_TRUNC | in main()
925 if (p->bfd < 0) { in main()
932 * Require more verbosity to print anything when -w or -b is in main()
936 verbose--; in main()
945 p->fd = fd = open("/dev/bpf", O_RDONLY); in main()
946 if (p->fd < 0) in main()
985 p->bufsize = v; in main()
986 p->buffer = (uint8_t *)malloc(p->bufsize); in main()
987 if (p->buffer == NULL) in main()
992 if (ioctl(p->fd, BIOCSETF, (caddr_t)&total_prog) < 0) in main()
1000 if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&tv) < 0) in main()
1027 if (p->fd > 0) in main()
1028 close(p->fd); in main()
1029 if (p->rfd > 0) in main()
1030 close(p->rfd); in main()
1031 if (p->wfd > 0) in main()
1032 close(p->wfd); in main()
1033 if (p->bfd > 0) in main()
1034 close(p->bfd); in main()