summaryrefslogtreecommitdiffstats
path: root/src/net/mcast/McastPGMSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/mcast/McastPGMSocket.cpp')
-rw-r--r--src/net/mcast/McastPGMSocket.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/net/mcast/McastPGMSocket.cpp b/src/net/mcast/McastPGMSocket.cpp
index 0d6b694..41764d5 100644
--- a/src/net/mcast/McastPGMSocket.cpp
+++ b/src/net/mcast/McastPGMSocket.cpp
@@ -142,8 +142,15 @@ bool McastPGMSocket::open(McastConfiguration const* config, Direction direction)
sa_family_t family = addrinfo->ai_send_addrs[0].gsr_group.ss_family;
- good
- = pgm_socket(&_priv->socket, family, SOCK_SEQPACKET, IPPROTO_PGM, &err);
+ if(config->multicastUseUDP())
+ {
+ good = pgm_socket(&_priv->socket, family, SOCK_SEQPACKET, IPPROTO_UDP, &err);
+ }
+ else
+ {
+ good = pgm_socket(&_priv->socket, family, SOCK_SEQPACKET, IPPROTO_PGM, &err);
+ }
+
if (!good)
{
qCritical() << "Could not open socket: PGM Error: " << err->message;
@@ -209,6 +216,16 @@ bool McastPGMSocket::open(McastConfiguration const* config, Direction direction)
int const mtu = config->multicastMTU();
pgm_setsockopt(_priv->socket, PGM_MTU, &mtu, sizeof(mtu));
+ // UDP Encapsulation
+ if(config->multicastUseUDP())
+ {
+ const quint16 uport = config->multicastUDPUPort();
+ const quint16 mport = config->multicastUDPMPort();
+
+ pgm_setsockopt(_priv->socket, PGM_UDP_ENCAP_MCAST_PORT, &mport, sizeof(mport));
+ pgm_setsockopt(_priv->socket, PGM_UDP_ENCAP_UCAST_PORT, &uport, sizeof(uport));
+ }
+
pgm_sockaddr_t addr;
addr.sa_addr.sport = config->multicastSPort();
addr.sa_port = config->multicastDPort();