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.

931 lines
23 KiB

  1. /*
  2. File routerdb.c
  3. Implements a database abstraction for accessing router interfaces.
  4. If any caching/transactioning/commit-noncommit-moding is done, it
  5. should be implemented here with the api's remaining constant.
  6. */
  7. #include "precomp.h"
  8. EXTERN_C
  9. HRESULT APIENTRY HrRenameConnection(const GUID* guidId, PCWSTR pszNewName);
  10. typedef
  11. DWORD
  12. (WINAPI *PRasValidateEntryName)(
  13. LPWSTR lpszPhonebook, // pointer to full path and filename of phone-book file
  14. LPWSTR lpszEntry // pointer to the entry name to validate
  15. );
  16. typedef struct _RTR_IF_LIST
  17. {
  18. WCHAR pszName[MAX_INTERFACE_NAME_LEN + 1];
  19. struct _RTR_IF_LIST* pNext;
  20. } RTR_IF_LIST;
  21. //
  22. // Callback for RtrdbInterfaceEnumerate that adds the interface
  23. // to a list if the interface is type wan.
  24. //
  25. DWORD
  26. RtrdbAddWanIfToList(
  27. IN PWCHAR pwszIfName,
  28. IN DWORD dwLevel,
  29. IN DWORD dwFormat,
  30. IN PVOID pvData,
  31. IN HANDLE hData)
  32. {
  33. MPR_INTERFACE_0* pIf0 = (MPR_INTERFACE_0*)pvData;
  34. RTR_IF_LIST** ppList = (RTR_IF_LIST**)hData;
  35. RTR_IF_LIST* pNode = NULL;
  36. DWORD dwErr = NO_ERROR, dwSize;
  37. do
  38. {
  39. // See if the interface type is right
  40. //
  41. if (pIf0->dwIfType == ROUTER_IF_TYPE_FULL_ROUTER)
  42. {
  43. // Initialize a new node for the list
  44. //
  45. pNode = (RTR_IF_LIST*)
  46. IfutlAlloc(sizeof(RTR_IF_LIST), TRUE);
  47. if (pNode == NULL)
  48. {
  49. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  50. break;
  51. }
  52. dwSize = sizeof(pNode->pszName);
  53. dwErr = GetIfNameFromFriendlyName(
  54. pwszIfName,
  55. pNode->pszName,
  56. &dwSize);
  57. BREAK_ON_DWERR(dwErr);
  58. // Add the interface to the list
  59. //
  60. pNode->pNext = *ppList;
  61. *ppList = pNode;
  62. }
  63. } while (FALSE);
  64. // Cleanup
  65. {
  66. if (dwErr != NO_ERROR)
  67. {
  68. IfutlFree(pNode);
  69. }
  70. }
  71. return dwErr;
  72. }
  73. DWORD
  74. RtrdbValidatePhoneBookEntry(
  75. PWSTR pwszInterfaceName
  76. )
  77. {
  78. HMODULE hRasApi32;
  79. PRasValidateEntryName pfnRasValidateEntryName;
  80. DWORD dwErr;
  81. WCHAR rgwcPath[MAX_PATH+1];
  82. //
  83. // get phone book path + file name
  84. //
  85. if(g_pwszRouter is NULL)
  86. {
  87. dwErr =
  88. ExpandEnvironmentStringsW(LOCAL_ROUTER_PB_PATHW,
  89. rgwcPath,
  90. sizeof(rgwcPath)/sizeof(rgwcPath[0]));
  91. }
  92. else
  93. {
  94. dwErr = wsprintfW(rgwcPath,
  95. REMOTE_ROUTER_PB_PATHW,
  96. g_pwszRouter);
  97. }
  98. ASSERT(dwErr > 0);
  99. //
  100. // Load RASAPI32 DLL and call into it to verify specified
  101. // phone book entry
  102. //
  103. hRasApi32 = LoadLibraryW(L"RASAPI32.DLL");
  104. if(hRasApi32 isnot NULL)
  105. {
  106. pfnRasValidateEntryName =
  107. (PRasValidateEntryName) GetProcAddress(hRasApi32,
  108. "RasValidateEntryNameW");
  109. if(pfnRasValidateEntryName isnot NULL )
  110. {
  111. dwErr = pfnRasValidateEntryName(rgwcPath,
  112. pwszInterfaceName);
  113. if(dwErr is NO_ERROR)
  114. {
  115. dwErr = ERROR_CANNOT_FIND_PHONEBOOK_ENTRY;
  116. }
  117. else
  118. {
  119. if(dwErr is ERROR_ALREADY_EXISTS)
  120. {
  121. dwErr = NO_ERROR;
  122. }
  123. }
  124. }
  125. else
  126. {
  127. dwErr = GetLastError ();
  128. }
  129. FreeLibrary(hRasApi32);
  130. }
  131. else
  132. {
  133. dwErr = GetLastError();
  134. }
  135. return dwErr;
  136. }
  137. DWORD
  138. RtrInterfaceCreate(
  139. PMPR_INTERFACE_0 pIfInfo
  140. )
  141. {
  142. DWORD dwErr;
  143. HANDLE hIfCfg, hIfAdmin;
  144. dwErr = MprConfigInterfaceCreate(g_hMprConfig,
  145. 0,
  146. (PBYTE)pIfInfo,
  147. &hIfCfg);
  148. if(dwErr isnot NO_ERROR)
  149. {
  150. DisplayError(g_hModule,
  151. dwErr);
  152. return dwErr;
  153. }
  154. //
  155. // if router service is running add the interface
  156. // to it too.
  157. //
  158. if(IfutlIsRouterRunning())
  159. {
  160. dwErr = MprAdminInterfaceCreate(g_hMprAdmin,
  161. 0,
  162. (PBYTE)pIfInfo,
  163. &hIfAdmin);
  164. if(dwErr isnot NO_ERROR)
  165. {
  166. DisplayError(g_hModule,
  167. dwErr);
  168. return dwErr;
  169. }
  170. }
  171. return NO_ERROR;
  172. }
  173. DWORD
  174. RtrdbInterfaceAdd(
  175. IN PWCHAR pszInterface,
  176. IN DWORD dwLevel,
  177. IN PVOID pvInfo
  178. )
  179. /*++
  180. Routine Description:
  181. Adds an interface to the router
  182. Arguments:
  183. pIfInfo - Info for adding the interface
  184. Return Value:
  185. NO_ERROR
  186. --*/
  187. {
  188. DWORD dwErr;
  189. HANDLE hIfAdmin, hIfCfg;
  190. GUID Guid;
  191. MPR_INTERFACE_0* pIfInfo = (MPR_INTERFACE_0*)pvInfo;
  192. //
  193. // If an interface with this name exists, bug out
  194. //
  195. if(pIfInfo->dwIfType is ROUTER_IF_TYPE_FULL_ROUTER)
  196. {
  197. //
  198. // to create an interface we need a phone book entry
  199. // for it.
  200. //
  201. dwErr = RtrdbValidatePhoneBookEntry(pIfInfo->wszInterfaceName);
  202. if(dwErr isnot NO_ERROR)
  203. {
  204. DisplayMessage(g_hModule,
  205. EMSG_NO_PHONEBOOK,
  206. pIfInfo->wszInterfaceName);
  207. return dwErr;
  208. }
  209. }
  210. else
  211. {
  212. DisplayMessage(g_hModule,
  213. EMSG_BAD_IF_TYPE,
  214. pIfInfo->dwIfType);
  215. return ERROR_INVALID_PARAMETER;
  216. }
  217. //
  218. // create interface with defaults
  219. //
  220. pIfInfo->hInterface = INVALID_HANDLE_VALUE;
  221. dwErr = RtrInterfaceCreate(pIfInfo);
  222. if(dwErr isnot NO_ERROR)
  223. {
  224. DisplayMessage(g_hModule,
  225. EMSG_CANT_CREATE_IF,
  226. pIfInfo->wszInterfaceName,
  227. dwErr);
  228. }
  229. return dwErr;
  230. }
  231. DWORD
  232. RtrdbInterfaceDelete(
  233. IN PWCHAR pwszIfName
  234. )
  235. {
  236. DWORD dwErr, dwSize, dwIfType;
  237. HANDLE hIfCfg, hIfAdmin;
  238. GUID Guid;
  239. PMPR_INTERFACE_0 pIfInfo;
  240. do
  241. {
  242. dwErr = MprConfigInterfaceGetHandle(g_hMprConfig,
  243. pwszIfName,
  244. &hIfCfg);
  245. if(dwErr isnot NO_ERROR)
  246. {
  247. break;
  248. }
  249. dwErr = MprConfigInterfaceGetInfo(g_hMprConfig,
  250. hIfCfg,
  251. 0,
  252. (PBYTE *)&pIfInfo,
  253. &dwSize);
  254. if(dwErr isnot NO_ERROR)
  255. {
  256. break;
  257. }
  258. if(pIfInfo->dwIfType isnot ROUTER_IF_TYPE_FULL_ROUTER)
  259. {
  260. MprConfigBufferFree(pIfInfo);
  261. dwErr = ERROR_INVALID_PARAMETER;
  262. break;
  263. }
  264. if(IfutlIsRouterRunning())
  265. {
  266. dwErr = MprAdminInterfaceGetHandle(g_hMprAdmin,
  267. pwszIfName,
  268. &hIfAdmin,
  269. FALSE);
  270. if(dwErr isnot NO_ERROR)
  271. {
  272. break;
  273. }
  274. dwErr = MprAdminInterfaceDelete(g_hMprAdmin,
  275. hIfAdmin);
  276. if(dwErr isnot NO_ERROR)
  277. {
  278. break;
  279. }
  280. }
  281. dwIfType = pIfInfo->dwIfType;
  282. dwErr = MprConfigInterfaceDelete(g_hMprConfig,
  283. hIfCfg);
  284. MprConfigBufferFree(pIfInfo);
  285. if(dwErr isnot NO_ERROR)
  286. {
  287. break;
  288. }
  289. }while(FALSE);
  290. return dwErr;
  291. }
  292. DWORD
  293. RtrdbInterfaceEnumerate(
  294. IN DWORD dwLevel,
  295. IN DWORD dwFormat,
  296. IN RTR_IF_ENUM_FUNC pEnum,
  297. IN HANDLE hData
  298. )
  299. {
  300. DWORD dwErr, i, dwCount, dwTotal, dwResume, dwPrefBufSize;
  301. MPR_INTERFACE_0* pCurIf = NULL;
  302. LPBYTE pbBuffer = NULL;
  303. BOOL bRouter, bContinue;
  304. // Validate / Initiazlize
  305. if (pEnum == NULL)
  306. {
  307. return ERROR_INVALID_PARAMETER;
  308. }
  309. dwPrefBufSize = sizeof(MPR_INTERFACE_0) * 100;
  310. bRouter = IfutlIsRouterRunning();
  311. dwResume = 0;
  312. do
  313. {
  314. // Enumerate the first n interfaces
  315. //
  316. if (bRouter)
  317. {
  318. dwErr = MprAdminInterfaceEnum(
  319. g_hMprAdmin,
  320. 0,
  321. &pbBuffer,
  322. dwPrefBufSize,
  323. &dwCount,
  324. &dwTotal,
  325. &dwResume);
  326. }
  327. else
  328. {
  329. dwErr = MprConfigInterfaceEnum(
  330. g_hMprConfig,
  331. 0,
  332. &pbBuffer,
  333. dwPrefBufSize,
  334. &dwCount,
  335. &dwTotal,
  336. &dwResume);
  337. }
  338. if (dwErr == ERROR_MORE_DATA)
  339. {
  340. dwErr = NO_ERROR;
  341. bContinue = TRUE;
  342. }
  343. else
  344. {
  345. bContinue = FALSE;
  346. }
  347. if (dwErr != NO_ERROR)
  348. {
  349. break;
  350. }
  351. // Call the callback for each interface as long
  352. // as we're instructed to continue
  353. pCurIf = (MPR_INTERFACE_0*)pbBuffer;
  354. for (i = 0; (i < dwCount) && (dwErr == NO_ERROR); i++)
  355. {
  356. dwErr = (*pEnum)(
  357. pCurIf->wszInterfaceName,
  358. dwLevel,
  359. dwFormat,
  360. (PVOID)pCurIf,
  361. hData);
  362. pCurIf++;
  363. }
  364. if (dwErr != NO_ERROR)
  365. {
  366. break;
  367. }
  368. // Free up the interface list buffer
  369. if (pbBuffer)
  370. {
  371. if (bRouter)
  372. {
  373. MprAdminBufferFree(pbBuffer);
  374. }
  375. else
  376. {
  377. MprConfigBufferFree(pbBuffer);
  378. }
  379. pbBuffer = NULL;
  380. }
  381. // Keep this loop going until there are
  382. // no more interfaces
  383. //
  384. } while (bContinue);
  385. // Cleanup
  386. {
  387. }
  388. return dwErr;
  389. }
  390. DWORD
  391. RtrdbInterfaceRead(
  392. IN PWCHAR pwszIfName,
  393. IN DWORD dwLevel,
  394. IN PVOID pvInfo,
  395. IN BOOL bReadFromConfigOnError
  396. )
  397. {
  398. DWORD dwErr=NO_ERROR, dwSize;
  399. HANDLE hIfCfg, hIfAdmin;
  400. PMPR_INTERFACE_0 pInfo;
  401. do
  402. {
  403. pInfo = NULL;
  404. if(IfutlIsRouterRunning())
  405. {
  406. dwErr = MprAdminInterfaceGetHandle(g_hMprAdmin,
  407. pwszIfName,
  408. &hIfAdmin,
  409. FALSE);
  410. if(dwErr isnot NO_ERROR)
  411. {
  412. break;
  413. }
  414. dwErr = MprAdminInterfaceGetInfo(g_hMprAdmin,
  415. hIfAdmin,
  416. 0,
  417. (PBYTE *)&pInfo);
  418. if(dwErr isnot NO_ERROR)
  419. {
  420. break;
  421. }
  422. if (pInfo == NULL)
  423. {
  424. dwErr = ERROR_CAN_NOT_COMPLETE;
  425. break;
  426. }
  427. *((MPR_INTERFACE_0*)pvInfo) = *pInfo;
  428. MprAdminBufferFree(pInfo);
  429. }
  430. } while (FALSE);
  431. if (!IfutlIsRouterRunning()
  432. || (dwErr==ERROR_NO_SUCH_INTERFACE&&bReadFromConfigOnError))
  433. {
  434. do
  435. {
  436. pInfo = NULL;
  437. dwErr = MprConfigInterfaceGetHandle(g_hMprConfig,
  438. pwszIfName,
  439. &hIfCfg);
  440. if(dwErr isnot NO_ERROR)
  441. {
  442. break;
  443. }
  444. dwErr = MprConfigInterfaceGetInfo(g_hMprConfig,
  445. hIfCfg,
  446. 0,
  447. (PBYTE *)&pInfo,
  448. &dwSize);
  449. if(dwErr isnot NO_ERROR)
  450. {
  451. break;
  452. }
  453. *((MPR_INTERFACE_0*)pvInfo) = *pInfo;
  454. MprConfigBufferFree(pInfo);
  455. } while(FALSE);
  456. }
  457. return dwErr;
  458. }
  459. DWORD
  460. RtrdbInterfaceWrite(
  461. IN PWCHAR pwszIfName,
  462. IN DWORD dwLevel,
  463. IN PVOID pvInfo
  464. )
  465. {
  466. DWORD dwErr;
  467. HANDLE hIfCfg = NULL;
  468. MPR_INTERFACE_0* pIfInfo = (MPR_INTERFACE_0*)pvInfo;
  469. do
  470. {
  471. if(IfutlIsRouterRunning())
  472. {
  473. dwErr = MprAdminInterfaceSetInfo(g_hMprAdmin,
  474. pIfInfo->hInterface,
  475. 0,
  476. (BYTE*)pIfInfo);
  477. if(dwErr isnot NO_ERROR)
  478. {
  479. break;
  480. }
  481. dwErr = MprConfigInterfaceGetHandle(g_hMprConfig,
  482. pIfInfo->wszInterfaceName,
  483. &hIfCfg);
  484. if(dwErr isnot NO_ERROR)
  485. {
  486. break;
  487. }
  488. dwErr = MprConfigInterfaceSetInfo(g_hMprConfig,
  489. hIfCfg,
  490. 0,
  491. (BYTE*)pIfInfo);
  492. if(dwErr isnot NO_ERROR)
  493. {
  494. break;
  495. }
  496. }
  497. else
  498. {
  499. dwErr = MprConfigInterfaceSetInfo(g_hMprConfig,
  500. pIfInfo->hInterface,
  501. 0,
  502. (BYTE*)pIfInfo);
  503. if(dwErr isnot NO_ERROR)
  504. {
  505. break;
  506. }
  507. }
  508. } while(FALSE);
  509. return dwErr;
  510. }
  511. DWORD
  512. RtrdbInterfaceReadCredentials(
  513. IN PWCHAR pszIfName,
  514. IN PWCHAR pszUser OPTIONAL,
  515. IN PWCHAR pszPassword OPTIONAL,
  516. IN PWCHAR pszDomain OPTIONAL
  517. )
  518. {
  519. MPR_INTERFACE_0 If0;
  520. DWORD dwErr = NO_ERROR;
  521. do
  522. {
  523. ZeroMemory(&If0, sizeof(If0));
  524. dwErr = RtrdbInterfaceRead(
  525. pszIfName,
  526. 0,
  527. (PVOID)&If0,
  528. FALSE);
  529. BREAK_ON_DWERR(dwErr);
  530. if (If0.dwIfType != ROUTER_IF_TYPE_FULL_ROUTER)
  531. {
  532. DisplayError(g_hModule, EMSG_IF_BAD_CREDENTIALS_TYPE);
  533. dwErr = ERROR_CAN_NOT_COMPLETE;
  534. break;
  535. }
  536. // Set the credentials
  537. //
  538. if (pszUser)
  539. {
  540. pszUser[0] = L'\0';
  541. }
  542. if (pszDomain)
  543. {
  544. pszDomain[0] = L'\0';
  545. }
  546. if (pszPassword)
  547. {
  548. pszPassword[0] = L'\0';
  549. }
  550. dwErr = MprAdminInterfaceGetCredentials(
  551. g_pwszRouter,
  552. pszIfName,
  553. pszUser,
  554. NULL,
  555. pszDomain);
  556. BREAK_ON_DWERR(dwErr);
  557. if (pszPassword)
  558. {
  559. wcscpy(pszPassword, L"**********");
  560. }
  561. } while (FALSE);
  562. // Cleanup
  563. {
  564. }
  565. return dwErr;
  566. }
  567. DWORD
  568. RtrdbInterfaceWriteCredentials(
  569. IN PWCHAR pszIfName,
  570. IN PWCHAR pszUser OPTIONAL,
  571. IN PWCHAR pszPassword OPTIONAL,
  572. IN PWCHAR pszDomain OPTIONAL
  573. )
  574. {
  575. MPR_INTERFACE_0 If0;
  576. DWORD dwErr = NO_ERROR;
  577. do
  578. {
  579. ZeroMemory(&If0, sizeof(If0));
  580. dwErr = RtrdbInterfaceRead(
  581. pszIfName,
  582. 0,
  583. (PVOID)&If0,
  584. FALSE);
  585. BREAK_ON_DWERR(dwErr);
  586. if (If0.dwIfType != ROUTER_IF_TYPE_FULL_ROUTER)
  587. {
  588. DisplayError(g_hModule, EMSG_IF_BAD_CREDENTIALS_TYPE);
  589. dwErr = ERROR_CAN_NOT_COMPLETE;
  590. break;
  591. }
  592. // Set the credentials
  593. //
  594. dwErr = MprAdminInterfaceSetCredentials(
  595. g_pwszRouter,
  596. pszIfName,
  597. pszUser,
  598. pszDomain,
  599. pszPassword);
  600. BREAK_ON_DWERR(dwErr);
  601. } while (FALSE);
  602. // Cleanup
  603. {
  604. }
  605. return dwErr;
  606. }
  607. DWORD
  608. RtrdbInterfaceEnableDisable(
  609. IN PWCHAR pwszIfName,
  610. IN BOOL bEnable)
  611. {
  612. HRESULT hr = E_FAIL;
  613. INetConnectionManager *pNetConnectionManager = NULL;
  614. CoInitialize(NULL);
  615. hr = CoCreateInstance(&CLSID_ConnectionManager,
  616. NULL,
  617. CLSCTX_LOCAL_SERVER | CLSCTX_NO_CODE_DOWNLOAD,
  618. &IID_INetConnectionManager,
  619. (void**)(&pNetConnectionManager)
  620. );
  621. if (SUCCEEDED(hr))
  622. {
  623. // Get an enumurator for the set of connections on the system
  624. IEnumNetConnection* pEnumNetConnection;
  625. ULONG ulCount = 0;
  626. BOOL fFound = FALSE;
  627. HRESULT hrT = S_OK;
  628. INetConnectionManager_EnumConnections(pNetConnectionManager, NCME_DEFAULT, &pEnumNetConnection);
  629. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  630. // Enumurate through the list of adapters on the system and look for the one we want
  631. // NOTE: To include per-user RAS connections in the list, you need to set the COM
  632. // Proxy Blanket on all the interfaces. This is not needed for All-user RAS
  633. // connections or LAN connections.
  634. do
  635. {
  636. NETCON_PROPERTIES* pProps = NULL;
  637. INetConnection * pConn;
  638. // Find the next (or first connection)
  639. hrT = IEnumNetConnection_Next(pEnumNetConnection, 1, &pConn, &ulCount);
  640. if (SUCCEEDED(hrT) && 1 == ulCount)
  641. {
  642. hrT = INetConnection_GetProperties(pConn, &pProps); // Get the connection properties
  643. if (S_OK == hrT)
  644. {
  645. if (pwszIfName)
  646. {
  647. // Check if we have the correct connection (based on the name)
  648. if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, pwszIfName, -1, pProps->pszwName, -1) == CSTR_EQUAL)
  649. {
  650. fFound = TRUE;
  651. }
  652. }
  653. /*else
  654. {
  655. // Check if we have the correct connection (based on the GUID)
  656. if (IsEqualGUID(pProps->guidId, gdConnectionGuid))
  657. {
  658. fFound = TRUE;
  659. }
  660. }*/
  661. if (fFound)
  662. {
  663. if (bEnable)
  664. {
  665. hr = INetConnection_Connect(pConn);
  666. }
  667. else
  668. {
  669. hr = INetConnection_Disconnect(pConn);
  670. }
  671. }
  672. CoTaskMemFree (pProps->pszwName);
  673. CoTaskMemFree (pProps->pszwDeviceName);
  674. CoTaskMemFree (pProps);
  675. }
  676. INetConnection_Release(pConn);
  677. pConn = NULL;
  678. }
  679. } while (SUCCEEDED(hrT) && 1 == ulCount && !fFound);
  680. if (FAILED(hrT))
  681. {
  682. hr = hrT;
  683. }
  684. INetConnection_Release(pEnumNetConnection);
  685. }
  686. if (FAILED(hr) && hr != HRESULT_FROM_WIN32(ERROR_RETRY))
  687. {
  688. //printf("Could not enable or disable connection (0x%08x)\r\n", hr);
  689. }
  690. INetConnectionManager_Release(pNetConnectionManager);
  691. CoUninitialize();
  692. if (ERROR_RETRY == HRESULT_CODE(hr))
  693. {
  694. DisplayMessage(g_hModule, EMSG_COULD_NOT_GET_IPADDRESS);
  695. return ERROR_OKAY;
  696. }
  697. return HRESULT_CODE(hr);
  698. }
  699. DWORD
  700. RtrdbInterfaceRename(
  701. IN PWCHAR pwszIfName,
  702. IN DWORD dwLevel,
  703. IN PVOID pvInfo,
  704. IN PWCHAR pszNewName)
  705. {
  706. DWORD dwErr = NO_ERROR;
  707. HRESULT hr = S_OK;
  708. NTSTATUS ntStatus = STATUS_SUCCESS;
  709. UNICODE_STRING us;
  710. GUID Guid;
  711. do
  712. {
  713. // Get the guid from the interface name
  714. //
  715. RtlInitUnicodeString(&us, pwszIfName);
  716. ntStatus = RtlGUIDFromString(&us, &Guid);
  717. if (ntStatus != STATUS_SUCCESS)
  718. {
  719. dwErr = ERROR_BAD_FORMAT;
  720. break;
  721. }
  722. // Rename the interface
  723. //
  724. hr = HrRenameConnection(&Guid, pszNewName);
  725. if (FAILED(hr))
  726. {
  727. dwErr = HRESULT_CODE(hr);
  728. break;
  729. }
  730. } while (FALSE);
  731. // Cleanup
  732. //
  733. {
  734. }
  735. return dwErr;
  736. }
  737. DWORD
  738. RtrdbResetAll()
  739. {
  740. RTR_IF_LIST* pList = NULL, *pCur = NULL;
  741. DWORD dwErr = NO_ERROR;
  742. do
  743. {
  744. // Build a list of interfaces that can be
  745. // deleted
  746. //
  747. dwErr = RtrdbInterfaceEnumerate(
  748. 0,
  749. 0,
  750. RtrdbAddWanIfToList,
  751. (HANDLE)&pList);
  752. BREAK_ON_DWERR(dwErr);
  753. // Delete all of the interfaces
  754. //
  755. pCur = pList;
  756. while (pCur)
  757. {
  758. RtrdbInterfaceDelete(pCur->pszName);
  759. pCur = pCur->pNext;
  760. IfutlFree(pList);
  761. pList = pCur;
  762. }
  763. } while (FALSE);
  764. // Cleanup
  765. {
  766. }
  767. return NO_ERROR;
  768. }