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.

152 lines
3.9 KiB

  1. /* Copyright (c) 1993, Microsoft Corporation, all rights reserved
  2. **
  3. ** raspap.h
  4. ** Remote Access PPP Password Authentication Protocol
  5. **
  6. ** 11/05/93 Steve Cobb
  7. */
  8. #ifndef _RASPAP_H_
  9. #define _RASPAP_H_
  10. //General macros
  11. #define GEN_RAND_ENCODE_SEED ((CHAR) ( 1 + rand() % 250 ))
  12. /* PAP packet codes from PAP spec.
  13. */
  14. #define PAPCODE_Req 1
  15. #define PAPCODE_Ack 2
  16. #define PAPCODE_Nak 3
  17. #define MAXPAPCODE 3
  18. /* Returned by receive buffer parsing routines that discover the packet is
  19. ** corrupt, usually because the length fields don't make sense.
  20. */
  21. #define ERRORBADPACKET (DWORD )-1
  22. /* Defines states within the PAP protocol.
  23. */
  24. #define PAPSTATE enum tagPAPSTATE
  25. PAPSTATE
  26. {
  27. PS_Initial,
  28. PS_RequestSent,
  29. PS_WaitForRequest,
  30. PS_WaitForAuthenticationToComplete,
  31. PS_Done
  32. };
  33. /* Defines the WorkBuf stored for us by the PPP engine.
  34. */
  35. #define PAPWB struct tagPAPWB
  36. PAPWB
  37. {
  38. /* True if role is server, false if client.
  39. */
  40. BOOL fServer;
  41. /* The domain\username and password (applies to client only).
  42. */
  43. CHAR szAccount[ DNLEN + 1 + UNLEN + 1 ];
  44. CHAR szPassword[ PWLEN ];
  45. /* The current state in the PAP protocol.
  46. */
  47. PAPSTATE state;
  48. /* Last sequencing ID sent on this port. Incremented for each
  49. ** Authenticate-Req packet sent. Client side only.
  50. */
  51. BYTE bIdSent;
  52. HPORT hPort;
  53. /* Id of the last Authenticate-Req packet received on this port.
  54. ** Server side only.
  55. */
  56. BYTE bLastIdReceived;
  57. //
  58. // Used to get information to send to back-end server.
  59. //
  60. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  61. /* The final result, used to duplicate the original response for all
  62. ** subsequent Authenticate-Req packets. This is per PAP spec to cover
  63. ** lost Ack/Nak case without allowing malicious client to discover
  64. ** alternative identities under the covers during a connection. (applies
  65. ** to server only)
  66. */
  67. PPPAP_RESULT result;
  68. CHAR chSeed; //Used to encode password. Strange. We
  69. //send password cleartext on the line
  70. //and encode it in the program...
  71. };
  72. /* Prototypes.
  73. */
  74. DWORD CheckCredentials( CHAR*, CHAR*, CHAR*, DWORD*, BOOL*, CHAR*,
  75. BYTE*, CHAR*, HANDLE* );
  76. DWORD PapCMakeMessage( PAPWB*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_RESULT* );
  77. DWORD GetCredentialsFromRequest( PPP_CONFIG*, CHAR*, CHAR* );
  78. DWORD GetErrorFromNak( PPP_CONFIG* );
  79. VOID PapMakeRequestMessage( PAPWB*, PPP_CONFIG*, DWORD );
  80. VOID PapMakeResultMessage( DWORD, BYTE, PPP_CONFIG*, DWORD, RAS_AUTH_ATTRIBUTE* );
  81. DWORD PapBegin( VOID**, VOID* );
  82. DWORD PapEnd( VOID* );
  83. DWORD PapMakeMessage( VOID*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_RESULT*,
  84. PPPAP_INPUT* pInput );
  85. VOID PapExtractMessage(PPP_CONFIG*, PPPAP_RESULT*);
  86. DWORD PapSMakeMessage( PAPWB*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_INPUT* pInput, PPPAP_RESULT* );
  87. /* Globals.
  88. */
  89. #ifdef RASPAPGLOBALS
  90. #define GLOBALS
  91. #define EXTERN
  92. #else
  93. #define EXTERN extern
  94. #endif
  95. /* Next packet identifier to assign. Unlike CPs, APs must handle updating
  96. ** this sequence number themselves because the engine can't make as many
  97. ** assumptions about the protocol. It is stored global to all ports and
  98. ** authentication sessions to make it less likely that an ID will be used in
  99. ** sequential authentication sessions. Not to be confused with the 'bIdSent'
  100. ** updated on a per-port basis and used for matching.
  101. */
  102. EXTERN BYTE BNextIdPap
  103. #ifdef GLOBALS
  104. = 0
  105. #endif
  106. ;
  107. /* This value indicates whether or not to follow strict sequencing as defined
  108. ** in the PPP RFC for PAP. The RFC says that the PAP client MUST increase the
  109. ** sequence number for every new CONFIG_REQ packet sent out. However this
  110. ** causes problems with slow servers. See bug # 22508. Default is FALSE.
  111. */
  112. EXTERN BOOL fFollowStrictSequencing
  113. #ifdef GLOBALS
  114. = FALSE
  115. #endif
  116. ;
  117. EXTERN
  118. DWORD g_dwTraceIdPap
  119. #ifdef GLOBALS
  120. = INVALID_TRACEID;
  121. #endif
  122. ;
  123. #undef EXTERN
  124. #undef GLOBALS
  125. #endif // _RASPAP_H_