Skip to content

Commit

Permalink
[core] Removed 'm_' prefix in socket config structs (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Mar 4, 2021
1 parent 6e32509 commit 12d03fe
Show file tree
Hide file tree
Showing 10 changed files with 571 additions and 586 deletions.
34 changes: 17 additions & 17 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ bool CUDTSocket::readReady()
bool CUDTSocket::writeReady()
{
return (m_pUDT->m_bConnected
&& (m_pUDT->m_pSndBuffer->getCurrBufSize() < m_pUDT->m_config.m_iSndBufSize))
&& (m_pUDT->m_pSndBuffer->getCurrBufSize() < m_pUDT->m_config.iSndBufSize))
|| broken();
}

Expand Down Expand Up @@ -531,7 +531,7 @@ int CUDTUnited::newConnection(const SRTSOCKET listen, const sockaddr_any& peer,

w_hs.m_iISN = ns->m_pUDT->m_iISN;
w_hs.m_iMSS = ns->m_pUDT->MSS();
w_hs.m_iFlightFlagSize = ns->m_pUDT->m_config.m_iFlightFlagSize;
w_hs.m_iFlightFlagSize = ns->m_pUDT->m_config.iFlightFlagSize;
w_hs.m_iReqType = URQ_CONCLUSION;
w_hs.m_iID = ns->m_SocketID;

Expand Down Expand Up @@ -1004,7 +1004,7 @@ int CUDTUnited::listen(const SRTSOCKET u, int backlog)
// [[using assert(s->m_Status == OPENED)]];

// listen is not supported in rendezvous connection setup
if (s->m_pUDT->m_config.m_bRendezvous)
if (s->m_pUDT->m_config.bRendezvous)
throw CUDTException(MJ_NOTSUP, MN_ISRENDEZVOUS, 0);

s->m_uiBackLog = backlog;
Expand Down Expand Up @@ -1077,7 +1077,7 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
throw CUDTException(MJ_NOTSUP, MN_NOLISTEN, 0);

// no "accept" in rendezvous connection setup
if (ls->m_pUDT->m_config.m_bRendezvous)
if (ls->m_pUDT->m_config.bRendezvous)
{
LOGC(cnlog.Fatal, log << "CUDTUnited::accept: RENDEZVOUS flag passed through check in srt_listen when it set listen state");
// This problem should never happen because `srt_listen` function should have
Expand Down Expand Up @@ -1107,7 +1107,7 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
ls->m_QueuedSockets.erase(b);
accepted = true;
}
else if (!ls->m_pUDT->m_config.m_bSynRecving)
else if (!ls->m_pUDT->m_config.bSynRecving)
{
accepted = true;
}
Expand All @@ -1122,7 +1122,7 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
if (u == CUDT::INVALID_SOCK)
{
// non-blocking receiving, no connection available
if (!ls->m_pUDT->m_config.m_bSynRecving)
if (!ls->m_pUDT->m_config.bSynRecving)
throw CUDTException(MJ_AGAIN, MN_RDAVAIL, 0);

// listening socket is closed
Expand All @@ -1134,13 +1134,13 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
throw CUDTException(MJ_SETUP, MN_CLOSED, 0);

// Set properly the SRTO_GROUPCONNECT flag
s->core().m_config.m_GroupConnect = 0;
s->core().m_config.iGroupConnect = 0;

// Check if LISTENER has the SRTO_GROUPCONNECT flag set,
// and the already accepted socket has successfully joined
// the mirror group. If so, RETURN THE GROUP ID, not the socket ID.
#if ENABLE_EXPERIMENTAL_BONDING
if (ls->m_pUDT->m_config.m_GroupConnect == 1 && s->m_GroupOf)
if (ls->m_pUDT->m_config.iGroupConnect == 1 && s->m_GroupOf)
{
// Put a lock to protect the group against accidental deletion
// in the meantime.
Expand All @@ -1150,7 +1150,7 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
if (s->m_GroupOf)
{
u = s->m_GroupOf->m_GroupID;
s->core().m_config.m_GroupConnect = 1; // should be derived from ls, but make sure
s->core().m_config.iGroupConnect = 1; // should be derived from ls, but make sure

// Mark the beginning of the connection at the moment
// when the group ID is returned to the app caller
Expand Down Expand Up @@ -1498,14 +1498,14 @@ int CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, int ar
}

// Set it the groupconnect option, as all in-group sockets should have.
ns->m_pUDT->m_config.m_GroupConnect = 1;
ns->m_pUDT->m_config.iGroupConnect = 1;

// Every group member will have always nonblocking
// (this implies also non-blocking connect/accept).
// The group facility functions will block when necessary
// using epoll_wait.
ns->m_pUDT->m_config.m_bSynRecving = false;
ns->m_pUDT->m_config.m_bSynSending = false;
ns->m_pUDT->m_config.bSynRecving = false;
ns->m_pUDT->m_config.bSynSending = false;

HLOGC(aclog.Debug, log << "groupConnect: NOTIFIED AS PENDING @" << sid << " both read and write");
// If this socket is not to block the current connect process,
Expand Down Expand Up @@ -1827,7 +1827,7 @@ int CUDTUnited::connectIn(CUDTSocket* s, const sockaddr_any& target_addr, int32_

if (s->m_Status == SRTS_INIT)
{
if (s->m_pUDT->m_config.m_bRendezvous)
if (s->m_pUDT->m_config.bRendezvous)
throw CUDTException(MJ_NOTSUP, MN_ISRENDUNBOUND, 0);

// If bind() was done first on this socket, then the
Expand Down Expand Up @@ -1957,7 +1957,7 @@ int CUDTUnited::close(CUDTSocket* s)

HLOGC(smlog.Debug, log << s->m_pUDT->CONID() << " CLOSING (removing from listening, closing CUDT)");

const bool synch_close_snd = s->m_pUDT->m_config.m_bSynSending;
const bool synch_close_snd = s->m_pUDT->m_config.bSynSending;

SRTSOCKET u = s->m_SocketID;

Expand Down Expand Up @@ -2322,7 +2322,7 @@ int CUDTUnited::selectEx(
{
if (s->m_pUDT->m_bConnected
&& (s->m_pUDT->m_pSndBuffer->getCurrBufSize()
< s->m_pUDT->m_config.m_iSndBufSize))
< s->m_pUDT->m_config.iSndBufSize))
{
writefds->push_back(s->m_SocketID);
++ count;
Expand Down Expand Up @@ -2827,7 +2827,7 @@ void CUDTUnited::updateMux(
// In such a case rely exclusively on that very socket and
// use it the way as it is configured, of course, create also
// always a new multiplexer for that very socket.
if (!udpsock && s->m_pUDT->m_config.m_bReuseAddr)
if (!udpsock && s->m_pUDT->m_config.bReuseAddr)
{
const int port = addr.hport();

Expand Down Expand Up @@ -2993,7 +2993,7 @@ bool CUDTUnited::updateListenerMux(CUDTSocket* s, const CUDTSocket* ls)
if (!mux && fallback)
{
// It is allowed to reuse this multiplexer, but the socket must allow both IPv4 and IPv6
if (fallback->m_mcfg.m_iIpV6Only == 0)
if (fallback->m_mcfg.iIpV6Only == 0)
{
HLOGC(smlog.Warn, log << "updateListenerMux: reusing multiplexer from different family");
mux = fallback;
Expand Down
66 changes: 33 additions & 33 deletions srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ void CChannel::createSocket(int family)
#endif
#endif // ENABLE_SOCK_CLOEXEC

if ((m_mcfg.m_iIpV6Only != -1) && (family == AF_INET6)) // (not an error if it fails)
if ((m_mcfg.iIpV6Only != -1) && (family == AF_INET6)) // (not an error if it fails)
{
int res ATR_UNUSED = ::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_V6ONLY,
m_mcfg.pvIpV6Only(), sizeof(int));
(const char*) &m_mcfg.iIpV6Only, sizeof m_mcfg.iIpV6Only);
if (res == -1)
{
int err = errno;
char msg[160];
LOGC(kmlog.Error, log << "::setsockopt: failed to set IPPROTO_IPV6/IPV6_V6ONLY = "
<< m_mcfg.m_iIpV6Only << ": " << SysStrError(err, msg, 159));
<< m_mcfg.iIpV6Only << ": " << SysStrError(err, msg, 159));
}
}

Expand Down Expand Up @@ -266,22 +266,22 @@ void CChannel::setUDPSockOpt()
#if defined(BSD) || TARGET_OS_MAC
// BSD system will fail setsockopt if the requested buffer size exceeds system maximum value
int maxsize = 64000;
if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, m_mcfg.pvUDPRcvBufSize(), sizeof(int)))
::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (char*)&maxsize, sizeof(int));
if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, m_mcfg.pvUDPSndBufSize(), sizeof(int)))
::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, (char*)&maxsize, sizeof(int));
if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (const char*) &m_mcfg.iUDPRcvBufSize, sizeof m_mcfg.iUDPRcvBufSize))
::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (const char*) &maxsize, sizeof maxsize);
if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, (const char*)&m_mcfg.iUDPSndBufSize, sizeof m_mcfg.iUDPSndBufSize))
::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, (const char*) &maxsize, sizeof maxsize);
#else
// for other systems, if requested is greated than maximum, the maximum value will be automactally used
if ((0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, m_mcfg.pvUDPRcvBufSize(), sizeof(int))) ||
(0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, m_mcfg.pvUDPSndBufSize(), sizeof(int))))
if ((0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (const char*) &m_mcfg.iUDPRcvBufSize, sizeof m_mcfg.iUDPRcvBufSize)) ||
(0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, (const char*) &m_mcfg.iUDPSndBufSize, sizeof m_mcfg.iUDPSndBufSize)))
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
#endif

