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.

838 lines
24 KiB

  1. /* Copyright (c) 1993, Microsoft Corporation, all rights reserved
  2. **
  3. ** rasppp.c
  4. ** Remote Access PPP APIs
  5. **
  6. ** 11/15/93 Steve Cobb
  7. */
  8. #include <nt.h>
  9. #include <ntrtl.h>
  10. #include <nturtl.h>
  11. #include <windows.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <wchar.h>
  15. #include <ctype.h>
  16. #include <stdarg.h>
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <lmcons.h>
  20. #include <rasauth.h>
  21. #include <rasman.h>
  22. #include <rasppp.h>
  23. #include <ddmif.h>
  24. #include <rtutils.h>
  25. #include <mprlog.h>
  26. #include <raserror.h>
  27. #include <pppcp.h>
  28. #include <ppp.h>
  29. #include <util.h>
  30. #include <init.h>
  31. #include <worker.h>
  32. #include <bap.h>
  33. #include <raseapif.h>
  34. #define INCL_PWUTIL
  35. #include <ppputil.h>
  36. PPP_AUTH_ACCT_PROVIDER g_AuthProv;
  37. PPP_AUTH_ACCT_PROVIDER g_AcctProv;
  38. BOOL DDMInitialized = FALSE;
  39. //**
  40. //
  41. // Call: StartPPP
  42. //
  43. // Returns: NO_ERROR - Success.
  44. // Non zero return code - Failure
  45. //
  46. // Description:
  47. //
  48. DWORD APIENTRY
  49. StartPPP(
  50. DWORD NumPorts
  51. )
  52. {
  53. DWORD dwRetCode;
  54. //
  55. // Read registry info, load CP DLLS, initialize globals etc.
  56. //
  57. PcbTable.NumPcbBuckets = ((DWORD)NumPorts > MAX_NUMBER_OF_PCB_BUCKETS)
  58. ? MAX_NUMBER_OF_PCB_BUCKETS
  59. : (DWORD)NumPorts;
  60. dwRetCode = InitializePPP();
  61. if ( dwRetCode != NO_ERROR )
  62. {
  63. PPPCleanUp();
  64. }
  65. else
  66. {
  67. PppLog( 2, "PPP Initialized successfully." );
  68. }
  69. return( dwRetCode );
  70. }
  71. //**
  72. //
  73. // Call: StopPPP
  74. //
  75. // Returns: NO_ERROR - Success.
  76. // Non zero return code - Failure
  77. //
  78. DWORD APIENTRY
  79. StopPPP(
  80. HANDLE hEventStopPPP
  81. )
  82. {
  83. PCB_WORK_ITEM * pWorkItem;
  84. PppLog( 2, "StopPPP called" );
  85. //
  86. // Insert shutdown event
  87. //
  88. pWorkItem = (PCB_WORK_ITEM*)LOCAL_ALLOC(LPTR,sizeof(PCB_WORK_ITEM));
  89. if ( pWorkItem == (PCB_WORK_ITEM *)NULL )
  90. {
  91. return( GetLastError() );
  92. }
  93. pWorkItem->Process = ProcessStopPPP;
  94. pWorkItem->hEvent = hEventStopPPP;
  95. InsertWorkItemInQ( pWorkItem );
  96. return( NO_ERROR );
  97. }
  98. //**
  99. //
  100. // Call: SendPPPMessageToEngine
  101. //
  102. // Returns: NO_ERROR - Success
  103. // non-zero - FAILURE
  104. //
  105. // Description: Will create a PCB_WORK_ITEM from a PPPE_MESSAGE structure
  106. // received from client or rassrv and Send it to the engine.
  107. //
  108. DWORD APIENTRY
  109. SendPPPMessageToEngine(
  110. IN PPPE_MESSAGE* pMessage
  111. )
  112. {
  113. PCB_WORK_ITEM * pWorkItem = (PCB_WORK_ITEM *)LOCAL_ALLOC(
  114. LPTR,
  115. sizeof(PCB_WORK_ITEM));
  116. if ( pWorkItem == (PCB_WORK_ITEM *)NULL )
  117. {
  118. LogPPPEvent( ROUTERLOG_NOT_ENOUGH_MEMORY, 0 );
  119. return( GetLastError() );
  120. }
  121. //
  122. // Set up PCB_WORK_ITEM structure from the PPPE_MESSAGE
  123. //
  124. pWorkItem->hPort = pMessage->hPort;
  125. switch( pMessage->dwMsgId )
  126. {
  127. case PPPEMSG_Start:
  128. pWorkItem->Process = ProcessLineUp;
  129. pWorkItem->fServer = FALSE;
  130. pWorkItem->PppMsg.Start = pMessage->ExtraInfo.Start;
  131. //Create a seed for encoding the password
  132. // pMessage->ExtraInfo.Start.chSeed =
  133. // pWorkItem->PppMsg.Start.chSeed = GEN_RAND_ENCODE_SEED;
  134. PppLog( 2, "PPPEMSG_Start recvd, d=%s, hPort=%d,callback=%d,"
  135. "mask=%x,IfType=%d",
  136. pMessage->ExtraInfo.Start.szDomain,
  137. pWorkItem->hPort,
  138. pMessage->ExtraInfo.Start.fThisIsACallback,
  139. pMessage->ExtraInfo.Start.ConfigInfo.dwConfigMask,
  140. pMessage->ExtraInfo.Start.PppInterfaceInfo.IfType );
  141. // EncodePw( pWorkItem->PppMsg.Start.chSeed, pWorkItem->PppMsg.Start.szPassword );
  142. // EncodePw( pMessage->ExtraInfo.Start.chSeed, pMessage->ExtraInfo.Start.szPassword );
  143. if(NO_ERROR != EncodePassword(
  144. strlen(pWorkItem->PppMsg.Start.szPassword) + 1,
  145. pWorkItem->PppMsg.Start.szPassword,
  146. &pWorkItem->PppMsg.Start.DBPassword))
  147. {
  148. PppLog(1, "PPPEMSG_Start: Encode password failed");
  149. break;
  150. }
  151. //
  152. // wipe out the passwords
  153. //
  154. RtlSecureZeroMemory(pWorkItem->PppMsg.Start.szPassword,
  155. strlen(pWorkItem->PppMsg.Start.szPassword));
  156. RtlSecureZeroMemory(pMessage->ExtraInfo.Start.szPassword,
  157. strlen(pMessage->ExtraInfo.Start.szPassword));
  158. break;
  159. case PPPEMSG_Stop:
  160. PppLog( 2, "PPPEMSG_Stop recvd\r\n" );
  161. pWorkItem->Process = ProcessClose;
  162. pWorkItem->PppMsg.PppStop = pMessage->ExtraInfo.Stop;
  163. break;
  164. case PPPEMSG_Callback:
  165. PppLog( 2, "PPPEMSG_Callback recvd, hPort=%d\r\n",
  166. pWorkItem->hPort);
  167. pWorkItem->Process = ProcessGetCallbackNumberFromUser;
  168. pWorkItem->PppMsg.Callback = pMessage->ExtraInfo.Callback;
  169. break;
  170. case PPPEMSG_ChangePw:
  171. PppLog( 2, "PPPEMSG_ChangePw recvd, hPort=%d\r\n",
  172. pWorkItem->hPort);
  173. pWorkItem->Process = ProcessChangePassword;
  174. pWorkItem->PppMsg.ChangePw = pMessage->ExtraInfo.ChangePw;
  175. // pWorkItem->PppMsg.ChangePw.chSeed = pMessage->ExtraInfo.ChangePw.chSeed = GEN_RAND_ENCODE_SEED;
  176. if(NO_ERROR != EncodePassword(
  177. strlen(pWorkItem->PppMsg.ChangePw.szNewPassword) + 1,
  178. pWorkItem->PppMsg.ChangePw.szNewPassword,
  179. &pWorkItem->PppMsg.ChangePw.DBPassword))
  180. {
  181. PppLog(1, "EncodePassword failed");
  182. break;
  183. }
  184. if(NO_ERROR != EncodePassword(
  185. strlen(pWorkItem->PppMsg.ChangePw.szOldPassword) + 1,
  186. pWorkItem->PppMsg.ChangePw.szOldPassword,
  187. &pWorkItem->PppMsg.ChangePw.DBOldPassword))
  188. {
  189. PppLog(1, "EncodePassword failed");
  190. }
  191. //
  192. // wipe out the passwords
  193. //
  194. RtlSecureZeroMemory(pWorkItem->PppMsg.ChangePw.szOldPassword,
  195. strlen(pWorkItem->PppMsg.ChangePw.szOldPassword));
  196. RtlSecureZeroMemory(pWorkItem->PppMsg.ChangePw.szNewPassword,
  197. strlen(pWorkItem->PppMsg.ChangePw.szNewPassword));
  198. RtlSecureZeroMemory(pMessage->ExtraInfo.ChangePw.szOldPassword,
  199. strlen(pMessage->ExtraInfo.ChangePw.szOldPassword));
  200. RtlSecureZeroMemory(pMessage->ExtraInfo.ChangePw.szNewPassword,
  201. strlen(pMessage->ExtraInfo.ChangePw.szNewPassword));
  202. // EncodePw( pWorkItem->PppMsg.ChangePw.chSeed, pWorkItem->PppMsg.ChangePw.szNewPassword );
  203. // EncodePw( pMessage->ExtraInfo.ChangePw.chSeed, pMessage->ExtraInfo.ChangePw.szNewPassword );
  204. // EncodePw( pWorkItem->PppMsg.ChangePw.chSeed, pWorkItem->PppMsg.ChangePw.szOldPassword );
  205. // EncodePw( pMessage->ExtraInfo.ChangePw.chSeed, pMessage->ExtraInfo.ChangePw.szOldPassword );
  206. break;
  207. case PPPEMSG_Retry:
  208. PppLog( 2, "PPPEMSG_Retry recvd hPort=%d,u=%s",
  209. pWorkItem->hPort,
  210. pMessage->ExtraInfo.Start.szUserName );
  211. pWorkItem->Process = ProcessRetryPassword;
  212. pWorkItem->PppMsg.Retry = pMessage->ExtraInfo.Retry;
  213. // pWorkItem->PppMsg.Retry.chSeed = pMessage->ExtraInfo.Retry.chSeed = GEN_RAND_ENCODE_SEED;
  214. if(NO_ERROR != EncodePassword(
  215. strlen(pWorkItem->PppMsg.Retry.szPassword) + 1,
  216. pWorkItem->PppMsg.Retry.szPassword,
  217. &pWorkItem->PppMsg.Retry.DBPassword))
  218. {
  219. PppLog(1, "EncodePassword failed");
  220. break;
  221. }
  222. // EncodePw( pWorkItem->PppMsg.Retry.chSeed, pWorkItem->PppMsg.Retry.szPassword );
  223. // EncodePw( pMessage->ExtraInfo.Retry.chSeed, pMessage->ExtraInfo.Retry.szPassword );
  224. //
  225. // Wipe out the password
  226. //
  227. RtlSecureZeroMemory(pWorkItem->PppMsg.Retry.szPassword,
  228. strlen(pWorkItem->PppMsg.Retry.szPassword));
  229. RtlSecureZeroMemory(pMessage->ExtraInfo.Retry.szPassword,
  230. strlen(pMessage->ExtraInfo.Retry.szPassword));
  231. break;
  232. case PPPEMSG_Receive:
  233. pWorkItem->Process = ProcessReceive;
  234. pWorkItem->PacketLen = pMessage->ExtraInfo.Receive.dwNumBytes;
  235. PppLog( 2, "Packet received (%d bytes) for hPort %d",
  236. pWorkItem->PacketLen, pWorkItem->hPort );
  237. pWorkItem->pPacketBuf = (PPP_PACKET *)LOCAL_ALLOC(LPTR,
  238. pWorkItem->PacketLen);
  239. if ( pWorkItem->pPacketBuf == (PPP_PACKET*)NULL )
  240. {
  241. LogPPPEvent( ROUTERLOG_NOT_ENOUGH_MEMORY, 0 );
  242. LOCAL_FREE( pWorkItem );
  243. return( GetLastError() );
  244. }
  245. CopyMemory( pWorkItem->pPacketBuf,
  246. pMessage->ExtraInfo.Receive.pbBuffer,
  247. pWorkItem->PacketLen );
  248. break;
  249. case PPPEMSG_LineDown:
  250. PppLog( 2, "PPPEMSG_LineDown recvd, hPort=%d\r\n",
  251. pWorkItem->hPort);
  252. pWorkItem->Process = ProcessLineDown;
  253. break;
  254. case PPPEMSG_ListenResult:
  255. pWorkItem->Process = ProcessRasPortListenEvent;
  256. break;
  257. case PPPEMSG_BapEvent:
  258. BapTrace( "Threshold event on HCONN 0x%x. Type: %s, Threshold: %s",
  259. pMessage->hConnection,
  260. pMessage->ExtraInfo.BapEvent.fTransmit ? "transmit" : "receive",
  261. pMessage->ExtraInfo.BapEvent.fAdd ? "upper" : "lower");
  262. pWorkItem->Process = ProcessThresholdEvent;
  263. pWorkItem->hConnection = pMessage->hConnection;
  264. pWorkItem->PppMsg.BapEvent = pMessage->ExtraInfo.BapEvent;
  265. break;
  266. case PPPEMSG_DdmStart:
  267. pWorkItem->Process = ProcessLineUp;
  268. pWorkItem->fServer = TRUE;
  269. pWorkItem->PppMsg.DdmStart = pMessage->ExtraInfo.DdmStart;
  270. break;
  271. case PPPEMSG_DdmCallbackDone:
  272. PppLog( 2, "PPPEMSG_DdmCallbackDone recvd\r\n" );
  273. pWorkItem->Process = ProcessCallbackDone;
  274. pWorkItem->fServer = TRUE;
  275. pWorkItem->PppMsg.CallbackDone = pMessage->ExtraInfo.CallbackDone;
  276. break;
  277. case PPPEMSG_DdmInterfaceInfo:
  278. pWorkItem->Process = ProcessInterfaceInfo;
  279. pWorkItem->fServer = TRUE;
  280. pWorkItem->hConnection = pMessage->hConnection;
  281. pWorkItem->PppMsg.InterfaceInfo = pMessage->ExtraInfo.InterfaceInfo;
  282. PppLog(2,"PPPEMSG_DdmInterfaceInfo recvd,IPXif=%x,IPif=%x,Type=%x\r\n",
  283. pWorkItem->PppMsg.InterfaceInfo.hIPXInterface,
  284. pWorkItem->PppMsg.InterfaceInfo.hIPInterface,
  285. pWorkItem->PppMsg.InterfaceInfo.IfType );
  286. break;
  287. case PPPEMSG_DdmBapCallbackResult:
  288. pWorkItem->Process = ProcessCallResult;
  289. pWorkItem->hConnection = pMessage->hConnection;
  290. pWorkItem->PppMsg.BapCallResult.dwResult =
  291. pMessage->ExtraInfo.BapCallbackResult.dwCallbackResultCode;
  292. pWorkItem->PppMsg.BapCallResult.hRasConn = (HRASCONN) -1;
  293. break;
  294. case PPPEMSG_DhcpInform:
  295. pWorkItem->Process = ProcessDhcpInform;
  296. pWorkItem->hConnection = pMessage->hConnection;
  297. pWorkItem->PppMsg.DhcpInform = pMessage->ExtraInfo.DhcpInform;
  298. break;
  299. case PPPEMSG_EapUIData:
  300. pWorkItem->Process = ProcessEapUIData;
  301. pWorkItem->PppMsg.EapUIData = pMessage->ExtraInfo.EapUIData;
  302. break;
  303. case PPPEMSG_ProtocolEvent:
  304. pWorkItem->Process = ProcessProtocolEvent;
  305. pWorkItem->PppMsg.ProtocolEvent = pMessage->ExtraInfo.ProtocolEvent;
  306. break;
  307. case PPPEMSG_DdmChangeNotification:
  308. pWorkItem->Process = ProcessChangeNotification;
  309. break;
  310. case PPPEMSG_IpAddressLeaseExpired:
  311. pWorkItem->Process = ProcessIpAddressLeaseExpired;
  312. pWorkItem->PppMsg.IpAddressLeaseExpired =
  313. pMessage->ExtraInfo.IpAddressLeaseExpired;
  314. break;
  315. case PPPEMSG_PostLineDown:
  316. pWorkItem->Process = ProcessPostLineDown;
  317. pWorkItem->PppMsg.PostLineDown =
  318. pMessage->ExtraInfo.PostLineDown;
  319. break;
  320. case PPPEMSG_DdmRemoveQuarantine:
  321. pWorkItem->Process = ProcessRemoveQuarantine;
  322. pWorkItem->hConnection = pMessage->hConnection;
  323. break;
  324. case PPPEMSG_ResumeFromHibernate:
  325. pWorkItem->Process = ProcessResumeFromHibernate;
  326. break;
  327. default:
  328. PppLog( 2,"Unknown IPC message %d received\r\n", pMessage->dwMsgId );
  329. LOCAL_FREE( pWorkItem );
  330. pWorkItem = (PCB_WORK_ITEM*)NULL;
  331. }
  332. if ( pWorkItem != NULL )
  333. {
  334. InsertWorkItemInQ( pWorkItem );
  335. }
  336. return( NO_ERROR );
  337. }
  338. //**
  339. //
  340. // Call: PppDdmInit
  341. //
  342. // Returns: NO_ERROR - Success
  343. // Non-zero returns - Failure
  344. //
  345. // Description: Will initialize the entry point into DDM that it will call to
  346. // send DDM a PPP_MESSAGE
  347. //
  348. DWORD
  349. PppDdmInit(
  350. IN VOID (*SendPPPMessageToDdm)( PPP_MESSAGE * PppMsg ),
  351. IN DWORD dwServerFlags,
  352. IN DWORD dwLoggingLevel,
  353. IN DWORD dwNASIpAddress,
  354. IN BOOL fRadiusAuthentication,
  355. IN LPVOID lpfnRasAuthProviderAuthenticateUser,
  356. IN LPVOID lpfnRasAuthProviderFreeAttributes,
  357. IN LPVOID lpfnRasAcctProviderStartAccounting,
  358. IN LPVOID lpfnRasAcctProviderInterimAccounting,
  359. IN LPVOID lpfnRasAcctProviderStopAccounting,
  360. IN LPVOID lpfnRasAcctProviderFreeAttributes,
  361. IN LPVOID lpfnGetNextAccountingSessionId
  362. )
  363. {
  364. DWORD dwRetCode;
  365. PppConfigInfo.SendPPPMessageToDdm = SendPPPMessageToDdm;
  366. PppConfigInfo.ServerConfigInfo.dwConfigMask = dwServerFlags;
  367. PppConfigInfo.dwNASIpAddress = dwNASIpAddress;
  368. PppConfigInfo.dwLoggingLevel = dwLoggingLevel;
  369. if ( dwNASIpAddress == 0 )
  370. {
  371. DWORD dwComputerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
  372. //
  373. // Failed to get the LOCAL IP address, used computer name instead.
  374. //
  375. PppConfigInfo.dwNASIpAddress = 0;
  376. if ( !GetComputerNameA( PppConfigInfo.szNASIdentifier,
  377. &dwComputerNameLen ) )
  378. {
  379. return( GetLastError() );
  380. }
  381. }
  382. PppConfigInfo.fRadiusAuthenticationUsed = fRadiusAuthentication;
  383. PppConfigInfo.RasAuthProviderFreeAttributes =
  384. (DWORD(*)( RAS_AUTH_ATTRIBUTE *))
  385. lpfnRasAuthProviderFreeAttributes;
  386. PppConfigInfo.RasAuthProviderAuthenticateUser =
  387. (DWORD(*)( RAS_AUTH_ATTRIBUTE * ,
  388. PRAS_AUTH_ATTRIBUTE* ,
  389. DWORD *))
  390. lpfnRasAuthProviderAuthenticateUser;
  391. PppConfigInfo.RasAcctProviderStartAccounting =
  392. (DWORD(*)( RAS_AUTH_ATTRIBUTE *,
  393. PRAS_AUTH_ATTRIBUTE*))
  394. lpfnRasAcctProviderStartAccounting;
  395. PppConfigInfo.RasAcctProviderInterimAccounting =
  396. (DWORD(*)( RAS_AUTH_ATTRIBUTE * ,
  397. PRAS_AUTH_ATTRIBUTE*))
  398. lpfnRasAcctProviderInterimAccounting;
  399. PppConfigInfo.RasAcctProviderStopAccounting =
  400. (DWORD(*)( RAS_AUTH_ATTRIBUTE * ,
  401. PRAS_AUTH_ATTRIBUTE*))
  402. lpfnRasAcctProviderStopAccounting;
  403. PppConfigInfo.RasAcctProviderFreeAttributes =
  404. (DWORD(*)( RAS_AUTH_ATTRIBUTE *))
  405. lpfnRasAcctProviderFreeAttributes;
  406. PppConfigInfo.GetNextAccountingSessionId =
  407. (DWORD(*)(VOID))
  408. lpfnGetNextAccountingSessionId;
  409. ZeroMemory(&g_AuthProv, sizeof(PPP_AUTH_ACCT_PROVIDER));
  410. ZeroMemory(&g_AcctProv, sizeof(PPP_AUTH_ACCT_PROVIDER));
  411. g_AuthProv.fAuthProvider = TRUE;
  412. g_AuthProv.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  413. if(NULL == g_AuthProv.hEvent)
  414. {
  415. return GetLastError();
  416. }
  417. g_AcctProv.fAuthProvider = FALSE;
  418. g_AcctProv.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  419. if(NULL == g_AcctProv.hEvent)
  420. {
  421. DWORD dwErr = GetLastError();
  422. CloseHandle(g_AuthProv.hEvent);
  423. ZeroMemory(&g_AuthProv, sizeof(PPP_AUTH_ACCT_PROVIDER));
  424. return dwErr;
  425. }
  426. //
  427. // These will be deref'd in PppDdmDeInit
  428. //
  429. REF_PROVIDER(g_AuthProv);
  430. REF_PROVIDER(g_AcctProv);
  431. DDMInitialized = TRUE;
  432. return( NO_ERROR );
  433. }
  434. //**
  435. //
  436. // Call: PppDdmDeInit
  437. //
  438. // Returns: NO_ERROR - Success
  439. // Non-zero returns - Failure
  440. //
  441. // Description:
  442. //
  443. VOID
  444. PppDdmDeInit(
  445. VOID
  446. )
  447. {
  448. if(DDMInitialized)
  449. {
  450. HANDLE hEvents[2];
  451. //
  452. // Deref the ref applied in PppDdmInit
  453. //
  454. DEREF_PROVIDER(g_AuthProv);
  455. DEREF_PROVIDER(g_AcctProv);
  456. hEvents[0] = g_AuthProv.hEvent;
  457. hEvents[1] = g_AcctProv.hEvent;
  458. PppLog(2, "PppDdmDeInit: waiting for auth-acct providers");
  459. WaitForMultipleObjects(2, hEvents, TRUE, INFINITE);
  460. CloseHandle(g_AuthProv.hEvent);
  461. CloseHandle(g_AcctProv.hEvent);
  462. ZeroMemory(&g_AuthProv, sizeof(PPP_AUTH_ACCT_PROVIDER));
  463. ZeroMemory(&g_AcctProv, sizeof(PPP_AUTH_ACCT_PROVIDER));
  464. DDMInitialized = FALSE;
  465. }
  466. return;
  467. }
  468. //**
  469. //
  470. // Call: PppDdmCallbackDone
  471. //
  472. // Returns: NO_ERROR - Success
  473. // Non-zero returns - Failure
  474. //
  475. // Description: Will create a PPPEMSG_DdmCallbackDone and send it to the
  476. // worker thread of the PPP engine.
  477. //
  478. DWORD
  479. PppDdmCallbackDone(
  480. IN HPORT hPort,
  481. IN WCHAR* pwszCallbackNumber
  482. )
  483. {
  484. PPPE_MESSAGE PppMessage;
  485. PppMessage.hPort = hPort;
  486. PppMessage.dwMsgId = PPPEMSG_DdmCallbackDone;
  487. wcstombs( PppMessage.ExtraInfo.CallbackDone.szCallbackNumber,
  488. pwszCallbackNumber,
  489. sizeof( PppMessage.ExtraInfo.CallbackDone.szCallbackNumber ) );
  490. return( SendPPPMessageToEngine( &PppMessage ) );
  491. }
  492. //**
  493. //
  494. // Call: PppDdmStart
  495. //
  496. // Returns: NO_ERROR - Success
  497. // Non-zero returns - Failure
  498. //
  499. // Description: Will create a PPPEMSG_DdmStart and send it to the
  500. // worker thread of the PPP engine.
  501. //
  502. DWORD
  503. PppDdmStart(
  504. IN HPORT hPort,
  505. IN WCHAR * wszPortName,
  506. IN CHAR* pchFirstFrame,
  507. IN DWORD cbFirstFrame,
  508. IN DWORD dwAuthRetries
  509. )
  510. {
  511. PPPE_MESSAGE PppMessage;
  512. PppMessage.hPort = hPort;
  513. PppMessage.dwMsgId = PPPEMSG_DdmStart;
  514. PppMessage.ExtraInfo.DdmStart.dwAuthRetries = dwAuthRetries;
  515. wcstombs( PppMessage.ExtraInfo.DdmStart.szPortName,
  516. wszPortName,
  517. sizeof( PppMessage.ExtraInfo.DdmStart.szPortName ) );
  518. CopyMemory( &(PppMessage.ExtraInfo.DdmStart.achFirstFrame),
  519. pchFirstFrame,
  520. sizeof( PppMessage.ExtraInfo.DdmStart.achFirstFrame ) );
  521. PppMessage.ExtraInfo.DdmStart.cbFirstFrame = cbFirstFrame;
  522. return( SendPPPMessageToEngine( &PppMessage ) );
  523. }
  524. //**
  525. //
  526. // Call: PppStop
  527. //
  528. // Returns: NO_ERROR - Success
  529. // Non-zero returns - Failure
  530. //
  531. // Description: Will create a PPPEMSG_Stop and send it to the
  532. // worker thread of the PPP engine.
  533. //
  534. DWORD
  535. PppStop(
  536. IN HPORT hPort
  537. )
  538. {
  539. PPPE_MESSAGE PppMessage;
  540. PppLog( 2, "PppStop\r\n" );
  541. PppMessage.hPort = hPort;
  542. PppMessage.dwMsgId = PPPEMSG_Stop;
  543. PppMessage.ExtraInfo.Stop.dwStopReason = NO_ERROR;
  544. return( SendPPPMessageToEngine( &PppMessage ) );
  545. }
  546. //**
  547. //
  548. // Call: PppDdmStop
  549. //
  550. // Returns: NO_ERROR - Success
  551. // Non-zero returns - Failure
  552. //
  553. // Description: Will create a PPPEMSG_Stop and send it to the
  554. // worker thread of the PPP engine.
  555. //
  556. DWORD
  557. PppDdmStop(
  558. IN HPORT hPort,
  559. IN DWORD dwStopReason
  560. )
  561. {
  562. PPPE_MESSAGE PppMessage;
  563. PppLog( 2, "PppDdmStop\r\n" );
  564. PppMessage.hPort = hPort;
  565. PppMessage.dwMsgId = PPPEMSG_Stop;
  566. PppMessage.ExtraInfo.Stop.dwStopReason = dwStopReason;
  567. return( SendPPPMessageToEngine( &PppMessage ) );
  568. }
  569. //**
  570. //
  571. // Call: PppDdmSendInterfaceInfo
  572. //
  573. // Returns: NO_ERROR - Success
  574. // Non-zero returns - Failure
  575. //
  576. // Description: Will create a PPPEMSG_DdmInterfaceInfo and send it to the
  577. // worker thread of the PPP engine.
  578. //
  579. DWORD
  580. PppDdmSendInterfaceInfo(
  581. IN HCONN hConnection,
  582. IN PPP_INTERFACE_INFO * pInterfaceInfo
  583. )
  584. {
  585. PPPE_MESSAGE PppMessage;
  586. PppMessage.hConnection = hConnection;
  587. PppMessage.dwMsgId = PPPEMSG_DdmInterfaceInfo;
  588. PppMessage.ExtraInfo.InterfaceInfo = *pInterfaceInfo;
  589. return( SendPPPMessageToEngine( &PppMessage ) );
  590. }
  591. //**
  592. //
  593. // Call: PppDdmBapCallbackResult
  594. //
  595. // Returns: NO_ERROR - Success
  596. // Non-zero returns - Failure
  597. //
  598. // Description: Will create a PPPEMSG_DdmBapCallbackResult and send it to the
  599. // worker thread of the PPP engine.
  600. //
  601. DWORD
  602. PppDdmBapCallbackResult(
  603. IN HCONN hConnection,
  604. IN DWORD dwBapCallbackResultCode
  605. )
  606. {
  607. PPPE_MESSAGE PppMessage;
  608. PppMessage.hConnection = hConnection;
  609. PppMessage.dwMsgId = PPPEMSG_DdmBapCallbackResult;
  610. PppMessage.ExtraInfo.BapCallbackResult.dwCallbackResultCode
  611. = dwBapCallbackResultCode;
  612. return( SendPPPMessageToEngine( &PppMessage ) );
  613. }
  614. //**
  615. //
  616. // Call: PppDdmChangeNotification
  617. //
  618. // Returns: NO_ERROR - Success
  619. // Non-zero returns - Failure
  620. //
  621. // Description:
  622. //
  623. DWORD
  624. PppDdmChangeNotification(
  625. IN DWORD dwServerFlags,
  626. IN DWORD dwLoggingLevel
  627. )
  628. {
  629. PPPE_MESSAGE PppMessage;
  630. PppLog( 2, "PppDdmChangeNotification. New flags: 0x%x", dwServerFlags );
  631. PppMessage.dwMsgId = PPPEMSG_DdmChangeNotification;
  632. PppConfigInfo.ServerConfigInfo.dwConfigMask = dwServerFlags;
  633. PppConfigInfo.dwLoggingLevel = dwLoggingLevel;
  634. return( SendPPPMessageToEngine( &PppMessage ) );
  635. }
  636. //**
  637. //
  638. // Call: PppDdmRemoveQuarantine
  639. //
  640. // Returns: NO_ERROR - Success
  641. // Non-zero returns - Failure
  642. //
  643. // Description:
  644. //
  645. DWORD
  646. PppDdmRemoveQuarantine(
  647. IN HCONN hConnection
  648. )
  649. {
  650. PPPE_MESSAGE PppMessage;
  651. PppLog( 2, "PppDdmRemoveQuarantine. hConn: 0x%x", hConnection );
  652. PppMessage.dwMsgId = PPPEMSG_DdmRemoveQuarantine;
  653. PppMessage.hConnection = hConnection;
  654. return( SendPPPMessageToEngine( &PppMessage ) );
  655. }