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.

602 lines
17 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. // Interface structure between the engine and APs. This is passed to the
  133. // AP's via the RasCpBegin call.
  134. //
  135. typedef struct _PPPAP_INPUT
  136. {
  137. HPORT hPort; // Handle to Ras Port for this connection.
  138. BOOL fServer; // Is this server side authentication?
  139. BOOL fRouter;
  140. DWORD fConfigInfo;
  141. CHAR * pszUserName; // Client's account ID.
  142. CHAR * pszPassword; // Client's account password.
  143. CHAR * pszDomain; // Client's account domain.
  144. CHAR * pszOldPassword; // Client's old account password. This is set
  145. // only for change password processing.
  146. LUID Luid; // Used by LSA. Must get it in user's context
  147. // which is why it must be passed down.
  148. DWORD dwRetries; // Retries allowed by the server.
  149. DWORD APDataSize; // Size in bytes of the data pointed to by
  150. // pAPData
  151. PBYTE pAPData; // Pointer to the data that was received along
  152. // with the authentication option during LCP
  153. // negotiation. Data is in wire format.
  154. DWORD dwInitialPacketId;
  155. //
  156. // Passed in by the server when a call comes in. Identifies the port used,
  157. // etc.
  158. //
  159. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  160. //
  161. // Indicates that the authenticator has completed the request, if an
  162. // authenticator was used. Ignore this field otherwise.
  163. //
  164. BOOL fAuthenticationComplete;
  165. //
  166. // Indicates an error condition during the process of authentication if
  167. // value is non-zero. Valid only when the field above is TRUE.
  168. //
  169. DWORD dwAuthError;
  170. //
  171. // Result of the authentication process. NO_ERROR indicates success,
  172. // otherwise is a value from winerror.h, raserror.h or mprerror.h
  173. // indicating failure reason. Valid only when the field above is NO_ERROR.
  174. //
  175. DWORD dwAuthResultCode;
  176. //
  177. // When the fAuthenticationComplete flag is TRUE this will point to
  178. // attributes returned by the authenticator, if the authentication was
  179. // successful. ie. dwAuthResultCode and dwAuthError are both NO_ERROR.
  180. //
  181. OPTIONAL RAS_AUTH_ATTRIBUTE * pAttributesFromAuthenticator;
  182. //
  183. // Used for EAP only
  184. //
  185. HANDLE hTokenImpersonateUser;
  186. PRAS_CUSTOM_AUTH_DATA pCustomAuthConnData;
  187. PRAS_CUSTOM_AUTH_DATA pCustomAuthUserData;
  188. BOOL fLogon; // pCustomAuthUserData comes from WinLogon
  189. BOOL fThisIsACallback;
  190. BOOL fPortWillBeBundled;
  191. BOOL fNonInteractive;
  192. BOOL fSuccessPacketReceived;
  193. BOOL fEapUIDataReceived;
  194. PPP_EAP_UI_DATA EapUIData;
  195. DWORD dwEapTypeToBeUsed;
  196. }PPPAP_INPUT, *PPPPAP_INPUT;
  197. typedef enum _PPPAP_ACTION
  198. {
  199. //
  200. // These actions are provided by the AP as output from the
  201. // RasApMakeMessage API. They tell the PPP engine what action (if any) to
  202. // take on the APs behalf, and eventually inform the engine that the AP
  203. // has finished authentication.
  204. //
  205. APA_NoAction, // Be passive, i.e. listen without timeout (default)
  206. APA_Done, // End authentication session, dwError gives result
  207. APA_SendAndDone, // As above but send message without timeout first
  208. APA_Send, // Send message, don't timeout waiting for reply
  209. APA_SendWithTimeout, // Send message, timeout if reply not received
  210. APA_SendWithTimeout2,// As above, but don't increment retry count
  211. APA_Authenticate // Authenticate using specified credentials.
  212. } PPPAP_ACTION;
  213. typedef struct _PPPAP_RESULT
  214. {
  215. PPPAP_ACTION Action;
  216. //
  217. // The packet ID which will cause the timeout for this send to be removed
  218. // from the timer queue. Otherwise, the timer queue is not touched. The
  219. // packet received is returned to the AP regardless of whether the timer
  220. // queue is changed.
  221. //
  222. BYTE bIdExpected;
  223. //
  224. // dwError is valid only with an Action code of Done or SendAndDone. 0
  225. // indicates succesful authentication. Non-0 indicates unsuccessful
  226. // authentication with the value indicating the error that occurred.
  227. //
  228. DWORD dwError;
  229. //
  230. // Valid only when dwError is non-0. Indicates whether client is allowed
  231. // to retry without restarting authentication. (Will be true in MS
  232. // extended CHAP only)
  233. //
  234. BOOL fRetry;
  235. CHAR szUserName[ UNLEN + 1 ];
  236. //
  237. // Set to attributes to be used for this user. If this is NULL, attributes
  238. // from the authenticator will be used for this user. It is upto the
  239. // allocater of this memory to free it. Must be freed during the RasCpEnd
  240. // call.
  241. //
  242. OPTIONAL RAS_AUTH_ATTRIBUTE * pUserAttributes;
  243. //
  244. // Used by MS-CHAP to pass the challenge used during the authentication
  245. // protocol. These 8 bytes are used as the variant for the 128 bit
  246. // encryption keys.
  247. //
  248. BYTE abChallenge[MAX_CHALLENGE_SIZE];
  249. BYTE abResponse[MAX_RESPONSE_SIZE];
  250. //
  251. // Used only by EAP
  252. //
  253. BOOL fInvokeEapUI;
  254. PPP_INVOKE_EAP_UI InvokeEapUIData;
  255. DWORD dwEapTypeId;
  256. BOOL fSaveUserData;
  257. BYTE * pUserData;
  258. DWORD dwSizeOfUserData;
  259. BOOL fSaveConnectionData;
  260. PPP_SET_CUSTOM_AUTH_DATA SetCustomAuthData;
  261. CHAR * szReplyMessage;
  262. }PPPAP_RESULT;
  263. //
  264. // Interface structure between the engine and the callback control protocol.
  265. // This is passed to the CBCP via the RasCpBegin call.
  266. //
  267. typedef struct _PPPCB_INPUT
  268. {
  269. BOOL fServer;
  270. BYTE bfCallbackPrivilege;
  271. DWORD CallbackDelay;
  272. CHAR * pszCallbackNumber;
  273. } PPPCB_INPUT, *PPPPCB_INPUT;
  274. typedef struct _PPPCB_RESULT
  275. {
  276. PPPAP_ACTION Action;
  277. BYTE bIdExpected;
  278. CHAR szCallbackNumber[ MAX_CALLBACKNUMBER_SIZE + 1 ];
  279. BYTE bfCallbackPrivilege;
  280. DWORD CallbackDelay;
  281. BOOL fGetCallbackNumberFromUser;
  282. } PPPCB_RESULT, *PPPPCB_RESULT;
  283. typedef struct _PPPCP_INIT
  284. {
  285. BOOL fServer;
  286. HPORT hPort;
  287. DWORD dwDeviceType;
  288. VOID (*CompletionRoutine)(
  289. HCONN hPortOrBundle,
  290. DWORD Protocol,
  291. PPP_CONFIG * pSendConfig,
  292. DWORD dwError );
  293. CHAR* pszzParameters;
  294. BOOL fThisIsACallback;
  295. BOOL fDisableNetbt;
  296. PPP_CONFIG_INFO PppConfigInfo;
  297. CHAR * pszUserName;
  298. CHAR * pszPortName;
  299. HCONN hConnection;
  300. HANDLE hInterface;
  301. ROUTER_INTERFACE_TYPE IfType;
  302. RAS_AUTH_ATTRIBUTE * pAttributes;
  303. } PPPCP_INIT, *PPPPCP_INIT;
  304. //
  305. // This structure is passed by the engine to the CP via RasCpGetInfo call.
  306. // The Cp will fill up this structure.
  307. //
  308. typedef struct _PPPCP_INFO
  309. {
  310. DWORD Protocol; // Protocol number for this CP
  311. CHAR SzProtocolName[10]; // The name of this protocol
  312. // All Config codes upto (not including) this value are valid.
  313. DWORD Recognize;
  314. // Called to initialize/uninitialize this CP. In the former case,
  315. // fInitialize will be TRUE; in the latter case, it will be FALSE.
  316. // Even if RasCpInit(TRUE) returns FALSE, RasCpInit(FALSE) will be called.
  317. DWORD (*RasCpInit)( IN BOOL fInitialize );
  318. // Called to get the workbuffer for this CP and pass info if requred.
  319. // This will be called before any negotiation takes place.
  320. DWORD (*RasCpBegin)( OUT VOID ** ppWorkBuffer,
  321. IN VOID * pInfo );
  322. // Called to free the workbuffer for this CP. Called after negotiation
  323. // is completed successfully or not.
  324. DWORD (*RasCpEnd)( IN VOID * pWorkBuffer );
  325. // Called to notify the CP dll to (re)initiaize its option values.
  326. // This will be called at least once, right after RasCpBegin
  327. DWORD (*RasCpReset)( IN VOID * pWorkBuffer );
  328. // When leaving Initial or Stopped states. May be NULL.
  329. DWORD (*RasCpThisLayerStarted)(
  330. IN VOID * pWorkBuffer );
  331. // When entering Closed or Stopped states. May be NULL
  332. DWORD (*RasCpThisLayerFinished)(
  333. IN VOID * pWorkBuffer );
  334. // When entering the Opened state. May be NULL.
  335. DWORD (*RasCpThisLayerUp)(
  336. IN VOID * pWorkBuffer );
  337. // When leaving the Opened state. May be NULL.
  338. DWORD (*RasCpThisLayerDown)(
  339. IN VOID * pWorkBuffer );
  340. // Just before the line goes down. May be NULL.
  341. DWORD (*RasCpPreDisconnectCleanup)(
  342. IN VOID * pWorkBuffer );
  343. // Called to make a configure request.
  344. DWORD (*RasCpMakeConfigRequest)(
  345. IN VOID * pWorkBuffer,
  346. OUT PPP_CONFIG* pRequestBufffer,
  347. IN DWORD cbRequestBuffer );
  348. // Called when configure request is received and a result packet
  349. // Ack/Nak/Reject needs to be sent
  350. DWORD (*RasCpMakeConfigResult)(
  351. IN VOID * pWorkBuffer,
  352. IN PPP_CONFIG * pReceiveBufffer,
  353. OUT PPP_CONFIG * pResultBufffer,
  354. IN DWORD cbResultBuffer,
  355. IN BOOL fRejectNaks );
  356. // Called to process an Ack that was received.
  357. DWORD (*RasCpConfigAckReceived)(
  358. IN VOID * pWorkBuffer,
  359. IN PPP_CONFIG * pReceiveBuffer );
  360. // Called to process a Nak that was received.
  361. DWORD (*RasCpConfigNakReceived)(
  362. IN VOID * pWorkBuffer,
  363. IN PPP_CONFIG * pReceiveBuffer );
  364. // Called to process a Rej that was received.
  365. DWORD (*RasCpConfigRejReceived)(
  366. IN VOID * pWorkBuffer,
  367. IN PPP_CONFIG * pReceiveBuffer );
  368. // Called to get the network address from configured protocols.
  369. DWORD (*RasCpGetNegotiatedInfo)(
  370. IN VOID * pWorkBuffer,
  371. OUT VOID * pInfo );
  372. // Called after all CPs have completed their negotiation, successfully or
  373. // not, to notify each CP of the projection result. May be NULL.
  374. // To access information, cast pProjectionInfo to PPP_PROJECTION_RESULT*
  375. DWORD (*RasCpProjectionNotification)(
  376. IN VOID * pWorkBuffer,
  377. IN PVOID pProjectionResult );
  378. DWORD (*RasCpChangeNotification)( VOID );
  379. //
  380. // This entry point only applies to Authentication protocols.
  381. // MUST BE NULL FOR CONTROL PROTOCOLS.
  382. DWORD (*RasApMakeMessage)(
  383. IN VOID* pWorkBuf,
  384. IN PPP_CONFIG* pReceiveBuf,
  385. OUT PPP_CONFIG* pSendBuf,
  386. IN DWORD cbSendBuf,
  387. OUT PPPAP_RESULT* pResult,
  388. IN PPPAP_INPUT* pInput );
  389. } PPPCP_INFO, *PPPPCP_INFO;
  390. #define PPPCP_FLAG_INIT_CALLED 0x00000001 // RasCpInit has been called
  391. #define PPPCP_FLAG_AVAILABLE 0x00000002 // The protocol can be used
  392. //
  393. // The information that PPP needs to keep about each CP.
  394. //
  395. typedef struct _PPPCP_ENTRY
  396. {
  397. PPPCP_INFO CpInfo;
  398. DWORD fFlags;
  399. } PPPCP_ENTRY;
  400. //
  401. // Used to get result from NBFCP via the RasCpGetResult call
  402. //
  403. typedef struct _PPPCP_NBFCP_RESULT
  404. {
  405. DWORD dwNetBiosError;
  406. CHAR szName[ NETBIOS_NAME_LEN + 1 ];
  407. } PPPCP_NBFCP_RESULT;
  408. //
  409. // Function prototypes.
  410. //
  411. DWORD APIENTRY
  412. RasCpGetInfo(
  413. IN DWORD dwProtocolId,
  414. OUT PPPCP_INFO* pCpInfo
  415. );
  416. DWORD APIENTRY
  417. RasCpEnumProtocolIds(
  418. OUT DWORD * pdwProtocolIds,
  419. IN OUT DWORD * pcProtocolIds
  420. );
  421. #endif