Skip to content

Commit 8fb40e3

Browse files
add UDPARD_IPv4_SUBJECT_ID_MAX
1 parent 8a419c6 commit 8fb40e3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

libudpard/udpard.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ typedef unsigned char byte_t; ///< For compatibility with platforms where byte s
6969
/// transfers with transfer-ID less than or equal to N-ORDERING_WINDOW (modulo 2^64) as late.
7070
#define RX_TRANSFER_ORDERING_WINDOW 1024U
7171

72-
#define UDP_PORT 9382U
73-
#define IPv4_MCAST_PREFIX 0xEF000000UL
74-
#define IPv4_MCAST_SUFFIX_MASK 0x007FFFFFUL
72+
#define UDP_PORT 9382U
73+
#define IPv4_MCAST_PREFIX 0xEF000000UL
7574

7675
static size_t smaller(const size_t a, const size_t b) { return (a < b) ? a : b; }
7776
static size_t larger(const size_t a, const size_t b) { return (a > b) ? a : b; }
@@ -130,7 +129,7 @@ bool udpard_is_valid_endpoint(const udpard_udpip_ep_t ep)
130129

131130
udpard_udpip_ep_t udpard_make_subject_endpoint(const uint32_t subject_id)
132131
{
133-
return (udpard_udpip_ep_t){ .ip = IPv4_MCAST_PREFIX | (subject_id & IPv4_MCAST_SUFFIX_MASK), .port = UDP_PORT };
132+
return (udpard_udpip_ep_t){ .ip = IPv4_MCAST_PREFIX | (subject_id & UDPARD_IPv4_SUBJECT_ID_MAX), .port = UDP_PORT };
134133
}
135134

136135
// NOLINTNEXTLINE(misc-no-recursion)

libudpard/udpard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ extern "C"
7474
/// Timestamps supplied by the application must be non-negative monotonically increasing counts of microseconds.
7575
typedef int64_t udpard_us_t;
7676

77+
/// The subject-ID only affects the formation of the multicast UDP/IP endpoint address.
78+
/// In IPv4 networks, it is limited to 23 bits only due to the limited MAC multicast address space.
79+
/// In IPv6 networks, 32 bits are supported.
80+
#define UDPARD_IPv4_SUBJECT_ID_MAX 0x7FFFFFUL
81+
7782
#define UDPARD_PRIORITY_MAX 7U
7883

7984
typedef enum udpard_prio_t

0 commit comments

Comments
 (0)