Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11568 from SMarioMan/socket-broadcast
Network/Socket: Enable broadcast permissions in socket requests
  • Loading branch information
AdmiralCurtiss committed Mar 7, 2023
2 parents 16023ec + 078730c commit 0b9002e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Source/Core/Core/IOS/Network/Socket.cpp
Expand Up @@ -872,6 +872,26 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &opt_no_sigpipe, sizeof(opt_no_sigpipe)) < 0)
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
#endif

// Wii UDP sockets can use broadcast address by default
if (!is_rw)
{
const auto state = Common::SaveNetworkErrorState();
Common::ScopeGuard guard([&state] { Common::RestoreNetworkErrorState(state); });

int socket_type;
socklen_t option_length = sizeof(socket_type);
const bool is_udp = getsockopt(fd, SOL_SOCKET, SO_TYPE, reinterpret_cast<char*>(&socket_type),
&option_length) == 0 &&
socket_type == SOCK_DGRAM;
const int opt_broadcast = 1;
if (is_udp &&
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>(&opt_broadcast),
sizeof(opt_broadcast)) != 0)
{
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_BROADCAST on socket");
}
}
}

SetLastNetError(wii_fd);
Expand Down

0 comments on commit 0b9002e

Please sign in to comment.