if (m_mcfg.m_iIpTTL != -1)
if (m_mcfg.iIpTTL != -1)
{
if (m_BindAddr.family() == AF_INET)
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TTL, m_mcfg.pvIpTTL(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TTL, (const char*) &m_mcfg.iIpTTL, sizeof m_mcfg.iIpTTL))
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
else
Expand All @@ -291,27 +291,27 @@ void CChannel::setUDPSockOpt()
// For specified IPv6 address, set IPV6_UNICAST_HOPS ONLY UNLESS it's an IPv4-mapped-IPv6
if (IN6_IS_ADDR_UNSPECIFIED(&m_BindAddr.sin6.sin6_addr) || !IN6_IS_ADDR_V4MAPPED(&m_BindAddr.sin6.sin6_addr))
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, m_mcfg.pvIpTTL(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char*) &m_mcfg.iIpTTL, sizeof m_mcfg.iIpTTL))
{
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
}
// For specified IPv6 address, set IP_TTL ONLY WHEN it's an IPv4-mapped-IPv6
if (IN6_IS_ADDR_UNSPECIFIED(&m_BindAddr.sin6.sin6_addr) || IN6_IS_ADDR_V4MAPPED(&m_BindAddr.sin6.sin6_addr))
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TTL, m_mcfg.pvIpTTL(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TTL, (const char*) &m_mcfg.iIpTTL, sizeof m_mcfg.iIpTTL))
{
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
}
}
}

