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

Function psnet_ras_status

networking/networking.cpp:1966–2060  ·  view source on GitHub ↗

MTS: only used in this file functions to get the status of a RAS connection

Source from the content-addressed store, hash-verified

1964// MTS: only used in this file
1965// functions to get the status of a RAS connection
1966uint32_t psnet_ras_status() {
1967 int rval;
1968 DWORD size, num_connections, i;
1969 RASCONN rasbuffer[25];
1970 HINSTANCE ras_handle;
1971 uint32_t rasip = 0;
1972 RASPPPIP projection;
1973 int Ras_connected;
1974
1975 Ras_connected = 0;
1976
1977 // first, call a LoadLibrary to load the RAS api
1978 ras_handle = LoadLibrary("rasapi32.dll");
1979 if (ras_handle == NULL) {
1980 return INADDR_ANY;
1981 }
1982
1983 pRasEnumConnections =
1984 (DWORD(__stdcall *)(LPRASCONN, LPDWORD, LPDWORD))GetProcAddress(ras_handle, "RasEnumConnectionsA");
1985 if (!pRasEnumConnections) {
1986 FreeLibrary(ras_handle);
1987 return INADDR_ANY;
1988 }
1989 pRasGetConnectStatus =
1990 (DWORD(__stdcall *)(HRASCONN, LPRASCONNSTATUS))GetProcAddress(ras_handle, "RasGetConnectStatusA");
1991 if (!pRasGetConnectStatus) {
1992 FreeLibrary(ras_handle);
1993 return INADDR_ANY;
1994 }
1995 pRasGetProjectionInfo =
1996 (DWORD(__stdcall *)(HRASCONN, RASPROJECTION, LPVOID, LPDWORD))GetProcAddress(ras_handle, "RasGetProjectionInfoA");
1997 if (!pRasGetProjectionInfo) {
1998 FreeLibrary(ras_handle);
1999 return INADDR_ANY;
2000 }
2001
2002 size = sizeof(rasbuffer);
2003 rasbuffer[0].dwSize = sizeof(RASCONN);
2004
2005 rval = pRasEnumConnections(rasbuffer, &size, &num_connections);
2006 if (rval) {
2007 FreeLibrary(ras_handle);
2008 return INADDR_ANY;
2009 }
2010
2011 // JAS: My computer gets to this point, but I have no RAS connections,
2012 // so just exit
2013 if (num_connections < 1) {
2014 mprintf(0, "Found no RAS connections\n");
2015 FreeLibrary(ras_handle);
2016 return INADDR_ANY;
2017 }
2018
2019 mprintf(0, "Found %d connections\n", num_connections);
2020
2021 for (i = 0; i < num_connections; i++) {
2022 RASCONNSTATUS status;
2023 DWORD size;

Callers 1

nw_GetThisIPFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected