Skip to content

Commit

Permalink
[apps] Fixed conditional IP_ADD_SOURCE_MEMBERSHIP in testmedia (#2780).
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris authored Aug 16, 2023
1 parent 4682646 commit 33a620b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions testing/testmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2754,9 +2754,8 @@ void UdpCommon::Setup(string host, int port, map<string,string> attr)

if (is_multicast)
{
ip_mreq_source mreq_ssm;
ip_mreq mreq;
sockaddr_any maddr;
sockaddr_any maddr (AF_INET);
int opt_name;
void* mreq_arg_ptr;
socklen_t mreq_arg_size;
Expand All @@ -2777,13 +2776,18 @@ void UdpCommon::Setup(string host, int port, map<string,string> attr)

if (attr.count("source"))
{
#ifdef IP_ADD_SOURCE_MEMBERSHIP
ip_mreq_source mreq_ssm;
/* this is an ssm. we need to use the right struct and opt */
opt_name = IP_ADD_SOURCE_MEMBERSHIP;
mreq_ssm.imr_multiaddr.s_addr = sadr.sin.sin_addr.s_addr;
mreq_ssm.imr_interface.s_addr = maddr.sin.sin_addr.s_addr;
inet_pton(AF_INET, attr.at("source").c_str(), &mreq_ssm.imr_sourceaddr);
mreq_arg_size = sizeof(mreq_ssm);
mreq_arg_ptr = &mreq_ssm;
#else
throw std::runtime_error("UdpCommon: source-filter multicast not supported by OS");
#endif
}
else
{
Expand Down

0 comments on commit 33a620b

Please sign in to comment.