if (m_mcfg.m_iIpToS != -1)
if (m_mcfg.iIpToS != -1)
{
if (m_BindAddr.family() == AF_INET)
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TOS, m_mcfg.pvIpToS(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TOS, (const char*) &m_mcfg.iIpToS, sizeof m_mcfg.iIpToS))
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
else
Expand All @@ -322,7 +322,7 @@ void CChannel::setUDPSockOpt()
// For specified IPv6 address, set IPV6_TCLASS ONLY UNLESS it's an IPv4-mapped-IPv6
if (IN6_IS_ADDR_UNSPECIFIED(&m_BindAddr.sin6.sin6_addr) || !IN6_IS_ADDR_V4MAPPED(&m_BindAddr.sin6.sin6_addr))
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_TCLASS, m_mcfg.pvIpToS(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IPV6, IPV6_TCLASS, (const char*) &m_mcfg.iIpToS, sizeof m_mcfg.iIpToS))
{
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
Expand All @@ -332,7 +332,7 @@ void CChannel::setUDPSockOpt()
// For specified IPv6 address, set IP_TOS ONLY WHEN it's an IPv4-mapped-IPv6
if (IN6_IS_ADDR_UNSPECIFIED(&m_BindAddr.sin6.sin6_addr) || IN6_IS_ADDR_V4MAPPED(&m_BindAddr.sin6.sin6_addr))
{
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TOS, m_mcfg.pvIpToS(), sizeof (int)))
if (0 != ::setsockopt(m_iSocket, IPPROTO_IP, IP_TOS, (const char*) &m_mcfg.iIpToS, sizeof m_mcfg.iIpToS))
{
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
Expand All @@ -341,7 +341,7 @@ void CChannel::setUDPSockOpt()
}

