Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
15 KiB

  1. /******************************************************************\
  2. * Microsoft Windows NT *
  3. * Copyright(c) Microsoft Corp., 1992 *
  4. \******************************************************************/
  5. /*++
  6. Module Name:
  7. RASSAPIP.H
  8. Description:
  9. This file contains structure defs and defines used in implementing
  10. the RASADMIN APIs.
  11. Author:
  12. Michael Salamone (MikeSa) July 13,1992
  13. Revision History:
  14. --*/
  15. #ifndef _RASSAPIP_H_
  16. #define _RASAAPIP_H_
  17. #define RASSAPI_MAX_CALLBACK_NUMBER_SIZE 48
  18. #define RASSAPI_MAX_DEVICE_NAME_OLD 32
  19. // 3rd party DLLs don't need this version information because they will only
  20. // be administering a NT3.51 or greater server.
  21. #define RAS_SERVER_20 20 // identifies a NT RAS 2.0 server
  22. //
  23. // Number of port statistics returned by a RAS 1.0 server
  24. //
  25. #define RAS10_MAX_STATISTICS 6
  26. //
  27. // RAS10 specific port statistics defines
  28. //
  29. #define RAS10_BYTES_RCVED 0
  30. #define RAS10_BYTES_XMITED 1
  31. #define RAS10_SERIAL_OVERRUN_ERR 2
  32. #define RAS10_TIMEOUT_ERR 3
  33. #define RAS10_FRAMING_ERR 4
  34. #define RAS10_CRC_ERR 5
  35. #define MEDIA_NAME_DEFAULT L"SERIAL"
  36. #define DEVICE_TYPE_DEFAULT L"MODEM"
  37. #define DEVICE_NAME_DEFAULT L"UNKNOWN"
  38. //
  39. // structures used by down level RAS 1.x servers
  40. //
  41. typedef struct tagWpdStatisticsInfo
  42. {
  43. ULONG stat_bytesreceived;
  44. ULONG stat_bytesxmitted;
  45. USHORT stat_overrunerr;
  46. USHORT stat_timeouterr;
  47. USHORT stat_framingerr;
  48. USHORT stat_crcerr;
  49. } WpdStatisticsInfo;
  50. struct dialin_user_info_0
  51. {
  52. unsigned char duseri0_privilege_mask ;
  53. char duseri0_phone_number[RASSAPI_MAX_PHONENUMBER_SIZE + 1];
  54. };
  55. struct dialin_user_info_1
  56. {
  57. struct dialin_user_info_0 duseri0;
  58. char duseri1_name[LM20_UNLEN+1];
  59. };
  60. struct dialin_user_info_2
  61. {
  62. struct dialin_user_info_0 duseri0;
  63. USER_INFO_2 usri2;
  64. };
  65. struct dialin_port_info_0
  66. {
  67. char dporti0_username[LM20_UNLEN+1]; // name of user using the port
  68. char dporti0_computer[NETBIOS_NAME_LEN+1]; // computer user dialed in from
  69. // Used when the admin wants to
  70. // send a message to this user
  71. unsigned short dporti0_comid; // COM1 = 1 etc
  72. unsigned long dporti0_time; // time user dialed in and
  73. // authenticated - number of seconds
  74. // since 00:00:00 Jan 1, 1970
  75. unsigned short dporti0_line_condition; // If RAS_PORT_AUTHENTICATED, then
  76. // comid, time username and computer
  77. // name fields are valid.
  78. unsigned short dporti0_modem_condition;
  79. };
  80. struct dialin_port_info_1
  81. {
  82. struct dialin_port_info_0 dporti0;
  83. unsigned long dporti1_baud;
  84. WpdStatisticsInfo dporti1_stats;
  85. };
  86. struct dialin_server_info_0
  87. {
  88. unsigned short dserveri0_total_ports;
  89. unsigned short dserveri0_ports_in_use;
  90. };
  91. //
  92. // defined to support RAS 1.x - the max ports in RAS 2.0 and greater
  93. // is 64 (could be greater)
  94. //
  95. #define RAS_MAX_SERVER_PORTS 16
  96. //
  97. // Max length of RAS 1.0 port name including terminating
  98. // NULL character - eg., "COM16"
  99. //
  100. #define RAS10_MAX_PORT_NAME 6
  101. //
  102. // How long a client will wait for a pipe connection (milliseconds)
  103. // if it is busy.
  104. //
  105. #define PIPE_CONNECTION_TIMEOUT 10000L
  106. #define PIPE_BUFSIZE 512
  107. //
  108. // Name of pipe that will be used to process requests
  109. //
  110. #define RASADMIN_PIPE TEXT("\\pipe\\dialin\\adminsrv")
  111. //
  112. // Pipe path to which RASADMIN_PIPE should be concatenated for local
  113. // machine
  114. //
  115. #define LOCAL_PIPE TEXT("\\\\.")
  116. //
  117. // Request codes for RAS 1.x server
  118. //
  119. #define RASADMINREQ_DISCONNECT_USER 1
  120. #define RASADMINREQ_GET_PORT_INFO 2
  121. #define RASADMINREQ_CLEAR_PORT_STATS 3
  122. #define RASADMINREQ_ENUM_PORTS 4
  123. #define RASADMINREQ_GET_SERVER_INFO 5
  124. //
  125. // Request codes for RAS 2.0 server
  126. //
  127. #define RASADMIN20_REQ_DISCONNECT_USER 2001
  128. #define RASADMIN20_REQ_GET_PORT_INFO 2002
  129. #define RASADMIN20_REQ_CLEAR_PORT_STATS 2003
  130. #define RASADMIN20_REQ_ENUM_PORTS 2004
  131. #define RASADMIN20_REQ_ENUM_RESUME 2005
  132. //
  133. // This request code remains the same as in RAS 1.0
  134. // so that, if RAS 1.0 admin tried to connect, it
  135. // will get server info back, but not in the format
  136. // that it recognizes. It will then be unable to
  137. // admin the RAS 2.0 server.
  138. //
  139. #define RASADMIN20_REQ_GET_SERVER_INFO 5
  140. //
  141. // These can be returned in the RetCode field of server response
  142. // packet sent to the client. These should not be changed in
  143. // order to preserve compatibility with different versions of
  144. // RASADMIN.
  145. //
  146. #define ERR_NO_SUCH_DEVICE 635
  147. #define ERR_SERVER_SYSTEM_ERR 636
  148. //
  149. // These are the packets sent back and forth between RAS 1.x server
  150. // and the RASADMIN APIs.
  151. //
  152. struct PortEnumRequestPkt
  153. {
  154. unsigned short Request; // ENUM_PORTS
  155. }; // ENUM_PORTS_TOTALAVAIL
  156. struct PortEnumReceivePkt
  157. {
  158. unsigned short RetCode;
  159. unsigned short TotalAvail;
  160. struct dialin_port_info_0 Data[RAS_MAX_SERVER_PORTS];
  161. };
  162. struct DisconnectUserRequestPkt
  163. {
  164. unsigned short Request; // DISCONNECT_USER
  165. unsigned short ComId;
  166. };
  167. struct DisconnectUserReceivePkt
  168. {
  169. unsigned short RetCode;
  170. };
  171. struct PortClearRequestPkt
  172. {
  173. unsigned short Request; // CLEAR_PORT_STATISTICS
  174. unsigned short ComId;
  175. };
  176. struct PortClearReceivePkt
  177. {
  178. unsigned short RetCode;
  179. };
  180. struct ServerInfoRequestPkt
  181. {
  182. unsigned short Request; // GET_SERVER_INFO
  183. };
  184. struct ServerInfoReceivePkt
  185. {
  186. unsigned short RetCode;
  187. struct dialin_server_info_0 Data;
  188. };
  189. struct PortInfoRequestPkt
  190. {
  191. unsigned short Request; // GET_PORT_INFO
  192. unsigned short ComId;
  193. };
  194. struct PortInfoReceivePkt
  195. {
  196. unsigned short RetCode;
  197. struct dialin_port_info_1 Data;
  198. };
  199. //
  200. // These are the packed structures that are sent out on the network.
  201. // It is up to the receiver to unpack and convert to the proper endian
  202. // for the host.
  203. //
  204. typedef struct _P_WPD_STATISTICS_INFO
  205. {
  206. BYTE stat_bytesreceived[4];
  207. BYTE stat_bytesxmitted[4];
  208. BYTE stat_overrunerr[2];
  209. BYTE stat_timeouterr[2];
  210. BYTE stat_framingerr[2];
  211. BYTE stat_crcerr[2];
  212. } P_WPD_STATISTICS_INFO, *PP_WPD_STATISTICS_INFO;
  213. typedef struct _P_DIALIN_PORT_INFO_0
  214. {
  215. BYTE dporti0_username[LM20_UNLEN+1]; // name of user using the port
  216. BYTE dporti0_computer[NETBIOS_NAME_LEN+1]; // computer user dialed in from
  217. // Used when the admin wants to
  218. // send a message to this user
  219. BYTE dporti0_comid[2]; // COM1 = 1 etc
  220. BYTE dporti0_time[4]; // time user dialed in and
  221. // authenticated - number of seconds
  222. // since 00:00:00 Jan 1, 1970
  223. BYTE dporti0_line_condition[2]; // If RAS_PORT_AUTHENTICATED, then
  224. // comid, time username and computer
  225. // name fields are valid.
  226. BYTE dporti0_modem_condition[2];
  227. } P_DIALIN_PORT_INFO_0, *PP_DIALIN_PORT_INFO_0;
  228. typedef struct _P_DIALIN_PORT_INFO_1
  229. {
  230. P_DIALIN_PORT_INFO_0 dporti0;
  231. BYTE dporti1_baud[4];
  232. P_WPD_STATISTICS_INFO dporti1_stats;
  233. } P_DIALIN_PORT_INFO_1, *PP_DIALIN_PORT_INFO_1;
  234. typedef struct _P_DIALIN_SERVER_INFO_0
  235. {
  236. BYTE dserveri0_total_ports[2];
  237. BYTE dserveri0_ports_in_use[2];
  238. } P_DIALIN_SERVER_INFO_0, *PP_DIALIN_SERVER_INFO_0;
  239. typedef struct _P_PORT_ENUM_REQUEST_PKT
  240. {
  241. BYTE Request[2]; // ENUM_PORTS
  242. } P_PORT_ENUM_REQUEST_PKT, *PP_PORT_ENUM_REQUEST_PKT; // ENUM_PORTS_TOTALAVAIL
  243. typedef struct _P_PORT_ENUM_RECEIVE_PKT
  244. {
  245. BYTE RetCode[2];
  246. BYTE TotalAvail[2];
  247. P_DIALIN_PORT_INFO_0 Data[RAS_MAX_SERVER_PORTS];
  248. } P_PORT_ENUM_RECEIVE_PKT, *PP_PORT_ENUM_RECEIVE_PKT;
  249. typedef struct _P_DISCONNECT_USER_REQUEST_PKT
  250. {
  251. BYTE Request[2]; // DISCONNECT_USER
  252. BYTE ComId[2];
  253. } P_DISCONNECT_USER_REQUEST_PKT, *PP_DISCONNECT_USER_REQUEST_PKT;
  254. typedef struct _P_DISCONNECT_USER_RECEIVE_PKT
  255. {
  256. BYTE RetCode[2];
  257. } P_DISCONNECT_USER_RECEIVE_PKT, *PP_DISCONNECT_USER_RECEIVE_PKT;
  258. typedef struct _P_PORT_CLEAR_REQUEST_PKT
  259. {
  260. BYTE Request[2]; // CLEAR_PORT_STATISTICS
  261. BYTE ComId[2];
  262. } P_PORT_CLEAR_REQUEST_PKT, *PP_PORT_CLEAR_REQUEST_PKT;
  263. typedef struct _P_PORT_CLEAR_RECEIVE_PKT
  264. {
  265. BYTE RetCode[2];
  266. } P_PORT_CLEAR_RECEIVE_PKT, *PP_PORT_CLEAR_RECEIVE_PKT;
  267. typedef struct _P_SERVER_INFO_REQUEST_PKT
  268. {
  269. BYTE Request[2]; // GET_SERVER_INFO
  270. } P_SERVER_INFO_REQUEST_PKT, *PP_SERVER_INFO_REQUEST_PKT;
  271. typedef struct _P_SERVER_INFO_RECEIVE_PKT
  272. {
  273. BYTE RetCode[2];
  274. P_DIALIN_SERVER_INFO_0 Data;
  275. } P_SERVER_INFO_RECEIVE_PKT, *PP_SERVER_INFO_RECEIVE_PKT;
  276. typedef struct _P_PORT_INFO_REQUEST_PKT
  277. {
  278. BYTE Request[2]; // GET_PORT_INFO
  279. BYTE ComId[2];
  280. } P_PORT_INFO_REQUEST_PKT, *PP_PORT_INFO_REQUEST_PKT;
  281. typedef struct _P_PORT_INFO_RECEIVE_PKT
  282. {
  283. BYTE RetCode[2];
  284. P_DIALIN_PORT_INFO_1 Data;
  285. } P_PORT_INFO_RECEIVE_PKT, *PP_PORT_INFO_RECEIVE_PKT;
  286. //
  287. // These are the packets sent back and forth between a RAS 2.0 server
  288. // and the RASADMIN APIs
  289. //
  290. typedef struct tagPortEnumReceivePkt
  291. {
  292. DWORD RetCode;
  293. WORD TotalAvail;
  294. RAS_PORT_0 *Data;
  295. } PORT_ENUM_RECEIVE, *PPORT_ENUM_RECEIVE;
  296. typedef struct tagPortInfoReceivePkt
  297. {
  298. DWORD RetCode;
  299. DWORD ReqBufSize;
  300. RAS_PORT_1 Data;
  301. } PORT_INFO_RECEIVE, *PPORT_INFO_RECEIVE;
  302. typedef struct tagPortClearReceivePkt
  303. {
  304. DWORD RetCode;
  305. } PORT_CLEAR_RECEIVE, *PPORT_CLEAR_RECEIVE;
  306. typedef struct tagDisconnectUserReceivePkt
  307. {
  308. DWORD RetCode;
  309. } DISCONNECT_USER_RECEIVE, *PDISCONNECT_USER_RECEIVE;
  310. typedef struct tagServerInfoReceivePkt
  311. {
  312. WORD RetCode; // VERY IMPORTANT TO BE A WORD!!! - RAS1.0 COMPATIBILITY
  313. RAS_SERVER_0 Data;
  314. } SERVER_INFO_RECEIVE, *PSERVER_INFO_RECEIVE;
  315. typedef struct _CLIENT_REQUEST
  316. {
  317. WORD RequestCode;
  318. WCHAR PortName[RASSAPI_MAX_PORT_NAME];
  319. DWORD RcvBufSize;
  320. DWORD ClientVersion;
  321. } CLIENT_REQUEST, *PCLIENT_REQUEST;
  322. //
  323. // These are the packed structures that are sent out on the network.
  324. // It is up to the receiver to unpack and convert to the proper endian
  325. // for the host.
  326. //
  327. typedef struct _P_RAS_PORT_0
  328. {
  329. BYTE wszPortName[2 * RASSAPI_MAX_PORT_NAME];
  330. BYTE wszDeviceType[2 * RASSAPI_MAX_DEVICETYPE_NAME];
  331. BYTE wszDeviceName[2 * RASSAPI_MAX_DEVICE_NAME_OLD];
  332. BYTE wszMediaName[2 * RASSAPI_MAX_MEDIA_NAME];
  333. BYTE reserved[4];
  334. BYTE Flags[4];
  335. BYTE wszUserName[2 * (UNLEN + 1)];
  336. BYTE wszComputer[2 * NETBIOS_NAME_LEN];
  337. BYTE dwStartSessionTime[4];
  338. BYTE wszLogonDomain[2 * (DNLEN + 1)];
  339. BYTE fAdvancedServer[4];
  340. } P_RAS_PORT_0, *PP_RAS_PORT_0;
  341. typedef struct _P_RAS_STATISTIC
  342. {
  343. BYTE Stat[4];
  344. } P_RAS_STATISTIC, *PP_RAS_STATISTIC;
  345. /* PPP control protocol results returned by RasPppGetInfo.
  346. */
  347. typedef struct __PPP_NBFCP_RESULT
  348. {
  349. BYTE dwError[4];
  350. BYTE dwNetBiosError[4];
  351. BYTE szName[NETBIOS_NAME_LEN + 1];
  352. BYTE wszWksta[2 * (NETBIOS_NAME_LEN + 1)];
  353. } P_PPP_NBFCP_RESULT, *PP_PPP_NBFCP_RESULT;
  354. typedef struct __PPP_IPCP_RESULT
  355. {
  356. BYTE dwError[4];
  357. BYTE wszAddress[2 * (RAS_IPADDRESSLEN + 1)];
  358. } P_PPP_IPCP_RESULT, *PP_PPP_IPCP_RESULT;
  359. typedef struct __PPP_IPXCP_RESULT
  360. {
  361. BYTE dwError[4];
  362. BYTE wszAddress[2 * (RAS_IPXADDRESSLEN + 1)];
  363. } P_PPP_IPXCP_RESULT, *PP_PPP_IPXCP_RESULT;
  364. typedef struct __PPP_ATCP_RESULT
  365. {
  366. BYTE dwError[4];
  367. BYTE wszAddress[2 * (RAS_ATADDRESSLEN + 1)];
  368. } P_PPP_ATCP_RESULT, *PP_PPP_ATCP_RESULT;
  369. typedef struct __PPP_PROJECTION_RESULT
  370. {
  371. P_PPP_NBFCP_RESULT nbf;
  372. P_PPP_IPCP_RESULT ip;
  373. P_PPP_IPXCP_RESULT ipx;
  374. P_PPP_ATCP_RESULT at;
  375. } P_PPP_PROJECTION_RESULT, *PP_PPP_PROJECTION_RESULT;
  376. typedef struct _P_RAS_PORT_1
  377. {
  378. P_RAS_PORT_0 rasport0;
  379. BYTE LineCondition[4];
  380. BYTE HardwareCondition[4];
  381. BYTE LineSpeed[4]; // in bits/second
  382. BYTE NumStatistics[2];
  383. BYTE NumMediaParms[2];
  384. BYTE SizeMediaParms[4];
  385. P_PPP_PROJECTION_RESULT ProjResult;
  386. } P_RAS_PORT_1, *PP_RAS_PORT_1;
  387. typedef struct _P_RAS_FORMAT
  388. {
  389. BYTE Format[4];
  390. } P_RAS_FORMAT, *PP_RAS_FORMAT;
  391. typedef union _P_RAS_VALUE
  392. {
  393. BYTE Number[4];
  394. struct
  395. {
  396. BYTE Length[4];
  397. BYTE Offset[4];
  398. } String;
  399. } P_RAS_VALUE, *PP_RAS_VALUE;
  400. typedef struct _P_RAS_PARAMS
  401. {
  402. BYTE P_Key[RASSAPI_MAX_PARAM_KEY_SIZE];
  403. P_RAS_FORMAT P_Type;
  404. BYTE P_Attributes;
  405. P_RAS_VALUE P_Value;
  406. } P_RAS_PARAMS, *PP_RAS_PARAMS;
  407. typedef struct _P_RAS_SERVER_0
  408. {
  409. BYTE TotalPorts[2];
  410. BYTE PortsInUse[2];
  411. BYTE RasVersion[4];
  412. } P_RAS_SERVER_0, *PP_RAS_SERVER_0;
  413. typedef struct _P_PORT_ENUM_RECEIVE
  414. {
  415. BYTE RetCode[4];
  416. BYTE TotalAvail[2];
  417. P_RAS_PORT_0 Data[1];
  418. } P_PORT_ENUM_RECEIVE, *PP_PORT_ENUM_RECEIVE;
  419. typedef struct _P_PORT_INFO_RECEIVE
  420. {
  421. BYTE RetCode[4];
  422. BYTE ReqBufSize[4];
  423. P_RAS_PORT_1 Data;
  424. } P_PORT_INFO_RECEIVE, *PP_PORT_INFO_RECEIVE;
  425. typedef struct _P_PORT_CLEAR_RECEIVE
  426. {
  427. BYTE RetCode[4];
  428. } P_PORT_CLEAR_RECEIVE, *PP_PORT_CLEAR_RECEIVE;
  429. typedef struct _P_DISCONNECT_USER_RECEIVE
  430. {
  431. BYTE RetCode[4];
  432. } P_DISCONNECT_USER_RECEIVE, *PP_DISCONNECT_USER_RECEIVE;
  433. typedef struct _P_SERVER_INFO_RECEIVE
  434. {
  435. BYTE RetCode[2];
  436. P_RAS_SERVER_0 Data;
  437. } P_SERVER_INFO_RECEIVE, *PP_SERVER_INFO_RECEIVE;
  438. typedef struct _P_CLIENT_REQUEST
  439. {
  440. BYTE RequestCode[2];
  441. BYTE PortName[2 * RASSAPI_MAX_PORT_NAME];
  442. BYTE RcvBufSize[4];
  443. BYTE ClientVersion[4];
  444. } P_CLIENT_REQUEST, *PP_CLIENT_REQUEST;
  445. //
  446. // The following macros deal with on-the-wire integer and long values
  447. // On the wire format is little-endian i.e. a long value of 0x01020304 is
  448. // represented as 04 03 02 01. Similarly an int value of 0x0102 is
  449. // represented as 02 01.
  450. //
  451. // The host format is not assumed since it will vary from processor to
  452. // processor.
  453. //
  454. // Get a short from on-the-wire format to the host format
  455. #define GETUSHORT(DstPtr, SrcPtr) \
  456. *(unsigned short *)(DstPtr) = \
  457. ((*((unsigned char *)(SrcPtr)+1) << 8) +\
  458. (*((unsigned char *)(SrcPtr)+0)))
  459. // Get a dword from on-the-wire format to the host format
  460. #define GETULONG(DstPtr, SrcPtr) \
  461. *(unsigned long *)(DstPtr) = \
  462. ((*((unsigned char *)(SrcPtr)+3) << 24) +\
  463. (*((unsigned char *)(SrcPtr)+2) << 16) + \
  464. (*((unsigned char *)(SrcPtr)+1) << 8) + \
  465. (*((unsigned char *)(SrcPtr)+0)))
  466. // Put a ushort from the host format to on-the-wire format
  467. #define PUTUSHORT(DstPtr, Src) \
  468. *((unsigned char *)(DstPtr)+1)=(unsigned char)((unsigned short)(Src) >> 8),\
  469. *((unsigned char *)(DstPtr)+0)=(unsigned char)(Src)
  470. // Put a ulong from the host format to on-the-wire format
  471. #define PUTULONG(DstPtr, Src) \
  472. *((unsigned char *)(DstPtr)+3)=(unsigned char)((unsigned long)(Src) >> 24),\
  473. *((unsigned char *)(DstPtr)+2)=(unsigned char)((unsigned long)(Src) >> 16),\
  474. *((unsigned char *)(DstPtr)+1)=(unsigned char)((unsigned long)(Src) >> 8),\
  475. *((unsigned char *)(DstPtr)+0)=(unsigned char)(Src)
  476. #endif // _RASSAPIP_H_
  477.