1 /***********************************************************************\
2 *                               rassapi.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module windows.rassapi;
12 nothrow:
13 private import windows.lmcons, windows.windef;
14 
15 // FIXME: check types of constants
16 
17 const size_t
18 	RASSAPI_MAX_PHONENUMBER_SIZE = 128,
19 	RASSAPI_MAX_MEDIA_NAME	     =  16,
20 	RASSAPI_MAX_PORT_NAME	     =  16,
21 	RASSAPI_MAX_DEVICE_NAME      = 128,
22 	RASSAPI_MAX_DEVICETYPE_NAME  =  16,
23 	RASSAPI_MAX_PARAM_KEY_SIZE   =  32;
24 
25 const RASPRIV_NoCallback        = 0x01;
26 const RASPRIV_AdminSetCallback  = 0x02;
27 const RASPRIV_CallerSetCallback = 0x04;
28 const RASPRIV_DialinPrivilege   = 0x08;
29 const RASPRIV_CallbackType      = 0x07;
30 
31 enum {
32 	RAS_MODEM_OPERATIONAL = 1,
33 	RAS_MODEM_NOT_RESPONDING,
34 	RAS_MODEM_HARDWARE_FAILURE,
35 	RAS_MODEM_INCORRECT_RESPONSE,
36 	RAS_MODEM_UNKNOWN  // = 5
37 }
38 
39 enum {
40 	RAS_PORT_NON_OPERATIONAL = 1,
41 	RAS_PORT_DISCONNECTED,
42 	RAS_PORT_CALLING_BACK,
43 	RAS_PORT_LISTENING,
44 	RAS_PORT_AUTHENTICATING,
45 	RAS_PORT_AUTHENTICATED,
46 	RAS_PORT_INITIALIZING // = 7
47 }
48 
49 enum {
50 	MEDIA_UNKNOWN,
51 	MEDIA_SERIAL,
52 	MEDIA_RAS10_SERIAL,
53 	MEDIA_X25,
54 	MEDIA_ISDN
55 }
56 
57 const USER_AUTHENTICATED = 0x0001;
58 const MESSENGER_PRESENT  = 0x0002;
59 const PPP_CLIENT         = 0x0004;
60 const GATEWAY_ACTIVE     = 0x0008;
61 const REMOTE_LISTEN      = 0x0010;
62 const PORT_MULTILINKED   = 0x0020;
63 
64 const size_t
65 	RAS_IPADDRESSLEN  = 15,
66 	RAS_IPXADDRESSLEN = 22,
67 	RAS_ATADDRESSLEN  = 32;
68 
69 // FIXME: should these be grouped together?
70 enum {
71 	RASDOWNLEVEL     = 10,
72 	RASADMIN_35      = 35,
73 	RASADMIN_CURRENT = 40
74 }
75 
76 alias ULONG IPADDR;
77 
78 enum RAS_PARAMS_FORMAT {
79     ParamNumber = 0,
80     ParamString
81 }
82 
83 union RAS_PARAMS_VALUE {
84 	DWORD Number;
85 	struct _String {
86 		DWORD Length;
87 		PCHAR Data;
88 	}
89 	_String String;
90 }
91 
92 struct RAS_PARAMETERS {
93 	CHAR[RASSAPI_MAX_PARAM_KEY_SIZE] P_Key;
94 	RAS_PARAMS_FORMAT                P_Type;
95 	BYTE                             P_Attributes;
96 	RAS_PARAMS_VALUE                 P_Value;
97 }
98 
99 struct RAS_USER_0 {
100 	BYTE                                    bfPrivilege;
101 	WCHAR[RASSAPI_MAX_PHONENUMBER_SIZE + 1] szPhoneNumber;
102 }
103 alias RAS_USER_0* PRAS_USER_0;
104 
105 struct RAS_PORT_0 {
106 	WCHAR[RASSAPI_MAX_PORT_NAME]       wszPortName;
107 	WCHAR[RASSAPI_MAX_DEVICETYPE_NAME] wszDeviceType;
108 	WCHAR[RASSAPI_MAX_DEVICE_NAME]     wszDeviceName;
109 	WCHAR[RASSAPI_MAX_MEDIA_NAME]      wszMediaName;
110 	DWORD                              reserved;
111 	DWORD                              Flags;
112 	WCHAR[UNLEN + 1]                   wszUserName;
113 	WCHAR[NETBIOS_NAME_LEN]            wszComputer;
114 	DWORD                              dwStartSessionTime; // seconds from 1/1/1970
115 	WCHAR[DNLEN + 1]                   wszLogonDomain;
116 	BOOL                               fAdvancedServer;
117 }
118 alias RAS_PORT_0* PRAS_PORT_0;
119 
120 struct RAS_PPP_NBFCP_RESULT {
121 	DWORD dwError;
122 	DWORD dwNetBiosError;
123 	CHAR[NETBIOS_NAME_LEN + 1]  szName;
124 	WCHAR[NETBIOS_NAME_LEN + 1] wszWksta;
125 }
126 
127 struct RAS_PPP_IPCP_RESULT {
128 	DWORD dwError;
129 	WCHAR[RAS_IPADDRESSLEN + 1] wszAddress;
130 }
131 
132 struct RAS_PPP_IPXCP_RESULT {
133 	DWORD dwError;
134 	WCHAR[RAS_IPXADDRESSLEN + 1] wszAddress;
135 }
136 
137 struct RAS_PPP_ATCP_RESULT {
138 	DWORD dwError;
139 	WCHAR[RAS_ATADDRESSLEN + 1] wszAddress;
140 }
141 
142 struct RAS_PPP_PROJECTION_RESULT {
143 	RAS_PPP_NBFCP_RESULT nbf;
144 	RAS_PPP_IPCP_RESULT  ip;
145 	RAS_PPP_IPXCP_RESULT ipx;
146 	RAS_PPP_ATCP_RESULT  at;
147 }
148 
149 struct RAS_PORT_1 {
150 	RAS_PORT_0 rasport0;
151 	DWORD      LineCondition;
152 	DWORD      HardwareCondition;
153 	DWORD      LineSpeed;
154 	WORD       NumStatistics;
155 	WORD       NumMediaParms;
156 	DWORD      SizeMediaParms;
157 	RAS_PPP_PROJECTION_RESULT ProjResult;
158 }
159 alias RAS_PORT_1* PRAS_PORT_1;
160 
161 struct RAS_PORT_STATISTICS {
162 	DWORD dwBytesXmited;
163 	DWORD dwBytesRcved;
164 	DWORD dwFramesXmited;
165 	DWORD dwFramesRcved;
166 	DWORD dwCrcErr;
167 	DWORD dwTimeoutErr;
168 	DWORD dwAlignmentErr;
169 	DWORD dwHardwareOverrunErr;
170 	DWORD dwFramingErr;
171 	DWORD dwBufferOverrunErr;
172 	DWORD dwBytesXmitedUncompressed;
173 	DWORD dwBytesRcvedUncompressed;
174 	DWORD dwBytesXmitedCompressed;
175 	DWORD dwBytesRcvedCompressed;
176 	DWORD dwPortBytesXmited;
177 	DWORD dwPortBytesRcved;
178 	DWORD dwPortFramesXmited;
179 	DWORD dwPortFramesRcved;
180 	DWORD dwPortCrcErr;
181 	DWORD dwPortTimeoutErr;
182 	DWORD dwPortAlignmentErr;
183 	DWORD dwPortHardwareOverrunErr;
184 	DWORD dwPortFramingErr;
185 	DWORD dwPortBufferOverrunErr;
186 	DWORD dwPortBytesXmitedUncompressed;
187 	DWORD dwPortBytesRcvedUncompressed;
188 	DWORD dwPortBytesXmitedCompressed;
189 	DWORD dwPortBytesRcvedCompressed;
190 }
191 alias RAS_PORT_STATISTICS* PRAS_PORT_STATISTICS;
192 
193 struct RAS_SERVER_0 {
194 	WORD TotalPorts;
195 	WORD PortsInUse;
196 	DWORD RasVersion;
197 }
198 alias RAS_SERVER_0* PRAS_SERVER_0;
199 
200 extern (Windows) {
201 	DWORD RasAdminServerGetInfo(const(WCHAR)*, PRAS_SERVER_0);
202 	DWORD RasAdminGetUserAccountServer(const(WCHAR)*, const(WCHAR)*, LPWSTR);
203 	DWORD RasAdminUserGetInfo(const(WCHAR)*, const(WCHAR)*, PRAS_USER_0);
204 	DWORD RasAdminUserSetInfo(const(WCHAR)*, const(WCHAR)*, PRAS_USER_0);
205 	DWORD RasAdminPortEnum(WCHAR*, PRAS_PORT_0*, WORD*);
206 	DWORD RasAdminPortGetInfo(const(WCHAR)*, const(WCHAR)*, RAS_PORT_1*,
207 	 RAS_PORT_STATISTICS*, RAS_PARAMETERS**);
208 	DWORD RasAdminPortClearStatistics(const(WCHAR)*, const(WCHAR)*);
209 	DWORD RasAdminPortDisconnect(const(WCHAR)*, const(WCHAR)*);
210 	DWORD RasAdminFreeBuffer(PVOID);
211 	DWORD RasAdminGetErrorString(UINT, WCHAR*, DWORD);
212 	BOOL RasAdminAcceptNewConnection(RAS_PORT_1*, RAS_PORT_STATISTICS*,
213 	 RAS_PARAMETERS*);
214 	VOID RasAdminConnectionHangupNotification(RAS_PORT_1*,
215 	  RAS_PORT_STATISTICS*, RAS_PARAMETERS*);
216 	DWORD RasAdminGetIpAddressForUser (WCHAR*, WCHAR*, IPADDR*, BOOL*);
217 	VOID RasAdminReleaseIpAddress (WCHAR*, WCHAR*,IPADDR*);
218 	DWORD RasAdminGetUserParms(WCHAR*, PRAS_USER_0);
219 	DWORD RasAdminSetUserParms(WCHAR*, DWORD, PRAS_USER_0);
220 }