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.

1154 lines
35 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: ppp.h
  7. //
  8. // Description: Contains structures and constants used by the PPP engine.
  9. //
  10. // History:
  11. // Nov 11,1993. NarenG Created original version.
  12. // Jan 9,1995 RamC Added hToken to the PCB structure to store
  13. // the LSA token. This will be closed in the
  14. // ProcessLineDownWorker() routine to release
  15. // the RAS license.
  16. //
  17. // Schematic of PPP Data Structures
  18. // ================================
  19. //
  20. // |---------|
  21. // | PCB | |-------|
  22. // | | |CPTable|
  23. // | BCB* |--------------->|-------| | |
  24. // |---------| | BCB | |-------|
  25. // | LCP CB | | | | LCP |
  26. // |---------| |-------| |-------|
  27. // | AP |(Authenticator) | NCP1CB| | NCP1 |
  28. // |---------| |-------| |-------|
  29. // | AP |(Authenticatee) | NCP2CB| | NCP2 |
  30. // |---------| |-------| |-------|
  31. // | LCP CB | | etc,..| |etc,.. |
  32. // |---------| |-------| |-------|
  33. // | AP1 |
  34. // |-------|
  35. // | AP2 |
  36. // |-------|
  37. // | etc,..|
  38. // |-------|
  39. //
  40. //
  41. #ifndef _PPP_
  42. #define _PPP_
  43. #include <rasauth.h>
  44. #include <rasppp.h>
  45. #include <wincrypt.h>
  46. #define RAS_KEYPATH_PPP \
  47. "SYSTEM\\CurrentControlSet\\Services\\RasMan\\ppp"
  48. #define RAS_KEYPATH_PROTOCOLS \
  49. "SYSTEM\\CurrentControlSet\\Services\\RasMan\\ppp\\ControlProtocols"
  50. #define RAS_KEYPATH_REMOTEACCESS \
  51. "SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Parameters"
  52. #define RAS_KEYPATH_EAP \
  53. "SYSTEM\\CurrentControlSet\\Services\\RasMan\\ppp\\Eap"
  54. #define RAS_KEYPATH_BUILTIN \
  55. "SYSTEM\\CurrentControlSet\\Services\\RasMan\\ppp\\ControlProtocols\\BuiltIn"
  56. #define RAS_VALUENAME_PATH "Path"
  57. #define RAS_VALUENAME_MAXTERMINATE "MaxTerminate"
  58. #define RAS_VALUENAME_MAXCONFIGURE "MaxConfigure"
  59. #define RAS_VALUENAME_MAXFAILURE "MaxFailure"
  60. #define RAS_VALUENAME_MAXREJECT "MaxReject"
  61. #define RAS_VALUENAME_RESTARTTIMER "RestartTimer"
  62. #define RAS_VALUENAME_NEGOTIATETIME "NegotiateTime"
  63. #define RAS_VALUENAME_CALLBACKDELAY "DefaultCallbackDelay"
  64. #define RAS_VALUENAME_PORTLIMIT "DefaultPortLimit"
  65. #define RAS_VALUENAME_SESSIONTIMEOUT "DefaultSessionTimeout"
  66. #define RAS_VALUENAME_IDLETIMEOUT "DefaultIdleTimeout"
  67. #define RAS_VALUENAME_BAPTHRESHOLD "LowerBandwidthThreshold"
  68. #define RAS_VALUENAME_BAPTIME "TimeBelowTheshold"
  69. #define RAS_VALUENAME_BAPLISTENTIME "BapListenTimeout"
  70. #define RAS_DONTNEGOTIATE_MULTILINKONSINGLELINK "DontNegotiateMultiLinkOnSingleLink"
  71. #define RAS_VALUENAME_UNKNOWNPACKETTRACESIZE "UnknownPacketTraceSize"
  72. #define RAS_ECHO_REQUEST_INTERVAL "EchoRequestInterval" //Interval between echo requests
  73. #define RAS_ECHO_REQUEST_IDLE "IdleTimeBeforeEcho" //Idle time before the echo request starts
  74. #define RAS_ECHO_NUM_MISSED_ECHOS "MissedEchosBeforeDisconnect" //Number of missed echos before disconnect.
  75. #define RAS_VALUENAME_DOBAPONVPN "DoBapOnVpn"
  76. #define RAS_VALUENAME_PARSEDLLPATH "ParseDllPath"
  77. #define MS_RAS_WITH_MESSENGER "MSRAS-1-"
  78. #define MS_RAS_WITHOUT_MESSENGER "MSRAS-0-"
  79. #define MS_RAS "MSRAS"
  80. #define MS_RAS_VERSION "MSRASV5.20"
  81. #define PPP_DEF_MAXTERMINATE 2
  82. #define PPP_DEF_MAXCONFIGURE 10
  83. #define PPP_DEF_MAXFAILURE 5
  84. #define PPP_DEF_MAXREJECT 5
  85. #define PPP_DEF_RESTARTTIMER 3
  86. #define PPP_DEF_AUTODISCONNECTTIME 20
  87. #define PPP_DEF_NEGOTIATETIME 150
  88. #define PPP_DEF_CALLBACKDELAY 12
  89. #define PPP_DEF_PORTLIMIT 0xFFFFFFFF
  90. #define PPP_DEF_SESSIONTIMEOUT 0
  91. #define PPP_DEF_IDLETIMEOUT 0
  92. #define PPP_DEF_BAPLISTENTIME 45
  93. #define PPP_DEF_UNKNOWNPACKETTRACESIZE 64
  94. #define PPP_DEF_ECHO_TEXT "94ae90cc3531"
  95. #define PPP_DEF_ECHO_REQUEST_INTERVAL 60
  96. #define PPP_DEF_ECHO_REQUEST_IDLE 300
  97. #define PPP_DEF_ECHO_NUM_MISSED_ECHOS 3
  98. //
  99. // IMPORTANT: Make sure that if you change PPP_NUM_USER_ATTRIBUTES
  100. // you also change PPP_NUM_ACCOUNTING_ATTRIBUTES. PPP_NUM_ACCOUNTING_ATTRIBUTES
  101. // definition should really be changed to _USER_ATTRIBUTES+n.
  102. //
  103. #define PPP_NUM_ACCOUNTING_ATTRIBUTES 43
  104. #define PPP_NUM_USER_ATTRIBUTES 21
  105. //
  106. // Note that the size of the BAP Phone-Delta option <= 0xFF
  107. //
  108. #define BAP_PHONE_DELTA_SIZE 0xFF
  109. #define PPP_HEAP_INITIAL_SIZE 20000 // approx 20K
  110. #define PPP_HEAP_MAX_SIZE 0 // Grow heap as required
  111. //
  112. // Debug trace component values
  113. //
  114. #define TRACE_LEVEL_1 (0x00010000|TRACE_USE_MASK|TRACE_USE_MSEC)
  115. #define TRACE_LEVEL_2 (0x00020000|TRACE_USE_MASK|TRACE_USE_MSEC)
  116. //
  117. // Event Logging macros
  118. //
  119. #define PppLogWarning( LogId, NumStrings, lpwsSubStringArray ) \
  120. if ( PppConfigInfo.dwLoggingLevel > 1 ) { \
  121. RouterLogWarning( PppConfigInfo.hLogEvents, LogId, \
  122. NumStrings, lpwsSubStringArray, 0 ); }
  123. #define PppLogError( LogId, NumStrings, lpwsSubStringArray, dwRetCode ) \
  124. if ( PppConfigInfo.dwLoggingLevel > 0 ) { \
  125. RouterLogError( PppConfigInfo.hLogEvents, LogId, \
  126. NumStrings, lpwsSubStringArray, dwRetCode ); }
  127. #define PppLogErrorString(LogId,NumStrings,lpwsSubStringArray,dwRetCode,dwPos ) \
  128. if ( PppConfigInfo.dwLoggingLevel > 0 ) { \
  129. RouterLogErrorString( PppConfigInfo.hLogEvents, LogId, NumStrings, \
  130. lpwsSubStringArray, dwRetCode, dwPos ); }
  131. #define PppLogInformation( LogId, NumStrings, lpwsSubStringArray ) \
  132. if ( PppConfigInfo.dwLoggingLevel > 2 ) { \
  133. RouterLogInformation( PppConfigInfo.hLogEvents, \
  134. LogId, NumStrings, lpwsSubStringArray, 0 ); }
  135. //General macros
  136. #define GEN_RAND_ENCODE_SEED ((CHAR) ( 1 + rand() % 250 ))
  137. //
  138. // PPP packet header
  139. //
  140. typedef struct _PPP_PACKET
  141. {
  142. BYTE Protocol[2]; // Protocol Number
  143. BYTE Information[1]; // Data
  144. } PPP_PACKET, *PPPP_PACKET;
  145. #define PPP_PACKET_HDR_LEN ( sizeof( PPP_PACKET ) - 1 )
  146. //
  147. // PPP Link phases
  148. //
  149. typedef enum PPP_PHASE
  150. {
  151. PPP_LCP,
  152. PPP_AP,
  153. PPP_NEGOTIATING_CALLBACK,
  154. PPP_NCP
  155. } PPP_PHASE;
  156. #define LCP_INDEX 0
  157. //
  158. // Different types of timer events that can occur
  159. //
  160. typedef enum TIMER_EVENT_TYPE
  161. {
  162. TIMER_EVENT_TIMEOUT,
  163. TIMER_EVENT_AUTODISCONNECT,
  164. TIMER_EVENT_HANGUP,
  165. TIMER_EVENT_NEGOTIATETIME,
  166. TIMER_EVENT_SESSION_TIMEOUT,
  167. TIMER_EVENT_FAV_PEER_TIMEOUT,
  168. TIMER_EVENT_INTERIM_ACCOUNTING,
  169. TIMER_EVENT_LCP_ECHO
  170. } TIMER_EVENT_TYPE;
  171. //
  172. // FSM states
  173. //
  174. typedef enum FSM_STATE
  175. {
  176. FSM_INITIAL = 0,
  177. FSM_STARTING,
  178. FSM_CLOSED,
  179. FSM_STOPPED,
  180. FSM_CLOSING,
  181. FSM_STOPPING,
  182. FSM_REQ_SENT,
  183. FSM_ACK_RCVD,
  184. FSM_ACK_SENT,
  185. FSM_OPENED
  186. } FSM_STATE;
  187. //
  188. // Phase of PPP connection.
  189. //
  190. typedef enum NCP_PHASE
  191. {
  192. NCP_DEAD,
  193. NCP_CONFIGURING,
  194. NCP_UP,
  195. NCP_DOWN
  196. } NCP_PHASE;
  197. //
  198. // BAP states
  199. //
  200. typedef enum BAP_STATE
  201. {
  202. BAP_STATE_INITIAL,
  203. BAP_STATE_SENT_CALL_REQ,
  204. BAP_STATE_SENT_CALLBACK_REQ,
  205. BAP_STATE_SENT_DROP_REQ,
  206. BAP_STATE_SENT_STATUS_IND,
  207. BAP_STATE_CALLING,
  208. BAP_STATE_LISTENING
  209. } BAP_STATE;
  210. #define BAP_STATE_LIMIT BAP_STATE_LISTENING // Highest number we can handle
  211. //
  212. // List of messages to be collected by the owner of this port
  213. //
  214. typedef struct _CLIENT_MESSAGE
  215. {
  216. struct _CLIENT_MESSAGE * pNext;
  217. PPP_MESSAGE Msg;
  218. } CLIENT_MESSAGE, *PCLIENT_MESSAGE;
  219. //
  220. // Values of the PCB->fFlags field
  221. //
  222. #define PCBFLAG_CAN_BE_BUNDLED 0x00000001 // MultiLink was negotiated
  223. #define PCBFLAG_IS_BUNDLED 0x00000002 // This link is part of a bundle
  224. #define PCBFLAG_IS_SERVER 0x00000004 // Port opened by server
  225. #define PCBFLAG_THIS_IS_A_CALLBACK 0x00000008 // Current call is a callbak
  226. #define PCBFLAG_NEGOTIATE_CALLBACK 0x00000010 // LCP indicates CBCP should run
  227. #define PCBFLAG_DOING_CALLBACK 0x00000020 // Shutting down for callback
  228. #define PCBFLAG_IS_ADVANCED_SERVER 0x00000040
  229. #define PCBFLAG_NCPS_INITIALIZED 0x00000080
  230. #define PCBFLAG_PORT_IN_LISTENING_STATE \
  231. 0x00000100 // We have done a RasPortOpen
  232. // on this port. We need to
  233. // do a RasPortClose finally.
  234. #define PCBFLAG_MPPE_KEYS_SET 0x00000200
  235. #define PCBFLAG_CONNECTION_LOGGED 0x00000400
  236. #define PCBFLAG_NON_INTERACTIVE 0x00000800 // We cannot display any UI
  237. #define PCBFLAG_INTERIM_ACCT_SENT 0x00001000 // Interim accounting packet sent
  238. #define PCBFLAG_SERVICE_UNAVAILABLE 0x00002000 // Acct-Terminate-Cause is
  239. // Service Unavailable
  240. #define PCBFLAG_ACCOUNTING_STARTED 0x00004000 // Accounting has been started
  241. #define PCBFLAG_STOPPED_MSG_SENT 0x00008000 // PPPMSG_Stopped has been sent
  242. // to rasman
  243. #define PCBFLAG_DISABLE_NETBT 0x00010000
  244. #define PCBFLAG_RECVD_TERM_REQ 0x00020000
  245. #define PCBFLAG_QUARANTINE_TIMEOUT 0x00040000 // indicates that the session timeout
  246. // is happening because of quaratine
  247. //
  248. // Values of the BCB->fFlags field
  249. //
  250. #define BCBFLAG_CAN_DO_BAP 0x00000001 // We can do BAP/BACP
  251. #define BCBFLAG_CAN_CALL 0x00000002 // We can call out
  252. #define BCBFLAG_CAN_ACCEPT_CALLS 0x00000004 // We can accept calls
  253. #define BCBFLAG_PEER_CANT_CALL 0x00000008 // Peer rejects Callback-Requests
  254. #define BCBFLAG_PEER_CANT_ACCEPT_CALLS 0x00000010 // Peer rejects Call-Requests
  255. #define BCBFLAG_BAP_REQUIRED 0x00000020 // BAP is required
  256. #define BCBFLAG_LOGON_USER_DATA 0x00000040 // The pCustomAuthUserData has
  257. // come from Winlogon
  258. #define BCBFLAG_WKSTA_IN 0x00000080 // Incoming call on workstation
  259. #define BCBFLAG_LISTENING 0x00000100 // Temporary hack till Rao
  260. // provides RasPortCancelListen
  261. #define BCBFLAG_IS_SERVER 0x00000200 // Port opened by server
  262. #define BCBFLAG_IPCP_VJ_NEGOTIATED 0x00000400 // IPCP VJ negotiated
  263. #define BCBFLAG_BASIC_ENCRYPTION 0x00000800 // 40-bit RC4/DES
  264. #define BCBFLAG_STRONGER_ENCRYPTION 0x00001000 // 56-bit RC4/DES
  265. #define BCBFLAG_STRONGEST_ENCRYPTION 0x00002000 // 128-bit RC4 or 3DES
  266. #define BCBFLAG_QUARANTINE_TIMEOUT 0x00004000 // Indicates that bundle is on q-timeout
  267. //
  268. // This structure is used at initialize time to load all the dlls.
  269. //
  270. typedef struct _DLL_ENTRY_POINTS
  271. {
  272. FARPROC pRasCpEnumProtocolIds;
  273. FARPROC pRasCpGetInfo;
  274. CHAR * pszModuleName;
  275. HINSTANCE hInstance;
  276. } DLL_ENTRY_POINTS, *PDLL_ENTRY_POINTS;
  277. //
  278. // Contains all information pertaining to a control protocol
  279. //
  280. typedef struct _CONTROL_PROTOCOL_CONTROL_BLOCK
  281. {
  282. FSM_STATE State; // State this FSM is in currently
  283. DWORD Protocol; // Protocol (used only for Auth. protocols)
  284. DWORD LastId; // ID of the last REQ sent
  285. PVOID pWorkBuf; // Pointer to work buffer for this CP.
  286. DWORD ConfigRetryCount; // # of retries for Config requests.
  287. DWORD TermRetryCount; // # of retries for Terminate requests.
  288. DWORD NakRetryCount; // # of retries for Nak
  289. DWORD RejRetryCount; // # of retries for Rej before terminating.
  290. DWORD dwError; // Contains error code if NCP failed
  291. BOOL fConfigurable; // Indicates if this protocol may be configured
  292. BOOL fBeginCalled; // RasCpBegin was successfully called.
  293. NCP_PHASE NcpPhase; // NCP_DEAD, NCP_CONFIGURING, NCP_UP, NCP_DOWN
  294. } CPCB, *PCPCB;
  295. //
  296. // Contains all information pertaining to BAP
  297. //
  298. typedef struct _BAP_CONTROL_BLOCK
  299. {
  300. BAP_STATE BapState;
  301. //
  302. // Number of retries for request. Initialized in FSendInitialBapRequest.
  303. //
  304. DWORD dwRetryCount;
  305. //
  306. // Number of links up when the last BAP_PACKET_DROP_REQ was sent. Set in
  307. // BapEventDropLink.
  308. //
  309. DWORD dwLinkCount;
  310. //
  311. // Forcibly drop the link if the peer NAKs. Useful when sending
  312. // BAP_PACKET_DROP_REQ. Set in BapEventDropLink and BapEventRecvDropReq.
  313. //
  314. DWORD fForceDropOnNak;
  315. //
  316. // The ID in the Call-Status-Indication packet should be the same as the one
  317. // in last Call-Request sent or the last Callback-Request received. Set in
  318. // BapEventRecvCallOrCallbackReq[Resp]
  319. //
  320. DWORD dwStatusIndicationId;
  321. //
  322. // If we send a Callback-Request or receive a Call-Request, szPortName will
  323. // contain the port to use for RasPortListen(). Non-Router Clients only.
  324. //
  325. CHAR szPortName[MAX_PORT_NAME + 1];
  326. //
  327. // If we send a Call-Request or receive a Callback-Request, dwSubEntryIndex
  328. // will contain the sub entry for RasDial() and szPeerPhoneNumber will
  329. // contain the phone number to dial (Call-Request case). Clients and Routers
  330. // only.
  331. //
  332. DWORD dwSubEntryIndex;
  333. CHAR szPeerPhoneNumber[RAS_MaxPhoneNumber+1];
  334. //
  335. // If the server receives a Callback-Request, hPort will contain the port on
  336. // which the server will call. Non-Router Servers only.
  337. //
  338. HPORT hPort;
  339. //
  340. // For a client, szServerPhoneNumber is the phone number first dialed. For a
  341. // server, szServerPhoneNumber is the phone number the client first dialed.
  342. // Set in ProcessLineUpWorker.
  343. //
  344. CHAR * szServerPhoneNumber;
  345. //
  346. // For a server, szClientPhoneNumber is the phone number first dialed.
  347. // Allocated in ProcessLineUpWorker, set in FReadPhoneDelta.
  348. //
  349. CHAR * szClientPhoneNumber;
  350. //
  351. // pbPhoneDeltaRemote is allocated by FCallInitial(). At that time
  352. // dwPhoneDeltaRemoteOffset is set to 0. Every time we pluck a Phone-Delta
  353. // from pbPhoneDeltaRemote in FCall(), we increment dwPhoneDeltaRemoteOffset
  354. // to point to the next Phone-Delta. When there are no more Phone-Deltas to
  355. // pluck, we deallocate phPhoneDeltaRemote.
  356. //
  357. BOOL fPeerSuppliedPhoneNumber; // We have to use pbPhoneDeltaRemote
  358. BYTE * pbPhoneDeltaRemote; // The Phone-Delta sent by the peer
  359. DWORD dwPhoneDeltaRemoteOffset; // Offset into pbPhoneDeltaRemote
  360. //
  361. // The following variables hold values of the various BAP Datagram Options.
  362. //
  363. DWORD dwOptions; // The options to send. See BAP_OPTION_*
  364. DWORD dwType; // Type of last BAP REQ packet sent
  365. DWORD dwId; // ID of last BAP REQ packet sent.
  366. // Initialized in AllocateAndInitBcb.
  367. DWORD dwLinkSpeed; // Link-Speed in Link-Type option
  368. DWORD dwLinkType; // Link-Type in Link-Type option
  369. //
  370. // If there are three Phone-Deltas with
  371. //
  372. // Unique-Digits = 4, Subscriber-Number = "1294", Sub-Address = "56",
  373. // Unique-Digits = 0, Subscriber-Number = "", Sub-Address = "",
  374. // Unique-Digits = 3, Subscriber-Number = "703", Sub-Address = "",
  375. //
  376. // pbPhoneDelta will have:
  377. // 4 0 '1' '2' '9' '4' 0 '5' '6' 0 FF 3 0 '7' '0' '3' 0 0 0
  378. //
  379. // 0's separate the Sub-Options. The last 0 inidicates that there are no
  380. // more Phone-Deltas.
  381. //
  382. // Unique-Digits is equal to the size of the Subscriber-Number (we ignore
  383. // additional digits sent by the peer). If Unique-Digits is 0, then we
  384. // represent that Phone-Delta with one byte (0xFF) instead of 0 0 0 because
  385. // the latter is indistinguishable from the termination of the Phone-Deltas.
  386. //
  387. // Phone-Deltas can only occupy the first BAP_PHONE_DELTA_SIZE bytes. The
  388. // last byte must always be 0.
  389. //
  390. BYTE pbPhoneDelta[BAP_PHONE_DELTA_SIZE + 1]; // Phone-Delta option
  391. DWORD dwLinkDiscriminator; // Link-Discriminator option
  392. DWORD dwStatus; // Status in Call-Status option
  393. DWORD dwAction; // Action in Call-Status option
  394. } BAPCB;
  395. struct _PORT_CONTROL_BLOCK;
  396. //
  397. // Multilinked Bundle Control Block
  398. //
  399. typedef struct _BCB
  400. {
  401. struct _BCB * pNext;
  402. struct _PORT_CONTROL_BLOCK** ppPcb; // Array of back pointers to PCBs
  403. DWORD dwLinkCount; // Number of links in the bundle
  404. DWORD dwAcctLinkCount; // The value of raatAcctLinkCount
  405. DWORD dwMaxLinksAllowed; // Max number of links allowed
  406. DWORD dwBundleId; // Used for timeouts.
  407. DWORD UId; // Bundle wide unique Id.
  408. HCONN hConnection; // Connection handle for this bundle.
  409. // This is unique and not recycled.
  410. DWORD dwPpcbArraySize; // Size of the back pointers array
  411. DWORD fFlags; // See BCBFLAG_*
  412. HANDLE hLicense;
  413. HANDLE hTokenImpersonateUser; // Valid for non router clients only
  414. DWORD dwQuarantineSessionTimeout; // In seconds
  415. PRAS_CUSTOM_AUTH_DATA pCustomAuthConnData; // Valid for clients only
  416. PRAS_CUSTOM_AUTH_DATA pCustomAuthUserData; // Valid for clients only
  417. PPP_EAP_UI_DATA EapUIData; // Valid for clients only
  418. PPP_BAPPARAMS BapParams;
  419. BAPCB BapCb;
  420. DWORD nboRemoteAddress;
  421. CHAR * szPhonebookPath; // For clients only
  422. CHAR * szEntryName; // For clients only
  423. CHAR * szTextualSid; // For clients only
  424. CHAR * szReplyMessage;
  425. CHAR * szRemoteIdentity;
  426. // CHAR chSeed; //Seed for encrypting the password
  427. DATA_BLOB DBPassword;
  428. DATA_BLOB DBOldPassword;
  429. CHAR szRemoteUserName[UNLEN+1];
  430. CHAR szRemoteDomain[DNLEN+1];
  431. CHAR szLocalUserName[UNLEN+1];
  432. CHAR szLocalDomain[DNLEN+1];
  433. CHAR szPassword[PWLEN+1];
  434. CHAR szOldPassword[PWLEN+1];
  435. CHAR szComputerName[MAX_COMPUTERNAME_LENGTH +
  436. sizeof( MS_RAS_WITH_MESSENGER ) + 1];//Peer's Name is
  437. //extracted from LCP
  438. //identification message
  439. //and stored here
  440. CHAR szClientVersion[sizeof(MS_RAS_VERSION) + 1]; //Peer's version
  441. //is stored here
  442. PPP_INTERFACE_INFO InterfaceInfo;
  443. CPCB CpCb[1]; // C.P.s for the bundle.
  444. }BCB,*PBCB;
  445. //
  446. // Contains all information regarding a port.
  447. //
  448. typedef struct _PORT_CONTROL_BLOCK
  449. {
  450. struct _PORT_CONTROL_BLOCK * pNext;
  451. BCB * pBcb; // Pointer to the BCB if this port is bundled.
  452. HPORT hPort; // Handle to the RAS PORT
  453. BYTE UId; // Used to get port-wide unique Id.
  454. DWORD RestartTimer; // Seconds to wait before timing out.
  455. PPP_PACKET* pSendBuf; // Pointer to send buffer
  456. PPP_PHASE PppPhase; // Phase the PPP connection process is in.
  457. DWORD dwAuthRetries;
  458. DWORD fFlags;
  459. DWORD dwDeviceType;
  460. DWORD dwPortId; // Used for timeouts on this port
  461. HPORT hportBundleMember;//hPort of port that this port is bundled with
  462. DWORD dwSessionTimeout; // In Seconds
  463. DWORD dwAutoDisconnectTime; // In Seconds
  464. DWORD dwLCPEchoTimeInterval; //Time interval between LCP echos
  465. DWORD dwIdleBeforeEcho; //Idle time before the LCP echo begins
  466. DWORD dwNumMissedEchosBeforeDisconnect; //Num missed echos before disconnect
  467. DWORD fEchoRequestSend; //Flag indicating that echo request is send
  468. //and we are in the wait mode...
  469. DWORD dwNumEchoResponseMissed; //Number of Echo Responses missed...
  470. DWORD fCallbackPrivilege;
  471. DWORD dwOutstandingAuthRequestId;
  472. HCONN hConnection; // Set in BapEventRecvCallOrCallbackResp.
  473. // Used in ProcessRasPortListenEvent.
  474. DWORD dwEapTypeToBeUsed;
  475. DWORD dwClientEapTypeId;
  476. DWORD dwServerEapTypeId;
  477. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  478. RAS_AUTH_ATTRIBUTE * pAuthenticatorAttributes;
  479. RAS_AUTH_ATTRIBUTE * pAuthProtocolAttributes;
  480. RAS_AUTH_ATTRIBUTE * pAccountingAttributes;
  481. PPP_CONFIG_INFO ConfigInfo;
  482. DWORD dwSubEntryIndex; // Valid for clients only
  483. CPCB CallbackCb;
  484. CPCB AuthenticatorCb;
  485. CPCB AuthenticateeCb;
  486. CPCB LcpCb;
  487. ULARGE_INTEGER qwActiveTime;
  488. LUID Luid;
  489. CHAR szCallbackNumber[MAX_PHONE_NUMBER_LEN+1];
  490. CHAR szPortName[MAX_PORT_NAME+1];
  491. DWORD dwAccountingDone; //Flag to signify that accounting is done.
  492. DWORD dwAccountingSessionId; // AccountingSession Id send across in case
  493. // accounting is turned on. Now we need to
  494. // also send it in case of access request
  495. // to correlate access and accounting logs
  496. } PCB, *PPCB;
  497. //
  498. // Bucket containing a linked list of Port Control Blocks.
  499. //
  500. typedef struct _PCB_BUCKET
  501. {
  502. PCB * pPorts; // Pointer to list of ports in this bucket
  503. } PCB_BUCKET, *PPCB_BUCKET;
  504. //
  505. // Bucket containing a linked list of Bundle Control Blocks.
  506. //
  507. typedef struct _BCB_BUCKET
  508. {
  509. BCB * pBundles; // Pointer to list of ports in this bucket
  510. } BCB_BUCKET, *PBCB_BUCKET;
  511. #define MAX_NUMBER_OF_PCB_BUCKETS 61
  512. //
  513. // Array or hash table of buckets of Port Control Blocks and buckets of Bundle
  514. // Control Blocks
  515. //
  516. typedef struct _PCB_TABLE
  517. {
  518. PCB_BUCKET* PcbBuckets; // Array of PCB buckets
  519. BCB_BUCKET* BcbBuckets; // Array of BCB buckets
  520. DWORD NumPcbBuckets; // Number of buckets in the array.
  521. } PCB_TABLE, *PPCB_TABLE;
  522. typedef struct _PPP_AUTH_INFO
  523. {
  524. DWORD dwError;
  525. DWORD dwId;
  526. DWORD dwResultCode;
  527. RAS_AUTH_ATTRIBUTE * pInAttributes;
  528. RAS_AUTH_ATTRIBUTE * pOutAttributes;
  529. } PPP_AUTH_INFO, *PPPP_AUTH_INFO;
  530. //
  531. // BAP call attempt result
  532. //
  533. typedef struct _BAP_CALL_RESULT
  534. {
  535. DWORD dwResult;
  536. HRASCONN hRasConn;
  537. } BAP_CALL_RESULT;
  538. //
  539. // Contains information regarding work to be done by the worker thread.
  540. //
  541. typedef struct _PCB_WORK_ITEM
  542. {
  543. struct _PCB_WORK_ITEM * pNext;
  544. VOID (*Process)( struct _PCB_WORK_ITEM * pPcbWorkItem );
  545. HPORT hPort; // Handle to RAS PORT
  546. HPORT hConnection; // Handle to the connection
  547. HANDLE hEvent; // Handle to stop event
  548. BOOL fServer;
  549. PPP_PACKET* pPacketBuf; // Used to process receives
  550. DWORD PacketLen; // Used to process receives
  551. DWORD dwPortId; // Used to process timeouts
  552. DWORD Id; // Used to process timeouts
  553. DWORD Protocol; // Used to process timeouts
  554. BOOL fAuthenticator; // Used to process timeouts
  555. TIMER_EVENT_TYPE TimerEventType; // Used to process timeouts
  556. union
  557. {
  558. PPP_START Start;
  559. PPPDDM_START DdmStart;
  560. PPP_CALLBACK_DONE CallbackDone;
  561. PPP_CALLBACK Callback;
  562. PPP_CHANGEPW ChangePw;
  563. PPP_RETRY Retry;
  564. PPP_STOP PppStop;
  565. PPP_INTERFACE_INFO InterfaceInfo;
  566. PPP_AUTH_INFO AuthInfo;
  567. PPP_BAP_EVENT BapEvent;
  568. BAP_CALL_RESULT BapCallResult;
  569. PPP_DHCP_INFORM DhcpInform;
  570. PPP_EAP_UI_DATA EapUIData;
  571. PPP_PROTOCOL_EVENT ProtocolEvent;
  572. PPP_IP_ADDRESS_LEASE_EXPIRED
  573. IpAddressLeaseExpired;
  574. PPP_POST_LINE_DOWN PostLineDown;
  575. }
  576. PppMsg;
  577. } PCB_WORK_ITEM, *PPCB_WORK_ITEM;
  578. //
  579. // Linked list of work items
  580. //
  581. typedef struct _PCB_WORK_ITEMQ
  582. {
  583. struct _PCB_WORK_ITEM * pQHead; // Head of work item Q
  584. struct _PCB_WORK_ITEM * pQTail; // Tail of work item Q
  585. CRITICAL_SECTION CriticalSection;// Mutex around this Q
  586. HANDLE hEventNonEmpty; // Indicates if the Q is non-empty
  587. } PCB_WORK_ITEMQ, *PPCB_WORK_ITEMQ;
  588. #define PPPCONFIG_FLAG_WKSTA 0x00000001 // Windows NT workstation
  589. #define PPPCONFIG_FLAG_DIRECT 0x00000002 // Direct incoming call on wksta
  590. #define PPPCONFIG_FLAG_TUNNEL 0x00000004 // Tunnel incoming call on wksta
  591. #define PPPCONFIG_FLAG_DIALUP 0x00000008 // DailUp incoming call on wksta
  592. #define PPPCONFIG_FLAG_RESUME 0x00000010 // if set means machine has resumed from hibernate.
  593. //
  594. // Structure containing PPP configuration data.
  595. //
  596. typedef struct _PPP_CONFIGURATION
  597. {
  598. DWORD NumberOfCPs; // Number of CPs in the PCB, starting from 0
  599. DWORD NumberOfAPs; // Number of APs in the PCB, starting from
  600. // NumberOfCPs + 1
  601. DWORD DefRestartTimer;// Configurable default restart timer.
  602. DWORD fFlags;
  603. //
  604. // Is RADIUS authentication being used?
  605. //
  606. BOOL fRadiusAuthenticationUsed;
  607. //
  608. // # of Terminate requests to send w/o receiving Terminate-Ack, def=2
  609. //
  610. DWORD MaxTerminate;
  611. //
  612. // # of Configure requests to send w/o receiving Configure-Ack/NaK/Reject
  613. // def=10
  614. DWORD MaxConfigure;
  615. //
  616. // # of Configure-Nak to send w/o sending a Configure-Ack. def=10
  617. //
  618. DWORD MaxFailure;
  619. //
  620. // # of Configure-Rej to send before assuming that the negotiation will
  621. // not terminate.
  622. DWORD MaxReject;
  623. //
  624. // High level timer for the PPP negotiation. If PPP does not complete
  625. // within this amount of time the line will be hung up.
  626. //
  627. DWORD NegotiateTime;
  628. DWORD dwCallbackDelay;
  629. DWORD dwTraceId;
  630. DWORD dwDefaultPortLimit;
  631. DWORD dwDefaultSessionTimeout;
  632. DWORD dwDefaulIdleTimeout;
  633. DWORD dwHangUpExtraSampleSeconds;
  634. DWORD dwHangupExtraPercent;
  635. DWORD dwBapListenTimeoutSeconds;
  636. DWORD dwUnknownPacketTraceSize;
  637. DWORD dwDontNegotiateMultiLinkOnSingleLink;
  638. DWORD dwLoggingLevel;
  639. DWORD dwLCPEchoTimeInterval; //Time interval between LCP echos
  640. DWORD dwIdleBeforeEcho; //Idle time before the LCP echo begins
  641. DWORD dwNumMissedEchosBeforeDisconnect; //Num missed echos before disconnect
  642. HANDLE hLogEvents;
  643. HANDLE hHeap;
  644. HANDLE hEventChangeNotification;
  645. HKEY hKeyPpp;
  646. HINSTANCE hInstanceParserDll;
  647. CHAR* pszParserDllPath;
  648. VOID (*SendPPPMessageToDdm)( IN PPP_MESSAGE * PppMsg );
  649. DWORD (*RasAuthProviderFreeAttributes)(
  650. IN RAS_AUTH_ATTRIBUTE * pInAttributes );
  651. DWORD (*RasAuthProviderAuthenticateUser)(
  652. IN RAS_AUTH_ATTRIBUTE * pInAttributes,
  653. OUT PRAS_AUTH_ATTRIBUTE* ppOutAttributes,
  654. OUT DWORD * lpdwResultCode);
  655. DWORD (*RasAcctProviderStartAccounting)(
  656. IN RAS_AUTH_ATTRIBUTE * pInAttributes,
  657. OUT PRAS_AUTH_ATTRIBUTE* ppOutAttributes);
  658. DWORD (*RasAcctProviderInterimAccounting)(
  659. IN RAS_AUTH_ATTRIBUTE * pInAttributes,
  660. OUT PRAS_AUTH_ATTRIBUTE* ppOutAttributes);
  661. DWORD (*RasAcctProviderStopAccounting)(
  662. IN RAS_AUTH_ATTRIBUTE * pInAttributes,
  663. OUT PRAS_AUTH_ATTRIBUTE* ppOutAttributes);
  664. DWORD (*RasAcctProviderFreeAttributes)(
  665. IN RAS_AUTH_ATTRIBUTE * pInAttributes );
  666. DWORD (*GetNextAccountingSessionId)( VOID );
  667. DWORD (*RasIpcpDhcpInform)( IN VOID * pWorkBuf,
  668. IN PPP_DHCP_INFORM * pDhcpInform );
  669. VOID (*RasIphlpDhcpCallback)( IN ULONG nboIpAddr );
  670. VOID (*PacketFromPeer)(
  671. IN HANDLE hPort,
  672. IN BYTE* pbDataIn,
  673. IN DWORD dwSizeIn,
  674. OUT BYTE** ppbDataOut,
  675. OUT DWORD* pdwSizeOut );
  676. VOID (*PacketToPeer)(
  677. IN HANDLE hPort,
  678. IN BYTE* pbDataIn,
  679. IN DWORD dwSizeIn,
  680. OUT BYTE** ppbDataOut,
  681. OUT DWORD* pdwSizeOut );
  682. VOID (*PacketFree)(
  683. IN BYTE* pbData );
  684. DWORD dwNASIpAddress;
  685. DWORD PortUIDGenerator;
  686. //
  687. // Server config info. Contains information as to what CPs to mark as
  688. // configurable
  689. //
  690. PPP_CONFIG_INFO ServerConfigInfo;
  691. CHAR szNASIdentifier[MAX_COMPUTERNAME_LENGTH+1];
  692. //
  693. // This is the Multilink endpoint discriminator option. It is stored in
  694. // network form. It contains the class and address fields.
  695. BYTE EndPointDiscriminator[21];
  696. } PPP_CONFIGURATION, *PPPP_CONFIGURATION;
  697. //
  698. //
  699. // Timer queue item
  700. //
  701. typedef struct _TIMER_EVENT
  702. {
  703. struct _TIMER_EVENT* pNext;
  704. struct _TIMER_EVENT* pPrev;
  705. TIMER_EVENT_TYPE EventType;
  706. DWORD dwPortId; // Id of the port/bundle REQ this timeout is for
  707. HPORT hPort; // Handle of the port REQ this timeout is for.
  708. DWORD Protocol; // Protocol for the timeout event.
  709. DWORD Id; // ID of the REQ this timeout is for
  710. BOOL fAuthenticator;// Used to determine the side of Auth protocols
  711. DWORD Delta; // # of secs. to wait after prev. TIMER_EVENT
  712. } TIMER_EVENT, *PTIMER_EVENT;
  713. //
  714. // Head of timer queue.
  715. //
  716. typedef struct _TIMER_Q {
  717. TIMER_EVENT * pQHead;
  718. HANDLE hEventNonEmpty; // Indicates that the Q is not empty.
  719. } TIMER_Q, *PTIMER_Q;
  720. //
  721. // Context atructure for Stop Accounting
  722. //
  723. typedef struct _STOP_ACCOUNTING_CONTEXT
  724. {
  725. PCB * pPcb; //Pointer to the PCB
  726. RAS_AUTH_ATTRIBUTE * pAuthAttributes; //List of Authentication Attributes.
  727. } STOP_ACCOUNTING_CONTEXT, * PSTOP_ACCOUNTING_CONTEXT ;
  728. #define REF_PROVIDER(_provider) \
  729. { \
  730. InterlockedIncrement(&_provider.ulRef); \
  731. } \
  732. #define DEREF_PROVIDER(_provider) \
  733. { \
  734. ASSERT(_provider.ulRef > 0); \
  735. InterlockedDecrement(&_provider.ulRef); \
  736. if(_provider.ulRef == 0) \
  737. { \
  738. SetEvent(_provider.hEvent); \
  739. } \
  740. } \
  741. typedef struct _PPP_AUTH_ACCT_PROVIDER
  742. {
  743. BOOL fAuthProvider;
  744. ULONG ulRef;
  745. HANDLE hEvent;
  746. } PPP_AUTH_ACCT_PROVIDER, *PPPP_AUTH_ACCT_PROVIDER;
  747. // Declare global data structures.
  748. //
  749. #ifdef _ALLOCATE_GLOBALS_
  750. #define PPP_EXTERN
  751. CHAR *FsmStates[] =
  752. {
  753. "Initial",
  754. "Starting",
  755. "Closed",
  756. "Stopped",
  757. "Closing",
  758. "Stopping",
  759. "Req Sent",
  760. "Ack Rcvd",
  761. "Ack Sent",
  762. "Opened"
  763. };
  764. CHAR *FsmCodes[] =
  765. {
  766. NULL,
  767. "Configure-Req",
  768. "Configure-Ack",
  769. "Configure-Nak",
  770. "Configure-Reject",
  771. "Terminate-Req",
  772. "Terminate-Ack",
  773. "Code-Reject",
  774. "Protocol-Reject",
  775. "Echo-Request",
  776. "Echo-Reply",
  777. "Discard-Request",
  778. "Identification",
  779. "Time-Remaining",
  780. };
  781. CHAR *SzBapStateName[] =
  782. {
  783. "INITIAL",
  784. "SENT_CALL_REQ",
  785. "SENT_CALLBACK_REQ",
  786. "SENT_DROP_REQ",
  787. "SENT_STATUS_IND",
  788. "CALLING",
  789. "LISTENING"
  790. };
  791. CHAR *SzBapPacketName[] =
  792. {
  793. "",
  794. "CALL_REQ",
  795. "CALL_RESP",
  796. "CALLBACK_REQ",
  797. "CALLBACK_RESP",
  798. "DROP_REQ",
  799. "DROP_RESP",
  800. "STATUS_IND",
  801. "STAT_RESP"
  802. };
  803. #else
  804. #define PPP_EXTERN extern
  805. extern CHAR * FsmStates[];
  806. extern CHAR * FsmCodes[];
  807. extern CHAR * SzBapStateName[];
  808. extern CHAR * SzBapPacketName[];
  809. #endif
  810. PPP_EXTERN PCB_TABLE PcbTable;
  811. PPP_EXTERN PCB_WORK_ITEMQ WorkItemQ;
  812. PPP_EXTERN PPP_CONFIGURATION PppConfigInfo;
  813. PPP_EXTERN PPPCP_ENTRY * CpTable;
  814. PPP_EXTERN TIMER_Q TimerQ;
  815. PPP_EXTERN DWORD DwBapTraceId;
  816. PPP_EXTERN DWORD PrivateTraceId;
  817. // BAP is meaningless over VPN's. For testing purposes, we may want to allow it.
  818. PPP_EXTERN BOOL FDoBapOnVpn;
  819. VOID
  820. PrivateTrace(
  821. IN CHAR* Format,
  822. ...
  823. );
  824. #endif