diff --git a/srtcore/group.cpp b/srtcore/group.cpp index c0df17ac8..2c2d88835 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -347,6 +347,31 @@ void CUDTGroup::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen) switch (optName) { + // First go options that are NOT ALLOWED to be modified on the group. + // (socket-only), or are read-only. + + case SRTO_ISN: // read-only + case SRTO_STATE: // read-only + case SRTO_EVENT: // read-only + case SRTO_SNDDATA: // read-only + case SRTO_RCVDATA: // read-only + case SRTO_KMSTATE: // read-only + case SRTO_VERSION: // read-only + case SRTO_PEERVERSION: // read-only + case SRTO_SNDKMSTATE: + case SRTO_RCVKMSTATE: + case SRTO_GROUPTYPE: // read-only + LOGC(gmlog.Error, log << "group option setter: this option ("<< int(optName) << ") is read-only"); + throw CUDTException(MJ_NOTSUP, MN_INVAL, 0); + + case SRTO_SENDER: // deprecated (1.2.0 version legacy) + case SRTO_IPV6ONLY: // link-type specific + case SRTO_RENDEZVOUS: // socket-only + case SRTO_BINDTODEVICE: // socket-specific + case SRTO_GROUPCONNECT: // listener-specific + LOGC(gmlog.Error, log << "group option setter: this option ("<< int(optName) << ") is socket- or link-specific"); + throw CUDTException(MJ_NOTSUP, MN_INVAL, 0); + case SRTO_RCVSYN: m_bSynRecving = cast_optval(optval, optlen); return; @@ -369,7 +394,7 @@ void CUDTGroup::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen) const int min_timeo_ms = (int) CSrtConfig::COMM_DEF_MIN_STABILITY_TIMEOUT_MS; if (val_ms < min_timeo_ms) { - LOGC(qmlog.Error, + LOGC(gmlog.Error, log << "group option: SRTO_GROUPMINSTABLETIMEO min allowed value is " << min_timeo_ms << " ms."); throw CUDTException(MJ_NOTSUP, MN_INVAL, 0); } @@ -385,7 +410,7 @@ void CUDTGroup::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen) if (val_ms > idletmo) { - LOGC(qmlog.Error, + LOGC(gmlog.Error, log << "group option: SRTO_GROUPMINSTABLETIMEO=" << val_ms << " exceeds SRTO_PEERIDLETIMEO=" << idletmo); throw CUDTException(MJ_NOTSUP, MN_INVAL, 0); } diff --git a/srtcore/srt.h b/srtcore/srt.h index 614a85aea..71ac2c3af 100644 --- a/srtcore/srt.h +++ b/srtcore/srt.h @@ -182,7 +182,7 @@ typedef enum SRT_SOCKOPT { SRTO_RCVTIMEO = 14, // recv() timeout SRTO_REUSEADDR = 15, // reuse an existing port or create a new one SRTO_MAXBW = 16, // maximum bandwidth (bytes per second) that the connection can use - SRTO_STATE = 17, // current socket state, see UDTSTATUS, read only + SRTO_STATE = 17, // current socket state, see SRT_SOCKSTATUS, read only SRTO_EVENT = 18, // current available events associated with the socket SRTO_SNDDATA = 19, // size of data in the sending buffer SRTO_RCVDATA = 20, // size of data available for recv diff --git a/test/test_bonding.cpp b/test/test_bonding.cpp index 309a4ba21..b86baa96d 100644 --- a/test/test_bonding.cpp +++ b/test/test_bonding.cpp @@ -352,7 +352,7 @@ TEST(Bonding, Options) TestInit srtinit; // Create a group - const SRTSOCKET grp = srt_create_group(SRT_GTYPE_BROADCAST); + MAKE_UNIQUE_SOCK(grp, "broadcast group", srt_create_group(SRT_GTYPE_BROADCAST)); // rendezvous shall not be allowed to be set on the group // XXX actually it is possible, but no one tested it. POSTPONE. @@ -437,9 +437,10 @@ TEST(Bonding, Options) // First wait - until it's let go with accepting latch.wait(ux); - sockaddr_any revsa; - SRTSOCKET gs = srt_accept(lsn, revsa.get(), &revsa.len); - ASSERT_NE(gs, SRT_ERROR); + //sockaddr_any revsa; + SRTSOCKET lsna [1] = { lsn }; + SRTSOCKET gs = srt_accept_bond(lsna, 1, 1000); + ASSERT_NE(gs, SRT_INVALID_SOCK); check_streamid(gs); @@ -541,7 +542,6 @@ TEST(Bonding, Options) } accept_and_close.join(); - srt_close(grp); } inline SRT_SOCKGROUPCONFIG PrepareEndpoint(const std::string& host, int port)