This adds a check to the usbus control stack to ensure that the amount
of data received with a setup request does not exceed the amount
indicated within the setup request
This adds a sanity check to the line coding request of the CDC ACM code
to chcek the length parameter in the setup request with the size of the
expected payload struct
This truncates the incomming frames to ETHERNET_FRAME_LEN and silently
discards the rest of the frame until the end of the frame. This should
be modified to an endpoint halt condition after #17090 is merged, but
for now this should be good enough.
Stalling the endpoint with the current stall implementation could cause
a ping of death scenario, so for now the data is truncated until the
above solution can be implemented.
The SetLineCoding request is optional to support (CDC PSTN subclass). No
need to claim to support it to the host and actually discard the data if
it is not supported by the implementation.
This adds compile-time options to configure the serial of an USB
peripheral. The serial be autogenerated with a configured number of
bytes. It is also possible to configure a fixed serial string for a
device and disable the autogeneration of the serial.
Previously, the function would always return the max_len parameter.
This poses two issues:
1. the API requires to return the actual packet size
2. the API requires that if the packet is larger than max_len, the
packet is flushed and -ENOBUFS is returned
3. this basically bypasses the packet flushing, consequtive _recv()
would return the last packet again
This commit fixes those issues.
This changes the prefixes of the symbols generated from USEMODULE and
USEPKG variables. The changes are as follow:
KCONFIG_MODULE_ => KCONFIG_USEMODULE_
KCONFIG_PKG_ => KCONFIG_USEPKG_
MODULE_ => USEMODULE_
PKG_ => USEPKG_
Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:
1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
functions
The private parts need USB definitions (and are thus preferably used
from USB_H_USER_IS_RIOT_INTERNAL compilation units). Functions like
usb_board_reset_in_bootloader do not depend on USB headers for their
definitions and are fair game throughout the application even for
generic RIOT USB devices.
This
* renames DEFAULT_xID to USB_xID_TESTING as it is not really a default
(if anyting, the 7D00 is, and it's not that)
* moves the check into Makefile
* generalizes the check to all test PID/VID pairs
* in doing so, fixes the "or" (which would have ruled out warning-free
use of an allocated pid.codes number), and compares to the actual
testing PID rather than the RIOT-peripheral PID
* removes all occurrences of duplicated checks in examples or tests,
leaving definitions only where they are needed
* moves the Kconfig defaults of the usbus_minimal example into the main
Kconfig, as these are good defaults for all cases when USB is enabled
manually
Closes: https://github.com/RIOT-OS/RIOT/issues/12273
The configuration length verification was not taking additional alt
interface descriptors into account. This breaks situations where an alt
interface is used such as is the case with CDC ECM
This commit adds runtime assertions to validate that the total length of
the configuration descriptor as communicated to the host device matches the
generated length of the configuration descriptor.
This adds an early exit when the usb interface with the data endpoints
is not activated. This prevents the cdc_ecm_netdev code from attempting
to send the PDU when the USB device is not yet initialized or activated
by a host.
The OUT endpoint of the cdc ecm data endpoint is only expected to
receive data when the alternative interface is activated. Signalling
ready in the init function can cause issues as the endpoints are not yet
enabled in the low level USB peripheral driver.
This commit changes the name of the requests over the control endpoints
to control requests instead of setup requests. This is a terminology fix
to follow the USB specification more closely as technically only the
first stage of a control request is named setup which contains a setup
packet. The whole transfer is a control transfer.