Skip to content

Commit b32d423

Browse files
committed
udpsrc: store source address and destination IPV6 address
1 parent 0f253a8 commit b32d423

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/upipe/uref_block.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ UREF_ATTR_VOID_UREF(block, start, UREF_FLAG_BLOCK_START, start of logical block)
4747
UREF_ATTR_VOID_UREF(block, end, UREF_FLAG_BLOCK_END, end of logical block)
4848
UREF_ATTR_UNSIGNED(block, header_size, "b.header", global headers size)
4949
UREF_ATTR_UNSIGNED(block, net_ifindex, "b.ifindex", network interface index)
50+
UREF_ATTR_SOCKADDR(block, net_srcaddr, "b.srcaddr", source address)
51+
UREF_ATTR_SOCKADDR(block, net_ipi6_addr, "b.ipi6_addr", destination address when packet was received)
5052

5153
/** @This returns a new uref pointing to a new ubuf pointing to a block.
5254
* This is equivalent to the two operations sequentially, and is a shortcut.

lib/upipe-modules/upipe_udp_source.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ static void upipe_udpsrc_worker(struct upump *upump)
239239
} else if (c->cmsg_level == IPPROTO_IPV6 && c->cmsg_type == IPV6_PKTINFO) {
240240
struct in6_pktinfo *info = (void*)CMSG_DATA(c);
241241
ifindex = info->ipi6_ifindex;
242+
struct sockaddr_in6 in6 = {
243+
.sin6_family = AF_INET6,
244+
.sin6_port = 0,
245+
.sin6_flowinfo = 0,
246+
.sin6_scope_id = 0,
247+
};
248+
memcpy(&in6.sin6_addr, &info->ipi6_addr, sizeof(in6.sin6_addr));
249+
uref_block_set_net_ipi6_addr(uref, (struct sockaddr*)&in6, sizeof(in6));
242250
}
243251
}
244252

@@ -275,6 +283,8 @@ static void upipe_udpsrc_worker(struct upump *upump)
275283
memcpy(&upipe_udpsrc->addr, &addr, addrlen);
276284
}
277285

286+
uref_block_set_net_srcaddr(uref, (struct sockaddr*)&addr, addrlen);
287+
278288
if (unlikely(ret == 0)) {
279289
uref_free(uref);
280290
if (likely(upipe_udpsrc->uclock == NULL)) {

0 commit comments

Comments
 (0)