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.

879 lines
28 KiB

  1. // Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. //
  3. // penettab.c
  4. // Remote Access Common Dialog APIs
  5. // Phonebook Entry property sheet (Networking tab)
  6. //
  7. // 12/10/97 Shaun Cox
  8. //
  9. #include "rasdlgp.h"
  10. #include "entryps.h"
  11. #include "inetcfgp.h"
  12. #include "initguid.h"
  13. #include "netcfgp.h"
  14. #include "netconp.h"
  15. #include "devguid.h"
  16. #include "uiinfo.h"
  17. typedef struct
  18. _MAP_SZ_DWORD
  19. {
  20. LPCTSTR pszValue;
  21. DWORD dwValue;
  22. }
  23. MAP_SZ_DWORD;
  24. //For whistler bug#194394
  25. //For 64bit, IPX wont show up
  26. //For 32/64 bit, NETBEUI wont show up
  27. //
  28. #ifdef _WIN64
  29. static const MAP_SZ_DWORD c_mapProtocols [] =
  30. {
  31. { NETCFG_TRANS_CID_MS_TCPIP, NP_Ip },
  32. { NETCFG_TRANS_CID_MS_NETMON, NP_Netmon },
  33. };
  34. #else
  35. static const MAP_SZ_DWORD c_mapProtocols [] =
  36. {
  37. { NETCFG_TRANS_CID_MS_TCPIP, NP_Ip },
  38. { NETCFG_TRANS_CID_MS_NWIPX, NP_Ipx },
  39. { NETCFG_TRANS_CID_MS_NETMON, NP_Netmon },
  40. };
  41. #endif
  42. //+---------------------------------------------------------------------------
  43. //
  44. // Function: DwProtocolFromComponentId
  45. //
  46. // Purpose: Return the DWORD value of the protocol corresponding to
  47. // the string value in c_mapProtocols.
  48. //
  49. // Arguments:
  50. // pszComponentId [in] Component id to find.
  51. //
  52. // Returns: NP_xxx value
  53. //
  54. // Author: shaunco 13 Dec 1997
  55. //
  56. // Notes: The input argument must exist in c_mapProtocols.
  57. //
  58. DWORD
  59. DwProtocolFromComponentId (
  60. LPCTSTR pszComponentId)
  61. {
  62. int i;
  63. for (i = 0; i < sizeof(c_mapProtocols) / sizeof(c_mapProtocols[0]); i++)
  64. {
  65. if (0 == lstrcmpi (pszComponentId, c_mapProtocols[i].pszValue))
  66. {
  67. return c_mapProtocols[i].dwValue;
  68. }
  69. }
  70. // Should never get here as we should never pass a protocol that is not
  71. // in c_mapProtocols.
  72. //
  73. ASSERT (FALSE);
  74. return 0;
  75. }
  76. //+---------------------------------------------------------------------------
  77. //
  78. // Function: GetComponentImageIndex
  79. //
  80. // Purpose: Returns the index into pcild corresponding to the class of
  81. // pComponent.
  82. //
  83. // Arguments:
  84. // pComponent [in] Component who's class should be used.
  85. // pcild [in] Returned from SetupDiGetClassImageList
  86. //
  87. // Returns: A valid index or zero (which may also be valid).
  88. //
  89. // Author: shaunco 12 Dec 1997
  90. //
  91. // Notes:
  92. //
  93. int
  94. GetComponentImageIndex (
  95. INetCfgComponent* pComponent,
  96. SP_CLASSIMAGELIST_DATA* pcild)
  97. {
  98. int iImage = 0;
  99. GUID guidClass;
  100. HRESULT hr = INetCfgComponent_GetClassGuid (pComponent, &guidClass);
  101. if (SUCCEEDED(hr))
  102. {
  103. SetupDiGetClassImageIndex (pcild, &guidClass, &iImage);
  104. }
  105. return iImage;
  106. }
  107. //+---------------------------------------------------------------------------
  108. //
  109. // Function: HrEnumComponentsForListView
  110. //
  111. // Purpose: Return an array of INetCfgComponents that are candidates
  112. // for adding to our list view. This is composed of all
  113. // clients and servcies, and a few select protocols. (No
  114. // net adapters.) Hidden components could be returned and
  115. // should be checked before adding to the list view.
  116. //
  117. // Arguments:
  118. // pNetCfg [in]
  119. // celt [in]
  120. // rgelt [out]
  121. // pceltFetched [out]
  122. //
  123. // Returns: S_OK or an error.
  124. //
  125. // Author: shaunco 12 Dec 1997
  126. //
  127. // Notes:
  128. //
  129. HRESULT
  130. HrEnumComponentsForListView (
  131. INetCfg* pNetCfg,
  132. ULONG celt,
  133. INetCfgComponent** rgelt,
  134. ULONG* pceltFetched)
  135. {
  136. static const GUID* c_apguidClasses [] =
  137. {
  138. &GUID_DEVCLASS_NETCLIENT,
  139. &GUID_DEVCLASS_NETSERVICE,
  140. };
  141. HRESULT hr;
  142. int i;
  143. ULONG celtFetched = 0;
  144. // Initialize the output parameters.
  145. //
  146. ZeroMemory (rgelt, celt * sizeof (*rgelt));
  147. *pceltFetched = 0;
  148. // Enumerate the clients and services.
  149. //
  150. hr = HrEnumComponentsInClasses (pNetCfg,
  151. sizeof(c_apguidClasses) / sizeof(c_apguidClasses[0]),
  152. (GUID**)c_apguidClasses,
  153. celt, rgelt, &celtFetched);
  154. // Find the protocols if they are installed.
  155. //
  156. for (i = 0; i < sizeof(c_mapProtocols) / sizeof(c_mapProtocols[0]); i++)
  157. {
  158. INetCfgComponent* pComponent;
  159. hr = INetCfg_FindComponent (pNetCfg, c_mapProtocols[i].pszValue,
  160. &pComponent);
  161. if (S_OK == hr)
  162. {
  163. rgelt [celtFetched++] = pComponent;
  164. }
  165. }
  166. *pceltFetched = celtFetched;
  167. return S_OK;
  168. }
  169. //+---------------------------------------------------------------------------
  170. //
  171. // Function: HrNeRefreshListView
  172. //
  173. // Purpose: Clear and re-add all of the items that belong in the list
  174. // view.
  175. //
  176. // Arguments:
  177. // pInfo [in]
  178. //
  179. // Returns: S_OK or an error code.
  180. //
  181. // Author: shaunco 12 Dec 1997
  182. //
  183. // Notes:
  184. //
  185. HRESULT
  186. HrNeRefreshListView (
  187. PEINFO* pInfo)
  188. {
  189. HRESULT hr = S_OK;
  190. INetCfgComponent* aComponents [256];
  191. ULONG cComponents;
  192. HIMAGELIST himlSmall;
  193. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  194. PBFILE* pFile = pInfo->pArgs->pFile;
  195. // Delete all existing items. The LVN_DELETEITEM handler is expected to
  196. // release the objects we have attached prior.
  197. //
  198. ListView_DeleteAllItems (pInfo->hwndLvComponents);
  199. hr = HrEnumComponentsForListView (pInfo->pNetCfg,
  200. sizeof(aComponents)/sizeof(aComponents[0]),
  201. aComponents, &cComponents);
  202. if (SUCCEEDED(hr))
  203. {
  204. BOOL fHasPermission = TRUE;
  205. ULONG i;
  206. // check if user has any permission to change the bindings
  207. INetConnectionUiUtilities * pncuu = NULL;
  208. hr = HrCreateNetConnectionUtilities(&pncuu);
  209. if (SUCCEEDED(hr))
  210. {
  211. fHasPermission =
  212. INetConnectionUiUtilities_UserHasPermission(
  213. pncuu, NCPERM_ChangeBindState);
  214. INetConnectionUiUtilities_Release(pncuu);
  215. }
  216. for (i = 0; i < cComponents; i++)
  217. {
  218. INetCfgComponent* pComponent = aComponents [i];
  219. DWORD dwCharacter;
  220. LPWSTR pszwName = NULL;
  221. LPWSTR pszwId = NULL;
  222. int iItem;
  223. LV_ITEM item = {0};
  224. BOOL fCheck, fForceCheck = FALSE;
  225. GUID guid;
  226. BOOL fDisableCheckbox = FALSE;
  227. // We'll release it if inserting it failed or we decided to
  228. // skip it. By not releasing it, we pass ownership to the
  229. // list view.
  230. //
  231. BOOL fReleaseComponent = TRUE;
  232. // Don't add hidden components. Silently skip components
  233. // that we fail to get the class GUID or display name for.
  234. // (After all, what could we have the user do to fix the error?
  235. // Might as well show them what we can.)
  236. //
  237. if ( FAILED(INetCfgComponent_GetCharacteristics (pComponent, &dwCharacter))
  238. || (dwCharacter & NCF_HIDDEN)
  239. || FAILED(INetCfgComponent_GetDisplayName (pComponent, &pszwName)))
  240. {
  241. goto skip_component;
  242. }
  243. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  244. {
  245. WCHAR * pszwTmpId = NULL;
  246. //for whistler bug 29356 filter out Network Load Balancing
  247. //
  248. pszwTmpId = StrDupWFromT(NETCFG_SERVICE_CID_MS_WLBS);
  249. if(pszwTmpId)
  250. {
  251. if ( 0 == lstrcmpW(pszwId, pszwTmpId))
  252. {
  253. Free0(pszwTmpId);
  254. CoTaskMemFree (pszwId);
  255. goto skip_component;
  256. }
  257. Free0(pszwTmpId);
  258. }
  259. //
  260. //for .Net 605988 filter out IPX for x86 router case
  261. // IPX is already filtered our for 64 bit case
  262. //
  263. if( pInfo->pArgs->fRouter )
  264. {
  265. pszwTmpId = StrDupWFromT(NETCFG_TRANS_CID_MS_NWIPX);
  266. if(pszwTmpId)
  267. {
  268. if ( 0 == lstrcmpW(pszwId, pszwTmpId))
  269. {
  270. Free0(pszwTmpId);
  271. CoTaskMemFree (pszwId);
  272. goto skip_component;
  273. }
  274. Free0(pszwTmpId);
  275. }
  276. pszwTmpId = StrDupWFromT( TEXT("ms_nwnb") );
  277. if(pszwTmpId)
  278. {
  279. if ( 0 == lstrcmpW(pszwId, pszwTmpId))
  280. {
  281. Free0(pszwTmpId);
  282. CoTaskMemFree(pszwId);
  283. return FALSE;
  284. }
  285. Free0(pszwTmpId);
  286. }
  287. }
  288. CoTaskMemFree (pszwId);
  289. }
  290. // Disable the checkbox on components whose bindings are not user adjustable
  291. // or user has no permission to adjust binding
  292. if (NCF_FIXED_BINDING & dwCharacter)
  293. {
  294. fDisableCheckbox = TRUE;
  295. }
  296. // Bug #157213: Don't add any protocols other than IP if SLIP
  297. // is enabled
  298. //
  299. // Bug #294401: Also filter out CSNW when server type is SLIP
  300. if (pInfo->pArgs->pEntry->dwBaseProtocol == BP_Slip)
  301. {
  302. if (SUCCEEDED(INetCfgComponent_GetClassGuid(pComponent, &guid)))
  303. {
  304. BOOL fSkip = FALSE;
  305. if (IsEqualGUID(&guid, &GUID_DEVCLASS_NETTRANS))
  306. {
  307. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  308. {
  309. if (DwProtocolFromComponentId(pszwId) == NP_Ip)
  310. {
  311. // This item is IP. We should disable the check
  312. // box so the user can't disable TCP/IP in SLIP
  313. // mode. This is done after the item is inserted.
  314. //
  315. fDisableCheckbox = TRUE;
  316. // 122024
  317. //
  318. // We should also force the ui to show ip as enabled
  319. // since IP is always used with SLIP.
  320. //
  321. fForceCheck = TRUE;
  322. }
  323. else
  324. {
  325. fSkip = TRUE;
  326. }
  327. CoTaskMemFree (pszwId);
  328. }
  329. }
  330. else if (IsEqualGUID(&guid, &GUID_DEVCLASS_NETCLIENT))
  331. {
  332. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  333. {
  334. // For whistler 522872
  335. if ( CSTR_EQUAL == CompareStringW(
  336. LOCALE_INVARIANT,
  337. NORM_IGNORECASE,
  338. L"MS_NWCLIENT",
  339. -1,
  340. pszwId,
  341. -1
  342. )
  343. )
  344. {
  345. fSkip = TRUE;
  346. }
  347. CoTaskMemFree (pszwId);
  348. }
  349. }
  350. if (fSkip)
  351. {
  352. goto skip_component;
  353. }
  354. }
  355. }
  356. // pmay: 348623
  357. //
  358. // If we are remote admining a router, only allow tcpip and
  359. // ipx to be displayed.
  360. //
  361. if (pInfo->pArgs->fRouter && pInfo->pArgs->fRemote)
  362. {
  363. if (SUCCEEDED(INetCfgComponent_GetClassGuid(pComponent, &guid)))
  364. {
  365. BOOL fSkip = TRUE;
  366. DWORD dwId;
  367. if (IsEqualGUID(&guid, &GUID_DEVCLASS_NETTRANS))
  368. {
  369. if (SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  370. {
  371. dwId = DwProtocolFromComponentId(pszwId);
  372. if ((dwId == NP_Ip) || (dwId == NP_Ipx))
  373. {
  374. fSkip = FALSE;
  375. }
  376. CoTaskMemFree (pszwId);
  377. }
  378. }
  379. if (fSkip)
  380. {
  381. goto skip_component;
  382. }
  383. }
  384. }
  385. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  386. item.pszText = pszwName;
  387. item.iImage = GetComponentImageIndex (pComponent, &pInfo->cild);
  388. item.lParam = (LPARAM)pComponent;
  389. // Add the item.
  390. //
  391. iItem = ListView_InsertItem (pInfo->hwndLvComponents, &item);
  392. if (-1 != iItem)
  393. {
  394. // List view now has it. We can't release it.
  395. //
  396. fReleaseComponent = FALSE;
  397. // Set its check state.
  398. //
  399. if (! fForceCheck)
  400. {
  401. fCheck = NeIsComponentEnabled (pInfo, pComponent);
  402. }
  403. else
  404. {
  405. fCheck = TRUE;
  406. }
  407. ListView_SetCheck (pInfo->hwndLvComponents, iItem, fCheck);
  408. // Disable the checkbox if this is psched. We don't allow
  409. // users to change check state of psched from ras connections.
  410. // bug 255749 [raos].
  411. //
  412. if(SUCCEEDED(INetCfgComponent_GetId(pComponent, &pszwId)))
  413. {
  414. // Check to see if this is psched.
  415. //
  416. if( (0 == _wcsicmp(pszwId, L"ms_psched"))
  417. || (0 == _wcsicmp(pszwId, L"ms_NetMon")))
  418. {
  419. fDisableCheckbox = TRUE;
  420. }
  421. }
  422. if (fDisableCheckbox)
  423. {
  424. ListView_DisableCheck(pInfo->hwndLvComponents, iItem);
  425. }
  426. }
  427. skip_component:
  428. if (fReleaseComponent)
  429. {
  430. ReleaseObj (pComponent);
  431. }
  432. CoTaskMemFree (pszwName);
  433. }
  434. // Select first item
  435. ListView_SetItemState(pInfo->hwndLvComponents, 0,
  436. LVIS_SELECTED | LVIS_FOCUSED,
  437. LVIS_SELECTED | LVIS_FOCUSED);
  438. }
  439. return hr;
  440. }
  441. //+---------------------------------------------------------------------------
  442. //
  443. // Function: PComponentFromItemIndex
  444. //
  445. // Purpose: Return the INetCfgComponent associated with the specified
  446. // list view item.
  447. //
  448. // Arguments:
  449. // hwndLv [in]
  450. // iItem [in]
  451. //
  452. // Returns: A (non-AddRef'd) copy of the INetCfgComponent pointer
  453. // associated with the item.
  454. //
  455. // Author: shaunco 14 Dec 1997
  456. //
  457. // Notes: The returned value is NOT AddRef'd.
  458. //
  459. INetCfgComponent*
  460. PComponentFromItemIndex (
  461. HWND hwndLv,
  462. int iItem)
  463. {
  464. INetCfgComponent* pComponent = NULL;
  465. LV_ITEM item = {0};
  466. item.mask = LVIF_PARAM;
  467. item.iItem = iItem;
  468. if (ListView_GetItem (hwndLv, &item))
  469. {
  470. pComponent = (INetCfgComponent*)item.lParam;
  471. ASSERT (pComponent);
  472. }
  473. return pComponent;
  474. }
  475. //+---------------------------------------------------------------------------
  476. //
  477. // Function: PComponentFromCurSel
  478. //
  479. // Purpose:
  480. //
  481. // Arguments:
  482. // hwndLv [in] Window handle of list view
  483. // piItem [out] Optional address of integer to receive selected item.
  484. //
  485. // Returns:
  486. //
  487. // Author: shaunco 30 Dec 1997
  488. //
  489. // Notes:
  490. //
  491. INetCfgComponent*
  492. PComponentFromCurSel (
  493. HWND hwndLv,
  494. int* piItem)
  495. {
  496. INetCfgComponent* pComponent = NULL;
  497. // Get the current selection if it exists.
  498. //
  499. int iItem = ListView_GetNextItem (hwndLv, -1, LVNI_SELECTED);
  500. if (-1 != iItem)
  501. {
  502. // Get the component associated with the current selection. It must
  503. // exist.
  504. //
  505. pComponent = PComponentFromItemIndex (hwndLv, iItem);
  506. ASSERT (pComponent);
  507. }
  508. // Return the index of the item if requested.
  509. //
  510. if (piItem)
  511. {
  512. *piItem = iItem;
  513. }
  514. return pComponent;
  515. }
  516. //+---------------------------------------------------------------------------
  517. //
  518. // Function: PeQueryOrChangeComponentEnabled
  519. //
  520. // Purpose:
  521. //
  522. // Arguments:
  523. // pInfo []
  524. // pComponent []
  525. // fChange []
  526. // fNewValue []
  527. //
  528. // Returns:
  529. //
  530. // Author: shaunco 14 Dec 1997
  531. //
  532. // Notes:
  533. //
  534. BOOL
  535. NeQueryOrChangeComponentEnabled (
  536. PEINFO* pInfo,
  537. INetCfgComponent* pComponent,
  538. BOOL fChange,
  539. BOOL fValue)
  540. {
  541. BOOL fOldValue;
  542. GUID guidClass;
  543. HRESULT hr;
  544. hr = INetCfgComponent_GetClassGuid (pComponent, &guidClass);
  545. if (SUCCEEDED(hr))
  546. {
  547. LPWSTR pszwId;
  548. hr = INetCfgComponent_GetId (pComponent, &pszwId);
  549. if (SUCCEEDED(hr))
  550. {
  551. // We handle protocols in a hard-coded (er, well known) fashion.
  552. //
  553. if (IsEqualGUID (&guidClass, &GUID_DEVCLASS_NETTRANS))
  554. {
  555. DWORD* pdwValue = &pInfo->pArgs->pEntry->dwfExcludedProtocols;
  556. // Check if the protocol is exluded.
  557. //
  558. DWORD dwProtocol = DwProtocolFromComponentId (pszwId);
  559. if (fChange)
  560. {
  561. if (fValue)
  562. {
  563. // Include the protocol. (By not explicitly excluding
  564. // it.
  565. //
  566. *pdwValue &= ~dwProtocol;
  567. }
  568. else
  569. {
  570. // Exclude the protocol. (Remember, its a list of
  571. // excluded protocols.
  572. //
  573. *pdwValue |= dwProtocol;
  574. }
  575. }
  576. else
  577. {
  578. fValue = !(dwProtocol & *pdwValue);
  579. }
  580. }
  581. else
  582. {
  583. if (fChange)
  584. {
  585. EnableOrDisableNetComponent (pInfo->pArgs->pEntry,
  586. pszwId, fValue);
  587. }
  588. else
  589. {
  590. // Default to enabled for the case whenthe value isn't
  591. // found in the entry. This will be the case for pre-NT5
  592. // entries and entries that have not yet been to the
  593. // Networking tab for edits.
  594. //
  595. BOOL fEnabled;
  596. fValue = TRUE;
  597. if (FIsNetComponentListed(pInfo->pArgs->pEntry,
  598. pszwId, &fEnabled, NULL))
  599. {
  600. fValue = fEnabled;
  601. }
  602. }
  603. }
  604. CoTaskMemFree (pszwId);
  605. }
  606. }
  607. return fValue;
  608. }
  609. VOID
  610. NeEnableComponent (
  611. PEINFO* pInfo,
  612. INetCfgComponent* pComponent,
  613. BOOL fEnable)
  614. {
  615. NeQueryOrChangeComponentEnabled (pInfo, pComponent, TRUE, fEnable);
  616. }
  617. BOOL
  618. NeIsComponentEnabled (
  619. PEINFO* pInfo,
  620. INetCfgComponent* pComponent)
  621. {
  622. return NeQueryOrChangeComponentEnabled (pInfo, pComponent, FALSE, FALSE);
  623. }
  624. VOID
  625. NeShowComponentProperties (
  626. IN PEINFO* pInfo)
  627. {
  628. HRESULT hr;
  629. // Get the component for the current selection.
  630. //
  631. INetCfgComponent* pComponent;
  632. pComponent = PComponentFromCurSel (pInfo->hwndLvComponents, NULL);
  633. ASSERT (pComponent);
  634. if(NULL == pComponent)
  635. {
  636. return;
  637. }
  638. // Create the UI info callback object if we haven't done so yet.
  639. // If this fails, we can still show properties. TCP/IP just might
  640. // not know which UI-variant to show.
  641. //
  642. if (!pInfo->punkUiInfoCallback)
  643. {
  644. HrCreateUiInfoCallbackObject (pInfo, &pInfo->punkUiInfoCallback);
  645. }
  646. // Show the component's property UI. If S_OK is returned, it means
  647. // something changed.
  648. //
  649. hr = INetCfgComponent_RaisePropertyUi (pComponent,
  650. pInfo->hwndDlg,
  651. NCRP_SHOW_PROPERTY_UI,
  652. pInfo->punkUiInfoCallback);
  653. if (S_OK == hr)
  654. {
  655. // Get the INetCfgComponentPrivate interface so we can query the
  656. // notify object directly.
  657. //
  658. INetCfgComponentPrivate* pPrivate;
  659. hr = INetCfgComponent_QueryInterface (pComponent,
  660. &IID_INetCfgComponentPrivate,
  661. (VOID**)&pPrivate);
  662. if (SUCCEEDED(hr))
  663. {
  664. // Get the INetRasConnectionIpUiInfo interface from the notify
  665. // object.
  666. //
  667. INetRasConnectionIpUiInfo* pIpUiInfo;
  668. hr = INetCfgComponentPrivate_QueryNotifyObject (pPrivate,
  669. &IID_INetRasConnectionIpUiInfo,
  670. (VOID**)&pIpUiInfo);
  671. if (SUCCEEDED(hr))
  672. {
  673. // Get the UI info from TCP/IP.
  674. //
  675. RASCON_IPUI info;
  676. hr = INetRasConnectionIpUiInfo_GetUiInfo (pIpUiInfo, &info);
  677. if (SUCCEEDED(hr))
  678. {
  679. PBENTRY* pEntry = pInfo->pArgs->pEntry;
  680. // Get rid of our current data before we copy the new
  681. // data.
  682. //
  683. pEntry->dwIpAddressSource = ASRC_ServerAssigned;
  684. pEntry->dwIpNameSource = ASRC_ServerAssigned;
  685. Free0 (pEntry->pszIpAddress);
  686. pEntry->pszIpAddress = NULL;
  687. Free0 (pEntry->pszIpDnsAddress);
  688. pEntry->pszIpDnsAddress = NULL;
  689. Free0 (pEntry->pszIpDns2Address);
  690. pEntry->pszIpDns2Address = NULL;
  691. Free0 (pEntry->pszIpWinsAddress);
  692. pEntry->pszIpWinsAddress = NULL;
  693. Free0 (pEntry->pszIpWins2Address);
  694. pEntry->pszIpWins2Address = NULL;
  695. Free0 (pEntry->pszIpDnsSuffix);
  696. pEntry->pszIpDnsSuffix = StrDup (info.pszwDnsSuffix);
  697. if ((info.dwFlags & RCUIF_USE_IP_ADDR) &&
  698. *info.pszwIpAddr)
  699. {
  700. pEntry->dwIpAddressSource = ASRC_RequireSpecific;
  701. pEntry->pszIpAddress = StrDup (info.pszwIpAddr);
  702. }
  703. else
  704. {
  705. pEntry->dwIpAddressSource = ASRC_ServerAssigned;
  706. Free0 (pEntry->pszIpAddress);
  707. pEntry->pszIpAddress = NULL;
  708. }
  709. if (info.dwFlags & RCUIF_USE_NAME_SERVERS)
  710. {
  711. if (*info.pszwDnsAddr)
  712. {
  713. pEntry->dwIpNameSource = ASRC_RequireSpecific;
  714. pEntry->pszIpDnsAddress = StrDup (info.pszwDnsAddr);
  715. }
  716. if (*info.pszwDns2Addr)
  717. {
  718. pEntry->dwIpNameSource = ASRC_RequireSpecific;
  719. pEntry->pszIpDns2Address = StrDup (info.pszwDns2Addr);
  720. }
  721. if (*info.pszwWinsAddr)
  722. {
  723. pEntry->dwIpNameSource = ASRC_RequireSpecific;
  724. pEntry->pszIpWinsAddress = StrDup (info.pszwWinsAddr);
  725. }
  726. if (*info.pszwWins2Addr)
  727. {
  728. pEntry->dwIpNameSource = ASRC_RequireSpecific;
  729. pEntry->pszIpWins2Address = StrDup (info.pszwWins2Addr);
  730. }
  731. }
  732. // pmay: 389632
  733. //
  734. // Use this convoluted logic to store something reasonable
  735. // about the registration process.
  736. //
  737. if (info.dwFlags & RCUIF_USE_DISABLE_REGISTER_DNS)
  738. {
  739. pEntry->dwIpDnsFlags = 0;
  740. }
  741. else
  742. {
  743. BOOL bSuffix =
  744. ((pEntry->pszIpDnsSuffix) && (*(pEntry->pszIpDnsSuffix)));
  745. pEntry->dwIpDnsFlags = DNS_RegPrimary;
  746. if (info.dwFlags & RCUIF_USE_PRIVATE_DNS_SUFFIX)
  747. {
  748. if (bSuffix)
  749. {
  750. pEntry->dwIpDnsFlags |= DNS_RegPerConnection;
  751. }
  752. else
  753. {
  754. pEntry->dwIpDnsFlags |= DNS_RegDhcpInform;
  755. }
  756. }
  757. }
  758. // 277478
  759. // Enable the NBT over IP controls
  760. //
  761. if (info.dwFlags & RCUIF_ENABLE_NBT)
  762. {
  763. pEntry->dwIpNbtFlags = PBK_ENTRY_IP_NBT_Enable;
  764. }
  765. else
  766. {
  767. pEntry->dwIpNbtFlags = 0;
  768. }
  769. if (pInfo->pArgs->fRouter)
  770. {
  771. pEntry->fIpPrioritizeRemote = FALSE;
  772. }
  773. else
  774. {
  775. pEntry->fIpPrioritizeRemote = info.dwFlags & RCUIF_USE_REMOTE_GATEWAY;
  776. }
  777. pEntry->fIpHeaderCompression = info.dwFlags & RCUIF_USE_HEADER_COMPRESSION;
  778. pEntry->dwFrameSize = info.dwFrameSize;
  779. }
  780. ReleaseObj (pIpUiInfo);
  781. }
  782. ReleaseObj (pPrivate);
  783. }
  784. }
  785. }