| 1812 | } |
| 1813 | |
| 1814 | void Net::addressToString(const NetAddress *address, char addressString[256]) |
| 1815 | { |
| 1816 | if(address->type == NetAddress::IPAddress || address->type == NetAddress::IPBroadcastAddress) |
| 1817 | { |
| 1818 | sockaddr_in ipAddr; |
| 1819 | NetAddressToIPSocket(address, &ipAddr); |
| 1820 | |
| 1821 | if (ipAddr.sin_addr.s_addr == htonl(INADDR_BROADCAST) || address->type == NetAddress::IPBroadcastAddress) |
| 1822 | { |
| 1823 | if (ipAddr.sin_port == 0) |
| 1824 | dSprintf(addressString, 256, "IP:Broadcast"); |
| 1825 | else |
| 1826 | dSprintf(addressString, 256, "IP:Broadcast:%d", ntohs(ipAddr.sin_port)); |
| 1827 | } |
| 1828 | else |
| 1829 | { |
| 1830 | char buffer[256]; |
| 1831 | buffer[0] = '\0'; |
| 1832 | inet_ntop(AF_INET, &(ipAddr.sin_addr), buffer, sizeof(buffer)); |
| 1833 | if (ipAddr.sin_port == 0) |
| 1834 | dSprintf(addressString, 256, "IP:%s", buffer); |
| 1835 | else |
| 1836 | dSprintf(addressString, 256, "IP:%s:%i", buffer, ntohs(ipAddr.sin_port)); |
| 1837 | } |
| 1838 | } |
| 1839 | else if (address->type == NetAddress::IPV6Address) |
| 1840 | { |
| 1841 | char buffer[256]; |
| 1842 | buffer[0] = '\0'; |
| 1843 | sockaddr_in6 ipAddr; |
| 1844 | NetAddressToIPSocket6(address, &ipAddr); |
| 1845 | inet_ntop(AF_INET6, &(ipAddr.sin6_addr), buffer, sizeof(buffer)); |
| 1846 | if (ipAddr.sin6_port == 0) |
| 1847 | dSprintf(addressString, 256, "IP6:%s", buffer); |
| 1848 | else |
| 1849 | dSprintf(addressString, 256, "IP6:[%s]:%i", buffer, ntohs(ipAddr.sin6_port)); |
| 1850 | } |
| 1851 | else if (address->type == NetAddress::IPV6MulticastAddress) |
| 1852 | { |
| 1853 | if (address->port == 0) |
| 1854 | dSprintf(addressString, 256, "IP6:Multicast"); |
| 1855 | else |
| 1856 | dSprintf(addressString, 256, "IP6:Multicast:%d", address->port); |
| 1857 | } |
| 1858 | else |
| 1859 | { |
| 1860 | *addressString = 0; |
| 1861 | return; |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | void Net::enableMulticast() |
| 1866 | { |
nothing calls this directly
no test coverage detected