ReactOS 0.4.15-dev-7953-g1f49173
rasdial.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32/src/rasdial.c
5 * PURPOSE: RAS Auto-Dial Support
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ws2_32.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* DATA **********************************************************************/
17
18typedef BOOL
21 IN INT NameLength
22);
23
24typedef BOOL
26
27typedef VOID
31);
32
39
40#define WsRasLock() EnterCriticalSection(&WsRasHelperLock)
41#define WsRasUnlock() LeaveCriticalSection(&WsRasHelperLock)
42
43/* FUNCTIONS *****************************************************************/
44
45VOID
48{
49 /* Initialize the autodial lock */
51}
52
53VOID
56{
57 /* Acquire lock */
58 WsRasLock();
59
60 /* Free the library if it's loaded */
63
64 /* Release and delete lock */
67}
68
69INT
72{
73 CHAR HelperPath[MAX_PATH];
74 HKEY WinsockKey;
76 DWORD RegType = REG_SZ;
77 DWORD RegSize = MAX_PATH;
78
79 /* Acquire the lock */
80 WsRasLock();
81
82 /* Check if we were already initialized */
84 {
85 /* Open the registry root key */
86 WinsockKey = WsOpenRegistryRoot();
87 if (WinsockKey)
88 {
89 /* Read the helper's location */
90 ErrorCode = RegQueryValueEx(WinsockKey,
91 "AutodialDLL",
92 0,
93 &RegType,
94 (LPBYTE)&HelperPath,
95 &RegSize);
96 RegCloseKey(WinsockKey);
97
98 /* Make sure we read the path */
100 {
101 /* Now load it */
102 WsRasDllHandle = LoadLibrary(HelperPath);
103 }
104 }
105
106 /* Check if we weren't able to load it and load the default */
107 if (!WsRasDllHandle) WsRasDllHandle = LoadLibrary("rasadhlp.dll");
108
109 /* Check again if we loaded it */
110 if (WsRasDllHandle)
111 {
112 /* Get function pointers */
115 "WSAttemptAutodialAddr");
118 "WSAttemptAutodialName");
121 "WSNoteSuccessfulHostentLookup");
122 }
123
124 /* Mark us as loaded */
126 }
127
128 /* Release lock */
129 WsRasUnlock();
130
131 /* Return status */
132 return WsRasInitialized;
133}
134
135BOOL
136WSAAPI
138 IN INT NameLength)
139{
140 /* Load the helper DLL and make sure it exports this routine */
142
143 /* Call the function in the helper */
144 return lpfnWSAttemptAutodialAddr(Name, NameLength);
145}
146
147BOOL
148WSAAPI
150{
151 /* Load the helper DLL and make sure it exports this routine */
153
154 /* Call the function in the helper */
155 return lpfnWSAttemptAutodialName(lpqsRestrictions);
156}
157
158VOID
159WSAAPI
162{
163 /* Load the helper DLL and make sure it exports this routine */
165
166 /* Call the function in the helper */
168}
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
struct NameRec_ * Name
Definition: cdprocs.h:460
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define FAR
Definition: zlib.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_SZ
Definition: layer.c:22
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define BOOL
Definition: nt_native.h:43
#define CONST
Definition: pedump.c:81
static WCHAR Address[46]
Definition: ping.c:68
BOOL(WSAAPI * PWS_ATTEMPT_AUTODIAL_NAME)(IN CONST LPWSAQUERYSETW lpqsRestrictions)
Definition: rasdial.c:25
VOID WSAAPI WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR *Name, IN CONST ULONG Address)
Definition: rasdial.c:160
BOOL WSAAPI WSAttemptAutodialName(IN CONST LPWSAQUERYSETW lpqsRestrictions)
Definition: rasdial.c:149
HINSTANCE WsRasDllHandle
Definition: rasdial.c:34
BOOLEAN WsRasInitialized
Definition: rasdial.c:33
VOID(WSAAPI * PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP)(IN CONST CHAR FAR *Name, IN CONST ULONG Address)
Definition: rasdial.c:28
PWS_ATTEMPT_AUTODIAL_ADDR lpfnWSAttemptAutodialAddr
Definition: rasdial.c:36
VOID WSAAPI WsRasInitializeAutodial(VOID)
Definition: rasdial.c:47
INT WSAAPI WsRasLoadHelperDll(VOID)
Definition: rasdial.c:71
#define WsRasUnlock()
Definition: rasdial.c:41
BOOL WSAAPI WSAttemptAutodialAddr(IN CONST SOCKADDR FAR *Name, IN INT NameLength)
Definition: rasdial.c:137
BOOL(WSAAPI * PWS_ATTEMPT_AUTODIAL_ADDR)(IN CONST SOCKADDR FAR *Name, IN INT NameLength)
Definition: rasdial.c:19
PWS_ATTEMPT_AUTODIAL_NAME lpfnWSAttemptAutodialName
Definition: rasdial.c:37
#define WsRasLock()
Definition: rasdial.c:40
VOID WSAAPI WsRasUninitializeAutodial(VOID)
Definition: rasdial.c:55
PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP lpfnWSNoteSuccessfulHostentLookup
Definition: rasdial.c:38
CRITICAL_SECTION WsRasHelperLock
Definition: rasdial.c:35
static LPWSAQUERYSETW
Definition: sock.c:90
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
unsigned char * LPBYTE
Definition: typedefs.h:53
void * PVOID
Definition: typedefs.h:50
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define LoadLibrary
Definition: winbase.h:3862
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define RegQueryValueEx
Definition: winreg.h:524
#define WSAAPI
Definition: winsock2.h:605
HKEY WSAAPI WsOpenRegistryRoot(VOID)
Definition: wsautil.c:17
char CHAR
Definition: xmlstorage.h:175