| 78 | |
| 79 | |
| 80 | class USBpcap(Packet): |
| 81 | name = "USBpcap URB" |
| 82 | fields_desc = [ByteField("headerLen", None), |
| 83 | ByteField("res", 0), |
| 84 | XLELongField("irpId", 0), |
| 85 | LEIntEnumField("usbd_status", 0x0, _usbd_status_codes), |
| 86 | LEShortEnumField("function", 0, _urb_functions), |
| 87 | XByteField("info", 0), |
| 88 | LEShortField("bus", 0), |
| 89 | LEShortField("device", 0), |
| 90 | XByteField("endpoint", 0), |
| 91 | ByteEnumField("transfer", 0, _transfer_types), |
| 92 | LenField("dataLength", None, fmt="<I")] |
| 93 | |
| 94 | def post_build(self, p, pay): |
| 95 | if self.headerLen is None: |
| 96 | headerLen = len(p) |
| 97 | if isinstance(self.payload, (USBpcapTransferIsochronous, |
| 98 | USBpcapTransferInterrupt, |
| 99 | USBpcapTransferControl)): |
| 100 | headerLen += len(self.payload) - len(self.payload.payload) |
| 101 | p = chb(headerLen) + p[1:] |
| 102 | return p + pay |
| 103 | |
| 104 | def guess_payload_class(self, payload): |
| 105 | if self.headerLen == 27: |
| 106 | # No Transfer layer |
| 107 | return super(USBpcap, self).guess_payload_class(payload) |
| 108 | if self.transfer == 0: |
| 109 | return USBpcapTransferIsochronous |
| 110 | elif self.transfer == 1: |
| 111 | return USBpcapTransferInterrupt |
| 112 | elif self.transfer == 2: |
| 113 | return USBpcapTransferControl |
| 114 | return super(USBpcap, self).guess_payload_class(payload) |
| 115 | |
| 116 | |
| 117 | class USBpcapTransferIsochronous(Packet): |
nothing calls this directly
no test coverage detected
searching dependent graphs…