returns the ip address of this computer
| 858 | |
| 859 | // returns the ip address of this computer |
| 860 | uint32_t nw_GetThisIP() { |
| 861 | SOCKADDR_IN local_address; |
| 862 | int address_size = sizeof(SOCKADDR); |
| 863 | |
| 864 | if (Net_fixed_ip != INADDR_NONE) { |
| 865 | return Net_fixed_ip; |
| 866 | } |
| 867 | // Init local address to zero |
| 868 | local_address.sin_addr.s_addr = INADDR_ANY; |
| 869 | if (Dialup_connection) { |
| 870 | #ifdef WIN32 |
| 871 | local_address.sin_addr.s_addr = psnet_ras_status(); |
| 872 | #else |
| 873 | local_address.sin_addr.s_addr = INADDR_ANY; |
| 874 | #endif |
| 875 | } |
| 876 | if ((!Dialup_connection) || (!local_address.sin_addr.s_addr)) { |
| 877 | // Removed the fancy way, it worked worse than the easy way (some adsl/cable people had problems. |
| 878 | /* |
| 879 | // Get the local host name |
| 880 | ret = gethostname(local, 255 ); |
| 881 | if (ret != SOCKET_ERROR ) |
| 882 | { |
| 883 | // Resolve host name for local address |
| 884 | hostent = gethostbyname((LPSTR)local); |
| 885 | if ( hostent ) |
| 886 | local_address.sin_addr.s_addr = *((u_long FAR *)(hostent->h_addr)); |
| 887 | } |
| 888 | */ |
| 889 | local_address.sin_addr.s_addr = INADDR_ANY; |
| 890 | } |
| 891 | return local_address.sin_addr.s_addr; |
| 892 | } |
| 893 | |
| 894 | // Calculates a unique uint16_t checksum for a stream of data |
| 895 | uint16_t nw_CalculateChecksum(void *vptr, int len) { |
no test coverage detected