aboutsummaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-05-04 16:24:08 +0100
committerGravatar Sadie Powell2023-05-04 16:36:27 +0100
commitc330aa6250871c4d5c3ecf2f20e6dfa30be08ab0 (patch)
tree8557c8dfc60675ca521a5196a8917ddeb7602df1 /src/socket.cpp
parentFix the cloak modules on Clang and MSVC. (diff)
Check whether IPPROTO_SCTP works before trying to implicitly multistack.
Fixes bind warnings on platforms which have IPPROTO_SCTP defined but don't actually have support at runtime.
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 2dc94b85f..12f9fabda 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -33,6 +33,23 @@
#include "inspircd.h"
+namespace
+{
+ // Checks whether the system can create SCTP sockets.
+ bool CanCreateSCTPSocket()
+ {
+#ifdef IPPROTO_SCTP
+ int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
+ if (fd >= 0)
+ {
+ SocketEngine::Close(fd);
+ return true;
+ }
+#endif
+ return false;
+ }
+}
+
bool InspIRCd::BindPort(const std::shared_ptr<ConfigTag>& tag, const irc::sockets::sockaddrs& sa, std::vector<ListenSocket*>& old_ports, int protocol)
{
for (std::vector<ListenSocket*>::iterator n = old_ports.begin(); n != old_ports.end(); ++n)
@@ -128,7 +145,8 @@ size_t InspIRCd::BindPorts(FailedPortList& failed_ports)
{
protocols.push_back(0); // IPPROTO_TCP
#ifdef IPPROTO_SCTP
- protocols.push_back(IPPROTO_SCTP);
+ if (CanCreateSCTPSocket())
+ protocols.push_back(IPPROTO_SCTP);
#endif
}
else if (stdalgo::string::equalsci(protocol, "sctp"))