| 1863 | } |
| 1864 | |
| 1865 | void Net::enableMulticast() |
| 1866 | { |
| 1867 | SOCKET socketFd; |
| 1868 | |
| 1869 | if (Net::smIpv6Enabled) |
| 1870 | { |
| 1871 | socketFd = PlatformNetState::smReservedSocketList.resolve(PlatformNetState::udp6Socket); |
| 1872 | |
| 1873 | if (socketFd != InvalidSocketHandle) |
| 1874 | { |
| 1875 | PlatformNetState::multicast6Socket = PlatformNetState::udp6Socket; |
| 1876 | |
| 1877 | Net::Error error = NoError; |
| 1878 | |
| 1879 | if (error == NoError) |
| 1880 | { |
| 1881 | unsigned long multicastTTL = 1; |
| 1882 | |
| 1883 | if (setsockopt(socketFd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, |
| 1884 | (char*)&multicastTTL, sizeof(multicastTTL)) < 0) |
| 1885 | { |
| 1886 | error = PlatformNetState::getLastError(); |
| 1887 | } |
| 1888 | } |
| 1889 | |
| 1890 | // Find multicast to bind to... |
| 1891 | |
| 1892 | NetAddress multicastAddress; |
| 1893 | sockaddr_in6 multicastSocketAddress; |
| 1894 | |
| 1895 | const char *multicastAddressValue = Con::getVariable("pref::Net::Multicast6Address"); |
| 1896 | if (!multicastAddressValue || multicastAddressValue[0] == '\0') |
| 1897 | { |
| 1898 | multicastAddressValue = TORQUE_NET_DEFAULT_MULTICAST_ADDRESS; |
| 1899 | } |
| 1900 | |
| 1901 | error = Net::stringToAddress(multicastAddressValue, &multicastAddress, false); |
| 1902 | |
| 1903 | if (error == NoError) |
| 1904 | { |
| 1905 | dMemset(&PlatformNetState::multicast6Group, '\0', sizeof(&PlatformNetState::multicast6Group)); |
| 1906 | NetAddressToIPSocket6(&multicastAddress, &multicastSocketAddress); |
| 1907 | dMemcpy(&PlatformNetState::multicast6Group.ipv6mr_multiaddr, &multicastSocketAddress.sin6_addr, sizeof(PlatformNetState::multicast6Group.ipv6mr_multiaddr)); |
| 1908 | } |
| 1909 | |
| 1910 | // Setup group |
| 1911 | |
| 1912 | if (error == NoError) |
| 1913 | { |
| 1914 | const char *multicastInterface = Con::getVariable("pref::Net::Multicast6Interface"); |
| 1915 | |
| 1916 | if (multicastInterface && multicastInterface[0] != '\0') |
| 1917 | { |
| 1918 | #ifdef TORQUE_USE_WINSOCK |
| 1919 | PlatformNetState::multicast6Group.ipv6mr_interface = dAtoi(multicastInterface); |
| 1920 | #else |
| 1921 | PlatformNetState::multicast6Group.ipv6mr_interface = if_nametoindex(multicastInterface); |
| 1922 | #endif |
nothing calls this directly
no test coverage detected