home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / RASEAPIF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  13.4 KB  |  411 lines

  1. /********************************************************************/
  2. /**               Copyright(c) 1989 Microsoft Corporation.           **/
  3. /********************************************************************/
  4.  
  5. //***
  6. //
  7. // Filename:    raseapif.h
  8. //
  9. // Description: Defines interface between a third party authentication module
  10. //              and the Remote Access Service PPP engine.
  11. //
  12.  
  13. #ifndef _RASEAPIF_
  14. #pragma option push -b -a8 -pc -A- /*P_O_Push_S*/
  15. #define _RASEAPIF_
  16.  
  17. #include <lmcons.h>     // For UNLEN definition
  18.  
  19. //
  20. // Defines used for installtion of EAP DLL
  21. //
  22. // Custom EAP DLL (ex. Name=Sample.dll, Type=40) regsitry installation
  23. //
  24. // HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\PPP\EAP\40)
  25. //      Path                (REG_EXPAND_SZ) %SystemRoot%\system32\sample.dll  
  26. //      FriendlyName        (REG_SZ) Sample EAP Protocol
  27. //      ConfigUIPath        (REG_EXPAND_SZ) %SystemRoot%\system32\sample.dll  
  28. //      InteractiveUIPath   (REG_EXPAND_SZ) %SystemRoot%\system32\sample.dll  
  29. //      RequireConfigUI     (REG_DWORD) 1
  30. //
  31. //
  32.  
  33. #define RAS_EAP_REGISTRY_LOCATION   \
  34.     TEXT("System\\CurrentControlSet\\Services\\Rasman\\PPP\\EAP")
  35.  
  36. #define RAS_EAP_VALUENAME_PATH              TEXT("Path")   
  37. #define RAS_EAP_VALUENAME_CONFIGUI          TEXT("ConfigUIPath")
  38. #define RAS_EAP_VALUENAME_INTERACTIVEUI     TEXT("InteractiveUIPath")
  39. #define RAS_EAP_VALUENAME_FRIENDLY_NAME     TEXT("FriendlyName")
  40. #define RAS_EAP_VALUENAME_DEFAULT_DATA      TEXT("ConfigData")
  41. #define RAS_EAP_VALUENAME_DEFAULT_IDENTITY  TEXT("Identity")
  42. #define RAS_EAP_VALUENAME_REQUIRE_CONFIGUI  TEXT("RequireConfigUI")
  43. #define RAS_EAP_VALUENAME_INVOKE_STDUI   TEXT("InvokeStandardCredentialsDialog")
  44.  
  45. //
  46. // EAP packet codes from EAP spec.
  47. //
  48.  
  49. #define EAPCODE_Request         1
  50. #define EAPCODE_Response        2
  51. #define EAPCODE_Success         3
  52. #define EAPCODE_Failure         4
  53.  
  54. #define MAXEAPCODE              4
  55.  
  56. typedef struct _PPP_EAP_PACKET
  57. {
  58.     BYTE    Code;       // 1-Request, 2-Response, 3-Success, 4-Failure
  59.  
  60.     BYTE    Id;         // Id of this packet
  61.  
  62.     BYTE    Length[2];  // Length of this packet
  63.  
  64.     BYTE    Data[1];    // Data - First byte is Type for Request/Response
  65.  
  66. }PPP_EAP_PACKET, *PPPP_EAP_PACKET;
  67.  
  68. #define PPP_EAP_PACKET_HDR_LEN  ( sizeof( PPP_EAP_PACKET ) - 1 )
  69.  
  70. //
  71. // Interface structure between the engine and APs. This is passed to the
  72. // AP's via the RasCpBegin call. 
  73. //
  74.  
  75. typedef struct _PPP_EAP_INPUT
  76. {
  77.     //
  78.     // Size of this structure
  79.     //
  80.  
  81.     DWORD       dwSizeInBytes;  
  82.  
  83.     //
  84.     // The follwing four fields are valid only in RasEapBegin call
  85.     //
  86.  
  87.     HANDLE      hPort;          // Used to pass to back-end authenticator
  88.  
  89.     BOOL         fAuthenticator;    // Act as authenticator or authenticatee
  90.  
  91.     CHAR *      pszIdentity;    // Users's identity
  92.  
  93.     CHAR *      pszPassword;    // Client's account password.
  94.  
  95.     //
  96.     // Set of attributes for the currently dialed in user, set only on
  97.     // RasEapBegin call for the authenticator side. 
  98.     // Identifies the port used, NAS IP Address etc. May be used to send to
  99.     // the authentication provider, if this protocol is using one.
  100.     //
  101.  
  102.     RAS_AUTH_ATTRIBUTE * pUserAttributes;
  103.  
  104.     //
  105.     // The following fields are used only if the EAP DLL is using the 
  106.     // currently configured authentication provider ex: RADIUS or Windows NT 
  107.     // domain authentication, and the fAuthenticator field above is set to 
  108.     // TRUE.
  109.     //
  110.  
  111.     //
  112.     // This call should be used to make use of the installed back-end
  113.     // authenticator. It is upto the EAP DLL to free the pInAttributes
  114.     // memory. The pInAttributes structure may be freed soon after the
  115.     // call since a copy of this is made.
  116.     //
  117.  
  118.     DWORD  (APIENTRY *RasAuthenticateClient)(
  119.                                 IN  HANDLE                  hPort,
  120.                                 IN  RAS_AUTH_ATTRIBUTE *    pInAttributes );
  121.  
  122.     //
  123.     // Indicates that the authenticator has completed the previous call to
  124.     // RasAuthenticateClient. Ignore this field if an authentication provider
  125.     // is not being used.
  126.     //
  127.  
  128.     BOOL                fAuthenticationComplete;    
  129.  
  130.     //
  131.     // Used to indicate an error that did not allow the authentication process
  132.     // to complete successfully. NO_ERROR means the dwAuthResultCode field 
  133.     // below is valid. This field is valid only when the field above is TRUE.
  134.     //
  135.  
  136.     DWORD               dwAuthError;
  137.  
  138.     //
  139.     // Result of the authentication process by the authentication provider. 
  140.     // NO_ERROR indicates success, 
  141.     // otherwise is a value from winerror.h, raserror.h or mprerror.h 
  142.     // indicating failure reason. Valid only when the field above is NO_ERROR.
  143.     //
  144.  
  145.     DWORD               dwAuthResultCode;  
  146.  
  147.     //
  148.     // When the fAuthenticationComplete flag is TRUE this will point to 
  149.     // attributes returned by the authentication provider, if the 
  150.     // authentication was successful. ie. dwAuthResultCode and dwAuthError are 
  151.     // both NO_ERROR. This memory is not owned by the EAP DLL and it should 
  152.     // only used for read.
  153.     //
  154.  
  155.     OPTIONAL RAS_AUTH_ATTRIBUTE * pAttributesFromAuthenticator;
  156.  
  157.     //
  158.     // Valid only on the authenticatee side. This may be used on the 
  159.     // authenticatee side to impersonate the user being authenticated.
  160.     //
  161.  
  162.     HANDLE              hTokenImpersonateUser;
  163.  
  164.     //
  165.     // This variable should be examined only by the authenticatee side.
  166.     // The EAP specification states that the success packet may be lost and 
  167.     // since it is a non-acknowledged packet, reception of an NCP packet should
  168.     // be interpreted as a success packet. This varable is set to TRUE in this
  169.     // case only on the authenticatee side
  170.     //
  171.  
  172.     DWORD               fSuccessPacketReceived;
  173.  
  174.     //
  175.     // Will be set to TRUE only when the user dismissed the interactive
  176.     // UI that was invoked by the EAP dll
  177.     //
  178.  
  179.     DWORD               fDataReceivedFromInteractiveUI;
  180.  
  181.     //
  182.     // Data received from the Interactive UI. Will be set to non-NULL when
  183.     // fDataFromInteractiveUI is set to TRUE and the RasEapInvokeInteractiveUI
  184.     // returned non-NULL data. This buffer will be freed by the PPP engine
  185.     // on return from the RasEapMakeMessage call. A copy of this data should
  186.     // be made in the EAP Dll's memory space.
  187.     //
  188.  
  189.     OPTIONAL PBYTE      pDataFromInteractiveUI;
  190.  
  191.     //
  192.     // Size in bytes of data pointed to by pDataFromInteractiveUI. This may
  193.     // be 0 if there was no data passed back by the RasEapInvokeInteractiveUI
  194.     // call.
  195.     //
  196.  
  197.     DWORD               dwSizeOfDataFromInteractiveUI;
  198.  
  199.     //
  200.     // Data received from the Config UI. Will be set to non-NULL when
  201.     // fDataFromConfigUI is set to TRUE and the RasEapInvokeConfigUI
  202.     // returned non-NULL data. This buffer will be freed by the PPP engine
  203.     // on return from the RasEapMakeMessage call. A copy of this data should
  204.     // be made in the EAP Dll's memory space.
  205.     //
  206.  
  207.     OPTIONAL PBYTE      pDataFromConfigUI;
  208.  
  209.     //
  210.     // Size in bytes of data pointed to by pDataFromConfigUI. This may
  211.     // be 0 if there was no data passed back by the RasEapInvokeConfigUI
  212.     // call.
  213.     //
  214.  
  215.     DWORD               dwSizeOfDataFromConfigUI;
  216.  
  217. }PPP_EAP_INPUT, *PPPP_EAP_INPUT;
  218.  
  219. typedef enum _PPP_EAP_ACTION
  220. {
  221.     //
  222.     // These actions are provided by the EAP DLL as output from the
  223.     // RasEapMakeMessage API.  They tell the PPP engine what action (if any) to
  224.     // take on the EAP DLL's behalf, and eventually inform the engine that the 
  225.     // EAP DLL has finished authentication.
  226.     //
  227.  
  228.     EAPACTION_NoAction,     // Be passive, i.e. listen without timeout (default)
  229.     EAPACTION_Done,         // End auth session, dwAuthResultCode is set 
  230.     EAPACTION_SendAndDone,  // As above but send message without timeout first
  231.     EAPACTION_Send,         // Send message, don't timeout waiting for reply
  232.     EAPACTION_SendWithTimeout, // Send message, timeout if reply not received
  233.     EAPACTION_SendWithTimeoutInteractive // As above, but don't increment 
  234.                                          // retry count
  235.  
  236. }PPP_EAP_ACTION;
  237.  
  238. typedef struct _PPP_EAP_OUTPUT
  239. {
  240.     //
  241.     // Size of this structure
  242.     //
  243.  
  244.     DWORD                   dwSizeInBytes;  
  245.  
  246.     //
  247.     // Action that the PPP engine should take
  248.     //
  249.  
  250.     PPP_EAP_ACTION          Action;
  251.  
  252.     //
  253.     // MUST be set only if Action is EAPCTION_SendWithTimeout or
  254.     // EAPACTION_SendWithTimeoutInteractive. This value indicates to PPP engine
  255.     // to drop any responses with IDs that do not match this one.
  256.     //
  257.  
  258.     DWORD                   dwIdExpected;
  259.  
  260.     //
  261.     // dwAuthResultCode is valid only with an Action code of Done or 
  262.     // SendAndDone. Zero value indicates succesful authentication.  
  263.     // Non-zero indicates unsuccessful authentication with the value 
  264.     // indicating the reason for authentication failure.
  265.     // Non-zero return codes should be only from winerror.h, raserror.h and 
  266.     // mprerror.h
  267.     //
  268.  
  269.     DWORD                    dwAuthResultCode;
  270.  
  271.     //
  272.     // Must be set on the Authenticator side when Action is EAPACTION_Done or
  273.     // EAPACTION_SendAndDone. 
  274.     //
  275.  
  276.     CHAR                    szIdentity[UNLEN+1];
  277.  
  278.     //
  279.     // Non-NULL if there are any user attributes for this user. This is 
  280.     // allocated by the EAP DLL only if it is not using the currently configured
  281.     // authentication provider. It is upto the EAP DLL to free this memory in
  282.     // RasEapEnd call. Should only be set on the Authenticator side when 
  283.     // Action is EAPACTION_Done or EAPACTION_SendAndDone and if 
  284.     // dwAuthResultCode is 0. 
  285.     //
  286.  
  287.     OPTIONAL RAS_AUTH_ATTRIBUTE * pAuthenticatedUserAttributes;   
  288.  
  289.     //
  290.     // Flag set to true will cause the RasEapInvokeInteractiveUI call to be
  291.     // made.
  292.     //
  293.  
  294.     BOOL                    fInvokeInteractiveUI;
  295.  
  296.     //
  297.     // Pointer to context data, if any, to be sent to the UI. The EAP dll
  298.     // is responsible for freeing this buffer in the RasEapEnd call or when
  299.     // a response from the user for this invocation is obtained. 
  300.     //
  301.  
  302.     OPTIONAL PBYTE          pUIContextData;
  303.  
  304.     //
  305.     // Size in bytes of the data pointed to by pUIContextData. Ignored if 
  306.     // pUIContextData is NULL
  307.     //
  308.  
  309.     DWORD                   dwSizeOfUIContextData;
  310.     
  311.  
  312. }PPP_EAP_OUTPUT, *PPPP_EAP_OUTPUT;
  313.  
  314. typedef struct _PPP_EAP_INFO
  315. {
  316.     //
  317.     // Size of this structure
  318.     //
  319.  
  320.     DWORD   dwSizeInBytes;  
  321.  
  322.     DWORD   dwEapTypeId;
  323.  
  324.     //
  325.     // Called to get a context buffer for this EAP session and pass 
  326.     // initialization  information. This will be called before any other 
  327.     // call is made. Must return errorcodes only from winerror.h, raserror.h or
  328.     // mprerror.h
  329.     //
  330.  
  331.     DWORD   (APIENTRY *RasEapBegin)( OUT VOID **             ppWorkBuffer,
  332.                                      IN  PPP_EAP_INPUT *     pPppEapInput );
  333.  
  334.     //
  335.     // Called to free the context buffer for this EAP session. 
  336.     // Called after this session is completed successfully or not.
  337.     // Must return errorcodes only from winerror.h, raserror.h or mprerror.h
  338.     //
  339.  
  340.     DWORD   (APIENTRY *RasEapEnd)(   IN  VOID *     pWorkBuffer );
  341.  
  342.     //
  343.     // Called to process an incomming packet and/or send a packet.
  344.     // cbSendPacket is the size in bytes of the buffer pointed to by 
  345.     // pSendPacket. Must return errorcodes only from winerror.h, raserror.h or
  346.     // mprerror.h. Error return code indicates an error occurance during the
  347.     // authentication process.
  348.     //
  349.  
  350.     DWORD   (APIENTRY *RasEapMakeMessage)(
  351.                             IN  VOID*               pWorkBuf,
  352.                             IN  PPP_EAP_PACKET*     pReceivePacket,
  353.                             OUT PPP_EAP_PACKET*     pSendPacket,
  354.                             IN  DWORD               cbSendPacket,
  355.                             OUT PPP_EAP_OUTPUT*     pEapOutput,
  356.                             IN  PPP_EAP_INPUT*      pEapInput );
  357.  
  358. }PPP_EAP_INFO, *PPPP_EAP_INFO;
  359.  
  360. //
  361. // RasEapGetInfo should be exported by the 3rd party EAP dll installed in the
  362. // registry via the Path value.
  363. //
  364.  
  365. DWORD APIENTRY
  366. RasEapGetInfo(
  367.     IN  DWORD           dwEapTypeId,
  368.     OUT PPP_EAP_INFO*   pEapInfo
  369. );
  370.  
  371. //
  372. // RasEapInvokeInteractiveUI and RasEapFreeUserData should be exported by the 
  373. // 3rd party EAP dll installed in the registry via the InterfactiveUI value.
  374. //
  375.  
  376. DWORD APIENTRY 
  377. RasEapInvokeInteractiveUI(
  378.     IN  HWND            hwndParent,
  379.     IN  PBYTE           pUIContextData,
  380.     IN  DWORD           dwSizeofUIContextData,
  381.     OUT PBYTE *         ppUserData              OPTIONAL,
  382.     OUT DWORD *         lpdwSizeOfUserData
  383. );
  384.  
  385. DWORD APIENTRY 
  386. RasEapFreeUserData(
  387.     IN  PBYTE           pUserData
  388. );
  389.  
  390. //
  391. // RasEapInvokeConfigUI and RasEapFreeConfigData should be exported by the 
  392. // 3rd party EAP dll installed in the registry via the ConfigUI value.
  393. //
  394.  
  395. DWORD APIENTRY 
  396. RasEapInvokeConfigUI(
  397.     IN  HWND            hwndParent,
  398.     OUT BYTE *          pConfigData,
  399.     OUT DWORD *         lpdwSizeOfConfigData,
  400.     OUT BOOL  *         fInvokeStandardCredentialsDialog,
  401.     OUT LPSTR           szIdentity              OPTIONAL    
  402. );
  403.  
  404. DWORD APIENTRY 
  405. RasEapFreeConfigData(
  406.     IN  PBYTE           pConfigData
  407. );
  408.  
  409. #pragma option pop /*P_O_Pop*/
  410. #endif
  411.