From 66858d15a7916d6978eddcce96ac813ea6594cb8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 13 Jan 2019 23:04:48 +0100 Subject: [PATCH] Remove 'actual_length' parameter of USB_tranfer_compl We can simply cut the returned data octet string to the actual length instead. In this case, we must also adjust for the control pipe header in case of CONTROL IN transfers. --- src/USB_PT.cc | 6 ++++-- src/USB_PortTypes.ttcn | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/USB_PT.cc b/src/USB_PT.cc index 5c83729..a5f43a4 100644 --- a/src/USB_PT.cc +++ b/src/USB_PT.cc @@ -492,8 +492,10 @@ void USB__PT_PROVIDER::transfer_completed(USB_Transfer *t) xfc.transfer__hdl() = t->mID; xfc.ttype() = ttype_usb2titan((enum libusb_transfer_type) t->mXfer->type); xfc.endpoint() = t->mXfer->endpoint; - xfc.data() = OCTETSTRING(t->mXfer->length, t->mXfer->buffer); - xfc.actual__length() = t->mXfer->actual_length; + unsigned int len = t->mXfer->actual_length; + if (t->mXfer->type == LIBUSB_TRANSFER_TYPE_CONTROL && t->mXfer->buffer[0] & 0x80) + len += 8; + xfc.data() = OCTETSTRING(len, t->mXfer->buffer); xfc.status() = t->mXfer->status; incoming_message(xfc); } diff --git a/src/USB_PortTypes.ttcn b/src/USB_PortTypes.ttcn index 39d7c31..0d37ced 100644 --- a/src/USB_PortTypes.ttcn +++ b/src/USB_PortTypes.ttcn @@ -43,7 +43,6 @@ module USB_PortTypes { USB_endpoint endpoint, USB_transfer_type ttype, octetstring data, - integer actual_length, USB_transfer_status status };