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.

1419 lines
47 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: P V C D A T A. C P P
  7. //
  8. // Contents: PVC parameters
  9. //
  10. // Notes:
  11. //
  12. // Author: tongl 20 Feb, 1998
  13. //
  14. //-----------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "arpsobj.h"
  18. #include "auniobj.h"
  19. #include "atmutil.h"
  20. #include "ncstl.h"
  21. #include "pvcdata.h"
  22. #include "ncreg.h"
  23. extern const WCHAR c_szAdapters[];
  24. void SetPvcDwordParam(HKEY hkeyAdapterPVCId,
  25. PCWSTR pszParamName,
  26. DWORD dwParam)
  27. {
  28. HRESULT hrTmp;
  29. if (FIELD_UNSET == dwParam)
  30. {
  31. // delete the value
  32. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  33. pszParamName);
  34. }
  35. else
  36. {
  37. // save the value
  38. hrTmp = HrRegSetDword(hkeyAdapterPVCId, pszParamName, dwParam);
  39. }
  40. TraceTag(ttidAtmUni, "SetPvcDword Failed on %S", pszParamName);
  41. }
  42. void SetPvcBinaryParamFromString(HKEY hkeyAdapterPVCId,
  43. PCWSTR pszParamName,
  44. PCWSTR pszData)
  45. {
  46. HRESULT hrTmp;
  47. if (!(*pszData)) // empty string
  48. {
  49. // delete the value
  50. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId, pszParamName);
  51. }
  52. else
  53. {
  54. // convert to binary
  55. BYTE * pbData = NULL;
  56. DWORD cbData = 0;
  57. ConvertHexStringToBinaryWithAlloc(pszData, &pbData, &cbData);
  58. // save the value
  59. hrTmp = HrRegSetBinary(hkeyAdapterPVCId, pszParamName, pbData, cbData);
  60. delete pbData;
  61. }
  62. TraceTag(ttidAtmUni, "SetPvcBinaryParamFromString Failed on %S", pszParamName);
  63. }
  64. // Load PVC settings for the current adapter from registry to first memory
  65. HRESULT CAtmUniCfg::HrLoadPVCRegistry()
  66. {
  67. HRESULT hr = S_OK;
  68. HKEY hkeyUniParam;
  69. hr = m_pnccUni->OpenParamKey(&hkeyUniParam);
  70. if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  71. hr = S_OK;
  72. else if(SUCCEEDED(hr))
  73. {
  74. Assert(hkeyUniParam);
  75. // find the adapter we want to load
  76. for (UNI_ADAPTER_LIST::iterator iterAdapter = m_listAdapters.begin();
  77. iterAdapter != m_listAdapters.end();
  78. iterAdapter ++)
  79. {
  80. if (FIsSubstr(m_strGuidConn.c_str(), (*iterAdapter)->m_strBindName.c_str()))
  81. {
  82. // found the adapter we want to load ...
  83. // open the adapters subkey
  84. HKEY hkeyAdapters = NULL;
  85. hr = HrRegOpenKeyEx(hkeyUniParam, c_szAdapters,
  86. KEY_READ, &hkeyAdapters);
  87. if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  88. hr = S_OK;
  89. else if(SUCCEEDED(hr))
  90. {
  91. Assert(hkeyAdapters);
  92. HKEY hkeyAdapterParam = NULL;
  93. hr = HrRegOpenKeyEx(hkeyAdapters,
  94. (*iterAdapter)->m_strBindName.c_str(),
  95. KEY_READ, &hkeyAdapterParam);
  96. if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  97. hr = S_OK;
  98. else if(SUCCEEDED(hr))
  99. {
  100. Assert(hkeyAdapterParam);
  101. HrLoadAdapterPVCRegistry(hkeyAdapterParam, *iterAdapter);
  102. }
  103. RegSafeCloseKey(hkeyAdapterParam);
  104. }
  105. RegSafeCloseKey(hkeyAdapters);
  106. break;
  107. }
  108. }
  109. }
  110. RegSafeCloseKey(hkeyUniParam);
  111. TraceError("CAtmUniCfg::HrLoadPVCRegistry", hr);
  112. return hr;
  113. }
  114. HRESULT CAtmUniCfg::HrLoadAdapterPVCRegistry(HKEY hkeyAdapterParam,
  115. CUniAdapterInfo * pAdapterInfo)
  116. {
  117. HRESULT hr = S_OK;
  118. Assert(hkeyAdapterParam);
  119. Assert(pAdapterInfo);
  120. // there should not have been any PVC on the list
  121. Assert(pAdapterInfo->m_listPVCs.size() ==0);
  122. // open the PVC subkey and enumerate the PVCs under that
  123. HKEY hkeyAdapterPVC = NULL;
  124. hr = HrRegOpenKeyEx(hkeyAdapterParam,
  125. c_szPVC,
  126. KEY_READ,
  127. &hkeyAdapterPVC);
  128. if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  129. hr = S_OK;
  130. else if(SUCCEEDED(hr))
  131. {
  132. Assert(hkeyAdapterPVC);
  133. // enumerate the sub keys, and create a CPvcInfo object for each PVC
  134. VECSTR vstrPVCIdList;
  135. hr = HrLoadSubkeysFromRegistry(hkeyAdapterPVC, &vstrPVCIdList);
  136. // now load parameters for each PVC
  137. for (VECSTR::iterator iterPvcId = vstrPVCIdList.begin();
  138. iterPvcId != vstrPVCIdList.end();
  139. iterPvcId ++)
  140. {
  141. HKEY hkeyAdapterPVCId = NULL;
  142. hr = HrRegOpenKeyEx(hkeyAdapterPVC,
  143. (*iterPvcId)->c_str(),
  144. KEY_READ,
  145. &hkeyAdapterPVCId);
  146. if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  147. hr = S_OK;
  148. else if(SUCCEEDED(hr))
  149. {
  150. CPvcInfo * pNewPVC = new CPvcInfo((*iterPvcId)->c_str());
  151. if (pNewPVC)
  152. {
  153. pAdapterInfo->m_listPVCs.push_back(pNewPVC);
  154. HRESULT hrTmp = S_OK;
  155. // Get the PVC Type
  156. DWORD dwType;
  157. hrTmp = HrRegQueryDword(hkeyAdapterPVCId,
  158. c_szPVCType,
  159. &dwType);
  160. if (hrTmp == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  161. {
  162. pNewPVC->m_dwPVCType = PVC_CUSTOM;
  163. hrTmp = S_OK;
  164. }
  165. else if SUCCEEDED(hrTmp)
  166. {
  167. Assert( (dwType == PVC_ATMARP) ||
  168. (dwType == PVC_PPP_ATM_CLIENT) ||
  169. (dwType == PVC_PPP_ATM_SERVER) ||
  170. (dwType == PVC_CUSTOM));
  171. switch(dwType)
  172. {
  173. case PVC_ATMARP:
  174. pNewPVC->m_dwPVCType = PVC_ATMARP;
  175. break;
  176. case PVC_PPP_ATM_CLIENT:
  177. pNewPVC->m_dwPVCType = PVC_PPP_ATM_CLIENT;
  178. break;
  179. case PVC_PPP_ATM_SERVER:
  180. pNewPVC->m_dwPVCType = PVC_PPP_ATM_SERVER;
  181. break;
  182. default:
  183. pNewPVC->m_dwPVCType = PVC_CUSTOM;
  184. break;
  185. }
  186. }
  187. else
  188. {
  189. TraceError("Failed reading PVCType", hrTmp);
  190. hrTmp = S_OK;
  191. pNewPVC->m_dwPVCType = PVC_CUSTOM;
  192. }
  193. // set the default values for the type
  194. pNewPVC->SetDefaults(pNewPVC->m_dwPVCType);
  195. // now read any existing value from the registry
  196. // pvc name
  197. tstring strName;
  198. hrTmp = HrRegQueryString(hkeyAdapterPVCId, c_szPVCName, &strName);
  199. if SUCCEEDED(hrTmp)
  200. pNewPVC->m_strName = strName;
  201. // VPI (required), if failed, default to 0
  202. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szVpi, &(pNewPVC->m_dwVpi));
  203. // VCI (required), if failed, default to 0
  204. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szVci, &(pNewPVC->m_dwVci));
  205. // AAL Type
  206. DWORD dwAALType;
  207. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szAALType, &dwAALType);
  208. if SUCCEEDED(hrTmp)
  209. {
  210. switch (dwAALType)
  211. {
  212. /* $REVIEW(tongl 2/23/98): Per ArvindM, only AAL5 is supported in NT5
  213. case AAL_TYPE_AAL0:
  214. pNewPVC->m_dwAAL = AAL_TYPE_AAL0;
  215. break;
  216. case AAL_TYPE_AAL1:
  217. pNewPVC->m_dwAAL = AAL_TYPE_AAL1;
  218. break;
  219. case AAL_TYPE_AAL34:
  220. pNewPVC->m_dwAAL = AAL_TYPE_AAL34;
  221. break;
  222. */
  223. case AAL_TYPE_AAL5:
  224. pNewPVC->m_dwAAL = AAL_TYPE_AAL5;
  225. break;
  226. default:
  227. AssertSz(FALSE, "Invalid AAL type.");
  228. pNewPVC->m_dwAAL = AAL_TYPE_AAL5;
  229. }
  230. }
  231. // Local address
  232. tstring strCallingAddr;
  233. hrTmp = HrRegQueryString(hkeyAdapterPVCId, c_szCallingParty, &strCallingAddr);
  234. if SUCCEEDED(hrTmp)
  235. pNewPVC->m_strCallingAddr = strCallingAddr;
  236. // Destination address
  237. tstring strCalledAddr;
  238. hrTmp = HrRegQueryString(hkeyAdapterPVCId, c_szCalledParty, &strCalledAddr);
  239. if SUCCEEDED(hrTmp)
  240. pNewPVC->m_strCalledAddr = strCalledAddr;
  241. // Flags
  242. DWORD dwFlags;
  243. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szFlags, &dwFlags);
  244. if SUCCEEDED(hrTmp)
  245. pNewPVC->m_dwFlags = dwFlags;
  246. // Quality Info
  247. // TransmitPeakCellRate
  248. DWORD dwTransmitPeakCellRate;
  249. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szTransmitPeakCellRate,
  250. &dwTransmitPeakCellRate);
  251. if SUCCEEDED(hrTmp)
  252. pNewPVC->m_dwTransmitPeakCellRate = dwTransmitPeakCellRate*c_iCellSize/c_iKbSize;
  253. // TransmitAvgCellRate
  254. DWORD dwTransmitAvgCellRate;
  255. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szTransmitAvgCellRate,
  256. &dwTransmitAvgCellRate);
  257. if SUCCEEDED(hrTmp)
  258. pNewPVC->m_dwTransmitAvgCellRate = dwTransmitAvgCellRate*c_iCellSize/c_iKbSize;
  259. // TransmitByteBurstLength
  260. DWORD dwTransmitByteBurstLength;
  261. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szTransmitByteBurstLength,
  262. &dwTransmitByteBurstLength);
  263. if SUCCEEDED(hrTmp)
  264. pNewPVC->m_dwTransmitByteBurstLength = dwTransmitByteBurstLength;
  265. // TransmitMaxSduSize
  266. DWORD dwTransmitMaxSduSize;
  267. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szTransmitMaxSduSize,
  268. &dwTransmitMaxSduSize);
  269. if SUCCEEDED(hrTmp)
  270. pNewPVC->m_dwTransmitMaxSduSize = dwTransmitMaxSduSize;
  271. // TransmitServiceCategory
  272. DWORD dwTransmitServiceCategory;
  273. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szTransmitServiceCategory,
  274. &dwTransmitServiceCategory);
  275. if SUCCEEDED(hrTmp)
  276. {
  277. switch(dwTransmitServiceCategory)
  278. {
  279. case ATM_SERVICE_CATEGORY_CBR:
  280. pNewPVC->m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_CBR;
  281. break;
  282. case ATM_SERVICE_CATEGORY_VBR:
  283. pNewPVC->m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_VBR;
  284. break;
  285. case ATM_SERVICE_CATEGORY_UBR:
  286. pNewPVC->m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  287. break;
  288. case ATM_SERVICE_CATEGORY_ABR:
  289. pNewPVC->m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_ABR;
  290. break;
  291. default:
  292. AssertSz(FALSE, "Invalid service category.");
  293. pNewPVC->m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  294. }
  295. }
  296. // ReceivePeakCellRate
  297. DWORD dwReceivePeakCellRate;
  298. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szReceivePeakCellRate,
  299. &dwReceivePeakCellRate);
  300. if SUCCEEDED(hrTmp)
  301. pNewPVC->m_dwReceivePeakCellRate = dwReceivePeakCellRate*c_iCellSize/c_iKbSize;
  302. // ReceiveAvgCellRate
  303. DWORD dwReceiveAvgCellRate;
  304. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szReceiveAvgCellRate,
  305. &dwReceiveAvgCellRate);
  306. if SUCCEEDED(hrTmp)
  307. pNewPVC->m_dwReceiveAvgCellRate = dwReceiveAvgCellRate*c_iCellSize/c_iKbSize;
  308. // ReceiveByteBurstLength
  309. DWORD dwReceiveByteBurstLength;
  310. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szReceiveByteBurstLength,
  311. &dwReceiveByteBurstLength);
  312. if SUCCEEDED(hrTmp)
  313. pNewPVC->m_dwReceiveByteBurstLength = dwReceiveByteBurstLength;
  314. // ReceiveMaxSduSize
  315. DWORD dwReceiveMaxSduSize;
  316. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szReceiveMaxSduSize,
  317. &dwReceiveMaxSduSize);
  318. if SUCCEEDED(hrTmp)
  319. pNewPVC->m_dwReceiveMaxSduSize = dwReceiveMaxSduSize;
  320. // ReceiveServiceCategory
  321. DWORD dwReceiveServiceCategory;
  322. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szReceiveServiceCategory,
  323. &dwReceiveServiceCategory);
  324. if SUCCEEDED(hrTmp)
  325. {
  326. switch(dwReceiveServiceCategory)
  327. {
  328. case ATM_SERVICE_CATEGORY_CBR:
  329. pNewPVC->m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_CBR;
  330. break;
  331. case ATM_SERVICE_CATEGORY_VBR:
  332. pNewPVC->m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_VBR;
  333. break;
  334. case ATM_SERVICE_CATEGORY_UBR:
  335. pNewPVC->m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  336. break;
  337. case ATM_SERVICE_CATEGORY_ABR:
  338. pNewPVC->m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_ABR;
  339. break;
  340. default:
  341. AssertSz(FALSE, "Invalid service category.");
  342. pNewPVC->m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  343. }
  344. }
  345. // Local BLLI & BHLI
  346. DWORD dwLocalLayer2Protocol;
  347. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalLayer2Protocol,
  348. &dwLocalLayer2Protocol);
  349. if SUCCEEDED(hrTmp)
  350. pNewPVC->m_dwLocalLayer2Protocol = dwLocalLayer2Protocol;
  351. DWORD dwLocalUserSpecLayer2;
  352. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalUserSpecLayer2,
  353. &dwLocalUserSpecLayer2);
  354. if SUCCEEDED(hrTmp)
  355. pNewPVC->m_dwLocalUserSpecLayer2 = dwLocalUserSpecLayer2;
  356. DWORD dwLocalLayer3Protocol;
  357. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalLayer3Protocol,
  358. &dwLocalLayer3Protocol);
  359. if SUCCEEDED(hrTmp)
  360. pNewPVC->m_dwLocalLayer3Protocol = dwLocalLayer3Protocol;
  361. DWORD dwLocalUserSpecLayer3;
  362. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalUserSpecLayer3,
  363. &dwLocalUserSpecLayer3);
  364. if SUCCEEDED(hrTmp)
  365. pNewPVC->m_dwLocalUserSpecLayer3 = dwLocalUserSpecLayer3;
  366. DWORD dwLocalLayer3IPI;
  367. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalLayer3IPI,
  368. &dwLocalLayer3IPI);
  369. if SUCCEEDED(hrTmp)
  370. pNewPVC->m_dwLocalLayer3IPI = dwLocalLayer3IPI;
  371. BYTE * pbLocalSnapId = NULL;
  372. DWORD cbLocalSnapId = 0;
  373. hrTmp = HrRegQueryBinaryWithAlloc(hkeyAdapterPVCId, c_szLocalSnapId,
  374. &pbLocalSnapId, &cbLocalSnapId);
  375. if ( SUCCEEDED(hrTmp) &&
  376. (cbLocalSnapId >0) &&
  377. (cbLocalSnapId <= c_nSnapIdMaxBytes))
  378. {
  379. ConvertBinaryToHexString(pbLocalSnapId, cbLocalSnapId,
  380. &(pNewPVC->m_strLocalSnapId));
  381. MemFree(pbLocalSnapId);
  382. }
  383. DWORD dwLocalHighLayerInfoType;
  384. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szLocalHighLayerInfoType,
  385. &dwLocalHighLayerInfoType);
  386. if SUCCEEDED(hrTmp)
  387. pNewPVC->m_dwLocalHighLayerInfoType = dwLocalHighLayerInfoType;
  388. BYTE * pbLocalHighLayerInfo = NULL;
  389. DWORD cbLocalHighLayerInfo = 0;
  390. hrTmp = HrRegQueryBinaryWithAlloc(hkeyAdapterPVCId, c_szLocalHighLayerInfo,
  391. &pbLocalHighLayerInfo, &cbLocalHighLayerInfo);
  392. if ( SUCCEEDED(hrTmp) &&
  393. (cbLocalHighLayerInfo >0) &&
  394. (cbLocalHighLayerInfo <= c_nHighLayerInfoMaxBytes))
  395. {
  396. ConvertBinaryToHexString(pbLocalHighLayerInfo, cbLocalHighLayerInfo,
  397. &(pNewPVC->m_strLocalHighLayerInfo));
  398. MemFree(pbLocalHighLayerInfo);
  399. }
  400. // Destination BLLI and BHLI
  401. DWORD dwDestnLayer2Protocol;
  402. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnLayer2Protocol,
  403. &dwDestnLayer2Protocol);
  404. if SUCCEEDED(hrTmp)
  405. pNewPVC->m_dwDestnLayer2Protocol = dwDestnLayer2Protocol;
  406. DWORD dwDestnUserSpecLayer2;
  407. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnUserSpecLayer2,
  408. &dwDestnUserSpecLayer2);
  409. if SUCCEEDED(hrTmp)
  410. pNewPVC->m_dwDestnUserSpecLayer2 = dwDestnUserSpecLayer2;
  411. DWORD dwDestnLayer3Protocol;
  412. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnLayer3Protocol,
  413. &dwDestnLayer3Protocol);
  414. if SUCCEEDED(hrTmp)
  415. pNewPVC->m_dwDestnLayer3Protocol = dwDestnLayer3Protocol;
  416. DWORD dwDestnUserSpecLayer3;
  417. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnUserSpecLayer3,
  418. &dwDestnUserSpecLayer3);
  419. if SUCCEEDED(hrTmp)
  420. pNewPVC->m_dwDestnUserSpecLayer3 = dwDestnUserSpecLayer3;
  421. DWORD dwDestnLayer3IPI;
  422. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnLayer3IPI,
  423. &dwDestnLayer3IPI);
  424. if SUCCEEDED(hrTmp)
  425. pNewPVC->m_dwDestnLayer3IPI = dwDestnLayer3IPI;
  426. BYTE * pbDestnSnapId = NULL;
  427. DWORD cbDestnSnapId = 0;
  428. hrTmp = HrRegQueryBinaryWithAlloc(hkeyAdapterPVCId, c_szDestnSnapId,
  429. &pbDestnSnapId, &cbDestnSnapId);
  430. if ( SUCCEEDED(hrTmp) &&
  431. (cbDestnSnapId >0) &&
  432. (cbDestnSnapId <= c_nSnapIdMaxBytes))
  433. {
  434. ConvertBinaryToHexString(pbDestnSnapId, cbDestnSnapId,
  435. &(pNewPVC->m_strDestnSnapId));
  436. MemFree(pbDestnSnapId);
  437. }
  438. DWORD dwDestnHighLayerInfoType;
  439. hrTmp = HrRegQueryDword(hkeyAdapterPVCId, c_szDestnHighLayerInfoType,
  440. &dwDestnHighLayerInfoType);
  441. if SUCCEEDED(hrTmp)
  442. pNewPVC->m_dwDestnHighLayerInfoType = dwDestnHighLayerInfoType;
  443. BYTE * pbDestnHighLayerInfo = NULL;
  444. DWORD cbDestnHighLayerInfo = 0;
  445. hrTmp = HrRegQueryBinaryWithAlloc(hkeyAdapterPVCId, c_szDestnHighLayerInfo,
  446. &pbDestnHighLayerInfo, &cbDestnHighLayerInfo);
  447. if ( SUCCEEDED(hrTmp) &&
  448. (cbDestnHighLayerInfo >0) &&
  449. (cbDestnHighLayerInfo <= c_nHighLayerInfoMaxBytes))
  450. {
  451. ConvertBinaryToHexString(pbDestnHighLayerInfo, cbDestnHighLayerInfo,
  452. &(pNewPVC->m_strDestnHighLayerInfo));
  453. MemFree(pbDestnHighLayerInfo);
  454. }
  455. // Now initialize the "Old" values
  456. pNewPVC->ResetOldValues();
  457. }
  458. }
  459. RegSafeCloseKey(hkeyAdapterPVCId);
  460. }
  461. }
  462. RegSafeCloseKey(hkeyAdapterPVC);
  463. TraceError("CAtmUniCfg::HrLoadAdapterPVCRegistry", hr);
  464. return hr;
  465. }
  466. // Save PVC specific settings to registry
  467. HRESULT CAtmUniCfg::HrSaveAdapterPVCRegistry(HKEY hkeyAdapterParam,
  468. CUniAdapterInfo * pAdapterInfo)
  469. {
  470. HRESULT hr = S_OK;
  471. Assert(hkeyAdapterParam);
  472. Assert(pAdapterInfo);
  473. // open the PVC subkey and enumerate the PVCs under that
  474. HKEY hkeyAdapterPVC = NULL;
  475. DWORD dwDisposition;
  476. hr = HrRegCreateKeyEx(hkeyAdapterParam,
  477. c_szPVC,
  478. REG_OPTION_NON_VOLATILE,
  479. KEY_ALL_ACCESS,
  480. NULL,
  481. &hkeyAdapterPVC,
  482. &dwDisposition);
  483. if(SUCCEEDED(hr))
  484. {
  485. Assert(hkeyAdapterPVC);
  486. if (dwDisposition == REG_OPENED_EXISTING_KEY)
  487. {
  488. // clean up deleted PVCs
  489. HRESULT hrTmp = S_OK;
  490. // enumerate the sub keys, and create a CPvcInfo object for each PVC
  491. VECSTR vstrPVCIdList;
  492. hrTmp = HrLoadSubkeysFromRegistry(hkeyAdapterPVC, &vstrPVCIdList);
  493. if SUCCEEDED(hrTmp)
  494. {
  495. for (VECSTR::iterator iterPvcId = vstrPVCIdList.begin();
  496. iterPvcId != vstrPVCIdList.end();
  497. iterPvcId ++)
  498. {
  499. BOOL fFound = FALSE;
  500. for (PVC_INFO_LIST::iterator iterPvcInfo = pAdapterInfo->m_listPVCs.begin();
  501. iterPvcInfo != pAdapterInfo->m_listPVCs.end();
  502. iterPvcInfo ++)
  503. {
  504. if ((*iterPvcInfo)->m_fDeleted)
  505. continue;
  506. if (**iterPvcId == (*iterPvcInfo)->m_strPvcId)
  507. {
  508. fFound = TRUE;
  509. break;
  510. }
  511. }
  512. if (!fFound)
  513. {
  514. hrTmp = HrRegDeleteKeyTree(hkeyAdapterPVC,
  515. (*iterPvcId)->c_str());
  516. }
  517. }
  518. }
  519. }
  520. // save new or updated pvcs
  521. for (PVC_INFO_LIST::iterator iterPvcInfo = pAdapterInfo->m_listPVCs.begin();
  522. iterPvcInfo != pAdapterInfo->m_listPVCs.end();
  523. iterPvcInfo ++)
  524. {
  525. if ((*iterPvcInfo)->m_fDeleted)
  526. continue;
  527. HRESULT hrTmp = S_OK;
  528. // Create the subkey
  529. HKEY hkeyAdapterPVCId = NULL;
  530. hrTmp = HrRegCreateKeyEx(hkeyAdapterPVC,
  531. (*iterPvcInfo)->m_strPvcId.c_str(),
  532. REG_OPTION_NON_VOLATILE,
  533. KEY_ALL_ACCESS,
  534. NULL,
  535. &hkeyAdapterPVCId,
  536. &dwDisposition);
  537. if(SUCCEEDED(hrTmp))
  538. {
  539. Assert(hkeyAdapterPVCId);
  540. // PVC type
  541. hrTmp = HrRegSetDword(hkeyAdapterPVCId,
  542. c_szPVCType,
  543. (*iterPvcInfo)->m_dwPVCType);
  544. if SUCCEEDED(hr)
  545. hr = hrTmp;
  546. // pvc name
  547. hrTmp = HrRegSetString(hkeyAdapterPVCId, c_szPVCName,
  548. (*iterPvcInfo)->m_strName);
  549. if SUCCEEDED(hr)
  550. hr = hrTmp;
  551. // VPI
  552. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szVpi,
  553. (*iterPvcInfo)->m_dwVpi);
  554. if SUCCEEDED(hr)
  555. hr = hrTmp;
  556. // VCI
  557. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szVci,
  558. (*iterPvcInfo)->m_dwVci);
  559. if SUCCEEDED(hr)
  560. hr = hrTmp;
  561. // AAL Type
  562. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szAALType,
  563. (*iterPvcInfo)->m_dwAAL);
  564. if SUCCEEDED(hr)
  565. hr = hrTmp;
  566. // Local address
  567. hrTmp = HrRegSetString(hkeyAdapterPVCId, c_szCallingParty,
  568. (*iterPvcInfo)->m_strCallingAddr);
  569. if SUCCEEDED(hr)
  570. hr = hrTmp;
  571. // Destination address
  572. hrTmp = HrRegSetString(hkeyAdapterPVCId, c_szCalledParty,
  573. (*iterPvcInfo)->m_strCalledAddr);
  574. if SUCCEEDED(hr)
  575. hr = hrTmp;
  576. // Flags
  577. if (FIELD_UNSET == (*iterPvcInfo)->m_dwFlags)
  578. {
  579. // delete the value
  580. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId, c_szFlags);
  581. }
  582. else
  583. {
  584. // save the value
  585. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szFlags,
  586. (*iterPvcInfo)->m_dwFlags);
  587. }
  588. if SUCCEEDED(hrTmp)
  589. hr = hrTmp;
  590. // Quality Info
  591. // TransmitPeakCellRate
  592. if (FIELD_UNSET == (*iterPvcInfo)->m_dwTransmitPeakCellRate)
  593. {
  594. // delete the value
  595. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  596. c_szTransmitPeakCellRate);
  597. }
  598. else
  599. {
  600. // save the value
  601. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szTransmitPeakCellRate,
  602. (*iterPvcInfo)->m_dwTransmitPeakCellRate*c_iKbSize/c_iCellSize);
  603. }
  604. if SUCCEEDED(hrTmp)
  605. hr = hrTmp;
  606. // TransmitAvgCellRate
  607. if (FIELD_UNSET == (*iterPvcInfo)->m_dwTransmitAvgCellRate)
  608. {
  609. // delete the value
  610. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  611. c_szTransmitAvgCellRate);
  612. }
  613. else
  614. {
  615. // save the value
  616. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szTransmitAvgCellRate,
  617. (*iterPvcInfo)->m_dwTransmitAvgCellRate*c_iKbSize/c_iCellSize);
  618. }
  619. if SUCCEEDED(hrTmp)
  620. hr = hrTmp;
  621. // TransmitByteBurstLength
  622. if (FIELD_UNSET == (*iterPvcInfo)->m_dwTransmitByteBurstLength)
  623. {
  624. // delete the value
  625. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  626. c_szTransmitByteBurstLength);
  627. }
  628. else
  629. {
  630. // save the value
  631. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szTransmitByteBurstLength,
  632. (*iterPvcInfo)->m_dwTransmitByteBurstLength);
  633. }
  634. if SUCCEEDED(hrTmp)
  635. hr = hrTmp;
  636. // TransmitMaxSduSize
  637. if (FIELD_UNSET == (*iterPvcInfo)->m_dwTransmitMaxSduSize)
  638. {
  639. // delete the value
  640. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  641. c_szTransmitMaxSduSize);
  642. }
  643. else
  644. {
  645. // save the value
  646. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szTransmitMaxSduSize,
  647. (*iterPvcInfo)->m_dwTransmitMaxSduSize);
  648. }
  649. if SUCCEEDED(hrTmp)
  650. hr = hrTmp;
  651. // TransmitServiceCategory
  652. hrTmp = HrRegSetDword(hkeyAdapterPVCId,
  653. c_szTransmitServiceCategory,
  654. (*iterPvcInfo)->m_dwTransmitServiceCategory);
  655. if SUCCEEDED(hrTmp)
  656. hr = hrTmp;
  657. // ReceivePeakCellRate
  658. if (FIELD_UNSET == (*iterPvcInfo)->m_dwReceivePeakCellRate)
  659. {
  660. // delete the value
  661. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  662. c_szReceivePeakCellRate);
  663. }
  664. else
  665. {
  666. // save the value
  667. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szReceivePeakCellRate,
  668. (*iterPvcInfo)->m_dwReceivePeakCellRate*c_iKbSize/c_iCellSize);
  669. }
  670. if SUCCEEDED(hrTmp)
  671. hr = hrTmp;
  672. // ReceiveAvgCellRate
  673. if (FIELD_UNSET == (*iterPvcInfo)->m_dwReceiveAvgCellRate)
  674. {
  675. // delete the value
  676. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  677. c_szReceiveAvgCellRate);
  678. }
  679. else
  680. {
  681. // save the value
  682. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szReceiveAvgCellRate,
  683. (*iterPvcInfo)->m_dwReceiveAvgCellRate*c_iKbSize/c_iCellSize);
  684. }
  685. if SUCCEEDED(hrTmp)
  686. hr = hrTmp;
  687. // ReceiveByteBurstLength
  688. if (FIELD_UNSET == (*iterPvcInfo)->m_dwReceiveByteBurstLength)
  689. {
  690. // delete the value
  691. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  692. c_szReceiveByteBurstLength);
  693. }
  694. else
  695. {
  696. // save the value
  697. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szReceiveByteBurstLength,
  698. (*iterPvcInfo)->m_dwReceiveByteBurstLength);
  699. }
  700. if SUCCEEDED(hrTmp)
  701. hr = hrTmp;
  702. // ReceiveMaxSduSize
  703. if (FIELD_UNSET == (*iterPvcInfo)->m_dwReceiveMaxSduSize)
  704. {
  705. // delete the value
  706. hrTmp = HrRegDeleteValue(hkeyAdapterPVCId,
  707. c_szReceiveMaxSduSize);
  708. }
  709. else
  710. {
  711. // save the value
  712. hrTmp = HrRegSetDword(hkeyAdapterPVCId, c_szReceiveMaxSduSize,
  713. (*iterPvcInfo)->m_dwReceiveMaxSduSize);
  714. }
  715. if SUCCEEDED(hrTmp)
  716. hr = hrTmp;
  717. // ReceiveServiceCategory
  718. hrTmp = HrRegSetDword(hkeyAdapterPVCId,
  719. c_szReceiveServiceCategory,
  720. (*iterPvcInfo)->m_dwReceiveServiceCategory);
  721. if SUCCEEDED(hrTmp)
  722. hr = hrTmp;
  723. // Local BLLI & BHLI
  724. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalLayer2Protocol,
  725. (*iterPvcInfo)->m_dwLocalLayer2Protocol);
  726. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalUserSpecLayer2,
  727. (*iterPvcInfo)->m_dwLocalUserSpecLayer2);
  728. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalLayer3Protocol,
  729. (*iterPvcInfo)->m_dwLocalLayer3Protocol);
  730. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalUserSpecLayer3,
  731. (*iterPvcInfo)->m_dwLocalUserSpecLayer3);
  732. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalLayer3IPI,
  733. (*iterPvcInfo)->m_dwLocalLayer3IPI);
  734. SetPvcBinaryParamFromString(hkeyAdapterPVCId, c_szLocalSnapId,
  735. (*iterPvcInfo)->m_strLocalSnapId.c_str());
  736. SetPvcDwordParam(hkeyAdapterPVCId, c_szLocalHighLayerInfoType,
  737. (*iterPvcInfo)->m_dwLocalHighLayerInfoType);
  738. SetPvcBinaryParamFromString(hkeyAdapterPVCId, c_szLocalHighLayerInfo,
  739. (*iterPvcInfo)->m_strLocalHighLayerInfo.c_str());
  740. // Destination BLLI and BHLI info
  741. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnLayer2Protocol,
  742. (*iterPvcInfo)->m_dwDestnLayer2Protocol);
  743. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnUserSpecLayer2,
  744. (*iterPvcInfo)->m_dwDestnUserSpecLayer2);
  745. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnLayer3Protocol,
  746. (*iterPvcInfo)->m_dwDestnLayer3Protocol);
  747. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnUserSpecLayer3,
  748. (*iterPvcInfo)->m_dwDestnUserSpecLayer3);
  749. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnLayer3IPI,
  750. (*iterPvcInfo)->m_dwDestnLayer3IPI);
  751. SetPvcBinaryParamFromString(hkeyAdapterPVCId, c_szDestnSnapId,
  752. (*iterPvcInfo)->m_strDestnSnapId.c_str());
  753. SetPvcDwordParam(hkeyAdapterPVCId, c_szDestnHighLayerInfoType,
  754. (*iterPvcInfo)->m_dwDestnHighLayerInfoType);
  755. SetPvcBinaryParamFromString(hkeyAdapterPVCId, c_szDestnHighLayerInfo,
  756. (*iterPvcInfo)->m_strDestnHighLayerInfo.c_str());
  757. }
  758. RegSafeCloseKey(hkeyAdapterPVCId);
  759. }
  760. }
  761. RegSafeCloseKey(hkeyAdapterPVC);
  762. TraceError("CAtmUniCfg::HrSaveAdapterPVCRegistry", hr);
  763. return hr;
  764. }
  765. // load adapter PVC parameters from first memory to second memory
  766. HRESULT CAtmUniCfg::HrLoadAdapterPVCInfo()
  767. {
  768. HRESULT hr = HRESULT_FROM_WIN32(ERROR_NO_MATCH);
  769. delete m_pSecondMemoryAdapterInfo;
  770. m_pSecondMemoryAdapterInfo = NULL;
  771. for(UNI_ADAPTER_LIST::iterator iterAdapter = m_listAdapters.begin();
  772. iterAdapter != m_listAdapters.end();
  773. iterAdapter++)
  774. {
  775. if (FIsSubstr(m_strGuidConn.c_str(), (*iterAdapter)->m_strBindName.c_str()))
  776. {
  777. // enabled LAN adapter
  778. if ((*iterAdapter)->m_BindingState == BIND_ENABLE)
  779. {
  780. m_pSecondMemoryAdapterInfo = new CUniAdapterInfo;
  781. if (m_pSecondMemoryAdapterInfo == NULL)
  782. {
  783. continue;
  784. }
  785. *m_pSecondMemoryAdapterInfo = **iterAdapter;
  786. hr = S_OK;
  787. }
  788. }
  789. }
  790. AssertSz((S_OK == hr), "Can not raise UI on a disabled or non-exist adapter !");
  791. TraceError("CAtmUniCfg::HrLoadAdapterInfo", hr);
  792. return hr;
  793. }
  794. // save adapter PVC parameters from second memory to first memory
  795. HRESULT CAtmUniCfg::HrSaveAdapterPVCInfo()
  796. {
  797. HRESULT hr = HRESULT_FROM_WIN32(ERROR_NO_MATCH);
  798. for(UNI_ADAPTER_LIST::iterator iterAdapter = m_listAdapters.begin();
  799. iterAdapter != m_listAdapters.end();
  800. iterAdapter++)
  801. {
  802. if(m_pSecondMemoryAdapterInfo->m_strBindName == (*iterAdapter)->m_strBindName)
  803. {
  804. // The card can not get unbound while in the properties UI !
  805. Assert((*iterAdapter)->m_BindingState == BIND_ENABLE);
  806. Assert(m_pSecondMemoryAdapterInfo->m_BindingState == BIND_ENABLE);
  807. **iterAdapter = *m_pSecondMemoryAdapterInfo;
  808. hr = S_OK;
  809. break;
  810. }
  811. }
  812. AssertSz((S_OK == hr), "Adapter in second memory not found in first memory!");
  813. TraceError("CAtmUniCfg::HrSaveAdapterInfo", hr);
  814. return hr;
  815. }
  816. // CPvcInfo
  817. CPvcInfo::CPvcInfo(PCWSTR pszPvcId)
  818. {
  819. m_strPvcId = pszPvcId;
  820. m_fDeleted = FALSE;
  821. }
  822. CPvcInfo::~CPvcInfo()
  823. {
  824. }
  825. // copy operator
  826. CPvcInfo & CPvcInfo::operator=(const CPvcInfo & info)
  827. {
  828. Assert(this != &info);
  829. Assert(m_strPvcId == info.m_strPvcId);
  830. if (this == &info)
  831. return *this;
  832. m_fDeleted = info.m_fDeleted;
  833. m_dwPVCType = info.m_dwPVCType;
  834. m_dwOldPVCType = info.m_dwOldPVCType;
  835. m_strName = info.m_strName;
  836. m_strOldName = info.m_strOldName;
  837. m_dwVpi = info.m_dwVpi;
  838. m_dwOldVpi = info.m_dwOldVpi;
  839. m_dwVci = info.m_dwVci;
  840. m_dwOldVci = info.m_dwOldVci;
  841. m_dwAAL = info.m_dwAAL;
  842. m_dwOldAAL = info.m_dwOldAAL;
  843. m_strCallingAddr = info.m_strCallingAddr;
  844. m_strOldCallingAddr = info.m_strOldCallingAddr;
  845. m_strCalledAddr = info.m_strCalledAddr;
  846. m_strOldCalledAddr = info.m_strOldCalledAddr;
  847. m_dwFlags = info.m_dwFlags;
  848. m_dwTransmitPeakCellRate = info.m_dwTransmitPeakCellRate;
  849. m_dwOldTransmitPeakCellRate = info.m_dwOldTransmitPeakCellRate;
  850. m_dwTransmitAvgCellRate = info.m_dwTransmitAvgCellRate;
  851. m_dwOldTransmitAvgCellRate = info.m_dwOldTransmitAvgCellRate;
  852. m_dwTransmitByteBurstLength = info.m_dwTransmitByteBurstLength;
  853. m_dwOldTransmitByteBurstLength = info.m_dwOldTransmitByteBurstLength;
  854. m_dwTransmitMaxSduSize = info.m_dwTransmitMaxSduSize;
  855. m_dwOldTransmitMaxSduSize = info.m_dwOldTransmitMaxSduSize;
  856. m_dwTransmitServiceCategory = info.m_dwTransmitServiceCategory;
  857. m_dwOldTransmitServiceCategory = info.m_dwOldTransmitServiceCategory;
  858. m_dwReceivePeakCellRate = info.m_dwReceivePeakCellRate;
  859. m_dwOldReceivePeakCellRate = info.m_dwOldReceivePeakCellRate;
  860. m_dwReceiveAvgCellRate = info.m_dwReceiveAvgCellRate;
  861. m_dwOldReceiveAvgCellRate = info.m_dwOldReceiveAvgCellRate;
  862. m_dwReceiveByteBurstLength = info.m_dwReceiveByteBurstLength;
  863. m_dwOldReceiveByteBurstLength = info.m_dwOldReceiveByteBurstLength;
  864. m_dwReceiveMaxSduSize = info.m_dwReceiveMaxSduSize;
  865. m_dwOldReceiveMaxSduSize = info.m_dwOldReceiveMaxSduSize;
  866. m_dwReceiveServiceCategory = info.m_dwReceiveServiceCategory;
  867. m_dwOldReceiveServiceCategory = info.m_dwOldReceiveServiceCategory;
  868. // BLLI & BHLI
  869. m_dwLocalLayer2Protocol = info.m_dwLocalLayer2Protocol;
  870. m_dwOldLocalLayer2Protocol = info.m_dwOldLocalLayer2Protocol;
  871. m_dwLocalUserSpecLayer2 = info.m_dwLocalUserSpecLayer2;
  872. m_dwOldLocalUserSpecLayer2 = info.m_dwOldLocalUserSpecLayer2;
  873. m_dwLocalLayer3Protocol = info.m_dwLocalLayer3Protocol;
  874. m_dwOldLocalLayer3Protocol = info.m_dwOldLocalLayer3Protocol;
  875. m_dwLocalUserSpecLayer3 = info.m_dwLocalUserSpecLayer3;
  876. m_dwOldLocalUserSpecLayer3 = info.m_dwOldLocalUserSpecLayer3;
  877. m_dwLocalLayer3IPI = info.m_dwLocalLayer3IPI;
  878. m_dwOldLocalLayer3IPI = info.m_dwOldLocalLayer3IPI;
  879. m_strLocalSnapId = info.m_strLocalSnapId;
  880. m_strOldLocalSnapId = info.m_strOldLocalSnapId;
  881. m_dwLocalHighLayerInfoType = info.m_dwLocalHighLayerInfoType;
  882. m_dwOldLocalHighLayerInfoType = info.m_dwOldLocalHighLayerInfoType;
  883. m_strLocalHighLayerInfo = info.m_strLocalHighLayerInfo;
  884. m_strOldLocalHighLayerInfo = info.m_strOldLocalHighLayerInfo;
  885. // Destination BLLI and BHLI info
  886. m_dwDestnLayer2Protocol = info.m_dwDestnLayer2Protocol;
  887. m_dwOldDestnLayer2Protocol = info.m_dwOldDestnLayer2Protocol;
  888. m_dwDestnUserSpecLayer2 = info.m_dwDestnUserSpecLayer2;
  889. m_dwOldDestnUserSpecLayer2 = info.m_dwOldDestnUserSpecLayer2;
  890. m_dwDestnLayer3Protocol = info.m_dwDestnLayer3Protocol;
  891. m_dwOldDestnLayer3Protocol = info.m_dwOldDestnLayer3Protocol;
  892. m_dwDestnUserSpecLayer3 = info.m_dwDestnUserSpecLayer3;
  893. m_dwOldDestnUserSpecLayer3 = info.m_dwOldDestnUserSpecLayer3;
  894. m_dwDestnLayer3IPI = info.m_dwDestnLayer3IPI;
  895. m_dwOldDestnLayer3IPI = info.m_dwOldDestnLayer3IPI;
  896. m_strDestnSnapId = info.m_strDestnSnapId;
  897. m_strOldDestnSnapId = info.m_strOldDestnSnapId;
  898. m_dwDestnHighLayerInfoType = info.m_dwDestnHighLayerInfoType;
  899. m_dwOldDestnHighLayerInfoType = info.m_dwOldDestnHighLayerInfoType;
  900. m_strDestnHighLayerInfo = info.m_strDestnHighLayerInfo;
  901. m_strOldDestnHighLayerInfo = info.m_strOldDestnHighLayerInfo;
  902. return *this;
  903. }
  904. void CPvcInfo::SetDefaults(PVCType type)
  905. {
  906. m_dwPVCType = type;
  907. m_fDeleted = FALSE;
  908. m_strName = (PWSTR) SzLoadIds(IDS_PVC_UNSPECIFIED_NAME);
  909. m_dwAAL = AAL_TYPE_AAL5;
  910. m_dwVpi = 0;
  911. m_dwVci = FIELD_UNSET;
  912. SetTypeDefaults(type);
  913. ResetOldValues();
  914. }
  915. void CPvcInfo::SetTypeDefaults(PVCType type)
  916. {
  917. // set more specific defaults for each type
  918. m_dwPVCType = type;
  919. switch (m_dwPVCType)
  920. {
  921. case PVC_ATMARP:
  922. SetDefaultsForAtmArp();
  923. break;
  924. case PVC_PPP_ATM_CLIENT:
  925. SetDefaultsForPPPOut();
  926. break;
  927. case PVC_PPP_ATM_SERVER:
  928. SetDefaultsForPPPIn();
  929. break;
  930. case PVC_CUSTOM:
  931. SetDefaultsForCustom();
  932. break;
  933. }
  934. }
  935. void CPvcInfo::SetDefaultsForAtmArp()
  936. {
  937. m_dwPVCType = PVC_ATMARP;
  938. // addresses
  939. m_strCallingAddr = c_szDefaultCallingAtmAddr;
  940. m_strCalledAddr = c_szEmpty;
  941. // Flags
  942. m_dwFlags = 2;
  943. // Quality Info
  944. m_dwTransmitPeakCellRate = FIELD_UNSET;
  945. m_dwTransmitAvgCellRate = FIELD_UNSET;
  946. m_dwTransmitByteBurstLength = c_dwDefTransmitByteBurstLength;
  947. m_dwTransmitMaxSduSize = c_dwDefTransmitMaxSduSize;
  948. m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  949. m_dwReceivePeakCellRate = FIELD_UNSET;
  950. m_dwReceiveAvgCellRate = FIELD_UNSET;
  951. m_dwReceiveByteBurstLength = c_dwDefTransmitByteBurstLength;
  952. m_dwReceiveMaxSduSize = c_dwDefTransmitMaxSduSize;
  953. m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  954. // Local BLLI & BHLI
  955. m_dwLocalLayer2Protocol = 12;
  956. m_dwLocalUserSpecLayer2 = 0;
  957. m_dwLocalLayer3Protocol = FIELD_ABSENT;
  958. m_dwLocalUserSpecLayer3 = 0;
  959. m_dwLocalLayer3IPI = 0;
  960. m_strLocalSnapId = c_szEmpty;
  961. m_dwLocalHighLayerInfoType = FIELD_ABSENT;
  962. m_strLocalHighLayerInfo = c_szEmpty;
  963. // Destination BLLI and BHLI info
  964. m_dwDestnLayer2Protocol = 12;
  965. m_dwDestnUserSpecLayer2 = 0;
  966. m_dwDestnLayer3Protocol = FIELD_ABSENT;
  967. m_dwDestnUserSpecLayer3 = 0;
  968. m_dwDestnLayer3IPI = 0;
  969. m_strDestnSnapId = c_szEmpty;
  970. m_dwDestnHighLayerInfoType = FIELD_ABSENT;
  971. m_strDestnHighLayerInfo = c_szEmpty;
  972. }
  973. void CPvcInfo::SetDefaultsForPPPOut()
  974. {
  975. m_dwPVCType = PVC_PPP_ATM_CLIENT;
  976. // addresses
  977. m_strCallingAddr = c_szEmpty;
  978. m_strCalledAddr = c_szDefaultCalledAtmAddr;
  979. // Flags
  980. m_dwFlags = 4;
  981. // Quality Info
  982. m_dwTransmitPeakCellRate = FIELD_UNSET;
  983. m_dwTransmitAvgCellRate = FIELD_UNSET;
  984. m_dwTransmitByteBurstLength = FIELD_UNSET;
  985. m_dwTransmitMaxSduSize = 4096;
  986. m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  987. m_dwReceivePeakCellRate = FIELD_UNSET;
  988. m_dwReceiveAvgCellRate = FIELD_UNSET;
  989. m_dwReceiveByteBurstLength = FIELD_UNSET;
  990. m_dwReceiveMaxSduSize = 4096;
  991. m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  992. // Local BLLI & BHLI
  993. m_dwLocalLayer2Protocol = FIELD_ABSENT;
  994. m_dwLocalUserSpecLayer2 = 0;
  995. m_dwLocalLayer3Protocol = FIELD_ABSENT;
  996. m_dwLocalUserSpecLayer3 = 0;
  997. m_dwLocalLayer3IPI = 0;
  998. m_strLocalSnapId = c_szEmpty;
  999. m_dwLocalHighLayerInfoType = FIELD_ABSENT;
  1000. m_strLocalHighLayerInfo = c_szEmpty;
  1001. // Destination BLLI and BHLI info
  1002. m_dwDestnLayer2Protocol = FIELD_ABSENT;
  1003. m_dwDestnUserSpecLayer2 = 0;
  1004. m_dwDestnLayer3Protocol = 11;
  1005. m_dwDestnUserSpecLayer3 = 0;
  1006. m_dwDestnLayer3IPI = 207;
  1007. m_strDestnHighLayerInfo = c_szEmpty;
  1008. m_dwDestnHighLayerInfoType = FIELD_ABSENT;
  1009. m_strDestnHighLayerInfo = c_szEmpty;
  1010. }
  1011. void CPvcInfo::SetDefaultsForPPPIn()
  1012. {
  1013. m_dwPVCType = PVC_PPP_ATM_SERVER;
  1014. // addresses
  1015. m_strCallingAddr = c_szEmpty;
  1016. m_strCalledAddr = c_szEmpty;
  1017. // Flags
  1018. m_dwFlags = 2;
  1019. // Quality Info
  1020. m_dwTransmitPeakCellRate = FIELD_UNSET;
  1021. m_dwTransmitAvgCellRate = FIELD_UNSET;
  1022. m_dwTransmitByteBurstLength = FIELD_UNSET;
  1023. m_dwTransmitMaxSduSize = 4096;
  1024. m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  1025. m_dwReceivePeakCellRate = FIELD_UNSET;
  1026. m_dwReceiveAvgCellRate = FIELD_UNSET;
  1027. m_dwReceiveByteBurstLength = FIELD_UNSET;
  1028. m_dwReceiveMaxSduSize = 4096;
  1029. m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  1030. // Local BLLI & BHLI
  1031. m_dwLocalLayer2Protocol = FIELD_ABSENT;
  1032. m_dwLocalUserSpecLayer2 = 0;
  1033. m_dwLocalLayer3Protocol = 11;
  1034. m_dwLocalUserSpecLayer3 = 0;
  1035. m_dwLocalLayer3IPI = 207;
  1036. m_strLocalSnapId = c_szEmpty;
  1037. m_dwLocalHighLayerInfoType = FIELD_ABSENT;
  1038. m_strLocalHighLayerInfo = c_szEmpty;
  1039. // Destination BLLI and BHLI info
  1040. m_dwDestnLayer2Protocol = FIELD_ABSENT;
  1041. m_dwDestnUserSpecLayer2 = 0;
  1042. m_dwDestnLayer3Protocol = FIELD_ABSENT;
  1043. m_dwDestnUserSpecLayer3 = 0;
  1044. m_dwDestnLayer3IPI = 0;
  1045. m_strDestnSnapId = c_szEmpty;
  1046. m_dwDestnHighLayerInfoType = FIELD_ABSENT;
  1047. m_strDestnHighLayerInfo = c_szEmpty;
  1048. }
  1049. void CPvcInfo::SetDefaultsForCustom()
  1050. {
  1051. m_dwPVCType = PVC_CUSTOM;
  1052. // addresses
  1053. m_strCallingAddr = c_szEmpty;
  1054. m_strCalledAddr = c_szEmpty;
  1055. // Flags
  1056. m_dwFlags = FIELD_UNSET;
  1057. // Quality Info
  1058. m_dwTransmitPeakCellRate = FIELD_UNSET;
  1059. m_dwTransmitAvgCellRate = FIELD_UNSET;
  1060. m_dwTransmitByteBurstLength = FIELD_UNSET;
  1061. m_dwTransmitMaxSduSize = FIELD_UNSET;
  1062. m_dwTransmitServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  1063. m_dwReceivePeakCellRate = FIELD_UNSET;
  1064. m_dwReceiveAvgCellRate = FIELD_UNSET;
  1065. m_dwReceiveByteBurstLength = FIELD_UNSET;
  1066. m_dwReceiveMaxSduSize = FIELD_UNSET;
  1067. m_dwReceiveServiceCategory = ATM_SERVICE_CATEGORY_UBR;
  1068. // Local BLLI & BHLI
  1069. m_dwLocalLayer2Protocol = FIELD_ANY;
  1070. m_dwLocalUserSpecLayer2 = 0;
  1071. m_dwLocalLayer3Protocol = FIELD_ANY;
  1072. m_dwLocalUserSpecLayer3 = 0;
  1073. m_dwLocalLayer3IPI = 0;
  1074. m_strLocalSnapId = c_szEmpty;
  1075. m_dwLocalHighLayerInfoType = FIELD_ANY;
  1076. m_strLocalHighLayerInfo = c_szEmpty;
  1077. // Destination BLLI and BHLI info
  1078. m_dwDestnLayer2Protocol = FIELD_ANY;
  1079. m_dwDestnUserSpecLayer2 = 0;
  1080. m_dwDestnLayer3Protocol = FIELD_ANY;
  1081. m_dwDestnUserSpecLayer3 = 0;
  1082. m_dwDestnLayer3IPI = 0;
  1083. m_strDestnSnapId = c_szEmpty;
  1084. m_dwDestnHighLayerInfoType = FIELD_ANY;
  1085. m_strDestnHighLayerInfo = c_szEmpty;
  1086. }
  1087. void CPvcInfo::ResetOldValues()
  1088. {
  1089. m_dwOldPVCType = m_dwPVCType;
  1090. m_strOldName = m_strName;
  1091. m_dwOldVpi = m_dwVpi;
  1092. m_dwOldVci = m_dwVci;
  1093. m_dwOldAAL = m_dwAAL;
  1094. m_strOldCallingAddr = m_strCallingAddr;
  1095. m_strOldCalledAddr = m_strCalledAddr;
  1096. // Quality Info
  1097. m_dwOldTransmitPeakCellRate = m_dwTransmitPeakCellRate;
  1098. m_dwOldTransmitAvgCellRate = m_dwTransmitAvgCellRate;
  1099. m_dwOldTransmitByteBurstLength = m_dwTransmitByteBurstLength;
  1100. m_dwOldTransmitMaxSduSize = m_dwTransmitMaxSduSize;
  1101. m_dwOldTransmitServiceCategory = m_dwTransmitServiceCategory;
  1102. m_dwOldReceivePeakCellRate = m_dwReceivePeakCellRate;
  1103. m_dwOldReceiveAvgCellRate = m_dwReceiveAvgCellRate;
  1104. m_dwOldReceiveByteBurstLength = m_dwReceiveByteBurstLength;
  1105. m_dwOldReceiveMaxSduSize = m_dwReceiveMaxSduSize;
  1106. m_dwOldReceiveServiceCategory = m_dwReceiveServiceCategory;
  1107. // Local BLLI & BHLI
  1108. m_dwOldLocalLayer2Protocol = m_dwLocalLayer2Protocol;
  1109. m_dwOldLocalUserSpecLayer2 = m_dwLocalUserSpecLayer2;
  1110. m_dwOldLocalLayer3Protocol = m_dwLocalLayer3Protocol;
  1111. m_dwOldLocalUserSpecLayer3 = m_dwLocalUserSpecLayer3;
  1112. m_dwOldLocalLayer3IPI = m_dwLocalLayer3IPI;
  1113. m_strOldLocalSnapId = m_strLocalSnapId;
  1114. m_dwOldLocalHighLayerInfoType = m_dwLocalHighLayerInfoType;
  1115. m_strOldLocalHighLayerInfo = m_strLocalHighLayerInfo;
  1116. // Destination BLLI and BHLI info
  1117. m_dwOldDestnLayer2Protocol = m_dwDestnLayer2Protocol;
  1118. m_dwOldDestnUserSpecLayer2 = m_dwDestnUserSpecLayer2;
  1119. m_dwOldDestnLayer3Protocol = m_dwDestnLayer3Protocol;
  1120. m_dwOldDestnUserSpecLayer3 = m_dwDestnUserSpecLayer3;
  1121. m_dwOldDestnLayer3IPI = m_dwDestnLayer3IPI;
  1122. m_strOldDestnSnapId = m_strDestnSnapId;
  1123. m_dwOldDestnHighLayerInfoType = m_dwDestnHighLayerInfoType;
  1124. m_strOldDestnHighLayerInfo = m_strDestnHighLayerInfo;
  1125. }
  1126. // CUniAdapterInfo
  1127. CUniAdapterInfo & CUniAdapterInfo::operator=(const CUniAdapterInfo & info)
  1128. {
  1129. Assert(this != &info);
  1130. if (this == &info)
  1131. return *this;
  1132. // the adapter's binding state
  1133. m_strBindName = info.m_strBindName;
  1134. m_BindingState = info.m_BindingState;
  1135. m_fDeleted = info.m_fDeleted;
  1136. FreeCollectionAndItem(m_listPVCs);
  1137. for (PVC_INFO_LIST::iterator iterPVCInfo = info.m_listPVCs.begin();
  1138. iterPVCInfo != info.m_listPVCs.end();
  1139. iterPVCInfo ++)
  1140. {
  1141. CPvcInfo * pNewPvc = new CPvcInfo((*iterPVCInfo)->m_strPvcId.c_str());
  1142. if (pNewPvc == NULL)
  1143. {
  1144. continue;
  1145. }
  1146. *pNewPvc = **iterPVCInfo;
  1147. m_listPVCs.push_back(pNewPvc);
  1148. }
  1149. return *this;
  1150. }
  1151. void CUniAdapterInfo::SetDefaults(PCWSTR pszBindName)
  1152. {
  1153. m_strBindName = pszBindName;
  1154. m_BindingState = BIND_UNSET;
  1155. FreeCollectionAndItem(m_listPVCs);
  1156. m_fDeleted = FALSE;
  1157. }