module-avb: add transport abstraction for pluggable network backends

Introduce struct avb_transport_ops vtable with setup/send_packet/
make_socket/destroy callbacks. The existing raw AF_PACKET socket code
becomes the default "raw" transport. avdecc_server_new() defaults to
avb_transport_raw if no transport is set, and avdecc_server_free()
delegates cleanup through the transport ops.

This enables alternative transports (e.g. loopback for testing) without
modifying protocol handler code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian F.K. Schaller 2026-04-07 07:05:37 -04:00 committed by Wim Taymans
parent d9821d09c7
commit a73988d38d
2 changed files with 52 additions and 9 deletions

View file

@ -17,6 +17,15 @@ struct avb_mrp;
#define AVB_TSN_ETH 0x22f0
#define AVB_BROADCAST_MAC { 0x91, 0xe0, 0xf0, 0x01, 0x00, 0x00 };
struct avb_transport_ops {
int (*setup)(struct server *server);
int (*send_packet)(struct server *server, const uint8_t dest[6],
uint16_t type, void *data, size_t size);
int (*make_socket)(struct server *server, uint16_t type,
const uint8_t mac[6]);
void (*destroy)(struct server *server);
};
struct impl {
struct pw_loop *loop;
struct pw_timer_queue *timer_queue;
@ -77,6 +86,9 @@ struct server {
uint64_t entity_id;
int ifindex;
const struct avb_transport_ops *transport;
void *transport_data;
struct spa_source *source;
struct pw_timer timer;
@ -144,6 +156,8 @@ void avdecc_server_free(struct server *server);
void avdecc_server_add_listener(struct server *server, struct spa_hook *listener,
const struct server_events *events, void *data);
extern const struct avb_transport_ops avb_transport_raw;
int avb_server_make_socket(struct server *server, uint16_t type, const uint8_t mac[6]);
int avb_server_send_packet(struct server *server, const uint8_t dest[6],