Leaked source code of windows server 2003
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.

624 lines
19 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: pppcp.h
  7. //
  8. // Description: This header defines function prototypes, structures and
  9. // related constants used in the interface between the PPP
  10. // engine and the various CPs
  11. //
  12. // History:
  13. // Nov 5,1993. NarenG Created original version.
  14. //
  15. #ifndef _PPPCP_
  16. #define _PPPCP_
  17. #include <mprapi.h>
  18. #include <rasppp.h>
  19. #include <rasauth.h>
  20. //
  21. // Maximum number of CPs that can live in a single DLL
  22. //
  23. #define PPPCP_MAXCPSPERDLL 20
  24. //
  25. // Various control protocol IDs
  26. //
  27. #define PPP_LCP_PROTOCOL 0xC021 // Link Control Protocol
  28. #define PPP_PAP_PROTOCOL 0xC023 // Password Authentication Protocol
  29. #define PPP_CBCP_PROTOCOL 0xC029 // Callback Control Protocol
  30. #define PPP_BACP_PROTOCOL 0xC02B // Bandwidth Allocation Control Protocol
  31. #define PPP_BAP_PROTOCOL 0xc02D // Bandwidth Allocation Protocol
  32. #define PPP_CHAP_PROTOCOL 0xC223 // Challenge Handshake Auth. Protocol
  33. #define PPP_IPCP_PROTOCOL 0x8021 // Internet Protocol Control Protocol
  34. #define PPP_ATCP_PROTOCOL 0x8029 // Appletalk Control Protocol
  35. #define PPP_IPXCP_PROTOCOL 0x802B // Novel IPX Control Procotol
  36. #define PPP_NBFCP_PROTOCOL 0x803F // NetBIOS Framing Control Protocol
  37. #define PPP_CCP_PROTOCOL 0x80FD // Compression Control Protocol
  38. #define PPP_SPAP_NEW_PROTOCOL 0xC027 // Shiva PAP new protocol
  39. #define PPP_EAP_PROTOCOL 0xC227 // Extensible Authentication Protocol
  40. //
  41. // CHAP Digest codes
  42. //
  43. #define PPP_CHAP_DIGEST_MD5 0x05 // PPP standard MD5
  44. #define PPP_CHAP_DIGEST_MSEXT 0x80 // Microsoft extended CHAP (nonstandard)
  45. #define PPP_CHAP_DIGEST_MSEXT_NEW 0x81 // Microsoft extended CHAP (nonstandard)
  46. //
  47. // Config Codes
  48. //
  49. #define CONFIG_REQ 1
  50. #define CONFIG_ACK 2
  51. #define CONFIG_NAK 3
  52. #define CONFIG_REJ 4
  53. #define TERM_REQ 5
  54. #define TERM_ACK 6
  55. #define CODE_REJ 7
  56. #define PROT_REJ 8
  57. #define ECHO_REQ 9
  58. #define ECHO_REPLY 10
  59. #define DISCARD_REQ 11
  60. #define IDENTIFICATION 12
  61. #define TIME_REMAINING 13
  62. typedef struct _PPP_CONFIG
  63. {
  64. BYTE Code; // Config code
  65. BYTE Id; // ID of this config packet. CPs and APs need
  66. // not muck with this. The engine handles it.
  67. BYTE Length[2]; // Length of this packet
  68. BYTE Data[1]; // Data
  69. }PPP_CONFIG, *PPPP_CONFIG;
  70. #define PPP_CONFIG_HDR_LEN ( sizeof( PPP_CONFIG ) - 1 )
  71. typedef struct _BAP_RESPONSE
  72. {
  73. BYTE Type; // BAP packet type
  74. BYTE Id; // ID of this packet
  75. BYTE Length[2]; // Length of this packet
  76. BYTE ResponseCode; // BAP_RESPONSE_ACK, etc
  77. BYTE Data[1]; // Data
  78. } BAP_RESPONSE, *PBAP_RESPONSE;
  79. #define BAP_RESPONSE_HDR_LEN ( sizeof( BAP_RESPONSE ) - 1 )
  80. //
  81. // Option header structure
  82. //
  83. typedef struct _PPP_OPTION
  84. {
  85. BYTE Type; // Option Code
  86. BYTE Length; // Length of this option packet
  87. BYTE Data[1]; // Data
  88. }PPP_OPTION, *PPPP_OPTION;
  89. #define PPP_OPTION_HDR_LEN ( sizeof( PPP_OPTION ) - 1 )
  90. //
  91. // Vendor-Type ids for MS VSAs - taken from rfc 2548
  92. //
  93. #define MS_VSA_CHAP_RESPONSE 1
  94. #define MS_VSA_CHAP_Error 2
  95. #define MS_VSA_CHAP_CPW1 3
  96. #define MS_VSA_CHAP_CPW2 4
  97. #define MS_VSA_CHAP_LM_Enc_PW 5
  98. #define MS_VSA_CHAP_NT_Enc_PW 6
  99. #define MS_VSA_MPPE_Encryption_Policy 7
  100. #define MS_VSA_MPPE_Encryption_Type 8
  101. #define MS_VSA_RAS_Vendor 9
  102. #define MS_VSA_CHAP_Domain 10
  103. #define MS_VSA_CHAP_Challenge 11
  104. #define MS_VSA_CHAP_MPPE_Keys 12
  105. #define MS_VSA_BAP_Usage 13
  106. #define MS_VSA_Link_Utilization_Threshold 14
  107. #define MS_VSA_Link_Drop_Time_Limit 15
  108. #define MS_VSA_MPPE_Send_Key 16
  109. #define MS_VSA_MPPE_Recv_Key 17
  110. #define MS_VSA_RAS_Version 18
  111. #define MS_VSA_Old_ARAP_Password 19
  112. #define MS_VSA_New_ARAP_Password 20
  113. #define MS_VSA_ARAP_PW_Change_Reason 21
  114. #define MS_VSA_Filter 22
  115. #define MS_VSA_Acct_Auth_Type 23
  116. #define MS_VSA_Acct_EAP_Type 24
  117. #define MS_VSA_CHAP2_Response 25
  118. #define MS_VSA_CHAP2_Success 26
  119. #define MS_VSA_CHAP2_CPW 27
  120. #define MS_VSA_Primary_DNS_Server 28
  121. #define MS_VSA_Secondary_DNS_Server 29
  122. #define MS_VSA_Primary_NBNS_Server 30
  123. #define MS_VSA_Secondary_NBNS_Server 31
  124. #define MS_VSA_ARAP_Challenge 33
  125. #define MS_VSA_RAS_Client_Name 34
  126. #define MS_VSA_RAS_Client_Version 35
  127. #define MS_VSA_Quarantine_IP_Filter 36
  128. #define MS_VSA_Quarantine_Session_Timeout 37
  129. #define MS_VSA_Local_Magic_Number 38
  130. #define MS_VSA_Remote_Magic_Number 39
  131. //
  132. // defines for terminate-cause radius attribute
  133. //
  134. #define TERMINATE_CAUSE_USER_REQUEST 1
  135. #define TERMINATE_CAUSE_LOST_CARRIER 2
  136. #define TERMINATE_CAUSE_LOST_SERVICE 3
  137. #define TERMINATE_CAUSE_IDLE_TIMEOUT 4
  138. #define TERMINATE_CAUSE_SESSION_TIMEOUT 5
  139. #define TERMINATE_CAUSE_ADMIN_RESET 6
  140. #define TERMINATE_CAUSE_ADMIN_REBOOT 7
  141. #define TERMINATE_CAUSE_PORT_ERROR 8
  142. #define TERMINATE_CAUSE_NAS_ERROR 9
  143. #define TERMINATE_CAUSE_NAS_REQUEST 10
  144. #define TERMINATE_CAUSE_NAS_REBOOT 11
  145. #define TERMINATE_CAUSE_PORT_UNNEEDED 12
  146. #define TERMINATE_CAUSE_PORT_PREEMPTED 13
  147. #define TERMINATE_CAUSE_PORT_SUSPENDED 14
  148. #define TERMINATE_CAUSE_SERVICE_UNAVAILABLE 15
  149. #define TERMINATE_CAUSE_CALLBACK 16
  150. #define TERMINATE_CAUSE_USER_ERROR 17
  151. #define TERMINATE_CAUSE_HOST_REQUEST 18
  152. //
  153. // Interface structure between the engine and APs. This is passed to the
  154. // AP's via the RasCpBegin call.
  155. //
  156. typedef struct _PPPAP_INPUT
  157. {
  158. HPORT hPort; // Handle to Ras Port for this connection.
  159. BOOL fServer; // Is this server side authentication?
  160. BOOL fRouter;
  161. DWORD fConfigInfo;
  162. CHAR * pszUserName; // Client's account ID.
  163. CHAR * pszPassword; // Client's account password.
  164. CHAR * pszDomain; // Client's account domain.
  165. CHAR * pszOldPassword; // Client's old account password. This is set
  166. // only for change password processing.
  167. LUID Luid; // Used by LSA. Must get it in user's context
  168. // which is why it must be passed down.
  169. DWORD dwRetries; // Retries allowed by the server.
  170. DWORD APDataSize; // Size in bytes of the data pointed to by
  171. // pAPData
  172. PBYTE pAPData; // Pointer to the data that was received along
  173. // with the authentication option during LCP
  174. // negotiation. Data is in wire format.
  175. DWORD dwInitialPacketId;
  176. //
  177. // Passed in by the server when a call comes in. Identifies the port used,
  178. // etc.
  179. //
  180. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  181. //
  182. // Indicates that the authenticator has completed the request, if an
  183. // authenticator was used. Ignore this field otherwise.
  184. //
  185. BOOL fAuthenticationComplete;
  186. //
  187. // Indicates an error condition during the process of authentication if
  188. // value is non-zero. Valid only when the field above is TRUE.
  189. //
  190. DWORD dwAuthError;
  191. //
  192. // Result of the authentication process. NO_ERROR indicates success,
  193. // otherwise is a value from winerror.h, raserror.h or mprerror.h
  194. // indicating failure reason. Valid only when the field above is NO_ERROR.
  195. //
  196. DWORD dwAuthResultCode;
  197. //
  198. // When the fAuthenticationComplete flag is TRUE this will point to
  199. // attributes returned by the authenticator, if the authentication was
  200. // successful. ie. dwAuthResultCode and dwAuthError are both NO_ERROR.
  201. //
  202. OPTIONAL RAS_AUTH_ATTRIBUTE * pAttributesFromAuthenticator;
  203. //
  204. // Used for EAP only
  205. //
  206. HANDLE hTokenImpersonateUser;
  207. PRAS_CUSTOM_AUTH_DATA pCustomAuthConnData;
  208. PRAS_CUSTOM_AUTH_DATA pCustomAuthUserData;
  209. BOOL fLogon; // pCustomAuthUserData comes from WinLogon
  210. BOOL fThisIsACallback;
  211. BOOL fPortWillBeBundled;
  212. BOOL fNonInteractive;
  213. BOOL fSuccessPacketReceived;
  214. BOOL fEapUIDataReceived;
  215. PPP_EAP_UI_DATA EapUIData;
  216. DWORD dwEapTypeToBeUsed;
  217. }PPPAP_INPUT, *PPPPAP_INPUT;
  218. typedef enum _PPPAP_ACTION
  219. {
  220. //
  221. // These actions are provided by the AP as output from the
  222. // RasApMakeMessage API. They tell the PPP engine what action (if any) to
  223. // take on the APs behalf, and eventually inform the engine that the AP
  224. // has finished authentication.
  225. //
  226. APA_NoAction, // Be passive, i.e. listen without timeout (default)
  227. APA_Done, // End authentication session, dwError gives result
  228. APA_SendAndDone, // As above but send message without timeout first
  229. APA_Send, // Send message, don't timeout waiting for reply
  230. APA_SendWithTimeout, // Send message, timeout if reply not received
  231. APA_SendWithTimeout2,// As above, but don't increment retry count
  232. APA_Authenticate // Authenticate using specified credentials.
  233. } PPPAP_ACTION;
  234. typedef struct _PPPAP_RESULT
  235. {
  236. PPPAP_ACTION Action;
  237. //
  238. // The packet ID which will cause the timeout for this send to be removed
  239. // from the timer queue. Otherwise, the timer queue is not touched. The
  240. // packet received is returned to the AP regardless of whether the timer
  241. // queue is changed.
  242. //
  243. BYTE bIdExpected;
  244. //
  245. // dwError is valid only with an Action code of Done or SendAndDone. 0
  246. // indicates succesful authentication. Non-0 indicates unsuccessful
  247. // authentication with the value indicating the error that occurred.
  248. //
  249. DWORD dwError;
  250. //
  251. // Valid only when dwError is non-0. Indicates whether client is allowed
  252. // to retry without restarting authentication. (Will be true in MS
  253. // extended CHAP only)
  254. //
  255. BOOL fRetry;
  256. CHAR szUserName[ UNLEN + 1 ];
  257. //
  258. // Set to attributes to be used for this user. If this is NULL, attributes
  259. // from the authenticator will be used for this user. It is upto the
  260. // allocater of this memory to free it. Must be freed during the RasCpEnd
  261. // call.
  262. //
  263. OPTIONAL RAS_AUTH_ATTRIBUTE * pUserAttributes;
  264. //
  265. // Used by MS-CHAP to pass the challenge used during the authentication
  266. // protocol. These 8 bytes are used as the variant for the 128 bit
  267. // encryption keys.
  268. //
  269. BYTE abChallenge[MAX_CHALLENGE_SIZE];
  270. BYTE abResponse[MAX_RESPONSE_SIZE];
  271. //
  272. // Used only by EAP
  273. //
  274. BOOL fInvokeEapUI;
  275. PPP_INVOKE_EAP_UI InvokeEapUIData;
  276. DWORD dwEapTypeId;
  277. BOOL fSaveUserData;
  278. BYTE * pUserData;
  279. DWORD dwSizeOfUserData;
  280. BOOL fSaveConnectionData;
  281. PPP_SET_CUSTOM_AUTH_DATA SetCustomAuthData;
  282. CHAR * szReplyMessage;
  283. }PPPAP_RESULT;
  284. //
  285. // Interface structure between the engine and the callback control protocol.
  286. // This is passed to the CBCP via the RasCpBegin call.
  287. //
  288. typedef struct _PPPCB_INPUT
  289. {
  290. BOOL fServer;
  291. BYTE bfCallbackPrivilege;
  292. DWORD CallbackDelay;
  293. CHAR * pszCallbackNumber;
  294. } PPPCB_INPUT, *PPPPCB_INPUT;
  295. typedef struct _PPPCB_RESULT
  296. {
  297. PPPAP_ACTION Action;
  298. BYTE bIdExpected;
  299. CHAR szCallbackNumber[ MAX_CALLBACKNUMBER_SIZE + 1 ];
  300. BYTE bfCallbackPrivilege;
  301. DWORD CallbackDelay;
  302. BOOL fGetCallbackNumberFromUser;
  303. } PPPCB_RESULT, *PPPPCB_RESULT;
  304. typedef struct _PPPCP_INIT
  305. {
  306. BOOL fServer;
  307. HPORT hPort;
  308. DWORD dwDeviceType;
  309. VOID (*CompletionRoutine)(
  310. HCONN hPortOrBundle,
  311. DWORD Protocol,
  312. PPP_CONFIG * pSendConfig,
  313. DWORD dwError );
  314. CHAR* pszzParameters;
  315. BOOL fThisIsACallback;
  316. BOOL fDisableNetbt;
  317. PPP_CONFIG_INFO PppConfigInfo;
  318. CHAR * pszUserName;
  319. CHAR * pszPortName;
  320. HCONN hConnection;
  321. HANDLE hInterface;
  322. ROUTER_INTERFACE_TYPE IfType;
  323. RAS_AUTH_ATTRIBUTE * pAttributes;
  324. } PPPCP_INIT, *PPPPCP_INIT;
  325. //
  326. // This structure is passed by the engine to the CP via RasCpGetInfo call.
  327. // The Cp will fill up this structure.
  328. //
  329. typedef struct _PPPCP_INFO
  330. {
  331. DWORD Protocol; // Protocol number for this CP
  332. CHAR SzProtocolName[10]; // The name of this protocol
  333. // All Config codes upto (not including) this value are valid.
  334. DWORD Recognize;
  335. // Called to initialize/uninitialize this CP. In the former case,
  336. // fInitialize will be TRUE; in the latter case, it will be FALSE.
  337. // Even if RasCpInit(TRUE) returns FALSE, RasCpInit(FALSE) will be called.
  338. DWORD (*RasCpInit)( IN BOOL fInitialize );
  339. // Called to get the workbuffer for this CP and pass info if requred.
  340. // This will be called before any negotiation takes place.
  341. DWORD (*RasCpBegin)( OUT VOID ** ppWorkBuffer,
  342. IN VOID * pInfo );
  343. // Called to free the workbuffer for this CP. Called after negotiation
  344. // is completed successfully or not.
  345. DWORD (*RasCpEnd)( IN VOID * pWorkBuffer );
  346. // Called to notify the CP dll to (re)initiaize its option values.
  347. // This will be called at least once, right after RasCpBegin
  348. DWORD (*RasCpReset)( IN VOID * pWorkBuffer );
  349. // When leaving Initial or Stopped states. May be NULL.
  350. DWORD (*RasCpThisLayerStarted)(
  351. IN VOID * pWorkBuffer );
  352. // When entering Closed or Stopped states. May be NULL
  353. DWORD (*RasCpThisLayerFinished)(
  354. IN VOID * pWorkBuffer );
  355. // When entering the Opened state. May be NULL.
  356. DWORD (*RasCpThisLayerUp)(
  357. IN VOID * pWorkBuffer );
  358. // When leaving the Opened state. May be NULL.
  359. DWORD (*RasCpThisLayerDown)(
  360. IN VOID * pWorkBuffer );
  361. // Just before the line goes down. May be NULL.
  362. DWORD (*RasCpPreDisconnectCleanup)(
  363. IN VOID * pWorkBuffer );
  364. // Called to make a configure request.
  365. DWORD (*RasCpMakeConfigRequest)(
  366. IN VOID * pWorkBuffer,
  367. OUT PPP_CONFIG* pRequestBufffer,
  368. IN DWORD cbRequestBuffer );
  369. // Called when configure request is received and a result packet
  370. // Ack/Nak/Reject needs to be sent
  371. DWORD (*RasCpMakeConfigResult)(
  372. IN VOID * pWorkBuffer,
  373. IN PPP_CONFIG * pReceiveBufffer,
  374. OUT PPP_CONFIG * pResultBufffer,
  375. IN DWORD cbResultBuffer,
  376. IN BOOL fRejectNaks );
  377. // Called to process an Ack that was received.
  378. DWORD (*RasCpConfigAckReceived)(
  379. IN VOID * pWorkBuffer,
  380. IN PPP_CONFIG * pReceiveBuffer );
  381. // Called to process a Nak that was received.
  382. DWORD (*RasCpConfigNakReceived)(
  383. IN VOID * pWorkBuffer,
  384. IN PPP_CONFIG * pReceiveBuffer );
  385. // Called to process a Rej that was received.
  386. DWORD (*RasCpConfigRejReceived)(
  387. IN VOID * pWorkBuffer,
  388. IN PPP_CONFIG * pReceiveBuffer );
  389. // Called to get the network address from configured protocols.
  390. DWORD (*RasCpGetNegotiatedInfo)(
  391. IN VOID * pWorkBuffer,
  392. OUT VOID * pInfo );
  393. // Called after all CPs have completed their negotiation, successfully or
  394. // not, to notify each CP of the projection result. May be NULL.
  395. // To access information, cast pProjectionInfo to PPP_PROJECTION_RESULT*
  396. DWORD (*RasCpProjectionNotification)(
  397. IN VOID * pWorkBuffer,
  398. IN PVOID pProjectionResult );
  399. DWORD (*RasCpChangeNotification)( VOID );
  400. //
  401. // This entry point only applies to Authentication protocols.
  402. // MUST BE NULL FOR CONTROL PROTOCOLS.
  403. DWORD (*RasApMakeMessage)(
  404. IN VOID* pWorkBuf,
  405. IN PPP_CONFIG* pReceiveBuf,
  406. OUT PPP_CONFIG* pSendBuf,
  407. IN DWORD cbSendBuf,
  408. OUT PPPAP_RESULT* pResult,
  409. IN PPPAP_INPUT* pInput );
  410. } PPPCP_INFO, *PPPPCP_INFO;
  411. #define PPPCP_FLAG_INIT_CALLED 0x00000001 // RasCpInit has been called
  412. #define PPPCP_FLAG_AVAILABLE 0x00000002 // The protocol can be used
  413. //
  414. // The information that PPP needs to keep about each CP.
  415. //
  416. typedef struct _PPPCP_ENTRY
  417. {
  418. PPPCP_INFO CpInfo;
  419. DWORD fFlags;
  420. } PPPCP_ENTRY;
  421. //
  422. // Used to get result from NBFCP via the RasCpGetResult call
  423. //
  424. typedef struct _PPPCP_NBFCP_RESULT
  425. {
  426. DWORD dwNetBiosError;
  427. CHAR szName[ NETBIOS_NAME_LEN + 1 ];
  428. } PPPCP_NBFCP_RESULT;
  429. //
  430. // Function prototypes.
  431. //
  432. DWORD APIENTRY
  433. RasCpGetInfo(
  434. IN DWORD dwProtocolId,
  435. OUT PPPCP_INFO* pCpInfo
  436. );
  437. DWORD APIENTRY
  438. RasCpEnumProtocolIds(
  439. OUT DWORD * pdwProtocolIds,
  440. IN OUT DWORD * pcProtocolIds
  441. );
  442. #endif