1
0
Fork 0

calculate multicast addresses from universe numbers

This commit is contained in:
Kevin Matz 2021-08-30 13:30:36 -04:00
parent b8e6dcdcef
commit 9c10bd7124
1 changed files with 33 additions and 0 deletions

View File

@ -117,4 +117,37 @@ using ipAddress = ACN::SDT::UDP::ipAddress;
/// > through labelling, manufacturer documentation, or other means, which IP
/// > transports they support.
using ip_addr_spec = ACN::SDT::ip_addr_spec;
/**
* @brief \cite sACN 9.3.1 Allocation of IPv4 Multicast Addresses
*
* > Multicast addresses are from the IPv4 Local Scope and will be managed by
* > routers in conformance with RFC 2365 \cite ASIPM.
*/
static inline ipAddress IPv4MulticastAddress(universe_number universe) {
ipAddress addr;
addr.type = ACN::SDT::SDT_ADDR_IPV4;
addr.address.ipv4.bytes[3] = 239;
addr.address.ipv4.bytes[2] = 255;
addr.address.ipv4.bytes[1] = universe >> 8;
addr.address.ipv4.bytes[0] = universe & 0xff;
return addr;
};
/**
* @brief \cite sACN 9.3.2 Allocation of IPv6 Multicast Addresses
* @param universe
* @return
*/
static inline ipAddress IPv6MulticastAddress(universe_number universe) {
ipAddress addr;
addr.type = ACN::SDT::SDT_ADDR_IPV6;
addr.address.ipv6.group[3] = 131;
addr.address.ipv6.group[1] = universe >> 8;
addr.address.ipv6.group[0] = universe & 0xff;
return addr;
}
} // SACN