milan-avb: Make sure to get payload size not the packet size

This commit is contained in:
hackerman-kl 2026-01-09 09:36:28 +01:00
parent aec99d2b6f
commit d3a5b352b2

View file

@ -12,7 +12,7 @@
#include <pipewire/log.h> #include <pipewire/log.h>
#define AECP_UNSOL_BUFFER_SIZE (128U) #define AECP_UNSOL_BUFFER_SIZE (128U)
#define AECP_AEM_MIN_PACKET_LENGTH (64U) #define AECP_AEM_MIN_PACKET_LENGTH (60U)
static int reply_unsol_get_specific_info(struct aecp *aecp, struct descriptor *desc, static int reply_unsol_get_specific_info(struct aecp *aecp, struct descriptor *desc,
struct aecp_aem_unsol_notification_state **unsol_state, size_t *count) struct aecp_aem_unsol_notification_state **unsol_state, size_t *count)
@ -111,8 +111,8 @@ static void reply_unsol_notifications_prepare(struct aecp *aecp,
/* Here the value of 12 is the delta between the target_entity_id and /* Here the value of 12 is the delta between the target_entity_id and
start of the AECP message specific data. */ start of the AECP message specific data. */
ctrl_data_length = len - (sizeof(*h) + sizeof(*p)) + ctrl_data_length = len - (sizeof(*h) + sizeof(*p))
AVB_PACKET_CONTROL_DATA_OFFSET; + AVB_PACKET_CONTROL_DATA_OFFSET;
h = (struct avb_ethernet_header*) packet; h = (struct avb_ethernet_header*) packet;
p = SPA_PTROFF(h, sizeof(*h), void); p = SPA_PTROFF(h, sizeof(*h), void);
@ -137,6 +137,10 @@ int reply_unsolicited_notifications(struct aecp *aecp,
bool internal) bool internal)
{ {
uint8_t buf[AECP_UNSOL_BUFFER_SIZE]; uint8_t buf[AECP_UNSOL_BUFFER_SIZE];
/* Make sure to get the actual original len if the packet
* re-adjusted to comply with the 60 bytes min packet size.
*/
size_t original_len = len;
if (len < AECP_AEM_MIN_PACKET_LENGTH) { if (len < AECP_AEM_MIN_PACKET_LENGTH) {
memset(buf, 0, AECP_AEM_MIN_PACKET_LENGTH); memset(buf, 0, AECP_AEM_MIN_PACKET_LENGTH);
@ -146,7 +150,7 @@ int reply_unsolicited_notifications(struct aecp *aecp,
} }
/** Retrieve the entity descriptor */ /** Retrieve the entity descriptor */
reply_unsol_notifications_prepare(aecp, buf, packet, len); reply_unsol_notifications_prepare(aecp, buf, packet, original_len);
return reply_unsol_send(aecp, b_state->controller_entity_id, packet, len, return reply_unsol_send(aecp, b_state->controller_entity_id, packet, len,
internal); internal);