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.

721 lines
20 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. general.h
  7. Header file for the general DHCP snapin admin classes
  8. FILE HISTORY:
  9. */
  10. #ifndef _GENERAL_H
  11. #define _GENERAL_H
  12. extern const TCHAR g_szDefaultHelpTopic[];
  13. #define SCOPE_DFAULT_LEASE_DAYS 8
  14. #define SCOPE_DFAULT_LEASE_HOURS 0
  15. #define SCOPE_DFAULT_LEASE_MINUTES 0
  16. #define MSCOPE_DFAULT_LEASE_DAYS 30
  17. #define MSCOPE_DFAULT_LEASE_HOURS 0
  18. #define MSCOPE_DFAULT_LEASE_MINUTES 0
  19. #define DYN_BOOTP_DFAULT_LEASE_DAYS 30
  20. #define DYN_BOOTP_DFAULT_LEASE_HOURS 0
  21. #define DYN_BOOTP_DFAULT_LEASE_MINUTES 0
  22. #define DHCP_IP_ADDRESS_INVALID ((DHCP_IP_ADDRESS)0)
  23. #define DHCP_OPTION_ID_CSR 249
  24. class CDhcpServer;
  25. class CTimerDesc
  26. {
  27. public:
  28. SPITFSNode spNode;
  29. CDhcpServer * pServer;
  30. UINT_PTR uTimer;
  31. TIMERPROC timerProc;
  32. };
  33. typedef CArray<CTimerDesc *, CTimerDesc *> CTimerArrayBase;
  34. class CTimerMgr : CTimerArrayBase
  35. {
  36. public:
  37. CTimerMgr();
  38. ~CTimerMgr();
  39. public:
  40. int AllocateTimer(ITFSNode * pNode, CDhcpServer * pServer, UINT uTimerValue, TIMERPROC TimerProc);
  41. void FreeTimer(UINT_PTR uEventId);
  42. void ChangeInterval(UINT_PTR uEventId, UINT uNewInterval);
  43. CTimerDesc * GetTimerDesc(UINT_PTR uEventId);
  44. CCriticalSection m_csTimerMgr;
  45. };
  46. typedef CArray<DWORD_DWORD, DWORD_DWORD> CDWordDWordArray;
  47. /////////////////////////////////////////////////////////////////////
  48. //
  49. // CDhcpIpRange prototype
  50. //
  51. // Simple wrapper for a DHCP_IP_RANGE
  52. //
  53. /////////////////////////////////////////////////////////////////////
  54. class CDhcpClient
  55. {
  56. public:
  57. CDhcpClient ( const DHCP_CLIENT_INFO * pdhcClientInfo ) ;
  58. CDhcpClient ( const DHCP_CLIENT_INFO_V4 * pdhcClientInfo ) ;
  59. CDhcpClient () ;
  60. ~ CDhcpClient () ;
  61. const CString & QueryName () const
  62. { return m_strName ; }
  63. const CString & QueryComment () const
  64. { return m_strComment ; }
  65. const CString & QueryHostName ( BOOL bNetbios = FALSE ) const
  66. { return bNetbios ? m_strHostNetbiosName : m_strHostName ; }
  67. DHCP_IP_ADDRESS QueryIpAddress () const
  68. { return m_dhcpIpAddress ; }
  69. DHCP_IP_MASK QuerySubnet () const
  70. { return m_dhcpIpMask ; }
  71. DHCP_IP_ADDRESS QueryHostAddress () const
  72. { return m_dhcpIpHost ; }
  73. const DATE_TIME & QueryExpiryDateTime () const
  74. { return m_dtExpires ; }
  75. const CByteArray & QueryHardwareAddress () const
  76. { return m_baHardwareAddress ; }
  77. BYTE QueryClientType() const
  78. { return m_bClientType; }
  79. BOOL IsReservation () const
  80. { return m_bReservation ; }
  81. void SetReservation ( BOOL bReservation = TRUE )
  82. { m_bReservation = bReservation ; }
  83. // Data change accessors: SOME OF THESE THROW EXCEPTIONS
  84. void SetIpAddress ( DHCP_IP_ADDRESS dhipa )
  85. { m_dhcpIpAddress = dhipa ; }
  86. void SetIpMask ( DHCP_IP_ADDRESS dhipa )
  87. { m_dhcpIpMask = dhipa ; }
  88. void SetName ( const CString & cName )
  89. { m_strName = cName ; }
  90. void SetComment( const CString & cComment )
  91. { m_strComment = cComment ; }
  92. void SetHostName ( const CString & cHostName )
  93. { m_strHostName = cHostName ; }
  94. void SetHostNetbiosName ( const CString & cHostNbName )
  95. { m_strHostNetbiosName = cHostNbName ; }
  96. void SetHostIpAddress ( DHCP_IP_ADDRESS dhipa )
  97. { m_dhcpIpHost = dhipa ; }
  98. void SetExpiryDateTime ( DATE_TIME dt )
  99. { m_dtExpires = dt ; }
  100. void SetHardwareAddress ( const CByteArray & caByte ) ;
  101. void SetClientType(BYTE bClientType)
  102. { m_bClientType = bClientType; }
  103. protected:
  104. void InitializeData(const DHCP_CLIENT_INFO * pdhcClientInfo);
  105. protected:
  106. DHCP_IP_ADDRESS m_dhcpIpAddress; // Client's IP address
  107. DHCP_IP_MASK m_dhcpIpMask; // Client's subnet
  108. CByteArray m_baHardwareAddress; // hardware addresss
  109. CString m_strName; // Client name
  110. CString m_strComment; // Client comment
  111. DATE_TIME m_dtExpires; // date/time lease expires
  112. BOOL m_bReservation; // This is a reservation
  113. BYTE m_bClientType; // Client Type V4 and above only
  114. // Host information
  115. CString m_strHostName;
  116. CString m_strHostNetbiosName;
  117. DHCP_IP_ADDRESS m_dhcpIpHost;
  118. };
  119. /////////////////////////////////////////////////////////////////////
  120. //
  121. // CDhcpIpRange prototype
  122. //
  123. // Simple wrapper for a DHCP_IP_RANGE
  124. //
  125. /////////////////////////////////////////////////////////////////////
  126. class CDhcpIpRange
  127. {
  128. protected:
  129. DHCP_IP_RANGE m_dhcpIpRange;
  130. UINT m_RangeType;
  131. public:
  132. CDhcpIpRange (DHCP_IP_RANGE dhcpIpRange);
  133. CDhcpIpRange ();
  134. virtual ~CDhcpIpRange();
  135. operator DHCP_IP_RANGE ()
  136. { return m_dhcpIpRange; }
  137. operator DHCP_IP_RANGE () const
  138. { return m_dhcpIpRange; }
  139. // Return TRUE if both addresses are generally OK
  140. operator BOOL ()
  141. { return m_dhcpIpRange.StartAddress != DHCP_IP_ADDRESS_INVALID
  142. && m_dhcpIpRange.EndAddress != DHCP_IP_ADDRESS_INVALID
  143. && m_dhcpIpRange.StartAddress <= m_dhcpIpRange.EndAddress; }
  144. CDhcpIpRange & operator = (const DHCP_IP_RANGE dhcpIpRange);
  145. DHCP_IP_ADDRESS QueryAddr (BOOL bStart) const
  146. { return bStart ? m_dhcpIpRange.StartAddress : m_dhcpIpRange.EndAddress; }
  147. DHCP_IP_ADDRESS SetAddr (DHCP_IP_ADDRESS dhcpIpAddress, BOOL bStart);
  148. // Return TRUE if this range overlaps the given range.
  149. BOOL IsOverlap (DHCP_IP_RANGE dhcpIpRange);
  150. // Return TRUE if this range is a subset of the given range.
  151. BOOL IsSubset (DHCP_IP_RANGE dhcpIpRange);
  152. // Return TRUE if this range is a superset of the given range.
  153. BOOL IsSuperset (DHCP_IP_RANGE dhcpIpRange);
  154. // Sort helper function
  155. //int OrderByAddress ( const CObjectPlus * pobIpRange ) const;
  156. void SetRangeType(UINT uRangeType);
  157. UINT GetRangeType();
  158. };
  159. typedef CList<CDhcpIpRange *, CDhcpIpRange *> CExclusionList;
  160. /////////////////////////////////////////////////////////////////////
  161. //
  162. // CDhcpOptionValue prototype
  163. //
  164. // Simple wrapper for DHCP_OPTION_DATA
  165. //
  166. /////////////////////////////////////////////////////////////////////
  167. class CDhcpOptionValue
  168. {
  169. public:
  170. CDhcpOptionValue ( const DHCP_OPTION & dhcpOption );
  171. CDhcpOptionValue ( const DHCP_OPTION_VALUE & dhcpOptionValue );
  172. CDhcpOptionValue ( DHCP_OPTION_DATA_TYPE dhcDataType, INT cUpperBound = 0);
  173. // Copy constructor.
  174. CDhcpOptionValue ( const CDhcpOptionValue & cOptionValue );
  175. CDhcpOptionValue ( const CDhcpOptionValue * dhcpOption );
  176. // Assignment operator: assign a new value to this one.
  177. CDhcpOptionValue & operator = ( const CDhcpOptionValue & dhcpValue );
  178. CDhcpOptionValue () { };
  179. ~CDhcpOptionValue ();
  180. //
  181. // Query functions
  182. //
  183. DHCP_OPTION_DATA_TYPE QueryDataType () const
  184. {
  185. return m_dhcpOptionDataType;
  186. }
  187. int QueryUpperBound () const
  188. {
  189. return m_nUpperBound;
  190. }
  191. void SetUpperBound ( int nNewBound = 1 );
  192. void RemoveAll();
  193. long QueryNumber ( INT index = 0 ) const;
  194. DHCP_IP_ADDRESS QueryIpAddr ( INT index = 0 ) const;
  195. LPCTSTR QueryString ( INT index = 0 ) const;
  196. INT QueryBinary ( INT index = 0 ) const;
  197. const CByteArray * QueryBinaryArray () const;
  198. DWORD_DWORD QueryDwordDword ( INT index = 0 ) const;
  199. //
  200. // Return a string representation of the current value.
  201. //
  202. LONG QueryDisplayString ( CString & strResult, BOOL fLineFeed = FALSE ) const;
  203. LONG QueryRouteArrayDisplayString( CString & strResult) const;
  204. //
  205. // Modifiers: SetString accepts any string representation;
  206. // others are specific.
  207. //
  208. LONG SetData ( const DHCP_OPTION_DATA * podData );
  209. LONG SetData ( const CDhcpOptionValue * pOptionValue );
  210. BOOL SetDataType ( DHCP_OPTION_DATA_TYPE dhcpType, INT cUpperBound = 0 );
  211. LONG SetString ( LPCTSTR pszNewValue, INT index = 0 );
  212. LONG SetNumber ( INT nValue, INT nIndex = 0 );
  213. LONG SetIpAddr ( DHCP_IP_ADDRESS dhcpIpAddress, INT index = 0 );
  214. LONG SetDwordDword ( DWORD_DWORD dwdwValue, INT index = 0 );
  215. LONG RemoveString ( INT index = 0);
  216. LONG RemoveNumber ( INT index = 0);
  217. LONG RemoveIpAddr ( INT index = 0);
  218. LONG RemoveDwordDword ( INT index = 0);
  219. BOOL IsValid () const;
  220. LONG CreateOptionDataStruct(//const CDhcpOptionValue * pdhcpOptionValue,
  221. LPDHCP_OPTION_DATA * ppOptionData,
  222. BOOL bForceType = FALSE);
  223. LONG FreeOptionDataStruct();
  224. // implementation
  225. private:
  226. //
  227. // Release the value union data
  228. //
  229. void FreeValue ();
  230. //
  231. // Initialize the value union data
  232. //
  233. LONG InitValue ( DHCP_OPTION_DATA_TYPE dhcDataType,
  234. INT cUpperBound,
  235. BOOL bProvideDefaultValue = TRUE );
  236. BOOL CreateBinaryData ( const DHCP_BINARY_DATA * podBin, DHCP_BINARY_DATA * pobData ) ;
  237. BOOL CreateBinaryData ( const CByteArray * paByte, DHCP_BINARY_DATA * pobData ) ;
  238. // Attributes
  239. private:
  240. DHCP_OPTION_DATA_TYPE m_dhcpOptionDataType;
  241. DHCP_OPTION_DATA * m_pdhcpOptionDataStruct;
  242. INT m_nUpperBound ;
  243. union
  244. {
  245. CObject * pCObj; // Generic pointer
  246. CDWordArray * paDword; // 8-, 16-, 32-bit data.
  247. CStringArray * paString; // String data
  248. CByteArray * paBinary; // Binary and encapsulated data
  249. CDWordDWordArray * paDwordDword;// 62-bit data.
  250. } m_dhcpOptionValue;
  251. };
  252. /////////////////////////////////////////////////////////////////////
  253. //
  254. // CDhcpOption prototype
  255. //
  256. // Simple wrapper for DHCP_OPTION
  257. //
  258. /////////////////////////////////////////////////////////////////////
  259. class CDhcpOption
  260. {
  261. public:
  262. // Standard constructor uses API data
  263. CDhcpOption ( const DHCP_OPTION & dhpOption );
  264. // Constructor that must get info about option id referenced by the given value.
  265. CDhcpOption ( const DHCP_OPTION_VALUE & dhcpOptionValue,
  266. LPCTSTR pszVendor,
  267. LPCTSTR pszClass );
  268. // Constructor with overriding value.
  269. CDhcpOption ( const CDhcpOption & dhpType,
  270. const DHCP_OPTION_VALUE & dhcOptionValue );
  271. // Constructor for dynamic instances
  272. CDhcpOption ( DHCP_OPTION_ID nId,
  273. DHCP_OPTION_DATA_TYPE dhcType,
  274. LPCTSTR pszOptionName,
  275. LPCTSTR pszComment,
  276. DHCP_OPTION_TYPE dhcOptType = DhcpUnaryElementTypeOption );
  277. // Copy constructor
  278. CDhcpOption ( const CDhcpOption & dhpType );
  279. ~CDhcpOption ();
  280. CDhcpOptionValue & QueryValue ()
  281. {
  282. return m_dhcpOptionValue ;
  283. }
  284. const CDhcpOptionValue & QueryValue () const
  285. {
  286. return m_dhcpOptionValue ;
  287. }
  288. DHCP_OPTION_DATA_TYPE QueryDataType () const
  289. {
  290. return m_dhcpOptionValue.QueryDataType() ;
  291. }
  292. DHCP_OPTION_ID QueryId () const
  293. {
  294. return m_dhcpOptionId ;
  295. }
  296. LPCTSTR QueryName () const
  297. {
  298. return m_strName ;
  299. }
  300. LPCTSTR QueryComment () const
  301. {
  302. return m_strComment ;
  303. }
  304. void SetOptType ( DHCP_OPTION_TYPE dhcOptType ) ;
  305. DHCP_OPTION_TYPE QueryOptType() const
  306. {
  307. return m_dhcpOptionType ;
  308. }
  309. // Return TRUE if the option type is an array.
  310. BOOL IsArray () const
  311. {
  312. return QueryOptType() == DhcpArrayTypeOption ;
  313. }
  314. // Fill the given string with a displayable representation of the item.
  315. void QueryDisplayName ( CString & cStr ) const ;
  316. BOOL SetName ( LPCTSTR pszName ) ;
  317. BOOL SetComment ( LPCTSTR pszComment ) ;
  318. LONG Update ( const CDhcpOptionValue & dhcpOptionValue ) ;
  319. static INT MaxSizeOfType ( DHCP_OPTION_DATA_TYPE dhcType ) ;
  320. BOOL SetDirty(BOOL bDirty = TRUE)
  321. {
  322. BOOL bOldFlag = m_bDirty;
  323. m_bDirty = bDirty;
  324. return bOldFlag;
  325. }
  326. // vendor specifc option stuff
  327. void SetVendor(LPCTSTR pszVendor) { m_strVendor = pszVendor; }
  328. BOOL IsVendor() { return !m_strVendor.IsEmpty(); }
  329. LPCTSTR GetVendor() { return m_strVendor.IsEmpty() ? NULL : (LPCTSTR) m_strVendor; }
  330. BOOL IsDirty() { return m_bDirty; }
  331. // class ID methods
  332. LPCTSTR GetClassName() { return m_strClassName; }
  333. void SetClassName(LPCTSTR pClassName) { m_strClassName = pClassName; }
  334. BOOL IsClassOption() { return m_strClassName.IsEmpty() ? FALSE : TRUE; }
  335. DWORD SetApiErr(DWORD dwErr)
  336. {
  337. DWORD dwOldErr = m_dwErr;
  338. m_dwErr = dwErr;
  339. return dwOldErr;
  340. }
  341. DWORD QueryApiErr() { return m_dwErr; }
  342. protected:
  343. DHCP_OPTION_ID m_dhcpOptionId; // Option identifier
  344. DHCP_OPTION_TYPE m_dhcpOptionType; // Option type
  345. CDhcpOptionValue m_dhcpOptionValue; // Default value info
  346. CString m_strName; // Name of option
  347. CString m_strComment; // Comment for option
  348. CString m_strVendor; // Vendor Name for this option
  349. BOOL m_bDirty;
  350. DWORD m_dwErr; // stored err for later display
  351. CString m_strClassName;
  352. };
  353. /////////////////////////////////////////////////////////////////////
  354. //
  355. // COptionList
  356. //
  357. // Object contains a list of options. Can be iterated.
  358. //
  359. /////////////////////////////////////////////////////////////////////
  360. typedef CList<CDhcpOption*, CDhcpOption*> COptionListBase;
  361. class COptionList : public COptionListBase
  362. {
  363. public:
  364. COptionList()
  365. : m_pos(NULL), m_bDirty(FALSE) {}
  366. ~COptionList()
  367. {
  368. DeleteAll();
  369. }
  370. public:
  371. void DeleteAll()
  372. {
  373. while (!IsEmpty())
  374. {
  375. delete RemoveHead();
  376. }
  377. }
  378. // removes an option from the list
  379. void Remove(CDhcpOption * pOption)
  380. {
  381. POSITION pos = Find(pOption);
  382. if (pos)
  383. RemoveAt(pos);
  384. }
  385. void Reset() { m_pos = GetHeadPosition(); }
  386. CDhcpOption * Next()
  387. {
  388. if (m_pos)
  389. return GetNext(m_pos);
  390. else
  391. return NULL;
  392. }
  393. CDhcpOption * FindId(DWORD dwId, LPCTSTR pszVendor)
  394. {
  395. CDhcpOption * pOpt = NULL;
  396. CString strVendor = pszVendor;
  397. POSITION pos = GetHeadPosition();
  398. while (pos)
  399. {
  400. CDhcpOption * pCurOpt = GetNext(pos);
  401. if ( (pCurOpt->QueryId() == dwId) &&
  402. ( (!pszVendor && !pCurOpt->GetVendor()) ||
  403. (pCurOpt->GetVendor() && (strVendor.CompareNoCase(pCurOpt->GetVendor()) == 0) ) ) )
  404. {
  405. pOpt = pCurOpt;
  406. break;
  407. }
  408. }
  409. return pOpt;
  410. }
  411. BOOL SetAll(BOOL bDirty)
  412. {
  413. BOOL bWasDirty = FALSE;
  414. POSITION pos = GetHeadPosition();
  415. while (pos)
  416. {
  417. CDhcpOption * pCurOpt = GetNext(pos);
  418. if (pCurOpt->SetDirty(bDirty))
  419. bWasDirty = TRUE;
  420. }
  421. return bWasDirty;
  422. }
  423. BOOL SetDirty(BOOL bDirty = TRUE)
  424. {
  425. BOOL bOldFlag = m_bDirty;
  426. m_bDirty = bDirty;
  427. return bOldFlag;
  428. }
  429. static int __cdecl SortByIdHelper(const void * pa, const void * pb)
  430. {
  431. CDhcpOption ** ppOpt1 = (CDhcpOption **) pa;
  432. CDhcpOption ** ppOpt2 = (CDhcpOption **) pb;
  433. if ((*ppOpt1)->QueryId() < (*ppOpt2)->QueryId())
  434. return -1;
  435. else
  436. if ((*ppOpt1)->QueryId() > (*ppOpt2)->QueryId())
  437. return 1;
  438. else
  439. {
  440. // options have equal IDs, but standard options come first
  441. if ((*ppOpt1)->IsVendor() && !(*ppOpt2)->IsVendor())
  442. return 1;
  443. else
  444. if (!(*ppOpt1)->IsVendor() && (*ppOpt2)->IsVendor())
  445. return -1;
  446. else
  447. return 0; // they are either both standard or both vendor -- equal
  448. }
  449. }
  450. LONG SortById()
  451. {
  452. LONG err = 0;
  453. CDhcpOption * pOpt;
  454. int cItems = (int) GetCount();
  455. if ( cItems < 2 )
  456. return NO_ERROR;
  457. CATCH_MEM_EXCEPTION
  458. {
  459. // Allocate the array
  460. CDhcpOption ** paOpt = (CDhcpOption **) alloca(sizeof(CDhcpOption *) * cItems);
  461. /// Fill the helper array.
  462. POSITION pos = GetHeadPosition();
  463. for (UINT i = 0; pos != NULL; i++ )
  464. {
  465. pOpt = GetNext(pos);
  466. paOpt[i] = pOpt;
  467. }
  468. RemoveAll();
  469. ASSERT( GetCount() == 0 );
  470. // Sort the helper array
  471. ::qsort( paOpt,
  472. cItems,
  473. sizeof(paOpt[0]),
  474. SortByIdHelper ) ;
  475. // Refill the list from the helper array.
  476. for ( i = 0 ; i < (UINT) cItems ; i++ )
  477. {
  478. AddTail( paOpt[i] );
  479. }
  480. ASSERT( GetCount() == cItems ) ;
  481. }
  482. END_MEM_EXCEPTION(err)
  483. return err ;
  484. }
  485. private:
  486. POSITION m_pos;
  487. BOOL m_bDirty;
  488. };
  489. /*---------------------------------------------------------------------------
  490. Class: COptionValueEnum
  491. ---------------------------------------------------------------------------*/
  492. class COptionValueEnum : public COptionList
  493. {
  494. public:
  495. COptionValueEnum();
  496. DWORD Init(LPCTSTR pServer, LARGE_INTEGER & liVersion, DHCP_OPTION_SCOPE_INFO & dhcpOptionScopeInfo);
  497. DWORD Enum();
  498. void Copy(COptionValueEnum * pEnum);
  499. void Remove(DHCP_OPTION_ID optionId, LPCTSTR pszVendor, LPCTSTR pszClass);
  500. protected:
  501. DWORD EnumOptions();
  502. DWORD EnumOptionsV5();
  503. // V5 Helper
  504. HRESULT CreateOptions(LPDHCP_OPTION_VALUE_ARRAY pOptionValues, LPCTSTR pClassName, LPCTSTR pszVendor);
  505. public:
  506. DHCP_OPTION_SCOPE_INFO m_dhcpOptionScopeInfo;
  507. LARGE_INTEGER m_liVersion;
  508. CString m_strServer;
  509. CString m_strDynBootpClassName;
  510. };
  511. /////////////////////////////////////////////////////////////////////
  512. //
  513. // CDhcpDefaultOptionsOnServer prototype
  514. //
  515. // Object contains a list of default options on a DHCP server
  516. //
  517. /////////////////////////////////////////////////////////////////////
  518. class CDhcpDefaultOptionsOnServer
  519. {
  520. // constructors
  521. public:
  522. CDhcpDefaultOptionsOnServer();
  523. ~CDhcpDefaultOptionsOnServer();
  524. // exposed functions
  525. public:
  526. LONG Enumerate(LPCWSTR pServer, LARGE_INTEGER liVersion);
  527. CDhcpOption * Find(DHCP_OPTION_ID dhcpOptionId, LPCTSTR pszVendor);
  528. BOOL IsEmpty() { return m_listOptions.IsEmpty(); }
  529. int GetCount() { return (int) m_listOptions.GetCount(); }
  530. CDhcpOption * First();
  531. CDhcpOption * Next();
  532. void Reset();
  533. LONG SortById();
  534. COptionList & GetOptionList() { return m_listOptions; }
  535. // implementation
  536. private:
  537. LONG RemoveAll();
  538. LONG EnumerateV4(LPCWSTR pServer);
  539. LONG EnumerateV5(LPCWSTR pServer);
  540. // attributes
  541. private:
  542. COptionList m_listOptions;
  543. DWORD m_dwLastUpdate;
  544. DWORD m_dwOptionsTotal;
  545. POSITION m_pos;
  546. };
  547. /////////////////////////////////////////////////////////////////////
  548. //
  549. // CDhcpDefaultOptionsMasterList prototype
  550. //
  551. // Object contains master list of known options
  552. //
  553. /////////////////////////////////////////////////////////////////////
  554. enum OPT_FIELD
  555. {
  556. OPTF_OPTION,
  557. OPTF_NAME,
  558. OPTF_TYPE,
  559. OPTF_ARRAY_FLAG,
  560. OPTF_LENGTH,
  561. OPTF_DESCRIPTION,
  562. OPTF_REMARK,
  563. OPTF_MAX
  564. };
  565. typedef struct
  566. {
  567. int eOptType ;
  568. LPCTSTR pszOptTypeName ;
  569. } OPT_TOKEN ;
  570. class CDhcpDefaultOptionsMasterList
  571. {
  572. // constructors
  573. public:
  574. CDhcpDefaultOptionsMasterList();
  575. ~CDhcpDefaultOptionsMasterList();
  576. // exposed functions
  577. public:
  578. LONG BuildList();
  579. CDhcpOption * First();
  580. CDhcpOption * Next();
  581. void Reset();
  582. int GetCount();
  583. // implementation
  584. private:
  585. BOOL scanNextParamType(LPCTSTR * ppszText, CDhcpOption * * ppParamType);
  586. LPCTSTR scanNextField(LPCTSTR pszLine, LPTSTR pszOut, int cFieldSize);
  587. BOOL allDigits(LPCTSTR psz);
  588. int recognizeToken(OPT_TOKEN * apToken, LPCTSTR pszToken);
  589. LPCTSTR skipToNextLine(LPCTSTR pszLine);
  590. BOOL skipWs(LPCTSTR * ppszLine);
  591. // attributes
  592. private:
  593. COptionList m_listOptions;
  594. POSITION m_pos;
  595. };
  596. #endif _GENERAL_H