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.

878 lines
29 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "sminc.h"
  4. #include "smpsh.h"
  5. #include "ncui.h"
  6. #include "ndispnp.h"
  7. extern const WCHAR c_szDevice[];
  8. #include "initguid.h"
  9. DEFINE_GUID(CLSID_SharedAccessConnectionManager, 0xBA126AE0,0x2166,0x11D1,0xB1,0xD0,0x00,0x80,0x5F,0xC1,0x27,0x0E); // REMOVE
  10. //+---------------------------------------------------------------------------
  11. //
  12. // Member: CSharedAccessStatEngine::CSharedAccessStatEngine
  13. //
  14. // Purpose: Creator
  15. //
  16. // Arguments: None
  17. //
  18. // Returns: Nil
  19. //
  20. CSharedAccessStatEngine::CSharedAccessStatEngine(VOID)
  21. {
  22. m_ncmType = NCM_SHAREDACCESSHOST_LAN;
  23. m_ncsmType = NCSM_NONE;
  24. m_dwCharacter = 0;
  25. m_pGlobalInterfaceTable = NULL;
  26. m_dwCommonInterfaceCookie = 0;
  27. m_dwWANConnectionCookie = 0;
  28. m_bRequested = FALSE;
  29. m_Status = NCS_CONNECTED;
  30. m_ulTotalBytesSent = 0;
  31. m_ulTotalBytesReceived = 0;
  32. m_ulTotalPacketsSent = 0;
  33. m_ulTotalPacketsReceived = 0;
  34. m_ulUptime = 0;
  35. m_ulSpeedbps = 0;
  36. return;
  37. }
  38. HRESULT CSharedAccessStatEngine::FinalConstruct(VOID)
  39. {
  40. HRESULT hr = S_OK;
  41. TraceError("CSharedAccessStatEngine::FinalConstruct", hr);
  42. return hr;
  43. }
  44. HRESULT CSharedAccessStatEngine::FinalRelease(VOID)
  45. {
  46. if(0 != m_dwCommonInterfaceCookie)
  47. {
  48. m_pGlobalInterfaceTable->RevokeInterfaceFromGlobal(m_dwCommonInterfaceCookie);
  49. }
  50. if(0 != m_dwWANConnectionCookie)
  51. {
  52. m_pGlobalInterfaceTable->RevokeInterfaceFromGlobal(m_dwWANConnectionCookie);
  53. }
  54. if(NULL != m_pGlobalInterfaceTable)
  55. {
  56. ReleaseObj(m_pGlobalInterfaceTable);
  57. }
  58. return S_OK;
  59. }
  60. HRESULT CSharedAccessStatEngine::Initialize(NETCON_MEDIATYPE MediaType, INetSharedAccessConnection* pNetSharedAccessConnection)
  61. {
  62. HRESULT hr;
  63. m_ncmType = MediaType;
  64. m_ncsmType = NCSM_NONE;
  65. IGlobalInterfaceTable* pGlobalInterfaceTable;
  66. hr = HrCreateInstance(CLSID_StdGlobalInterfaceTable, CLSCTX_INPROC_SERVER, &m_pGlobalInterfaceTable);
  67. if(SUCCEEDED(hr))
  68. {
  69. GUID LocalDeviceGuid;
  70. hr = pNetSharedAccessConnection->GetLocalAdapterGUID(&LocalDeviceGuid);
  71. if(SUCCEEDED(hr))
  72. {
  73. const WCHAR c_szDevicePrefix[] = L"\\DEVICE\\";
  74. lstrcpy(m_szLocalDeviceGuidStorage, c_szDevicePrefix);
  75. SIZE_T DeviceLength = (sizeof(c_szDevicePrefix) / sizeof(WCHAR)) - 1;
  76. StringFromGUID2(LocalDeviceGuid, m_szLocalDeviceGuidStorage + DeviceLength, (sizeof(m_szLocalDeviceGuidStorage) / sizeof(WCHAR)) - DeviceLength);
  77. ::RtlInitUnicodeString(&m_LocalDeviceGuid, m_szLocalDeviceGuidStorage);
  78. }
  79. if(SUCCEEDED(hr))
  80. {
  81. IUPnPService* pWANCommonInterfaceConfigService;
  82. hr = pNetSharedAccessConnection->GetService(SAHOST_SERVICE_WANCOMMONINTERFACECONFIG, &pWANCommonInterfaceConfigService);
  83. if(SUCCEEDED(hr))
  84. {
  85. IUPnPService* pWANConnectionService;
  86. hr = pNetSharedAccessConnection->GetService(NCM_SHAREDACCESSHOST_LAN == m_ncmType ? SAHOST_SERVICE_WANIPCONNECTION : SAHOST_SERVICE_WANPPPCONNECTION, &pWANConnectionService);
  87. if(SUCCEEDED(hr))
  88. {
  89. hr = m_pGlobalInterfaceTable->RegisterInterfaceInGlobal(pWANCommonInterfaceConfigService, IID_IUPnPService, &m_dwCommonInterfaceCookie);
  90. if(SUCCEEDED(hr))
  91. {
  92. hr = m_pGlobalInterfaceTable->RegisterInterfaceInGlobal(pWANConnectionService, IID_IUPnPService, &m_dwWANConnectionCookie);
  93. }
  94. pWANConnectionService->Release();
  95. }
  96. pWANCommonInterfaceConfigService->Release();
  97. }
  98. }
  99. }
  100. return hr;
  101. }
  102. //+---------------------------------------------------------------------------
  103. //
  104. // Member: CSharedAccessStatEngine::HrUpdateData
  105. //
  106. // Purpose: Get new statistics from the devices. This data is used to be
  107. // displayed in the UI.
  108. //
  109. // Arguments: pdwChangeFlags - Where to modify the changed flags. This
  110. // param may be NULL.
  111. //
  112. // Returns: Error code
  113. //
  114. HRESULT
  115. CSharedAccessStatEngine::HrUpdateData (
  116. DWORD* pdwChangeFlags,
  117. BOOL* pfNoLongerConnected)
  118. {
  119. HRESULT hr = S_OK;
  120. // Initialize the output parameter.
  121. //
  122. *pfNoLongerConnected = FALSE;
  123. EnterCriticalSection(&g_csStatmonData);
  124. // Make sure we have a statistics structure
  125. //
  126. if (!m_psmEngineData)
  127. {
  128. m_psmEngineData = new STATMON_ENGINEDATA;
  129. if (m_psmEngineData)
  130. {
  131. ZeroMemory(m_psmEngineData, sizeof(STATMON_ENGINEDATA));
  132. }
  133. }
  134. if (m_psmEngineData)
  135. {
  136. if(FALSE == m_bRequested) // protected statmondata critsec
  137. {
  138. InternalAddRef(); // bump the refcount so the callback will have a valid ref
  139. m_bRequested = TRUE;
  140. if(0 == QueueUserWorkItem(StaticUpdateStats, this, WT_EXECUTEDEFAULT))
  141. {
  142. InternalRelease();
  143. m_bRequested = FALSE;
  144. }
  145. }
  146. if (fIsConnectedStatus(m_Status))
  147. {
  148. m_psmEngineData->SMED_CONNECTIONSTATUS = NCS_CONNECTED;
  149. // Update shared access data
  150. UINT64 uOldPacketsTransmitting = m_psmEngineData->SMED_PACKETSTRANSMITTING;
  151. UINT64 uOldPacketsReceiving = m_psmEngineData->SMED_PACKETSRECEIVING;
  152. m_psmEngineData->SMED_BYTESTRANSMITTING = static_cast<UINT64>(m_ulTotalBytesSent);
  153. m_psmEngineData->SMED_BYTESRECEIVING = static_cast<UINT64>(m_ulTotalBytesReceived);
  154. m_psmEngineData->SMED_PACKETSTRANSMITTING = static_cast<UINT64>(m_ulTotalPacketsSent);
  155. m_psmEngineData->SMED_PACKETSRECEIVING = static_cast<UINT64>(m_ulTotalPacketsReceived);
  156. m_psmEngineData->SMED_DURATION = static_cast<UINT>(m_ulUptime);
  157. m_psmEngineData->SMED_SPEEDTRANSMITTING = static_cast<UINT>(m_ulSpeedbps);
  158. m_psmEngineData->SMED_SPEEDRECEIVING = static_cast<UINT>(m_ulSpeedbps);
  159. // update the change flags
  160. if (pdwChangeFlags)
  161. {
  162. *pdwChangeFlags = SMDCF_NULL;
  163. if(uOldPacketsTransmitting != m_psmEngineData->SMED_PACKETSTRANSMITTING)
  164. {
  165. *pdwChangeFlags |= SMDCF_TRANSMITTING;
  166. }
  167. if(uOldPacketsReceiving != m_psmEngineData->SMED_PACKETSRECEIVING)
  168. {
  169. *pdwChangeFlags |= SMDCF_RECEIVING;
  170. }
  171. }
  172. HrGetAutoNetSetting(m_guidId, &(m_psmEngineData->SMED_DHCP_ADDRESS_TYPE) );
  173. m_psmEngineData->SMED_INFRASTRUCTURE_MODE = IM_NOT_SUPPORTED;
  174. NIC_STATISTICS nsNewLanStats;
  175. ZeroMemory(&nsNewLanStats, sizeof(nsNewLanStats));
  176. nsNewLanStats.Size = sizeof(NIC_STATISTICS);
  177. if(::NdisQueryStatistics(&m_LocalDeviceGuid, &nsNewLanStats))
  178. {
  179. m_psmEngineData->SMED_SALOCAL_BYTESTRANSMITTING = nsNewLanStats.BytesSent;
  180. m_psmEngineData->SMED_SALOCAL_BYTESRECEIVING = nsNewLanStats.DirectedBytesReceived;
  181. m_psmEngineData->SMED_SALOCAL_PACKETSTRANSMITTING = nsNewLanStats.PacketsSent;
  182. m_psmEngineData->SMED_SALOCAL_PACKETSRECEIVING = nsNewLanStats.DirectedPacketsReceived;
  183. }
  184. }
  185. else
  186. {
  187. *pfNoLongerConnected = TRUE;
  188. m_psmEngineData->SMED_CONNECTIONSTATUS = NCS_DISCONNECTED;
  189. }
  190. }
  191. else
  192. {
  193. hr = E_OUTOFMEMORY;
  194. }
  195. LeaveCriticalSection(&g_csStatmonData);
  196. TraceError("CSharedAccessStatEngine::HrUpdateData", hr);
  197. return hr;
  198. }
  199. HRESULT CSharedAccessStatEngine::UpdateStats()
  200. {
  201. HRESULT hr = S_OK;
  202. IUPnPService* pWANConnection;
  203. hr = m_pGlobalInterfaceTable->GetInterfaceFromGlobal(m_dwWANConnectionCookie, IID_IUPnPService, reinterpret_cast<void**>(&pWANConnection));
  204. if(SUCCEEDED(hr))
  205. {
  206. IUPnPService* pWANCommonInterfaceConfig;
  207. hr = m_pGlobalInterfaceTable->GetInterfaceFromGlobal(m_dwCommonInterfaceCookie, IID_IUPnPService, reinterpret_cast<void**>(&pWANCommonInterfaceConfig));
  208. if(SUCCEEDED(hr))
  209. {
  210. BSTR ConnectionStatus;
  211. hr = GetStringStateVariable(pWANConnection, L"ConnectionStatus", &ConnectionStatus);
  212. if(SUCCEEDED(hr))
  213. {
  214. if(0 == lstrcmp(ConnectionStatus, L"Connected"))
  215. {
  216. m_Status = NCS_CONNECTED;
  217. VARIANT OutArgs;
  218. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"X_GetICSStatistics", &OutArgs);
  219. if(SUCCEEDED(hr))
  220. {
  221. SAFEARRAY* pArray = V_ARRAY(&OutArgs);
  222. LONG lIndex = 0;
  223. VARIANT Param;
  224. lIndex = 0;
  225. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  226. if(SUCCEEDED(hr))
  227. {
  228. if(V_VT(&Param) == VT_UI4)
  229. {
  230. m_ulTotalBytesSent = V_UI4(&Param);
  231. }
  232. VariantClear(&Param);
  233. }
  234. lIndex = 1;
  235. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  236. if(SUCCEEDED(hr))
  237. {
  238. if(V_VT(&Param) == VT_UI4)
  239. {
  240. m_ulTotalBytesReceived = V_UI4(&Param);
  241. }
  242. VariantClear(&Param);
  243. }
  244. lIndex = 2;
  245. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  246. if(SUCCEEDED(hr))
  247. {
  248. if(V_VT(&Param) == VT_UI4)
  249. {
  250. m_ulTotalPacketsSent = V_UI4(&Param);
  251. }
  252. VariantClear(&Param);
  253. }
  254. lIndex = 3;
  255. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  256. if(SUCCEEDED(hr))
  257. {
  258. if(V_VT(&Param) == VT_UI4)
  259. {
  260. m_ulTotalPacketsReceived = V_UI4(&Param);
  261. }
  262. VariantClear(&Param);
  263. }
  264. lIndex = 4;
  265. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  266. if(SUCCEEDED(hr))
  267. {
  268. if(V_VT(&Param) == VT_UI4)
  269. {
  270. m_ulSpeedbps = V_UI4(&Param);
  271. }
  272. VariantClear(&Param);
  273. }
  274. lIndex = 5;
  275. hr = SafeArrayGetElement(pArray, &lIndex, &Param);
  276. if(SUCCEEDED(hr))
  277. {
  278. if(V_VT(&Param) == VT_UI4)
  279. {
  280. m_ulUptime = V_UI4(&Param);
  281. }
  282. VariantClear(&Param);
  283. }
  284. VariantClear(&OutArgs);
  285. }
  286. else if(UPNP_E_INVALID_ACTION == hr) // gateway does not support our custom action, revert to default chatty behavior
  287. {
  288. VARIANT OutArgs;
  289. LONG lIndex = 0;
  290. VARIANT Param;
  291. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"GetTotalBytesSent", &OutArgs);
  292. if(SUCCEEDED(hr))
  293. {
  294. lIndex = 0;
  295. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  296. if(SUCCEEDED(hr))
  297. {
  298. if(V_VT(&Param) == VT_UI4)
  299. {
  300. m_ulTotalBytesSent = V_UI4(&Param);
  301. }
  302. VariantClear(&Param);
  303. }
  304. VariantClear(&OutArgs);
  305. }
  306. if(SUCCEEDED(hr))
  307. {
  308. lIndex = 0;
  309. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"GetTotalBytesReceived", &OutArgs);
  310. if(SUCCEEDED(hr))
  311. {
  312. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  313. if(SUCCEEDED(hr))
  314. {
  315. if(V_VT(&Param) == VT_UI4)
  316. {
  317. m_ulTotalBytesReceived = V_UI4(&Param);
  318. }
  319. VariantClear(&Param);
  320. }
  321. VariantClear(&OutArgs);
  322. }
  323. }
  324. if(SUCCEEDED(hr))
  325. {
  326. lIndex = 0;
  327. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"GetTotalPacketsSent", &OutArgs);
  328. if(SUCCEEDED(hr))
  329. {
  330. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  331. if(SUCCEEDED(hr))
  332. {
  333. if(V_VT(&Param) == VT_UI4)
  334. {
  335. m_ulTotalPacketsSent = V_UI4(&Param);
  336. }
  337. VariantClear(&Param);
  338. }
  339. VariantClear(&OutArgs);
  340. }
  341. }
  342. if(SUCCEEDED(hr))
  343. {
  344. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"GetTotalPacketsReceived", &OutArgs);
  345. if(SUCCEEDED(hr))
  346. {
  347. lIndex = 0;
  348. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  349. if(SUCCEEDED(hr))
  350. {
  351. if(V_VT(&Param) == VT_UI4)
  352. {
  353. m_ulTotalPacketsReceived = V_UI4(&Param);
  354. }
  355. VariantClear(&Param);
  356. }
  357. VariantClear(&OutArgs);
  358. }
  359. }
  360. if(SUCCEEDED(hr))
  361. {
  362. hr = InvokeVoidAction(pWANCommonInterfaceConfig, L"GetCommonLinkProperties", &OutArgs);
  363. if(SUCCEEDED(hr))
  364. {
  365. lIndex = 2;
  366. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  367. if(SUCCEEDED(hr))
  368. {
  369. if(V_VT(&Param) == VT_UI4)
  370. {
  371. m_ulSpeedbps = V_UI4(&Param);
  372. }
  373. VariantClear(&Param);
  374. }
  375. VariantClear(&OutArgs);
  376. }
  377. }
  378. if(SUCCEEDED(hr))
  379. {
  380. hr = InvokeVoidAction(pWANConnection, L"GetStatusInfo", &OutArgs);
  381. if(SUCCEEDED(hr))
  382. {
  383. lIndex = 2;
  384. hr = SafeArrayGetElement(V_ARRAY(&OutArgs), &lIndex, &Param);
  385. if(SUCCEEDED(hr))
  386. {
  387. if(V_VT(&Param) == VT_UI4)
  388. {
  389. m_ulUptime = V_UI4(&Param);
  390. }
  391. VariantClear(&Param);
  392. }
  393. VariantClear(&OutArgs);
  394. }
  395. }
  396. if(UPNP_E_INVALID_ACTION == hr)
  397. {
  398. hr = S_OK; // server does not support statistics
  399. m_ulTotalBytesSent = 0;
  400. m_ulTotalBytesReceived = 0;
  401. m_ulTotalPacketsSent = 0;
  402. m_ulTotalPacketsReceived = 0;
  403. m_ulSpeedbps = 0;
  404. m_ulUptime = 0;
  405. }
  406. }
  407. if(FAILED(hr))
  408. {
  409. m_Status = NCS_DISCONNECTED;
  410. }
  411. }
  412. else
  413. {
  414. m_Status = NCS_DISCONNECTED;
  415. }
  416. SysFreeString(ConnectionStatus);
  417. }
  418. ReleaseObj(pWANCommonInterfaceConfig);
  419. }
  420. ReleaseObj(pWANConnection);
  421. }
  422. m_bRequested = FALSE;
  423. InternalRelease(); // release ref given to us in HrUpdateData
  424. return hr;
  425. }
  426. DWORD CSharedAccessStatEngine::StaticUpdateStats(LPVOID lpParameter)
  427. {
  428. HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  429. if(SUCCEEDED(hr))
  430. {
  431. CSharedAccessStatEngine* pThis = reinterpret_cast<CSharedAccessStatEngine*>(lpParameter);
  432. hr = pThis->UpdateStats();
  433. CoUninitialize();
  434. }
  435. return 0;
  436. }
  437. HRESULT CSharedAccessStatEngine::GetStringStateVariable(IUPnPService* pService, LPWSTR pszVariableName, BSTR* pString)
  438. {
  439. HRESULT hr = S_OK;
  440. VARIANT Variant;
  441. VariantInit(&Variant);
  442. BSTR VariableName;
  443. VariableName = SysAllocString(pszVariableName);
  444. if(NULL != VariableName)
  445. {
  446. hr = pService->QueryStateVariable(VariableName, &Variant);
  447. if(SUCCEEDED(hr))
  448. {
  449. if(V_VT(&Variant) == VT_BSTR)
  450. {
  451. *pString = V_BSTR(&Variant);
  452. }
  453. else
  454. {
  455. hr = E_UNEXPECTED;
  456. }
  457. }
  458. if(FAILED(hr))
  459. {
  460. VariantClear(&Variant);
  461. }
  462. SysFreeString(VariableName);
  463. }
  464. else
  465. {
  466. hr = E_OUTOFMEMORY;
  467. }
  468. TraceHr (ttidError, FAL, hr, FALSE, "CSharedAccessConnection::GetStringStateVariable");
  469. return hr;
  470. }
  471. HRESULT CSharedAccessStatEngine::InvokeVoidAction(IUPnPService * pService, LPTSTR pszCommand, VARIANT* pOutParams)
  472. {
  473. HRESULT hr;
  474. BSTR bstrActionName;
  475. bstrActionName = SysAllocString(pszCommand);
  476. if (NULL != bstrActionName)
  477. {
  478. SAFEARRAYBOUND rgsaBound[1];
  479. SAFEARRAY * psa = NULL;
  480. rgsaBound[0].lLbound = 0;
  481. rgsaBound[0].cElements = 0;
  482. psa = SafeArrayCreate(VT_VARIANT, 1, rgsaBound);
  483. if (psa)
  484. {
  485. LONG lStatus;
  486. VARIANT varInArgs;
  487. VARIANT varReturnVal;
  488. VariantInit(&varInArgs);
  489. VariantInit(pOutParams);
  490. VariantInit(&varReturnVal);
  491. varInArgs.vt = VT_VARIANT | VT_ARRAY;
  492. V_ARRAY(&varInArgs) = psa;
  493. hr = pService->InvokeAction(bstrActionName,
  494. varInArgs,
  495. pOutParams,
  496. &varReturnVal);
  497. if(SUCCEEDED(hr))
  498. {
  499. VariantClear(&varReturnVal);
  500. }
  501. SafeArrayDestroy(psa);
  502. }
  503. else
  504. {
  505. hr = E_OUTOFMEMORY;
  506. }
  507. SysFreeString(bstrActionName);
  508. }
  509. else
  510. {
  511. hr = E_OUTOFMEMORY;
  512. }
  513. return hr;
  514. }
  515. //////////////////////////////////////////////////////////////////////////////
  516. // //
  517. // CPspSharedAccessGen //
  518. // //
  519. //////////////////////////////////////////////////////////////////////////////
  520. CPspSharedAccessGen::CPspSharedAccessGen(VOID)
  521. {
  522. m_ncmType = NCM_SHAREDACCESSHOST_LAN;
  523. m_ncsmType = NCSM_NONE;
  524. m_dwCharacter =0;
  525. m_adwHelpIDs = NULL;
  526. return;
  527. }
  528. //+---------------------------------------------------------------------------
  529. //
  530. // Member: CPspSharedAccessGen::put_MediaType
  531. //
  532. // Purpose: Set the media typew
  533. //
  534. // Arguments: ncm - the media type
  535. // ncsm - the submedia type
  536. //
  537. // Returns: Nothing
  538. //
  539. void CPspSharedAccessGen::put_MediaType(NETCON_MEDIATYPE ncm, NETCON_SUBMEDIATYPE ncsm)
  540. {
  541. m_ncmType = ncm;
  542. m_ncsmType = ncsm;
  543. }
  544. //+---------------------------------------------------------------------------
  545. //
  546. // Member: CPspSharedAccessGen::ShouldShowPackets
  547. //
  548. // Purpose: Decided whether to show bytes or packets
  549. //
  550. // Arguments: pseNewData - The new stats being displayed on the page
  551. //
  552. // Returns: Nothing
  553. //
  554. BOOL CPspSharedAccessGen::ShouldShowPackets(const STATMON_ENGINEDATA* pseNewData)
  555. {
  556. return (((0 == pseNewData->SMED_BYTESTRANSMITTING) && (0 == pseNewData->SMED_BYTESRECEIVING)) ||
  557. ((0 == pseNewData->SMED_SALOCAL_BYTESTRANSMITTING) && (0 == pseNewData->SMED_SALOCAL_BYTESRECEIVING))); // REVIEW assuming all adapters can show packets
  558. }
  559. //+---------------------------------------------------------------------------
  560. //
  561. // Member: CPspSharedAccessGen::UpdatePageBytesTransmitting
  562. //
  563. // Purpose: Updates the bytes Transmitting display for the ICS host on the general page
  564. //
  565. // Arguments: pseOldData - The old stats being displayed on the page
  566. // pseNewData - The new stats being displayed on the page
  567. // iStat - The which stats to display
  568. //
  569. // Returns: Nothing
  570. //
  571. VOID
  572. CPspSharedAccessGen::UpdatePageBytesTransmitting(
  573. const STATMON_ENGINEDATA* pseOldData,
  574. const STATMON_ENGINEDATA* pseNewData,
  575. StatTrans iStat)
  576. {
  577. if(0 != pseNewData->SMED_SPEEDTRANSMITTING) // we use 0 in the speed field to indicate that statistics are not valid
  578. {
  579. CPspStatusMonitorGen::UpdatePageBytesTransmitting(pseOldData, pseNewData, iStat); // First update the local data
  580. }
  581. else
  582. {
  583. SetDlgItemText(IDC_TXT_SM_BYTES_TRANS, SzLoadIds(IDS_SM_NOTAVAILABLE));
  584. }
  585. UINT64 ui64Old;
  586. UINT64 ui64New;
  587. if (Stat_Bytes == iStat)
  588. {
  589. ui64Old = pseOldData->SMED_SALOCAL_BYTESTRANSMITTING;
  590. ui64New = pseNewData->SMED_SALOCAL_BYTESTRANSMITTING;
  591. }
  592. else
  593. {
  594. ui64Old = pseOldData->SMED_SALOCAL_PACKETSTRANSMITTING;
  595. ui64New = pseNewData->SMED_SALOCAL_PACKETSTRANSMITTING;
  596. }
  597. // See if either is different
  598. //
  599. if (ui64Old != ui64New)
  600. {
  601. SetDlgItemFormatted64bitInteger(
  602. m_hWnd,
  603. IDC_TXT_SM_SALOCAL_BYTES_TRANS,
  604. ui64New, FALSE);
  605. }
  606. }
  607. //+---------------------------------------------------------------------------
  608. //
  609. // Member: CPspSharedAccessGen::UpdatePageBytesReceiving
  610. //
  611. // Purpose: Updates the bytes receiving display for the ICS host on the general page
  612. //
  613. // Arguments: puiOld - The old stats being displayed on the page
  614. // puiNew - The new stats being displayed on the page
  615. // iStat - The which stats to display
  616. //
  617. // Returns: Nothing
  618. //
  619. VOID
  620. CPspSharedAccessGen::UpdatePageBytesReceiving(
  621. const STATMON_ENGINEDATA* pseOldData,
  622. const STATMON_ENGINEDATA* pseNewData,
  623. StatTrans iStat)
  624. {
  625. if(0 != pseNewData->SMED_SPEEDTRANSMITTING) // we use 0 in the speed field to indicate that statistics are not valid
  626. {
  627. CPspStatusMonitorGen::UpdatePageBytesReceiving(pseOldData, pseNewData, iStat); // First update the local data
  628. }
  629. else
  630. {
  631. SetDlgItemText(IDC_TXT_SM_BYTES_RCVD, SzLoadIds(IDS_SM_NOTAVAILABLE));
  632. }
  633. UINT64 ui64Old;
  634. UINT64 ui64New;
  635. if (Stat_Bytes == iStat)
  636. {
  637. ui64Old = pseOldData->SMED_SALOCAL_BYTESRECEIVING;
  638. ui64New = pseNewData->SMED_SALOCAL_BYTESRECEIVING;
  639. }
  640. else
  641. {
  642. ui64Old = pseOldData->SMED_SALOCAL_PACKETSRECEIVING;
  643. ui64New = pseNewData->SMED_SALOCAL_PACKETSRECEIVING;
  644. }
  645. // See if either is different
  646. //
  647. if (ui64Old != ui64New)
  648. {
  649. SetDlgItemFormatted64bitInteger(
  650. m_hWnd,
  651. IDC_TXT_SM_SALOCAL_BYTES_RCVD,
  652. ui64New, FALSE);
  653. }
  654. }
  655. VOID CPspSharedAccessGen::UpdatePageIcon(DWORD dwChangeFlags)
  656. {
  657. // Keep the flags for the next update
  658. //
  659. m_dwChangeFlags = dwChangeFlags;
  660. }
  661. VOID CPspSharedAccessGen::UpdatePageSpeed(
  662. const STATMON_ENGINEDATA* pseOldData,
  663. const STATMON_ENGINEDATA* pseNewData)
  664. {
  665. if(0 != pseNewData->SMED_SPEEDTRANSMITTING) // we use 0 in the speed field to indicate that statistics are not valid
  666. {
  667. CPspStatusMonitorGen::UpdatePageSpeed(pseOldData, pseNewData);
  668. }
  669. else
  670. {
  671. SetDlgItemText(IDC_TXT_SM_SPEED, SzLoadIds(IDS_SM_NOTAVAILABLE));
  672. }
  673. }
  674. VOID
  675. CPspSharedAccessGen::UpdatePageDuration(
  676. const STATMON_ENGINEDATA* pseOldData,
  677. const STATMON_ENGINEDATA* pseNewData)
  678. {
  679. if(0 != pseNewData->SMED_SPEEDTRANSMITTING) // we use 0 in the speed field to indicate that statistics are not valid
  680. {
  681. CPspStatusMonitorGen::UpdatePageDuration(pseOldData, pseNewData);
  682. }
  683. else
  684. {
  685. SetDlgItemText(IDC_TXT_SM_DURATION, SzLoadIds(IDS_SM_NOTAVAILABLE));
  686. }
  687. }
  688. //////////////////////////////////////////////////////////////////////////////
  689. // //
  690. // CPspSharedAccessTool //
  691. // //
  692. //////////////////////////////////////////////////////////////////////////////
  693. CPspSharedAccessTool::CPspSharedAccessTool(VOID)
  694. {
  695. m_ncmType = NCM_SHAREDACCESSHOST_LAN;
  696. m_ncsmType = NCSM_NONE;
  697. m_dwCharacter = 0;
  698. return;
  699. }
  700. //+---------------------------------------------------------------------------
  701. //
  702. // Member: CPspSharedAccessTool::HrInitToolPageType
  703. //
  704. // Purpose: Gets from the connection any information that is relevant to
  705. // this particular connection type.
  706. //
  707. // Arguments: pncInit - The connection assocatied with this dialog
  708. //
  709. // Returns: Error code
  710. //
  711. HRESULT CPspSharedAccessTool::HrInitToolPageType(INetConnection* pncInit)
  712. {
  713. HRESULT hr = S_OK;
  714. TraceError("CPspSharedAccessTool::HrInitToolPageType", hr);
  715. return hr;
  716. }
  717. //+---------------------------------------------------------------------------
  718. //
  719. // Member: CPspSharedAccessTool::HrAddCommandLineFlags
  720. //
  721. // Purpose: Adds the flags for this selection to the command line for the
  722. // tool being launched.
  723. //
  724. // Arguments: pstrFlags - The command line that the flags have to be
  725. // appended to
  726. // psmteSel - The tool entry associated with this selection
  727. //
  728. // Returns: Error code
  729. //
  730. HRESULT CPspSharedAccessTool::HrAddCommandLineFlags(tstring* pstrFlags,
  731. CStatMonToolEntry* psmteSel)
  732. {
  733. HRESULT hr = S_OK;
  734. DWORD dwFlags = 0x0;
  735. // Same some indirections
  736. //
  737. dwFlags = psmteSel->dwFlags;
  738. //
  739. // // Check what flags are asked for and provide them if we can
  740. // //
  741. //
  742. // if (SCLF_ADAPTER & dwFlags)
  743. // {
  744. // pstrFlags->append(c_szCmdLineFlagPrefix);
  745. // pstrFlags->append(g_asmtfMap[STFI_ADAPTER].pszFlag);
  746. // pstrFlags->append(c_szSpace);
  747. // pstrFlags->append(m_strLocalDeviceName);
  748. // }
  749. TraceError("CPspStatusMonitorTool::HrAddCommandLineFlags", hr);
  750. return hr;
  751. }
  752. HRESULT CPspSharedAccessTool::HrGetDeviceType(INetConnection* pncInit)
  753. {
  754. UINT uiRet = 0;
  755. // Set the default type
  756. m_strDeviceType = L"Ethernet";
  757. return S_OK;
  758. }
  759. HRESULT CPspSharedAccessTool::HrGetComponentList(INetConnection* pncInit)
  760. {
  761. // Get a readonly INetCfg, enumerate components bound to this adapter
  762. HRESULT hr = S_OK;
  763. return hr;
  764. }