#ifdef SRT_ENABLE_BINDTODEVICE
if (!m_mcfg.m_BindToDevice.empty())
if (!m_mcfg.sBindToDevice.empty())
{
if (m_BindAddr.family() != AF_INET)
{
Expand All @@ -350,7 +350,7 @@ void CChannel::setUDPSockOpt()
}

if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_BINDTODEVICE,
m_mcfg.m_BindToDevice.c_str(), m_mcfg.m_BindToDevice.size()))
m_mcfg.sBindToDevice.c_str(), m_mcfg.sBindToDevice.size()))
{
char buf[255];
const char* err = SysStrError(NET_ERROR, buf, 255);
Expand Down Expand Up @@ -397,16 +397,16 @@ void CChannel::close() const

int CChannel::getSndBufSize()
{
socklen_t size = sizeof(socklen_t);
::getsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, m_mcfg.pvUDPSndBufSize(), &size);
return m_mcfg.m_iUDPSndBufSize;
socklen_t size = (socklen_t) sizeof m_mcfg.iUDPSndBufSize;
::getsockopt(m_iSocket, SOL_SOCKET, SO_SNDBUF, (char*) &m_mcfg.iUDPSndBufSize, &size);
return m_mcfg.iUDPSndBufSize;
}

int CChannel::getRcvBufSize()
{
socklen_t size = sizeof(socklen_t);
::getsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, m_mcfg.pvUDPRcvBufSize(), &size);
return m_mcfg.m_iUDPRcvBufSize;
socklen_t size = (socklen_t) sizeof m_mcfg.iUDPRcvBufSize;
::getsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (char*) &m_mcfg.iUDPRcvBufSize, &size);
return m_mcfg.iUDPRcvBufSize;
}

void CChannel::setConfig(const CSrtMuxerConfig& config)
Expand All @@ -419,38 +419,38 @@ int CChannel::getIpTTL() const
if (m_iSocket == INVALID_SOCKET)
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);

socklen_t size = sizeof(int);
socklen_t size = (socklen_t) sizeof m_mcfg.iIpTTL;
if (m_BindAddr.family() == AF_INET)
{
::getsockopt(m_iSocket, IPPROTO_IP, IP_TTL, m_mcfg.pvIpTTL(), &size);
::getsockopt(m_iSocket, IPPROTO_IP, IP_TTL, (char*) &m_mcfg.iIpTTL, &size);
}
else if (m_BindAddr.family() == AF_INET6)
{
::getsockopt(m_iSocket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, m_mcfg.pvIpTTL(), &size);
::getsockopt(m_iSocket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (char*) &m_mcfg.iIpTTL, &size);
}
else
{
// If family is unspecified, the socket probably doesn't exist.
LOGC(kmlog.Error, log << "IPE: CChannel::getIpTTL called with unset family");
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);
}
return m_mcfg.m_iIpTTL;
return m_mcfg.iIpTTL;
}

int CChannel::getIpToS() const
{
if (m_iSocket == INVALID_SOCKET)
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);

socklen_t size = sizeof(int);
socklen_t size = (socklen_t) sizeof m_mcfg.iIpToS;
if (m_BindAddr.family() == AF_INET)
{
::getsockopt(m_iSocket, IPPROTO_IP, IP_TOS, m_mcfg.pvIpToS(), &size);
::getsockopt(m_iSocket, IPPROTO_IP, IP_TOS, (char*) &m_mcfg.iIpToS, &size);
}
else if (m_BindAddr.family() == AF_INET6)
{
#ifdef IPV6_TCLASS
::getsockopt(m_iSocket, IPPROTO_IPV6, IPV6_TCLASS, m_mcfg.pvIpToS(), &size);
::getsockopt(m_iSocket, IPPROTO_IPV6, IPV6_TCLASS, (char*) &m_mcfg.iIpToS, &size);
#endif
}
else
Expand All @@ -459,7 +459,7 @@ int CChannel::getIpToS() const
LOGC(kmlog.Error, log << "IPE: CChannel::getIpToS called with unset family");
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);
}
return m_mcfg.m_iIpToS;
return m_mcfg.iIpToS;
}

#ifdef SRT_ENABLE_BINDTODEVICE
Expand Down
4 changes: 2 additions & 2 deletions srtcore/congctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ class SrtCongestionControlBase
virtual int ACKTimeout_us() const { return 0; }

// Called when the settings concerning m_llMaxBW were changed.
// Arg 1: value of CUDT::m_llMaxBW
// Arg 2: value calculated out of CUDT::m_llInputBW and CUDT::m_iOverheadBW.
// Arg 1: value of CUDT's m_config.m_llMaxBW
// Arg 2: value calculated out of CUDT's m_config.llInputBW and m_config.iOverheadBW.
virtual void updateBandwidth(int64_t, int64_t) {}

virtual bool needsQuickACK(const CPacket&)
Expand Down
Loading

0 comments on commit 12d03fe

Please sign in to comment.