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.

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