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.

720 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. long QueryNumber ( INT index = 0 ) const;
  193. DHCP_IP_ADDRESS QueryIpAddr ( INT index = 0 ) const;
  194. LPCTSTR QueryString ( INT index = 0 ) const;
  195. INT QueryBinary ( INT index = 0 ) const;
  196. const CByteArray * QueryBinaryArray () const;
  197. DWORD_DWORD QueryDwordDword ( INT index = 0 ) const;
  198. //
  199. // Return a string representation of the current value.
  200. //
  201. LONG QueryDisplayString ( CString & strResult, BOOL fLineFeed = FALSE ) const;
  202. LONG QueryRouteArrayDisplayString( CString & strResult) const;
  203. //
  204. // Modifiers: SetString accepts any string representation;
  205. // others are specific.
  206. //
  207. LONG SetData ( const DHCP_OPTION_DATA * podData );
  208. LONG SetData ( const CDhcpOptionValue * pOptionValue );
  209. BOOL SetDataType ( DHCP_OPTION_DATA_TYPE dhcpType, INT cUpperBound = 0 );
  210. LONG SetString ( LPCTSTR pszNewValue, INT index = 0 );
  211. LONG SetNumber ( INT nValue, INT nIndex = 0 );
  212. LONG SetIpAddr ( DHCP_IP_ADDRESS dhcpIpAddress, INT index = 0 );
  213. LONG SetDwordDword ( DWORD_DWORD dwdwValue, INT index = 0 );
  214. LONG RemoveString ( INT index = 0);
  215. LONG RemoveNumber ( INT index = 0);
  216. LONG RemoveIpAddr ( INT index = 0);
  217. LONG RemoveDwordDword ( INT index = 0);
  218. BOOL IsValid () const;
  219. LONG CreateOptionDataStruct(//const CDhcpOptionValue * pdhcpOptionValue,
  220. LPDHCP_OPTION_DATA * ppOptionData,
  221. BOOL bForceType = FALSE);
  222. LONG FreeOptionDataStruct();
  223. // implementation
  224. private:
  225. //
  226. // Release the value union data
  227. //
  228. void FreeValue ();
  229. //
  230. // Initialize the value union data
  231. //
  232. LONG InitValue ( DHCP_OPTION_DATA_TYPE dhcDataType,
  233. INT cUpperBound,
  234. BOOL bProvideDefaultValue = TRUE );
  235. BOOL CreateBinaryData ( const DHCP_BINARY_DATA * podBin, DHCP_BINARY_DATA * pobData ) ;
  236. BOOL CreateBinaryData ( const CByteArray * paByte, DHCP_BINARY_DATA * pobData ) ;
  237. // Attributes
  238. private:
  239. DHCP_OPTION_DATA_TYPE m_dhcpOptionDataType;
  240. DHCP_OPTION_DATA * m_pdhcpOptionDataStruct;
  241. INT m_nUpperBound ;
  242. union
  243. {
  244. CObject * pCObj; // Generic pointer
  245. CDWordArray * paDword; // 8-, 16-, 32-bit data.
  246. CStringArray * paString; // String data
  247. CByteArray * paBinary; // Binary and encapsulated data
  248. CDWordDWordArray * paDwordDword;// 62-bit data.
  249. } m_dhcpOptionValue;
  250. };
  251. /////////////////////////////////////////////////////////////////////
  252. //
  253. // CDhcpOption prototype
  254. //
  255. // Simple wrapper for DHCP_OPTION
  256. //
  257. /////////////////////////////////////////////////////////////////////
  258. class CDhcpOption
  259. {
  260. public:
  261. // Standard constructor uses API data
  262. CDhcpOption ( const DHCP_OPTION & dhpOption );
  263. // Constructor that must get info about option id referenced by the given value.
  264. CDhcpOption ( const DHCP_OPTION_VALUE & dhcpOptionValue,
  265. LPCTSTR pszVendor,
  266. LPCTSTR pszClass );
  267. // Constructor with overriding value.
  268. CDhcpOption ( const CDhcpOption & dhpType,
  269. const DHCP_OPTION_VALUE & dhcOptionValue );
  270. // Constructor for dynamic instances
  271. CDhcpOption ( DHCP_OPTION_ID nId,
  272. DHCP_OPTION_DATA_TYPE dhcType,
  273. LPCTSTR pszOptionName,
  274. LPCTSTR pszComment,
  275. DHCP_OPTION_TYPE dhcOptType = DhcpUnaryElementTypeOption );
  276. // Copy constructor
  277. CDhcpOption ( const CDhcpOption & dhpType );
  278. ~CDhcpOption ();
  279. CDhcpOptionValue & QueryValue ()
  280. {
  281. return m_dhcpOptionValue ;
  282. }
  283. const CDhcpOptionValue & QueryValue () const
  284. {
  285. return m_dhcpOptionValue ;
  286. }
  287. DHCP_OPTION_DATA_TYPE QueryDataType () const
  288. {
  289. return m_dhcpOptionValue.QueryDataType() ;
  290. }
  291. DHCP_OPTION_ID QueryId () const
  292. {
  293. return m_dhcpOptionId ;
  294. }
  295. LPCTSTR QueryName () const
  296. {
  297. return m_strName ;
  298. }
  299. LPCTSTR QueryComment () const
  300. {
  301. return m_strComment ;
  302. }
  303. void SetOptType ( DHCP_OPTION_TYPE dhcOptType ) ;
  304. DHCP_OPTION_TYPE QueryOptType() const
  305. {
  306. return m_dhcpOptionType ;
  307. }
  308. // Return TRUE if the option type is an array.
  309. BOOL IsArray () const
  310. {
  311. return QueryOptType() == DhcpArrayTypeOption ;
  312. }
  313. // Fill the given string with a displayable representation of the item.
  314. void QueryDisplayName ( CString & cStr ) const ;
  315. BOOL SetName ( LPCTSTR pszName ) ;
  316. BOOL SetComment ( LPCTSTR pszComment ) ;
  317. LONG Update ( const CDhcpOptionValue & dhcpOptionValue ) ;
  318. static INT MaxSizeOfType ( DHCP_OPTION_DATA_TYPE dhcType ) ;
  319. BOOL SetDirty(BOOL bDirty = TRUE)
  320. {
  321. BOOL bOldFlag = m_bDirty;
  322. m_bDirty = bDirty;
  323. return bOldFlag;
  324. }
  325. // vendor specifc option stuff
  326. void SetVendor(LPCTSTR pszVendor) { m_strVendor = pszVendor; }
  327. BOOL IsVendor() { return !m_strVendor.IsEmpty(); }
  328. LPCTSTR GetVendor() { return m_strVendor.IsEmpty() ? NULL : (LPCTSTR) m_strVendor; }
  329. BOOL IsDirty() { return m_bDirty; }
  330. // class ID methods
  331. LPCTSTR GetClassName() { return m_strClassName; }
  332. void SetClassName(LPCTSTR pClassName) { m_strClassName = pClassName; }
  333. BOOL IsClassOption() { return m_strClassName.IsEmpty() ? FALSE : TRUE; }
  334. DWORD SetApiErr(DWORD dwErr)
  335. {
  336. DWORD dwOldErr = m_dwErr;
  337. m_dwErr = dwErr;
  338. return dwOldErr;
  339. }
  340. DWORD QueryApiErr() { return m_dwErr; }
  341. protected:
  342. DHCP_OPTION_ID m_dhcpOptionId; // Option identifier
  343. DHCP_OPTION_TYPE m_dhcpOptionType; // Option type
  344. CDhcpOptionValue m_dhcpOptionValue; // Default value info
  345. CString m_strName; // Name of option
  346. CString m_strComment; // Comment for option
  347. CString m_strVendor; // Vendor Name for this option
  348. BOOL m_bDirty;
  349. DWORD m_dwErr; // stored err for later display
  350. CString m_strClassName;
  351. };
  352. /////////////////////////////////////////////////////////////////////
  353. //
  354. // COptionList
  355. //
  356. // Object contains a list of options. Can be iterated.
  357. //
  358. /////////////////////////////////////////////////////////////////////
  359. typedef CList<CDhcpOption*, CDhcpOption*> COptionListBase;
  360. class COptionList : public COptionListBase
  361. {
  362. public:
  363. COptionList()
  364. : m_pos(NULL), m_bDirty(FALSE) {}
  365. ~COptionList()
  366. {
  367. DeleteAll();
  368. }
  369. public:
  370. void DeleteAll()
  371. {
  372. while (!IsEmpty())
  373. {
  374. delete RemoveHead();
  375. }
  376. }
  377. // removes an option from the list
  378. void Remove(CDhcpOption * pOption)
  379. {
  380. POSITION pos = Find(pOption);
  381. if (pos)
  382. RemoveAt(pos);
  383. }
  384. void Reset() { m_pos = GetHeadPosition(); }
  385. CDhcpOption * Next()
  386. {
  387. if (m_pos)
  388. return GetNext(m_pos);
  389. else
  390. return NULL;
  391. }
  392. CDhcpOption * FindId(DWORD dwId, LPCTSTR pszVendor)
  393. {
  394. CDhcpOption * pOpt = NULL;
  395. CString strVendor = pszVendor;
  396. POSITION pos = GetHeadPosition();
  397. while (pos)
  398. {
  399. CDhcpOption * pCurOpt = GetNext(pos);
  400. if ( (pCurOpt->QueryId() == dwId) &&
  401. ( (!pszVendor && !pCurOpt->GetVendor()) ||
  402. (pCurOpt->GetVendor() && (strVendor.CompareNoCase(pCurOpt->GetVendor()) == 0) ) ) )
  403. {
  404. pOpt = pCurOpt;
  405. break;
  406. }
  407. }
  408. return pOpt;
  409. }
  410. BOOL SetAll(BOOL bDirty)
  411. {
  412. BOOL bWasDirty = FALSE;
  413. POSITION pos = GetHeadPosition();
  414. while (pos)
  415. {
  416. CDhcpOption * pCurOpt = GetNext(pos);
  417. if (pCurOpt->SetDirty(bDirty))
  418. bWasDirty = TRUE;
  419. }
  420. return bWasDirty;
  421. }
  422. BOOL SetDirty(BOOL bDirty = TRUE)
  423. {
  424. BOOL bOldFlag = m_bDirty;
  425. m_bDirty = bDirty;
  426. return bOldFlag;
  427. }
  428. static int __cdecl SortByIdHelper(const void * pa, const void * pb)
  429. {
  430. CDhcpOption ** ppOpt1 = (CDhcpOption **) pa;
  431. CDhcpOption ** ppOpt2 = (CDhcpOption **) pb;
  432. if ((*ppOpt1)->QueryId() < (*ppOpt2)->QueryId())
  433. return -1;
  434. else
  435. if ((*ppOpt1)->QueryId() > (*ppOpt2)->QueryId())
  436. return 1;
  437. else
  438. {
  439. // options have equal IDs, but standard options come first
  440. if ((*ppOpt1)->IsVendor() && !(*ppOpt2)->IsVendor())
  441. return 1;
  442. else
  443. if (!(*ppOpt1)->IsVendor() && (*ppOpt2)->IsVendor())
  444. return -1;
  445. else
  446. return 0; // they are either both standard or both vendor -- equal
  447. }
  448. }
  449. LONG SortById()
  450. {
  451. LONG err = 0;
  452. CDhcpOption * pOpt;
  453. int cItems = (int) GetCount();
  454. if ( cItems < 2 )
  455. return NO_ERROR;
  456. CATCH_MEM_EXCEPTION
  457. {
  458. // Allocate the array
  459. CDhcpOption ** paOpt = (CDhcpOption **) alloca(sizeof(CDhcpOption *) * cItems);
  460. /// Fill the helper array.
  461. POSITION pos = GetHeadPosition();
  462. for (UINT i = 0; pos != NULL; i++ )
  463. {
  464. pOpt = GetNext(pos);
  465. paOpt[i] = pOpt;
  466. }
  467. RemoveAll();
  468. ASSERT( GetCount() == 0 );
  469. // Sort the helper array
  470. ::qsort( paOpt,
  471. cItems,
  472. sizeof(paOpt[0]),
  473. SortByIdHelper ) ;
  474. // Refill the list from the helper array.
  475. for ( i = 0 ; i < (UINT) cItems ; i++ )
  476. {
  477. AddTail( paOpt[i] );
  478. }
  479. ASSERT( GetCount() == cItems ) ;
  480. }
  481. END_MEM_EXCEPTION(err)
  482. return err ;
  483. }
  484. private:
  485. POSITION m_pos;
  486. BOOL m_bDirty;
  487. };
  488. /*---------------------------------------------------------------------------
  489. Class: COptionValueEnum
  490. ---------------------------------------------------------------------------*/
  491. class COptionValueEnum : public COptionList
  492. {
  493. public:
  494. COptionValueEnum();
  495. DWORD Init(LPCTSTR pServer, LARGE_INTEGER & liVersion, DHCP_OPTION_SCOPE_INFO & dhcpOptionScopeInfo);
  496. DWORD Enum();
  497. void Copy(COptionValueEnum * pEnum);
  498. void Remove(DHCP_OPTION_ID optionId, LPCTSTR pszVendor, LPCTSTR pszClass);
  499. protected:
  500. DWORD EnumOptions();
  501. DWORD EnumOptionsV5();
  502. // V5 Helper
  503. HRESULT CreateOptions(LPDHCP_OPTION_VALUE_ARRAY pOptionValues, LPCTSTR pClassName, LPCTSTR pszVendor);
  504. public:
  505. DHCP_OPTION_SCOPE_INFO m_dhcpOptionScopeInfo;
  506. LARGE_INTEGER m_liVersion;
  507. CString m_strServer;
  508. CString m_strDynBootpClassName;
  509. };
  510. /////////////////////////////////////////////////////////////////////
  511. //
  512. // CDhcpDefaultOptionsOnServer prototype
  513. //
  514. // Object contains a list of default options on a DHCP server
  515. //
  516. /////////////////////////////////////////////////////////////////////
  517. class CDhcpDefaultOptionsOnServer
  518. {
  519. // constructors
  520. public:
  521. CDhcpDefaultOptionsOnServer();
  522. ~CDhcpDefaultOptionsOnServer();
  523. // exposed functions
  524. public:
  525. LONG Enumerate(LPCWSTR pServer, LARGE_INTEGER liVersion);
  526. CDhcpOption * Find(DHCP_OPTION_ID dhcpOptionId, LPCTSTR pszVendor);
  527. BOOL IsEmpty() { return m_listOptions.IsEmpty(); }
  528. int GetCount() { return (int) m_listOptions.GetCount(); }
  529. CDhcpOption * First();
  530. CDhcpOption * Next();
  531. void Reset();
  532. LONG SortById();
  533. COptionList & GetOptionList() { return m_listOptions; }
  534. // implementation
  535. private:
  536. LONG RemoveAll();
  537. LONG EnumerateV4(LPCWSTR pServer);
  538. LONG EnumerateV5(LPCWSTR pServer);
  539. // attributes
  540. private:
  541. COptionList m_listOptions;
  542. DWORD m_dwLastUpdate;
  543. DWORD m_dwOptionsTotal;
  544. POSITION m_pos;
  545. };
  546. /////////////////////////////////////////////////////////////////////
  547. //
  548. // CDhcpDefaultOptionsMasterList prototype
  549. //
  550. // Object contains master list of known options
  551. //
  552. /////////////////////////////////////////////////////////////////////
  553. enum OPT_FIELD
  554. {
  555. OPTF_OPTION,
  556. OPTF_NAME,
  557. OPTF_TYPE,
  558. OPTF_ARRAY_FLAG,
  559. OPTF_LENGTH,
  560. OPTF_DESCRIPTION,
  561. OPTF_REMARK,
  562. OPTF_MAX
  563. };
  564. typedef struct
  565. {
  566. int eOptType ;
  567. LPCTSTR pszOptTypeName ;
  568. } OPT_TOKEN ;
  569. class CDhcpDefaultOptionsMasterList
  570. {
  571. // constructors
  572. public:
  573. CDhcpDefaultOptionsMasterList();
  574. ~CDhcpDefaultOptionsMasterList();
  575. // exposed functions
  576. public:
  577. LONG BuildList();
  578. CDhcpOption * First();
  579. CDhcpOption * Next();
  580. void Reset();
  581. int GetCount();
  582. // implementation
  583. private:
  584. BOOL scanNextParamType(LPCTSTR * ppszText, CDhcpOption * * ppParamType);
  585. LPCTSTR scanNextField(LPCTSTR pszLine, LPTSTR pszOut, int cFieldSize);
  586. BOOL allDigits(LPCTSTR psz);
  587. int recognizeToken(OPT_TOKEN * apToken, LPCTSTR pszToken);
  588. LPCTSTR skipToNextLine(LPCTSTR pszLine);
  589. BOOL skipWs(LPCTSTR * ppszLine);
  590. // attributes
  591. private:
  592. COptionList m_listOptions;
  593. POSITION m_pos;
  594. };
  595. #endif _GENERAL_H