Skip to content

Commit

Permalink
udpsink: set ifindex
Browse files Browse the repository at this point in the history
  • Loading branch information
funman committed Sep 13, 2024
1 parent 5f31d86 commit bfa2a06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/upipe-modules/upipe_udp_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <sys/socket.h>
#include <errno.h>
#include <assert.h>
#include <netinet/in.h>

/** tolerance for late packets */
#define SYSTIME_TOLERANCE UCLOCK_FREQ
Expand Down Expand Up @@ -289,6 +290,17 @@ static bool upipe_udpsink_output(struct upipe *upipe, struct uref *uref,
.msg_flags = 0,
};

uint8_t ancillary[CMSG_SPACE(sizeof(struct in_pktinfo))];
uint64_t ifindex;
if (ubase_check(uref_block_get_net_ifindex(uref, &ifindex))) {
struct in_pktinfo *info = (void*)ancillary;
info->ipi_ifindex = ifindex;
info->ipi_spec_dst.s_addr = 0,
info->ipi_addr.s_addr = 0,
msghdr.msg_control = ancillary;
msghdr.msg_controllen = sizeof(ancillary);
}

ssize_t ret = sendmsg(upipe_udpsink->fd, &msghdr, 0);
uref_block_iovec_unmap(uref, 0, -1, iovecs);

Expand Down

0 comments on commit bfa2a06

Please sign in to comment.