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.

1419 lines
40 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ACSData.h
  7. Defines the DataObject classes used in ACS
  8. FILE HISTORY:
  9. 11/11/97 Wei Jiang Created
  10. */
  11. #ifndef _ACSDATA_H_
  12. #define _ACSDATA_H_
  13. #include <list>
  14. #include <functional>
  15. #include <algorithm>
  16. #include "..\common\dataobj.h"
  17. class CACSHandle;
  18. // ACS data state
  19. // CDSObject has virtual function to test state
  20. // CACSHandle has virtual function to show state
  21. // currently, only for acspolicy to show confilict state
  22. #define ACSDATA_STATE_CONFLICT 0x00000001
  23. #define ACSDATA_STATE_DISABLED 0x00000002
  24. #define ACSDATA_STATE_NOOBJECT 0x00000004 // no policy defined for the subnet
  25. #define ERROR_NO_SUCH_OBJECT 0x80072030
  26. #define ATTR_FLAGS_ALL 0xffffffff
  27. #define ATTR_FLAGS_NONE 0x0
  28. #define TOMB(n) ((n) / 1024 / 1024)
  29. #define FROMMB(n) ((n) * 1024 * 1024)
  30. #define TOKBS(n) ((n) / 1024)
  31. #define FROMKBS(n) ((n) * 1024)
  32. #define MIN2SEC(n) ((n) * 60)
  33. #define SEC2MIN(n) ((n) / 60)
  34. #define IS_LARGE_UNLIMIT(large) ((large).LowPart == 0xffffffff && (large).HighPart == 0xffffffff)
  35. #define SET_LARGE_UNLIMIT(large) ((large.LowPart = 0xffffffff),(large.HighPart = 0xffffffff))
  36. #define UNLIMIT 0xffffffff
  37. #define SET_LARGE(l, h, lo) ((l).LowPart = (lo), (l).HighPart = (h))
  38. #define ACSPOLICY_DEFAULT _T("AcsPolicy0")
  39. #define ACSPOLICY_UNKNOWN _T("AcsPolicy1")
  40. // to check if the mentioned attribute will have data after the next save
  41. #define ATTR_WILL_EXIST_AFTER_SAVE(a, toBeSaved) \
  42. (((toBeSaved & a) != 0 && GetFlags(ATTR_FLAG_SAVE, a) != 0 ) || \
  43. ((toBeSaved & a) == 0 && GetFlags(ATTR_FLAG_LOAD, a) != 0 ) )
  44. /*
  45. When you create the global conatiner and the Authenticated and
  46. UnAuthenticated user objects you need to set the following default values:
  47. Authenticated user :
  48. Data rate: 500 Kbits/sec
  49. Peak Data rate: 500 kbits/sec
  50. Number of flows : 2
  51. UnAuthenticated user :
  52. Data rate: 64 Kbits/sec
  53. Peak data rate: 64 kbits/sec
  54. Number of flows : 1
  55. */
  56. #define ACS_GLOBAL_DEFAULT_DATARATE FROMKBS(500)
  57. #define ACS_GLOBAL_DEFAULT_PEAKRATE FROMKBS(500)
  58. #define ACS_GLOBAL_DEFAULT_FLOWS 2
  59. #define ACS_GLOBAL_UNKNOWN_DATARATE FROMKBS(64)
  60. #define ACS_GLOBAL_UNKNOWN_PEAKRATE FROMKBS(64)
  61. #define ACS_GLOBAL_UNKNOWN_FLOWS 1
  62. ///////////////////////////////////////////////////////////////////////////////
  63. // CIDSDataObject
  64. // Support Addtional format -- CFSTR_DSOBJECTNAMES
  65. //
  66. class CDSIDataObject : public CDataObject
  67. {
  68. public:
  69. CDSIDataObject()
  70. {
  71. m_bstrADsPath = NULL;
  72. m_bstrClass = NULL;
  73. };
  74. virtual ~CDSIDataObject()
  75. {
  76. SysFreeString(m_bstrADsPath);
  77. SysFreeString(m_bstrClass);
  78. }
  79. public:
  80. // Implemented functions of IDataObject
  81. STDMETHOD(GetData)(FORMATETC * pformatetcIn, STGMEDIUM * pmedium);
  82. void SetStrings(BSTR path, BSTR cls){m_bstrADsPath = path; m_bstrClass = cls;};
  83. protected:
  84. BSTR m_bstrADsPath;
  85. BSTR m_bstrClass;
  86. // Property Page Clipboard formats
  87. static UINT m_cfDsObjectNames;
  88. };
  89. ///////////////////////////////////////////////////////////////////////////////
  90. // CDSAttributes
  91. //
  92. struct CDSAttributeInfo
  93. {
  94. int id;
  95. WCHAR* name;
  96. ADSTYPE type;
  97. bool ifMultiValued;
  98. DWORD flag;
  99. };
  100. struct CDSAttribute
  101. {
  102. CDSAttributeInfo* pInfo;
  103. void* pBuffer;
  104. };
  105. // maximum number of attribute supported
  106. #define MAX_ATTRIBUTES 32
  107. enum ATTR_FLAG {
  108. ATTR_FLAG_LOAD = 0,
  109. ATTR_FLAG_SAVE,
  110. ATTR_FLAG_TOTAL
  111. };
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CDSObject
  114. class ATL_NO_VTABLE CDSObject :
  115. public CComObjectRootEx<CComSingleThreadModel>,
  116. // public CComCoClass<CDSObject, &CLSID_DSObject>,
  117. public IUnknown
  118. {
  119. BEGIN_COM_MAP(CDSObject)
  120. COM_INTERFACE_ENTRY(IUnknown)
  121. END_COM_MAP()
  122. CDSObject(bool bNoRefCountOnContainer = FALSE); // when container keeps ref count of
  123. // the this child, set bNoRefCountOnContainer to true
  124. virtual ~CDSObject();
  125. public:
  126. // its own functions
  127. // Set information about the DS object, without opening it
  128. STDMETHOD(SetInfo)( CDSObject* pContainer, // container
  129. LPCWSTR clsName, // class name
  130. LPCWSTR objName // object name
  131. );
  132. // load from DS -- derived need to override, when need to load data
  133. STDMETHOD(Open)( CDSObject* pContainer, // container
  134. LPCWSTR clsName, // class name
  135. LPCWSTR objName, // object name
  136. bool bCreateIfNonExist, // if create, [in, out]
  137. bool bPersistWhenCreate = true
  138. );
  139. virtual void SetHandle(CACSHandle* pHandle){ ASSERT(pHandle); m_pHandle = pHandle;};
  140. // load from DS -- derived need to override, when need to load data
  141. STDMETHOD(Reopen)();
  142. // load from DS -- derived need to override, when need to load data
  143. STDMETHOD(Attach)( CDSObject* pContainer, // container
  144. IADs* pIObject
  145. );
  146. // release the pointers, and free the buffer
  147. STDMETHOD(Close)();
  148. // save to DS -- derived must override
  149. STDMETHOD(Save)(DWORD dwAttrFlags);
  150. // delete the object from DS -- usually not override
  151. STDMETHOD(Delete)();
  152. // rename the DS object -- usually not override
  153. STDMETHOD(Rename)(LPCWSTR szName);
  154. // called after the object is created, before it actually become persist
  155. // derived class should set attribute values of the object
  156. // m_pIObject, m_pIContainer are available to use
  157. // initialize the attributes in DS should be done in this function
  158. STDMETHOD(OnCreate)(DWORD* pdwAttrFlags) { *pdwAttrFlags = 0xffffffff; return S_OK;};
  159. // called after the object is open,
  160. // m_pIObject, m_pIContainer are available to use
  161. // read attributes from DS should be done in this function
  162. STDMETHOD(OnOpen)() SAYOK;
  163. // called before SetInfo is called to set the object
  164. // m_pIObject, m_pIContainer are available to use
  165. // write attributes to DS should be done in this function
  166. STDMETHOD(OnSave)(DWORD dwAttrFlags) SAYOK;
  167. // called after the object is open,
  168. // m_pIObject, m_pIContainer are available to use
  169. // read attributes from DS should be done in this function
  170. STDMETHOD(LoadAttributes)();
  171. // called before SetInfo is called to set the object
  172. // m_pIObject, m_pIContainer are available to use
  173. // write attributes to DS should be done in this function
  174. STDMETHOD(SaveAttributes)(DWORD dwAttrFlags);
  175. //=========================================
  176. // functions about container
  177. // add a child object to this container
  178. STDMETHOD(AddChild)(CDSObject* pObject) SAYOK;
  179. // remove a child object from this container
  180. STDMETHOD(RemoveChild)(CDSObject* pObject) SAYOK;
  181. // remove all children object from this container
  182. STDMETHOD(RemoveAllChildren)(CDSObject* pObject) SAYOK;
  183. // ===========================================
  184. // get the data memebers
  185. STDMETHOD(GetIADs)(IADs** ppIADs);
  186. // ===========================================
  187. // get the data memebers
  188. STDMETHOD(GetString)(CString& str, int nCol);
  189. // when object is not in the DS
  190. HRESULT SetNoObjectState()
  191. {
  192. DWORD state = GetState();
  193. if (Reopen() == ERROR_NO_SUCH_OBJECT)
  194. {
  195. SetState(state | ACSDATA_STATE_NOOBJECT);
  196. return S_FALSE;
  197. }
  198. else
  199. {
  200. SetState(state & (~ACSDATA_STATE_NOOBJECT));
  201. return S_OK;
  202. }
  203. };
  204. STDMETHOD_(LPCWSTR, GetName)() { return m_bstrName + 3; /* L"CN="*/};
  205. STDMETHOD_(LPCWSTR, GetADsPath)() { return m_bstrADsPath;};
  206. STDMETHOD_(LPCWSTR, GetClass)() { return m_bstrClass;};
  207. STDMETHOD_(CDSObject*, GetContainer)()
  208. {
  209. if((CDSObject*)m_spContainer)
  210. m_spContainer->AddRef();
  211. return (CDSObject*)m_spContainer;
  212. };
  213. STDMETHOD_(CStrArray*, GetChildrenNameList)() { return NULL;};
  214. virtual CDSAttribute* GetAttributes() { return NULL;};
  215. // load attribute changes the flags, and save attribute uses the flag
  216. DWORD GetFlags(ATTR_FLAG load_or_save, DWORD flags)
  217. {
  218. ASSERT(load_or_save < ATTR_FLAG_TOTAL);
  219. return (m_dwAttributeFlags[load_or_save] & flags);
  220. };
  221. void ClearFlags(ATTR_FLAG load_or_save)
  222. {
  223. ASSERT(load_or_save < ATTR_FLAG_TOTAL);
  224. m_dwAttributeFlags[load_or_save] = 0;
  225. };
  226. void SetFlags(ATTR_FLAG load_or_save, DWORD flags, bool bSet)
  227. {
  228. ASSERT(load_or_save < ATTR_FLAG_TOTAL);
  229. if(bSet)
  230. m_dwAttributeFlags[load_or_save] |= flags;
  231. else // clear the flags
  232. m_dwAttributeFlags[load_or_save] &= (~flags);
  233. };
  234. virtual HRESULT SetState(DWORD state);
  235. virtual DWORD GetState() { return m_dwState;};
  236. HRESULT MakeSureExist(BOOL *pNewCreated)
  237. {
  238. HRESULT hr = Reopen();
  239. if(hr == ERROR_NO_SUCH_OBJECT) // not exist
  240. {
  241. ASSERT(m_spContainer.p && m_bstrClass && m_bstrName);
  242. hr = Open(m_spContainer, m_bstrClass, m_bstrName, true /* create if non exist*/, true /* not persist when create */);
  243. if(pNewCreated)
  244. *pNewCreated = TRUE;
  245. }
  246. else if(pNewCreated)
  247. *pNewCreated = FALSE;
  248. return hr;
  249. };
  250. // return resource error ID, 0 means OK
  251. virtual UINT PreSaveVerifyData(DWORD toBeSavedAttributes) { return 0;};
  252. bool IfOpened() { return (m_spIADs.p != NULL);};
  253. bool IfNewCreated() { return m_bNewCreated;};
  254. //================================================
  255. // protected data section
  256. protected:
  257. CComPtr<IADs> m_spIADs;
  258. CComPtr<CDSObject> m_spContainer;
  259. BSTR m_bstrADsPath;
  260. BSTR m_bstrClass;
  261. BSTR m_bstrName;
  262. bool m_bNewCreated;
  263. bool m_bNoRefCountOnContainer;
  264. bool m_bOpened;
  265. CACSHandle* m_pHandle; // not ref counted
  266. DWORD m_dwState; // the state of the object, current being used by policy to show conflict
  267. // used set if an paricular attribute are loaded, or need to be saved
  268. DWORD m_dwAttributeFlags[ATTR_FLAG_TOTAL];
  269. };
  270. //=============================================================================
  271. // container object for subnetworks container and policy container
  272. template <class T>
  273. class CACSContainerObject : public CDSObject
  274. {
  275. public:
  276. CACSContainerObject(bool bNoRefCountOnContainer = FALSE) : CDSObject(bNoRefCountOnContainer)
  277. {
  278. m_bListed = false;
  279. }
  280. virtual ~CACSContainerObject()
  281. {
  282. m_listChildrenName.DeleteAll();
  283. }
  284. public:
  285. //=========================================
  286. // functions about container
  287. // add a child object to this container
  288. STDMETHOD(AddChild)(CDSObject* pObject)
  289. {
  290. CString* pStr = new CString();
  291. *pStr = pObject->GetName();
  292. m_listChildrenName.Add(pStr);
  293. // childrenlist
  294. m_listChildren.push_back(pObject);
  295. return S_OK;
  296. }
  297. // remove a child object from this container
  298. STDMETHOD(RemoveChild)(CDSObject* pObject)
  299. {
  300. // childrenlist
  301. std::list<CDSObject*>::iterator j;
  302. j = std::find(m_listChildren.begin(), m_listChildren.end(), pObject);
  303. if(j!= m_listChildren.end())
  304. m_listChildren.erase(j);
  305. // name list
  306. CString Str;
  307. Str = pObject->GetName();
  308. int i = m_listChildrenName.Find(Str);
  309. if(i >= 0)
  310. {
  311. CString* pStr = m_listChildrenName[(INT_PTR)i];
  312. m_listChildrenName.RemoveAt(i);
  313. delete pStr;
  314. return S_OK;
  315. }
  316. else
  317. return S_FALSE;
  318. };
  319. // remove all children object from this container
  320. STDMETHOD(RemoveAllChildren)()
  321. {
  322. // childrenlist
  323. m_listChildren.erase(m_listChildren.begin(), m_listChildren.end());
  324. m_listChildrenName.DeleteAll();
  325. return S_OK;
  326. };
  327. // delete the object from DS -- usually not override
  328. STDMETHOD(Delete)()
  329. {
  330. HRESULT hr = CDSObject::Delete();
  331. if (hr == S_OK)
  332. RemoveAllChildren();
  333. return hr;
  334. };
  335. // create DSObject(Type T) for children under the container,
  336. // create the children name list at the same time
  337. HRESULT ListChildren(std::list<T*>& children, BSTR clsName);
  338. STDMETHOD_(CStrArray*, GetChildrenNameList)()
  339. {
  340. if(!m_bListed)
  341. {
  342. std::list<T*> children;
  343. if(S_OK != ListChildren(children, NULL))
  344. return NULL;
  345. }
  346. return &m_listChildrenName;
  347. };
  348. //================================================
  349. // protected data section
  350. protected:
  351. //== list of children's name
  352. CStrArray m_listChildrenName;
  353. std::list<CDSObject*> m_listChildren; // no ref count on children
  354. bool m_bListed;
  355. };
  356. ///////////////////////////////////////////////////////////////////////////////
  357. //
  358. // CACSPolicyElement : policy in DS is still a folder which is capable of
  359. // holding multiple policy data
  360. // while, for this version there is one DS object with predefined
  361. // name defined in policy folder
  362. //
  363. enum ACS_POLICY_ATTRIBUTE_ID {
  364. ACS_PAI_INVALID = 0 ,
  365. ACS_PAI_TIMEOFDAY ,
  366. ACS_PAI_DIRECTION ,
  367. ACS_PAI_PF_TOKENRATE ,
  368. ACS_PAI_PF_PEAKBANDWIDTH,
  369. ACS_PAI_PF_DURATION ,
  370. ACS_PAI_SERVICETYPE ,
  371. ACS_PAI_PRIORITY ,
  372. ACS_PAI_PERMISSIONBITS ,
  373. ACS_PAI_TT_FLOWS ,
  374. ACS_PAI_TT_PEAKBANDWIDTH,
  375. ACS_PAI_TT_TOKENRATE ,
  376. ACS_PAI_IDENTITYNAME,
  377. __ACS_PAI_COUNT
  378. };
  379. // flag for each attribute
  380. #define ACS_PAF_TIMEOFDAY 0x00000001
  381. #define ACS_PAF_DIRECTION 0x00000002
  382. #define ACS_PAF_PF_TOKENRATE 0x00000004
  383. #define ACS_PAF_PF_PEAKBANDWIDTH 0x00000008
  384. #define ACS_PAF_PF_DURATION 0x00000010
  385. #define ACS_PAF_SERVICETYPE 0x00000020
  386. #define ACS_PAF_PRIORITY 0x00000040
  387. #define ACS_PAF_PERMISSIONBITS 0x00000080
  388. #define ACS_PAF_TT_FLOWS 0x00000100
  389. #define ACS_PAF_TT_TOKENRATE 0x00000200
  390. #define ACS_PAF_TT_PEAKBANDWIDTH 0x00000400
  391. #define ACS_PAF_IDENTITYNAME 0x00000800
  392. class CPgTraffic;
  393. struct CACSPolicyElementData{
  394. // data memebers of policy
  395. CStrArray m_strArrayTimeOfDay; // not support in this version
  396. ADS_INTEGER m_dwDirection;
  397. ADS_LARGE_INTEGER m_ddPFTokenRate;
  398. ADS_LARGE_INTEGER m_ddPFPeakBandWidth;
  399. ADS_INTEGER m_dwPFDuration;
  400. ADS_INTEGER m_dwServiceType;
  401. ADS_INTEGER m_dwPriority;
  402. ADS_LARGE_INTEGER m_ddPermissionBits;
  403. ADS_INTEGER m_dwTTFlows;
  404. ADS_LARGE_INTEGER m_ddTTPeakBandWidth;
  405. ADS_LARGE_INTEGER m_ddTTTokenRate;
  406. CStrArray m_strArrayIdentityName;
  407. CACSPolicyElementData()
  408. {
  409. m_dwDirection = 0;
  410. SET_LARGE(m_ddPFTokenRate,0,0);
  411. SET_LARGE(m_ddPFPeakBandWidth, 0, 0);
  412. m_dwPFDuration = 0;
  413. m_dwServiceType = 0;
  414. m_dwPriority = 0;
  415. SET_LARGE(m_ddPermissionBits,0,0);
  416. m_dwTTFlows = 0;
  417. SET_LARGE(m_ddTTPeakBandWidth,0,0);
  418. SET_LARGE(m_ddTTTokenRate,0,0);
  419. };
  420. ~CACSPolicyElementData(){
  421. m_strArrayIdentityName.DeleteAll();
  422. };
  423. };
  424. enum AcsPolicyType
  425. {
  426. ACSPOLICYTYPE_DEFAULT,
  427. ACSPOLICYTYPE_UNKNOWN,
  428. ACSPOLICYTYPE_USER,
  429. ACSPOLICYTYPE_OU
  430. };
  431. #define ACSPOLICYTYPE_DELIMITER _T(':')
  432. // enterprise level default
  433. #define DEFAULT_AU_DATARATE FROMKBS(64) // default data rate for Any Unauthenticated User
  434. #define DEFAULT_AA_DATARATE FROMKBS(500) // default data rate for Any Authenticated User
  435. enum UserPolicyType
  436. {
  437. UNDEFINED = 0,
  438. GLOBAL_ANY_AUTHENTICATED,
  439. GLOBAL_ANY_UNAUTHENTICATED,
  440. };
  441. class CACSPolicyContainer;
  442. //
  443. // IdentityName attribute of policy is as format
  444. // 2:USerDN or 3:OUDN or 0 or 1 0-- for default, 1-- for unknown
  445. //
  446. class CACSPolicyElement : public CDSObject, public CACSPolicyElementData
  447. {
  448. public:
  449. ~CACSPolicyElement()
  450. {
  451. };
  452. CACSPolicyElement() : CDSObject(true)
  453. {
  454. void* pVoid;
  455. CDSAttributeInfo* pInfo = m_aPolicyAttributeInfo;
  456. m_bUseName_NewPolicy = FALSE;
  457. int count = 0;
  458. while(pInfo && pInfo->id)
  459. {
  460. m_aAttributes[count].pInfo = pInfo;
  461. switch(pInfo->id)
  462. {
  463. case ACS_PAI_TIMEOFDAY: pVoid = (void*)&m_strArrayTimeOfDay; break;// n
  464. case ACS_PAI_DIRECTION: pVoid = (void*)&m_dwDirection; break;
  465. case ACS_PAI_PF_TOKENRATE: pVoid = (void*)&m_ddPFTokenRate; break;
  466. case ACS_PAI_PF_PEAKBANDWIDTH: pVoid = (void*)&m_ddPFPeakBandWidth; break;
  467. case ACS_PAI_PF_DURATION: pVoid = (void*)&m_dwPFDuration; break;
  468. case ACS_PAI_SERVICETYPE: pVoid = (void*)&m_dwServiceType; break;
  469. case ACS_PAI_PRIORITY: pVoid = (void*)&m_dwPriority; break;
  470. case ACS_PAI_PERMISSIONBITS: pVoid = (void*)&m_ddPermissionBits; break;
  471. case ACS_PAI_TT_FLOWS: pVoid = (void*)&m_dwTTFlows; break;
  472. case ACS_PAI_TT_PEAKBANDWIDTH: pVoid = (void*)&m_ddTTPeakBandWidth; break;
  473. case ACS_PAI_TT_TOKENRATE: pVoid = (void*)&m_ddTTTokenRate; break;
  474. case ACS_PAI_IDENTITYNAME: pVoid = (void*)&m_strArrayIdentityName; break;
  475. default: ASSERT(0); break; // this should NOT happen
  476. }
  477. m_aAttributes[count++].pBuffer = pVoid;
  478. pInfo++;
  479. }
  480. m_aAttributes[count].pInfo = 0;
  481. m_aAttributes[count].pBuffer = 0;
  482. };
  483. DWORD SetGlobalDefault()
  484. // returning the flags which are the attributes have been set
  485. {
  486. // Direction and Service Type
  487. m_dwDirection = ACS_DIRECTION_BOTH;
  488. m_dwServiceType = ACS_SERVICETYPE_ALL;
  489. // make it Default
  490. CString* pStr = new CString(_T("0"));
  491. m_strArrayIdentityName.DeleteAll();
  492. m_strArrayIdentityName.Add(pStr);
  493. // Per flow rate
  494. // Total
  495. m_dwTTFlows = ACS_GLOBAL_DEFAULT_FLOWS;
  496. m_ddTTTokenRate.LowPart = ACS_GLOBAL_DEFAULT_DATARATE;
  497. m_ddTTTokenRate.HighPart = 0;
  498. m_ddTTPeakBandWidth.LowPart = ACS_GLOBAL_DEFAULT_PEAKRATE;
  499. m_ddTTPeakBandWidth.HighPart = 0;
  500. return (ACS_PAF_DIRECTION | ACS_PAF_SERVICETYPE | ACS_PAF_IDENTITYNAME // dirction, service type, identity
  501. // per flow
  502. | ACS_PAF_TT_FLOWS | ACS_PAF_TT_TOKENRATE | ACS_PAF_TT_PEAKBANDWIDTH); // total
  503. };
  504. // return resource error ID, 0 means OK
  505. virtual UINT PreSaveVerifyData(DWORD toBeSavedAttributes, UserPolicyType type)
  506. {
  507. // special checking for Global Any Authenticated, and Any Unauthenticated
  508. if(type == GLOBAL_ANY_AUTHENTICATED || type == GLOBAL_ANY_UNAUTHENTICATED)
  509. {
  510. UINT dataRateLimit;
  511. if(type == GLOBAL_ANY_AUTHENTICATED)
  512. dataRateLimit = DEFAULT_AA_DATARATE;
  513. else
  514. dataRateLimit = DEFAULT_AU_DATARATE;
  515. // total data rate and data rate -- one of them set to default
  516. if(ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_TOKENRATE, toBeSavedAttributes)
  517. && ATTR_WILL_EXIST_AFTER_SAVE( ACS_PAF_TT_TOKENRATE, toBeSavedAttributes) == 0
  518. && (!IS_LARGE_UNLIMIT(m_ddPFTokenRate))
  519. && m_ddPFTokenRate.LowPart > dataRateLimit)
  520. return IDS_ERR_TOTALRATE_LESS_RATE;
  521. if(ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_TOKENRATE, toBeSavedAttributes) == 0
  522. && ATTR_WILL_EXIST_AFTER_SAVE( ACS_PAF_TT_TOKENRATE, toBeSavedAttributes)
  523. && (!IS_LARGE_UNLIMIT(m_ddTTTokenRate))
  524. && dataRateLimit > m_ddTTTokenRate.LowPart)
  525. return IDS_ERR_TOTALRATE_LESS_RATE;
  526. }
  527. // data rate .. peak data rate
  528. if(ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_TOKENRATE, toBeSavedAttributes)
  529. && ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_PEAKBANDWIDTH, toBeSavedAttributes)
  530. && (!IS_LARGE_UNLIMIT(m_ddPFTokenRate)) && (!IS_LARGE_UNLIMIT(m_ddPFPeakBandWidth))
  531. && m_ddPFTokenRate.LowPart > m_ddPFPeakBandWidth.LowPart)
  532. return IDS_ERR_PEAKRATE_LESS_RATE;
  533. // total data rate and data rate
  534. if(ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_TOKENRATE, toBeSavedAttributes)
  535. && ATTR_WILL_EXIST_AFTER_SAVE( ACS_PAF_TT_TOKENRATE, toBeSavedAttributes)
  536. && (!IS_LARGE_UNLIMIT(m_ddPFTokenRate)) && (!IS_LARGE_UNLIMIT(m_ddTTTokenRate))
  537. && m_ddPFTokenRate.LowPart > m_ddTTTokenRate.LowPart)
  538. return IDS_ERR_TOTALRATE_LESS_RATE;
  539. // total data rate and total peak ...
  540. if(ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_TT_PEAKBANDWIDTH, toBeSavedAttributes)
  541. && ATTR_WILL_EXIST_AFTER_SAVE( ACS_PAF_TT_TOKENRATE, toBeSavedAttributes)
  542. && (!IS_LARGE_UNLIMIT(m_ddTTTokenRate)) && (!IS_LARGE_UNLIMIT(m_ddTTPeakBandWidth))
  543. && m_ddTTTokenRate.LowPart > m_ddTTPeakBandWidth.LowPart)
  544. return IDS_ERR_TOTALPEAK_LESS_TOTALRATE;
  545. // peak rate and total peak
  546. if(ATTR_WILL_EXIST_AFTER_SAVE( ACS_PAF_TT_PEAKBANDWIDTH, toBeSavedAttributes)
  547. && ATTR_WILL_EXIST_AFTER_SAVE(ACS_PAF_PF_PEAKBANDWIDTH, toBeSavedAttributes)
  548. && (!IS_LARGE_UNLIMIT(m_ddPFPeakBandWidth)) && (!IS_LARGE_UNLIMIT(m_ddTTPeakBandWidth))
  549. && m_ddPFPeakBandWidth.LowPart > m_ddTTPeakBandWidth.LowPart)
  550. return IDS_ERR_TOTALPEAK_LESS_PEAK;
  551. return 0;
  552. };
  553. DWORD SetGlobalUnknown()
  554. // returning the flags which are the attributes have been set
  555. {
  556. // Direction and ServiceType
  557. m_dwDirection = ACS_DIRECTION_BOTH;
  558. m_dwServiceType = ACS_SERVICETYPE_ALL;
  559. CString* pStr = new CString(_T("1"));
  560. m_strArrayIdentityName.DeleteAll();
  561. m_strArrayIdentityName.Add(pStr);
  562. // Per flow
  563. // Total
  564. m_dwTTFlows = ACS_GLOBAL_UNKNOWN_FLOWS;
  565. m_ddTTTokenRate.LowPart = ACS_GLOBAL_UNKNOWN_DATARATE;
  566. m_ddTTTokenRate.HighPart = 0;
  567. m_ddTTPeakBandWidth.LowPart = ACS_GLOBAL_UNKNOWN_PEAKRATE;
  568. m_ddTTPeakBandWidth.HighPart = 0;
  569. return (ACS_PAF_DIRECTION | ACS_PAF_SERVICETYPE | ACS_PAF_IDENTITYNAME // dirction, service type, identity
  570. // per flow
  571. | ACS_PAF_TT_FLOWS | ACS_PAF_TT_TOKENRATE | ACS_PAF_TT_PEAKBANDWIDTH); // total
  572. };
  573. DWORD SetDefault()
  574. // returning the flags which are the attributes have been set
  575. {
  576. // Direction and ServiceType
  577. m_dwDirection = ACS_DIRECTION_BOTH;
  578. m_dwServiceType = ACS_SERVICETYPE_ALL;
  579. CString* pStr = new CString(_T("0"));
  580. m_strArrayIdentityName.Add(pStr);
  581. return (ACS_PAF_DIRECTION | ACS_PAF_SERVICETYPE | ACS_PAF_IDENTITYNAME);
  582. };
  583. DWORD SetUnknown()
  584. // returning the flags which are the attributes have been set
  585. {
  586. // Direction and ServiceType
  587. m_dwDirection = ACS_DIRECTION_BOTH;
  588. m_dwServiceType = ACS_SERVICETYPE_ALL;
  589. CString* pStr = new CString(_T("1"));
  590. m_strArrayIdentityName.Add(pStr);
  591. return (ACS_PAF_DIRECTION | ACS_PAF_SERVICETYPE | ACS_PAF_IDENTITYNAME);
  592. };
  593. virtual CDSAttribute* GetAttributes() { return &(m_aAttributes[0]);};
  594. // identity type
  595. int GetIdentityType(int* pStrOffset) const // return -1, of the type is not recognized, or IdentityName doesn't exist
  596. {
  597. if(m_strArrayIdentityName.GetSize() == 0) return -1;
  598. ASSERT(m_strArrayIdentityName.GetSize() == 1); // more than one is not expected in this version
  599. CString strIdentityName(*m_strArrayIdentityName.GetAt(0));
  600. int i = strIdentityName.Find(ACSPOLICYTYPE_DELIMITER);
  601. if(i != -1)
  602. {
  603. *pStrOffset = i+1;
  604. strIdentityName = strIdentityName.Left(i);
  605. }
  606. return _ttoi(strIdentityName);
  607. };
  608. int GetIdentityType(CString& Str) const // return -1, of the type is not recognized, or IdentityName doesn't exist
  609. {
  610. int Offset;
  611. int Id = GetIdentityType(&Offset);
  612. if(Id != -1)
  613. Str = m_strArrayIdentityName[0]->Mid(Offset);
  614. return Id;
  615. }
  616. bool IsConflictInContainer();
  617. void InvalidateConflictState();
  618. bool IsConflictWith(const CACSPolicyElement& policy)
  619. {
  620. // disabled
  621. if(m_dwServiceType == ACS_SERVICETYPE_DISABLED || policy.m_dwServiceType == ACS_SERVICETYPE_DISABLED)
  622. return false;
  623. if(policy.m_strArrayIdentityName.GetSize() == 0 || m_strArrayIdentityName.GetSize() ==0)
  624. return false;
  625. if(m_dwServiceType != policy.m_dwServiceType)
  626. return false;
  627. if((m_dwDirection & policy.m_dwDirection) == 0)
  628. return false;
  629. if(m_strArrayIdentityName[(INT_PTR)0]->CompareNoCase(*policy.m_strArrayIdentityName[0]) != 0)
  630. return false;
  631. return true;
  632. };
  633. bool IsServiceTypeDisabled()
  634. {
  635. return (m_dwServiceType == ACS_SERVICETYPE_DISABLED);
  636. };
  637. // ===========================================
  638. // get the data memebers
  639. STDMETHOD(GetString)(CString& str, int nCol);
  640. BOOL m_bUseName_NewPolicy;
  641. protected:
  642. static CString m_strDirectionSend;
  643. static CString m_strDirectionReceive;
  644. static CString m_strDirectionBoth;
  645. static CString m_strServiceTypeAll;
  646. static CString m_strServiceTypeBestEffort;
  647. static CString m_strServiceTypeControlledLoad;
  648. static CString m_strServiceTypeGuaranteedService;
  649. static CString m_strServiceTypeDisabled;
  650. static CString m_strDefaultUser;
  651. static CString m_strUnknownUser;
  652. static CDSAttributeInfo m_aPolicyAttributeInfo[];
  653. CDSAttribute m_aAttributes[__ACS_PAI_COUNT];
  654. };
  655. ///////////////////////////////////////////////////////////////////////////////
  656. //
  657. // CACSPolicyContainer
  658. //
  659. class CACSPolicyContainer : public CACSContainerObject<CACSPolicyElement>
  660. {
  661. public:
  662. bool IsConflictWithExisting(CACSPolicyElement* pPolicy)
  663. // NO REF COUNT CHANGE
  664. {
  665. std::list<CDSObject*>::iterator i;
  666. bool bConflict = false;
  667. CACSPolicyElement* pExisting = NULL;
  668. for(i = m_listChildren.begin(); !bConflict && i != m_listChildren.end(); i++)
  669. {
  670. pExisting = dynamic_cast<CACSPolicyElement*>(*i);
  671. bConflict = ((pExisting != pPolicy) && pExisting->IsConflictWith(*pPolicy));
  672. }
  673. return bConflict;
  674. };
  675. // return # of conflict, this is always even number
  676. UINT SetChildrenConflictState()
  677. {
  678. std::list<CDSObject*>::iterator i;
  679. CACSPolicyElement* pSubject = NULL;
  680. UINT count = 0;
  681. for(i = m_listChildren.begin(); i != m_listChildren.end(); i++)
  682. {
  683. pSubject = dynamic_cast<CACSPolicyElement*>(*i);
  684. ASSERT(pSubject);
  685. DWORD state = pSubject->GetState();
  686. if(IsConflictWithExisting(pSubject))
  687. {
  688. count++;
  689. state = (state | ACSDATA_STATE_CONFLICT);
  690. }
  691. else
  692. {
  693. state = (state & (~ACSDATA_STATE_CONFLICT));
  694. }
  695. if(pSubject->IsServiceTypeDisabled())
  696. {
  697. state = (state | ACSDATA_STATE_DISABLED);
  698. }
  699. else
  700. {
  701. state = (state & (~ACSDATA_STATE_DISABLED));
  702. }
  703. pSubject->SetState(state);
  704. }
  705. return count;
  706. };
  707. };
  708. ///////////////////////////////////////////////////////////////////////////////
  709. //
  710. // CACSGlobalObject
  711. //
  712. class CACSGlobalObject : public CACSPolicyContainer
  713. {
  714. public:
  715. // load from DS -- derived need to override, when need to load data
  716. STDMETHOD(Open)();
  717. STDMETHOD(OnOpen)();
  718. UINT m_nOpenErrorId;
  719. CString m_strDomainName;
  720. };
  721. ///////////////////////////////////////////////////////////////////////////////
  722. //
  723. // CACSGlobalObject
  724. //
  725. class CACSSubnetsObject : public CACSContainerObject<CDSObject>
  726. {
  727. public:
  728. // load from DS -- derived need to override, when need to load data
  729. STDMETHOD(Open)();
  730. };
  731. ///////////////////////////////////////////////////////////////////////////////
  732. //
  733. // CACSSubnetConfig : subnet in DS is still a folder which is capable of
  734. // holding config object, users folder and profiles holder,
  735. // the class defined here is the config object contained in
  736. // subnet object
  737. //
  738. enum ACS_SUBNET_CONFIG_ATTRIBUTE_ID {
  739. ACS_SCAI_INVALID = 0 ,
  740. ACS_SCAI_ALLOCABLERSVPBW,
  741. ACS_SCAI_MAXPEAKBW,
  742. ACS_SCAI_ENABLERSVPMESSAGELOGGING,
  743. ACS_SCAI_EVENTLOGLEVEL,
  744. ACS_SCAI_ENABLEACSSERVICE,
  745. ACS_SCAI_MAX_PF_TOKENRATE,
  746. ACS_SCAI_MAX_PF_PEAKBW,
  747. ACS_SCAI_MAX_PF_DURATION,
  748. ACS_SCAI_RSVPLOGFILESLOCATION,
  749. ACS_SCAI_DESCRIPTION,
  750. ACS_SCAI_MAXNOOFLOGFILES,
  751. ACS_SCAI_MAXSIZEOFRSVPLOGFILE,
  752. ACS_SCAI_DSBMPRIORITY,
  753. ACS_SCAI_DSBMREFRESH,
  754. ACS_SCAI_DSBMDEADTIME,
  755. ACS_SCAI_CACHETIMEOUT,
  756. ACS_SCAI_NONRESERVEDTXLIMIT,
  757. // accounting -- added by WeiJiang 2/16/98
  758. ACS_SCAI_ENABLERSVPMESSAGEACCOUNTING,
  759. ACS_SCAI_RSVPACCOUNTINGFILESLOCATION,
  760. ACS_SCAI_MAXNOOFACCOUNTINGFILES,
  761. ACS_SCAI_MAXSIZEOFRSVPACCOUNTINGFILE,
  762. // server list
  763. ACS_SCAI_SERVERLIST,
  764. // the total count of the elementas
  765. __ACS_SCAI_COUNT
  766. };
  767. // bit flags for the attributes
  768. #define ACS_SCAF_ALLOCABLERSVPBW 0x00000001
  769. #define ACS_SCAF_MAXPEAKBW 0x00000002
  770. #define ACS_SCAF_ENABLERSVPMESSAGELOGGING 0x00000004
  771. #define ACS_SCAF_EVENTLOGLEVEL 0x00000008
  772. #define ACS_SCAF_ENABLEACSSERVICE 0x00000010
  773. #define ACS_SCAF_MAX_PF_TOKENRATE 0x00000020
  774. #define ACS_SCAF_MAX_PF_PEAKBW 0x00000040
  775. #define ACS_SCAF_MAX_PF_DURATION 0x00000080
  776. #define ACS_SCAF_DESCRIPTION 0x00000100
  777. #define ACS_SCAF_RSVPLOGFILESLOCATION 0x00000200
  778. #define ACS_SCAF_MAXNOOFLOGFILES 0x00000400
  779. #define ACS_SCAF_MAXSIZEOFRSVPLOGFILE 0x00000800
  780. #define ACS_SCAF_DSBMPRIORITY 0x00001000
  781. #define ACS_SCAF_DSBMREFRESH 0x00002000
  782. #define ACS_SCAF_DSBMDEADTIME 0x00004000
  783. #define ACS_SCAF_CACHETIMEOUT 0x00008000
  784. #define ACS_SCAF_NONRESERVEDTXLIMIT 0x00010000
  785. // accounting -- added by WeiJiang 2/16/98
  786. #define ACS_SCAF_ENABLERSVPMESSAGEACCOUNTING 0x00020000
  787. #define ACS_SCAF_RSVPACCOUNTINGFILESLOCATION 0x00040000
  788. #define ACS_SCAF_MAXNOOFACCOUNTINGFILES 0x00080000
  789. #define ACS_SCAF_MAXSIZEOFRSVPACCOUNTINGFILE 0x00100000
  790. //Server list
  791. #define ACS_SCAF_SERVERLIST 0x00200000
  792. class CACSSubnetConfig : public CDSObject
  793. {
  794. friend class CPgGeneral;
  795. friend class CPgLogging;
  796. friend class CPgSBM;
  797. friend class CPgAccounting;
  798. friend class CPgServers;
  799. public:
  800. CACSSubnetConfig() : CDSObject(true)
  801. {
  802. void* pVoid;
  803. CDSAttributeInfo* pInfo = m_aSubnetAttributeInfo;
  804. int count = 0;
  805. while(pInfo && pInfo->id)
  806. {
  807. m_aAttributes[count].pInfo = pInfo;
  808. switch(pInfo->id)
  809. {
  810. case ACS_SCAI_ALLOCABLERSVPBW: pVoid = (void*)&m_ddALLOCABLERSVPBW; break;
  811. case ACS_SCAI_MAXPEAKBW: pVoid = (void*)&m_ddMAXPEAKBW; break;
  812. case ACS_SCAI_ENABLERSVPMESSAGELOGGING: pVoid = (void*)&m_bENABLERSVPMESSAGELOGGING; break;
  813. case ACS_SCAI_EVENTLOGLEVEL: pVoid = (void*)&m_dwEVENTLOGLEVEL; break;
  814. case ACS_SCAI_ENABLEACSSERVICE: pVoid = (void*)&m_bENABLEACSSERVICE; break;
  815. case ACS_SCAI_MAX_PF_TOKENRATE: pVoid = (void*)&m_ddMAX_PF_TOKENRATE; break;
  816. case ACS_SCAI_MAX_PF_PEAKBW: pVoid = (void*)&m_ddMAX_PF_PEAKBW; break;
  817. case ACS_SCAI_MAX_PF_DURATION: pVoid = (void*)&m_dwMAX_PF_DURATION; break;
  818. case ACS_SCAI_RSVPLOGFILESLOCATION: pVoid = (void*)&m_strRSVPLOGFILESLOCATION; break;
  819. case ACS_SCAI_DESCRIPTION: pVoid = (void*)&m_strDESCRIPTION; break;
  820. case ACS_SCAI_MAXNOOFLOGFILES: pVoid = (void*)&m_dwMAXNOOFLOGFILES; break;
  821. case ACS_SCAI_MAXSIZEOFRSVPLOGFILE: pVoid = (void*)&m_dwMAXSIZEOFRSVPLOGFILE; break;
  822. case ACS_SCAI_DSBMPRIORITY: pVoid = (void*)&m_dwDSBMPRIORITY; break;
  823. case ACS_SCAI_DSBMREFRESH: pVoid = (void*)&m_dwDSBMREFRESH; break;
  824. case ACS_SCAI_DSBMDEADTIME: pVoid = (void*)&m_dwDSBMDEADTIME; break;
  825. case ACS_SCAI_CACHETIMEOUT: pVoid = (void*)&m_dwCACHETIMEOUT; break;
  826. case ACS_SCAI_NONRESERVEDTXLIMIT: pVoid = (void*)&m_ddNONRESERVEDTXLIMIT; break;
  827. // accounting added by WeiJiang 2/16/98
  828. case ACS_SCAI_ENABLERSVPMESSAGEACCOUNTING: pVoid = (void*)&m_bENABLERSVPMESSAGEACCOUNTING; break;
  829. case ACS_SCAI_RSVPACCOUNTINGFILESLOCATION: pVoid = (void*)&m_strRSVPACCOUNTINGFILESLOCATION; break;
  830. case ACS_SCAI_MAXNOOFACCOUNTINGFILES: pVoid = (void*)&m_dwMAXNOOFACCOUNTINGFILES; break;
  831. case ACS_SCAI_MAXSIZEOFRSVPACCOUNTINGFILE: pVoid = (void*)&m_dwMAXSIZEOFRSVPACCOUNTINGFILE; break;
  832. case ACS_SCAI_SERVERLIST: pVoid = (void*)&m_strArrayServerList; break;
  833. default: ASSERT(0); break; // this should NOT happen
  834. }
  835. m_aAttributes[count++].pBuffer = pVoid;
  836. pInfo++;
  837. }
  838. m_aAttributes[count].pInfo = 0;
  839. m_aAttributes[count].pBuffer = 0;
  840. };
  841. virtual CDSAttribute* GetAttributes() { return &(m_aAttributes[0]);};
  842. // ===========================================
  843. // get the data memebers
  844. STDMETHOD(GetString)(CString& str, int nCol);
  845. protected:
  846. static CDSAttributeInfo m_aSubnetAttributeInfo[];
  847. CDSAttribute m_aAttributes[__ACS_SCAI_COUNT];
  848. //===================================================
  849. // data member
  850. CString m_strDescription;
  851. ADS_LARGE_INTEGER m_ddALLOCABLERSVPBW;
  852. ADS_LARGE_INTEGER m_ddMAXPEAKBW;
  853. ADS_BOOLEAN m_bENABLERSVPMESSAGELOGGING;
  854. ADS_INTEGER m_dwEVENTLOGLEVEL;
  855. ADS_BOOLEAN m_bENABLEACSSERVICE;
  856. ADS_LARGE_INTEGER m_ddMAX_PF_TOKENRATE;
  857. ADS_LARGE_INTEGER m_ddMAX_PF_PEAKBW;
  858. ADS_INTEGER m_dwMAX_PF_DURATION;
  859. CString m_strRSVPLOGFILESLOCATION;
  860. CString m_strDESCRIPTION;
  861. ADS_INTEGER m_dwMAXNOOFLOGFILES;
  862. ADS_INTEGER m_dwMAXSIZEOFRSVPLOGFILE;
  863. ADS_INTEGER m_dwDSBMPRIORITY;
  864. ADS_INTEGER m_dwDSBMREFRESH;
  865. ADS_INTEGER m_dwDSBMDEADTIME;
  866. ADS_INTEGER m_dwCACHETIMEOUT;
  867. ADS_LARGE_INTEGER m_ddNONRESERVEDTXLIMIT;
  868. // accounting -- added by WeiJiang 2/16/98
  869. ADS_BOOLEAN m_bENABLERSVPMESSAGEACCOUNTING;
  870. CString m_strRSVPACCOUNTINGFILESLOCATION;
  871. ADS_INTEGER m_dwMAXNOOFACCOUNTINGFILES;
  872. ADS_INTEGER m_dwMAXSIZEOFRSVPACCOUNTINGFILE;
  873. // Server list
  874. CStrArray m_strArrayServerList;
  875. };
  876. //===============================================================
  877. // subnet service limit
  878. //
  879. // bit flags for the attributes
  880. #define ACS_SSLAF_ALLOCABLERSVPBW 0x00000001
  881. #define ACS_SSLAF_MAXPEAKBW 0x00000002
  882. #define ACS_SSLAF_MAX_PF_TOKENRATE 0x00000004
  883. #define ACS_SSLAF_MAX_PF_PEAKBW 0x00000008
  884. #define ACS_SSLAF_SERVICETYPE 0x00000010
  885. enum ACS_SUBNET_SERVICE_LIMITS_ATTRIBUTE_ID {
  886. ACS_SSLAI_INVALID = 0 ,
  887. ACS_SSLAI_ALLOCABLERSVPBW,
  888. ACS_SSLAI_MAXPEAKBW,
  889. ACS_SSLAI_MAX_PF_TOKENRATE,
  890. ACS_SSLAI_MAX_PF_PEAKBW,
  891. ACS_SSLAI_SERVICETYPE ,
  892. // the total count of the elementas
  893. __ACS_SSLAI_COUNT
  894. };
  895. class CACSSubnetServiceLimits : public CDSObject
  896. {
  897. public:
  898. CACSSubnetServiceLimits() : CDSObject(true)
  899. {
  900. void* pVoid;
  901. CDSAttributeInfo* pInfo = m_aSubnetServiceLimitsAttributeInfo;
  902. int count = 0;
  903. while(pInfo && pInfo->id)
  904. {
  905. m_aAttributes[count].pInfo = pInfo;
  906. switch(pInfo->id)
  907. {
  908. case ACS_SSLAI_ALLOCABLERSVPBW: pVoid = (void*)&m_ddALLOCABLERSVPBW; break;
  909. case ACS_SSLAI_MAXPEAKBW: pVoid = (void*)&m_ddMAXPEAKBW; break;
  910. case ACS_SSLAI_MAX_PF_TOKENRATE: pVoid = (void*)&m_ddMAX_PF_TOKENRATE; break;
  911. case ACS_SSLAI_MAX_PF_PEAKBW: pVoid = (void*)&m_ddMAX_PF_PEAKBW; break;
  912. case ACS_SSLAI_SERVICETYPE: pVoid = (void*)&m_dwServiceType; break;
  913. default: ASSERT(0); break; // this should NOT happen
  914. }
  915. m_aAttributes[count++].pBuffer = pVoid;
  916. pInfo++;
  917. }
  918. m_aAttributes[count].pInfo = 0;
  919. m_aAttributes[count].pBuffer = 0;
  920. };
  921. virtual CDSAttribute* GetAttributes() { return &(m_aAttributes[0]);};
  922. // ===========================================
  923. // get the data memebers
  924. STDMETHOD(GetString)(CString& str, int nCol)
  925. {
  926. switch(nCol)
  927. {
  928. case 0: // name
  929. // inteprete name based on service type
  930. //
  931. break;
  932. case 1: // per flow data
  933. break;
  934. case 2: // per flow peak
  935. break;
  936. case 3: // aggre data
  937. break;
  938. case 4: // aggre peak
  939. break;
  940. }
  941. return S_OK;
  942. };
  943. protected:
  944. static CDSAttributeInfo m_aSubnetServiceLimitsAttributeInfo[];
  945. CDSAttribute m_aAttributes[__ACS_SSLAI_COUNT];
  946. public:
  947. //===================================================
  948. // data member
  949. ADS_LARGE_INTEGER m_ddALLOCABLERSVPBW;
  950. ADS_LARGE_INTEGER m_ddMAXPEAKBW;
  951. ADS_LARGE_INTEGER m_ddMAX_PF_TOKENRATE;
  952. ADS_LARGE_INTEGER m_ddMAX_PF_PEAKBW;
  953. ADS_INTEGER m_dwServiceType;
  954. };
  955. class CACSSubnetLimitsContainer : public CACSContainerObject<CACSSubnetServiceLimits>
  956. {
  957. public:
  958. CACSSubnetLimitsContainer() : CACSContainerObject<CACSSubnetServiceLimits>(true)
  959. {};
  960. };
  961. ///////////////////////////////////////////////////////////////////////////////
  962. //
  963. // CACSSubnetObject
  964. //
  965. class CACSSubnetObject : public CACSPolicyContainer
  966. {
  967. public:
  968. // delete the object from DS -- usually not override
  969. STDMETHOD(Delete)()
  970. {
  971. HRESULT hr = CACSPolicyContainer::Delete();
  972. CHECK_HR(hr);
  973. m_spConfigObject.Release();
  974. L_ERR:
  975. return hr;
  976. };
  977. // called after the object is open,
  978. // m_pIObject, m_pIContainer are available to use
  979. // read attributes from DS should be done in this function
  980. STDMETHOD(OnOpen)()
  981. {
  982. HRESULT hr = S_OK;
  983. if(m_spConfigObject.p == NULL)
  984. {
  985. CComObject<CACSSubnetConfig>* pConfig;
  986. CHECK_HR(hr = CComObject<CACSSubnetConfig>::CreateInstance(&pConfig));
  987. ASSERT(pConfig);
  988. m_spConfigObject = pConfig;
  989. }
  990. if(m_spSubnetLimitsContainer.p == NULL)
  991. {
  992. CComObject<CACSSubnetLimitsContainer>* pCont;
  993. CHECK_HR(hr = CComObject<CACSSubnetLimitsContainer>::CreateInstance(&pCont));
  994. ASSERT(pCont);
  995. m_spSubnetLimitsContainer = pCont;
  996. }
  997. if (IfNewCreated())
  998. {
  999. // create policy for default user
  1000. CComObject<CACSPolicyElement>* pPolicy = NULL;
  1001. CComPtr<CACSPolicyElement> spPolicy;
  1002. // create the object in DS
  1003. CHECK_HR(hr = CComObject<CACSPolicyElement>::CreateInstance(&pPolicy)); // ref == 0
  1004. spPolicy = pPolicy; // ref == 1
  1005. if((CACSPolicyElement*)spPolicy)
  1006. {
  1007. spPolicy->SetFlags(ATTR_FLAG_SAVE, spPolicy->SetDefault(), true);
  1008. CHECK_HR(hr = spPolicy->Open(this, ACS_CLS_POLICY, ACSPOLICY_DEFAULT, true, true));
  1009. CHECK_HR(hr = spPolicy->Close());
  1010. }
  1011. // create policy for unknown user
  1012. // create the object in DS
  1013. CHECK_HR(hr = CComObject<CACSPolicyElement>::CreateInstance(&pPolicy)); // ref == 0
  1014. spPolicy = pPolicy; // ref == 1
  1015. if((CACSPolicyElement*)spPolicy)
  1016. {
  1017. spPolicy->SetFlags(ATTR_FLAG_SAVE, spPolicy->SetUnknown(), true);
  1018. CHECK_HR(hr = spPolicy->Open(this, ACS_CLS_POLICY, ACSPOLICY_UNKNOWN, true, true));
  1019. CHECK_HR(hr = spPolicy->Close());
  1020. }
  1021. // config object
  1022. CHECK_HR(hr = m_spConfigObject->Open(this, ACS_CLS_SUBNETCONFIG, ACS_NAME_SUBNETCONFIG, true, true));
  1023. // limits container object
  1024. CHECK_HR(hr = m_spSubnetLimitsContainer->Open(this, ACS_CLS_CONTAINER, ACS_NAME_SUBNETLIMITS, true, true));
  1025. // create default policies for the subnet
  1026. }
  1027. else
  1028. {
  1029. // config object
  1030. CHECK_HR(hr = m_spConfigObject->SetInfo(this, ACS_CLS_SUBNETCONFIG, ACS_NAME_SUBNETCONFIG));
  1031. #if 0 // fix bug 366384 1 D0707 johnmil a-leeb ACS: New snap-in not backward compatible with older subnets
  1032. // limits container object
  1033. CHECK_HR(hr = m_spLimitsContainer->SetInfo(this, ACS_CLS_CONTAINER, ACS_NAME_SUBNETLIMITS));
  1034. #else
  1035. // limits container object
  1036. CHECK_HR(hr = m_spSubnetLimitsContainer->Open(this, ACS_CLS_CONTAINER, ACS_NAME_SUBNETLIMITS, true, true));
  1037. #endif
  1038. }
  1039. L_ERR:
  1040. return hr;
  1041. };
  1042. // called before SetInfo is called to set the object
  1043. // m_pIObject, m_pIContainer are available to use
  1044. // write attributes to DS should be done in this function
  1045. STDMETHOD(OnSave)(DWORD dwAttrFlags)
  1046. {
  1047. if((CACSSubnetConfig*)m_spConfigObject) // if the subobject is open
  1048. return m_spConfigObject->Save(ATTR_FLAGS_ALL);
  1049. else
  1050. return S_OK;
  1051. };
  1052. HRESULT GetConfig(CACSSubnetConfig** ppConfig)
  1053. {
  1054. ASSERT(ppConfig);
  1055. *ppConfig = (CACSSubnetConfig*)m_spConfigObject;
  1056. if(*ppConfig) (*ppConfig)->AddRef();
  1057. return S_OK;
  1058. };
  1059. // Get service limits container object
  1060. HRESULT GetLimitsContainer( CACSSubnetLimitsContainer **ppContainer )
  1061. {
  1062. ASSERT(ppContainer);
  1063. *ppContainer = (CACSSubnetLimitsContainer*)m_spSubnetLimitsContainer;
  1064. if(*ppContainer) (*ppContainer)->AddRef();
  1065. return S_OK;
  1066. };
  1067. // ===========================================
  1068. // get the data memebers
  1069. STDMETHOD(GetString)(CString& str, int nCol);
  1070. protected:
  1071. CComPtr<CACSSubnetConfig> m_spConfigObject;
  1072. CComPtr<CACSSubnetLimitsContainer> m_spSubnetLimitsContainer;
  1073. };
  1074. ///////////////////////////////////////////////////////////////////////////////
  1075. //
  1076. // CACSContainerObject
  1077. //
  1078. //
  1079. //+----------------------------------------------------------------------------
  1080. //
  1081. // Method: CACSContainerObject::ListChildren
  1082. //
  1083. // Synopsis: list children to the list, create the children name list
  1084. //
  1085. //-----------------------------------------------------------------------------
  1086. template <class T>
  1087. HRESULT CACSContainerObject<T>::ListChildren(std::list<T*>& children, BSTR clsName)
  1088. {
  1089. CComPtr<IEnumVARIANT> spEnum;
  1090. CComPtr<IADsContainer> spContainer;
  1091. CComPtr<IADs> spChild;
  1092. CComPtr<IDispatch> spDisp;
  1093. BSTR bstr = NULL;
  1094. HRESULT hr = S_OK;
  1095. VARIANT var;
  1096. CComPtr< CComObject<T> > spDSObj;
  1097. VariantInit(&var);
  1098. RemoveAllChildren(); // RemoveAllChildren from the existing list
  1099. if(!(IADs*)m_spIADs)
  1100. CHECK_HR(hr = Reopen());
  1101. CHECK_HR(hr = m_spIADs->QueryInterface(IID_IADsContainer, (void**)&spContainer));
  1102. CHECK_HR(hr = ADsBuildEnumerator(spContainer, &spEnum));
  1103. try{
  1104. VariantClear(&var);
  1105. while(S_OK == (hr = ADsEnumerateNext(spEnum, 1, &var, NULL)))
  1106. {
  1107. spDisp.Release();
  1108. spDisp = var.pdispVal;
  1109. spChild.Release(); // make sure spChild is NULL
  1110. CHECK_HR(hr = spDisp->QueryInterface(IID_IADs, (VOID **)&spChild));
  1111. // if this object is a profile object
  1112. if(clsName)
  1113. {
  1114. CHECK_HR(spChild->get_Class(&bstr));
  1115. if (0 != _wcsicmp(bstr, clsName))
  1116. {
  1117. SysFreeString(bstr);
  1118. continue;
  1119. }
  1120. SysFreeString(bstr);
  1121. }
  1122. // create the object
  1123. spDSObj.Release(); // make sure it's NULL
  1124. CHECK_HR(hr = CComObject<T>::CreateInstance(&spDSObj)); // with 0 reference count
  1125. spDSObj->AddRef();
  1126. CHECK_HR(hr = spDSObj->Attach(this, spChild));
  1127. // add to the children list,
  1128. spDSObj->AddRef();
  1129. children.push_back(spDSObj);
  1130. // register the child in the children list
  1131. CHECK_HR(hr = AddChild(spDSObj));
  1132. CHECK_HR(hr = spDSObj->Close());
  1133. VariantClear(&var);
  1134. }
  1135. }
  1136. catch(CMemoryException&)
  1137. {
  1138. CHECK_HR(hr = E_OUTOFMEMORY);
  1139. }
  1140. m_bListed = true;
  1141. hr = S_OK;
  1142. L_ERR:
  1143. return hr;
  1144. }
  1145. //////
  1146. #endif
  1147. /////////////////////////////////////////////