MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / nw_GetThisIP

Function nw_GetThisIP

networking/networking.cpp:860–892  ·  view source on GitHub ↗

returns the ip address of this computer

Source from the content-addressed store, hash-verified

858
859// returns the ip address of this computer
860uint32_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
895uint16_t nw_CalculateChecksum(void *vptr, int len) {

Callers 2

nw_InitSocketsFunction · 0.85
InitDedicatedSocketFunction · 0.85

Calls 1

psnet_ras_statusFunction · 0.85

Tested by

no test coverage detected