| 841 | } |
| 842 | |
| 843 | static bool SetupMulticastCapture(MulticastCapture* capture) |
| 844 | { |
| 845 | dmSocket::Socket socket = dmSocket::INVALID_SOCKET_HANDLE; |
| 846 | if (dmSocket::New(dmSocket::DOMAIN_IPV4, dmSocket::TYPE_DGRAM, dmSocket::PROTOCOL_UDP, &socket) != dmSocket::RESULT_OK) |
| 847 | return false; |
| 848 | |
| 849 | if (dmSocket::SetReuseAddress(socket, true) != dmSocket::RESULT_OK |
| 850 | || dmSocket::Bind(socket, dmSocket::AddressFromIPString("0.0.0.0"), MDNS_PORT) != dmSocket::RESULT_OK |
| 851 | || dmSocket::SetBlocking(socket, false) != dmSocket::RESULT_OK) |
| 852 | { |
| 853 | dmSocket::Delete(socket); |
| 854 | return false; |
| 855 | } |
| 856 | |
| 857 | const dmSocket::Address multicast_address = dmSocket::AddressFromIPString(MDNS_MULTICAST_IPV4); |
| 858 | bool joined = dmSocket::AddMembership(socket, multicast_address, dmSocket::AddressFromIPString("0.0.0.0"), 255) == dmSocket::RESULT_OK; |
| 859 | |
| 860 | dmSocket::Address local_address; |
| 861 | if (dmSocket::GetLocalAddress(&local_address) == dmSocket::RESULT_OK && local_address.m_family == dmSocket::DOMAIN_IPV4) |
| 862 | { |
| 863 | joined = dmSocket::AddMembership(socket, multicast_address, local_address, 255) == dmSocket::RESULT_OK || joined; |
| 864 | } |
| 865 | |
| 866 | if (!joined) |
| 867 | { |
| 868 | dmSocket::Delete(socket); |
| 869 | return false; |
| 870 | } |
| 871 | |
| 872 | capture->m_Socket = socket; |
| 873 | return true; |
| 874 | } |
| 875 | |
| 876 | static bool SetupSendSocket(ScopedSocketHandle* socket) |
| 877 | { |
no test coverage detected