avb: clean up some packets

Listen to all messages. We don't seem to receive TSN messages from our
local host it seems.
Reply with not-implemented for an AEM_COMMANDS.
Implement some mode ADP messages.
This commit is contained in:
Wim Taymans 2022-03-16 17:34:27 +01:00
parent 07a4c5032e
commit 287e8cfe51
8 changed files with 414 additions and 157 deletions

View file

@ -48,68 +48,46 @@
#define AVBTP_SUBTYPE_MAAP 0xFE
#define AVBTP_SUBTYPE_EF_CONTROL 0xFF
struct avbtp_packet_common {
struct avbtp_ehternet_header {
uint8_t dest[6];
uint8_t src[6];
uint16_t type;
} __attribute__ ((__packed__));
struct avbtp_packet_header {
uint8_t subtype;
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned sv:1; /* stream_id valid */
unsigned version:3;
unsigned subtype_data1:4;
unsigned subtype_data2:5;
unsigned len1:3;
#elif __BYTE_ORDER == __LITTLE_ENDIAN
unsigned subtype_data1:4;
unsigned version:3;
unsigned sv:1;
unsigned len1:3;
unsigned subtype_data2:5;
#elif
#error "Unknown byte order"
#endif
uint16_t subtype_data2;
uint64_t stream_id;
uint8_t payload[0];
uint8_t len2:8;
} __attribute__ ((__packed__));
#define AVBTP_PACKET_SET_SUBTYPE(p,v) ((p)->subtype = (v))
#define AVBTP_PACKET_SET_SV(p,v) ((p)->sv = (v))
#define AVBTP_PACKET_SET_VERSION(p,v) ((p)->version = (v))
#define AVBTP_PACKET_SET_STREAM_ID(p,v) ((p)->stream_id = htobe64(v))
#define AVBTP_PACKET_SET_SUB1(p,v) ((p)->subtype_data1 = (v))
#define AVBTP_PACKET_SET_SUB2(p,v) ((p)->subtype_data2 = (v))
#define AVBTP_PACKET_SET_LENGTH(p,v) ((p)->len1 = ((v) >> 8),(p)->len2 = (v))
#define AVBTP_PACKET_GET_SUBTYPE(p) ((p)->subtype)
#define AVBTP_PACKET_GET_SV(p) ((p)->sv)
#define AVBTP_PACKET_GET_VERSION(p) ((p)->version)
#define AVBTP_PACKET_GET_STREAM_ID(p) be64toh((p)->stream_id)
struct avbtp_packet_cc {
uint8_t subtype;
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned sv:1;
unsigned version:3;
unsigned control_data1:4;
unsigned status:5;
unsigned len1:3;
#elif __BYTE_ORDER == __LITTLE_ENDIAN
unsigned control_data1:4;
unsigned version:3;
unsigned sv:1;
unsigned len1:3;
unsigned status:5;
#endif
uint8_t len2:8;
uint64_t stream_id;
uint8_t payload[0];
} __attribute__ ((__packed__));
#define AVBTP_PACKET_CC_SET_SUBTYPE(p,v) ((p)->subtype = (v))
#define AVBTP_PACKET_CC_SET_SV(p,v) ((p)->sv = (v))
#define AVBTP_PACKET_CC_SET_VERSION(p,v) ((p)->version = (v))
#define AVBTP_PACKET_CC_SET_STREAM_ID(p,v) ((p)->stream_id = htobe64(v))
#define AVBTP_PACKET_CC_SET_STATUS(p,v) ((p)->status = (v))
#define AVBTP_PACKET_CC_SET_LENGTH(p,v) ((p)->len1 = ((v) >> 8),(p)->len2 = (v))
#define AVBTP_PACKET_CC_GET_SUBTYPE(p) ((p)->subtype)
#define AVBTP_PACKET_CC_GET_SV(p) ((p)->sv)
#define AVBTP_PACKET_CC_GET_VERSION(p) ((p)->version)
#define AVBTP_PACKET_CC_GET_STREAM_ID(p) be64toh((p)->stream_id)
#define AVBTP_PACKET_CC_GET_STATUS(p) ((p)->status)
#define AVBTP_PACKET_CC_GET_LENGTH(p) ((p)->len1 << 8 || (p)->len2)
#define AVBTP_PACKET_GET_SUB1(p) ((p)->subtype_data1)
#define AVBTP_PACKET_GET_SUB2(p) ((p)->subtype_data2)
#define AVBTP_PACKET_GET_LENGTH(p) ((p)->len1 << 8 | (p)->len2)
#endif /* AVBTP_PACKETS_H */