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