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.

795 lines
20 KiB

  1. /******************************************************************
  2. CIPPersistedRTble.CPP -- WMI provider class implementation
  3. Generated by Microsoft WMI Code Generation Engine
  4. TO DO: - See individual function headers
  5. - When linking, make sure you link to framedyd.lib &
  6. msvcrtd.lib (debug) or framedyn.lib & msvcrt.lib (retail).
  7. Description:
  8. ******************************************************************/
  9. #include "precomp.h"
  10. #include <winsock2.h>
  11. #include <provexpt.h>
  12. #include <provtempl.h>
  13. #include <provmt.h>
  14. #include <typeinfo.h>
  15. #include <provcont.h>
  16. #include <provval.h>
  17. #include <provtype.h>
  18. #include <cregcls.h>
  19. #include "CIPPersistedRTble.h"
  20. extern const WCHAR *RouteDestination ;
  21. extern const WCHAR *RouteInformation ;
  22. extern const WCHAR *RouteMask ;
  23. extern const WCHAR *RouteMetric1 ;
  24. extern const WCHAR *RouteNextHop ;
  25. extern const WCHAR *RouteName ;
  26. extern const WCHAR *RouteCaption ;
  27. extern const WCHAR *RouteDescription ;
  28. #define TCIP_PERSISTENT_REG L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\PersistentRoutes"
  29. #define MAX_METRIC1 9999
  30. #define PERSITENT_ROUTE_SEP L','
  31. CIPPersistedRouteTable MyCIPPersistedRouteTableSet (
  32. PROVIDER_NAME_CIPPERSISTEDROUTETABLE ,
  33. L"root\\cimv2"
  34. ) ;
  35. /*****************************************************************************
  36. *
  37. * FUNCTION : CIPPersistedRouteTable::CIPPersistedRouteTable
  38. *
  39. * DESCRIPTION : Constructor
  40. *
  41. * INPUTS : none
  42. *
  43. * RETURNS : nothing
  44. *
  45. * COMMENTS : Calls the Provider constructor.
  46. *
  47. *****************************************************************************/
  48. CIPPersistedRouteTable :: CIPPersistedRouteTable (
  49. LPCWSTR lpwszName,
  50. LPCWSTR lpwszNameSpace
  51. ) : Provider ( lpwszName , lpwszNameSpace )
  52. {
  53. }
  54. /*****************************************************************************
  55. *
  56. * FUNCTION : CIPPersistedRouteTable::~CIPPersistedRouteTable
  57. *
  58. * DESCRIPTION : Destructor
  59. *
  60. * INPUTS : none
  61. *
  62. * RETURNS : nothing
  63. *
  64. * COMMENTS :
  65. *
  66. *****************************************************************************/
  67. CIPPersistedRouteTable :: ~CIPPersistedRouteTable ()
  68. {
  69. }
  70. /*****************************************************************************
  71. *
  72. * FUNCTION : CIPPersistedRouteTable::EnumerateInstances
  73. *
  74. * DESCRIPTION : Returns all the instances of this class.
  75. *
  76. * INPUTS : A pointer to the MethodContext for communication with WinMgmt.
  77. * A long that contains the flags described in
  78. * IWbemServices::CreateInstanceEnumAsync. Note that the following
  79. * flags are handled by (and filtered out by) WinMgmt:
  80. * WBEM_FLAG_DEEP
  81. * WBEM_FLAG_SHALLOW
  82. * WBEM_FLAG_RETURN_IMMEDIATELY
  83. * WBEM_FLAG_FORWARD_ONLY
  84. * WBEM_FLAG_BIDIRECTIONAL
  85. *
  86. * RETURNS : WBEM_S_NO_ERROR if successful
  87. *
  88. * COMMENTS : TO DO: All instances on the machine should be returned here and
  89. * all properties that this class knows how to populate must
  90. * be filled in. If there are no instances, return
  91. * WBEM_S_NO_ERROR. It is not an error to have no instances.
  92. * If you are implementing a 'method only' provider, you
  93. * should remove this method.
  94. *
  95. *****************************************************************************/
  96. HRESULT CIPPersistedRouteTable :: EnumerateInstances (
  97. MethodContext *pMethodContext,
  98. long lFlags
  99. )
  100. {
  101. HRESULT hRes = WBEM_S_NO_ERROR ;
  102. CRegistry t_Reg;
  103. DWORD dwError = ERROR_SUCCESS;
  104. if ( ( dwError = t_Reg.Open( HKEY_LOCAL_MACHINE, TCIP_PERSISTENT_REG, KEY_READ) ) == ERROR_SUCCESS)
  105. {
  106. WCHAR *pValueName = NULL ;
  107. BYTE *pValueData = NULL ;
  108. try
  109. {
  110. for(DWORD i = 0 ; i < t_Reg.GetValueCount() && SUCCEEDED(hRes); i++)
  111. {
  112. DWORD dwRetCode = t_Reg.EnumerateAndGetValues(i, pValueName, pValueData) ;
  113. if(dwRetCode == ERROR_SUCCESS)
  114. {
  115. CHString t_Dest ;
  116. CHString t_Mask ;
  117. CHString t_NextHop ;
  118. long t_Metric ;
  119. if ( Parse ( pValueName , t_Dest , t_Mask , t_NextHop , t_Metric ) )
  120. {
  121. CInstance *pInstance = CreateNewInstance ( pMethodContext ) ;
  122. if (pInstance != NULL )
  123. {
  124. /*
  125. * Initialize the instance
  126. */
  127. pInstance->SetCHString( RouteDestination, t_Dest ) ;
  128. pInstance->SetCHString( RouteMask, t_Mask ) ;
  129. pInstance->SetCHString( RouteNextHop, t_NextHop ) ;
  130. pInstance->SetDWORD ( RouteMetric1, t_Metric ) ;
  131. //set the inherited properties that are sensible
  132. SetInheritedProperties (
  133. t_Dest ,
  134. t_NextHop ,
  135. t_Mask ,
  136. t_Metric ,
  137. *pInstance
  138. ) ;
  139. /*
  140. * Forward the instance onto the core wmi service
  141. */
  142. hRes = Commit ( pInstance ) ;
  143. }
  144. }
  145. }
  146. if ( pValueName )
  147. {
  148. delete [] pValueName ;
  149. pValueName = NULL ;
  150. }
  151. if ( pValueData )
  152. {
  153. delete [] pValueData ;
  154. pValueData = NULL ;
  155. }
  156. }
  157. t_Reg.Close() ;
  158. }
  159. catch ( ... )
  160. {
  161. if ( pValueName )
  162. {
  163. delete [] pValueName ;
  164. pValueName = NULL ;
  165. }
  166. if ( pValueData )
  167. {
  168. delete [] pValueData ;
  169. pValueData = NULL ;
  170. }
  171. throw ;
  172. }
  173. }
  174. else
  175. {
  176. if ( ERROR_ACCESS_DENIED == dwError )
  177. {
  178. hRes = WBEM_E_ACCESS_DENIED ;
  179. }
  180. else
  181. {
  182. hRes = WBEM_E_FAILED ;
  183. }
  184. }
  185. return hRes ;
  186. }
  187. /*****************************************************************************
  188. *
  189. * FUNCTION : CIPPersistedRouteTable::GetObject
  190. *
  191. * DESCRIPTION : Find a single instance based on the key properties for the
  192. * class.
  193. *
  194. * INPUTS : A pointer to a CInstance object containing the key properties.
  195. * A long that contains the flags described in
  196. * IWbemServices::GetObjectAsync.
  197. *
  198. * RETURNS : WBEM_S_NO_ERROR if the instance can be found
  199. * WBEM_E_NOT_FOUND if the instance described by the key properties
  200. * could not be found
  201. * WBEM_E_FAILED if the instance could be found but another error
  202. * occurred.
  203. *
  204. * COMMENTS : If you are implementing a 'method only' provider, you should
  205. * remove this method.
  206. *
  207. *****************************************************************************/
  208. HRESULT CIPPersistedRouteTable :: GetObject (
  209. CInstance *pInstance,
  210. long lFlags
  211. )
  212. {
  213. HRESULT hr = WBEM_E_NOT_FOUND;
  214. CHString t_Dest ;
  215. CHString t_Mask ;
  216. CHString t_NextHop ;
  217. long t_Metric1 = 1;
  218. pInstance->GetCHString ( RouteDestination , t_Dest ) ;
  219. pInstance->GetCHString ( RouteMask , t_Mask ) ;
  220. pInstance->GetCHString ( RouteNextHop , t_NextHop ) ;
  221. pInstance->GetDWORD ( RouteMetric1 , (DWORD&)t_Metric1 ) ;
  222. CRegistry t_Reg;
  223. DWORD dwError = ERROR_SUCCESS;
  224. if ( ( dwError = t_Reg.Open( HKEY_LOCAL_MACHINE, TCIP_PERSISTENT_REG, KEY_READ) ) == ERROR_SUCCESS)
  225. {
  226. WCHAR buff [ 20 ];
  227. buff [ 0 ] = L'\0' ;
  228. _ultow( t_Metric1, buff , 10 ) ;
  229. CHString t_ValName = t_Dest + PERSITENT_ROUTE_SEP + t_Mask + PERSITENT_ROUTE_SEP + t_NextHop + PERSITENT_ROUTE_SEP + buff ;
  230. if ( RegQueryValueEx ( t_Reg.GethKey(), t_ValName , NULL , NULL , NULL , NULL ) == ERROR_SUCCESS )
  231. {
  232. hr = S_OK ;
  233. /*
  234. * Initialize the instance
  235. */
  236. //set the inherited properties that are sensible
  237. SetInheritedProperties (
  238. t_Dest ,
  239. t_NextHop ,
  240. t_Mask ,
  241. t_Metric1,
  242. *pInstance
  243. ) ;
  244. }
  245. t_Reg.Close();
  246. }
  247. else
  248. {
  249. if ( ERROR_ACCESS_DENIED == dwError )
  250. {
  251. hr = WBEM_E_ACCESS_DENIED ;
  252. }
  253. else
  254. {
  255. hr = WBEM_E_FAILED ;
  256. }
  257. }
  258. return hr ;
  259. }
  260. /*****************************************************************************
  261. *
  262. * FUNCTION : CIPPersistedRouteTable::PutInstance
  263. *
  264. * DESCRIPTION : PutInstance should be used in provider classes that can
  265. * write instance information back to the hardware or
  266. * software. For example: Win32_Environment will allow a
  267. * PutInstance to create or update an environment variable.
  268. * However, a class like MotherboardDevice will not allow
  269. * editing of the number of slots, since it is difficult for
  270. * a provider to affect that number.
  271. *
  272. * INPUTS : A pointer to a CInstance object containing the key properties.
  273. * A long that contains the flags described in
  274. * IWbemServices::PutInstanceAsync.
  275. *
  276. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if PutInstance is not available
  277. * WBEM_E_FAILED if there is an error delivering the instance
  278. * WBEM_E_INVALID_PARAMETER if any of the instance properties
  279. * are incorrect.
  280. * WBEM_S_NO_ERROR if instance is properly delivered
  281. *
  282. * COMMENTS : TO DO: If you don't intend to support writing to your provider,
  283. * or are creating a 'method only' provider, remove this
  284. * method.
  285. *
  286. *****************************************************************************/
  287. HRESULT CIPPersistedRouteTable :: PutInstance (
  288. const CInstance &Instance,
  289. long lFlags
  290. )
  291. {
  292. HRESULT hr = WBEM_E_FAILED ;
  293. switch ( lFlags & (WBEM_FLAG_CREATE_OR_UPDATE | WBEM_FLAG_CREATE_ONLY | WBEM_FLAG_UPDATE_ONLY) )
  294. {
  295. case WBEM_FLAG_CREATE_OR_UPDATE:
  296. case WBEM_FLAG_CREATE_ONLY:
  297. {
  298. CHString t_ValName ;
  299. hr = CheckParameters ( Instance , t_ValName ) ;
  300. if ( SUCCEEDED ( hr ) )
  301. {
  302. CRegistry t_Reg;
  303. DWORD dwError = ERROR_SUCCESS;
  304. if ( ( dwError = t_Reg.Open( HKEY_LOCAL_MACHINE, TCIP_PERSISTENT_REG, KEY_ALL_ACCESS) ) == ERROR_SUCCESS)
  305. {
  306. CHString t_temp;
  307. if ( ERROR_SUCCESS != t_Reg.SetCurrentKeyValue( t_ValName, t_temp ) )
  308. {
  309. hr = S_OK ;
  310. }
  311. t_Reg.Close () ;
  312. }
  313. else
  314. {
  315. if ( ERROR_ACCESS_DENIED == dwError )
  316. {
  317. hr = WBEM_E_ACCESS_DENIED ;
  318. }
  319. else
  320. {
  321. hr = WBEM_E_FAILED ;
  322. }
  323. }
  324. }
  325. else
  326. {
  327. hr = WBEM_E_INVALID_PARAMETER ;
  328. }
  329. }
  330. break ;
  331. default:
  332. {
  333. hr = WBEM_E_PROVIDER_NOT_CAPABLE ;
  334. }
  335. break ;
  336. }
  337. return hr ;
  338. }
  339. HRESULT CIPPersistedRouteTable :: CheckParameters (
  340. const CInstance &a_Instance ,
  341. CHString &a_ValueName
  342. )
  343. {
  344. bool t_Exists ;
  345. VARTYPE t_Type ;
  346. long t_mask = 0 ;
  347. long t_dest = 0 ;
  348. long t_nexthop = 0 ;
  349. CHString t_RouteDestinationString ;
  350. if ( a_Instance.GetStatus ( RouteDestination , t_Exists , t_Type ) )
  351. {
  352. if ( t_Exists && ( t_Type == VT_BSTR ) )
  353. {
  354. if ( a_Instance.GetCHString ( RouteDestination , t_RouteDestinationString ) && ! t_RouteDestinationString.IsEmpty () )
  355. {
  356. ProvIpAddressType t_Address ( t_RouteDestinationString ) ;
  357. if ( t_Address.IsValid () )
  358. {
  359. t_dest = htonl ( t_Address.GetValue () ) ;
  360. if ( t_dest == -1 )
  361. {
  362. return WBEM_E_INVALID_PARAMETER ;
  363. }
  364. }
  365. else
  366. {
  367. return WBEM_E_INVALID_PARAMETER ;
  368. }
  369. }
  370. else
  371. {
  372. // Zero Length string
  373. return WBEM_E_INVALID_PARAMETER ;
  374. }
  375. }
  376. else
  377. {
  378. return WBEM_E_INVALID_PARAMETER ;
  379. }
  380. }
  381. else
  382. {
  383. return WBEM_E_FAILED ;
  384. }
  385. CHString t_RouteDestinationMaskString ;
  386. if ( a_Instance.GetStatus ( RouteMask , t_Exists , t_Type ) )
  387. {
  388. if ( t_Exists && ( t_Type == VT_BSTR ) )
  389. {
  390. if ( a_Instance.GetCHString ( RouteMask , t_RouteDestinationMaskString ) && ! t_RouteDestinationMaskString.IsEmpty () )
  391. {
  392. ProvIpAddressType t_Address ( t_RouteDestinationMaskString ) ;
  393. if ( t_Address.IsValid () )
  394. {
  395. t_mask = htonl ( t_Address.GetValue () ) ;
  396. if ( ( t_dest & t_mask ) != t_dest )
  397. {
  398. return WBEM_E_INVALID_PARAMETER;
  399. }
  400. }
  401. else
  402. {
  403. return WBEM_E_INVALID_PARAMETER ;
  404. }
  405. }
  406. else
  407. {
  408. // Zero Length string
  409. return WBEM_E_INVALID_PARAMETER ;
  410. }
  411. }
  412. else
  413. {
  414. return WBEM_E_INVALID_PARAMETER ;
  415. }
  416. }
  417. else
  418. {
  419. return WBEM_E_FAILED ;
  420. }
  421. CHString t_RouteNextHopString ;
  422. if ( a_Instance.GetStatus ( RouteNextHop, t_Exists , t_Type ) )
  423. {
  424. if ( t_Exists && ( t_Type == VT_BSTR ) )
  425. {
  426. if ( a_Instance.GetCHString ( RouteNextHop , t_RouteNextHopString ) && ! t_RouteNextHopString.IsEmpty () )
  427. {
  428. ProvIpAddressType t_Address ( t_RouteNextHopString ) ;
  429. if ( t_Address.IsValid () )
  430. {
  431. t_nexthop = htonl ( t_Address.GetValue () ) ;
  432. if ( t_nexthop == -1 )
  433. {
  434. return WBEM_E_INVALID_PARAMETER ;
  435. }
  436. }
  437. else
  438. {
  439. return WBEM_E_INVALID_PARAMETER ;
  440. }
  441. }
  442. else
  443. {
  444. // Zero Length string
  445. return WBEM_E_INVALID_PARAMETER ;
  446. }
  447. }
  448. else
  449. {
  450. return WBEM_E_INVALID_PARAMETER ;
  451. }
  452. }
  453. else
  454. {
  455. return WBEM_E_FAILED ;
  456. }
  457. DWORD t_Metric = 0 ;
  458. if ( a_Instance.GetStatus ( RouteMetric1 , t_Exists , t_Type ) )
  459. {
  460. if ( t_Exists && ( t_Type == VT_I4 ) )
  461. {
  462. if ( !a_Instance.GetDWORD ( RouteMetric1 , t_Metric ) || ( t_Metric < 1) || ( t_Metric > MAX_METRIC1) )
  463. {
  464. return WBEM_E_INVALID_PARAMETER ;
  465. }
  466. }
  467. else
  468. {
  469. return WBEM_E_INVALID_PARAMETER ;
  470. }
  471. }
  472. else
  473. {
  474. return WBEM_E_FAILED ;
  475. }
  476. WCHAR buff [ 20 ] ;
  477. buff [ 0 ] = L'\0' ;
  478. _ultow ( t_Metric , buff , 10 ) ;
  479. a_ValueName = t_RouteDestinationString + PERSITENT_ROUTE_SEP
  480. + t_RouteDestinationMaskString + PERSITENT_ROUTE_SEP
  481. + t_RouteNextHopString + PERSITENT_ROUTE_SEP
  482. + buff;
  483. return S_OK ;
  484. }
  485. /*****************************************************************************
  486. *
  487. * FUNCTION : CIPPersistedRouteTable::DeleteInstance
  488. *
  489. * DESCRIPTION : DeleteInstance, like PutInstance, actually writes information
  490. * to the software or hardware. For most hardware devices,
  491. * DeleteInstance should not be implemented, but for software
  492. * configuration, DeleteInstance implementation is plausible.
  493. *
  494. * INPUTS : A pointer to a CInstance object containing the key properties.
  495. * A long that contains the flags described in
  496. * IWbemServices::DeleteInstanceAsync.
  497. *
  498. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if DeleteInstance is not available.
  499. * WBEM_E_FAILED if there is an error deleting the instance.
  500. * WBEM_E_INVALID_PARAMETER if any of the instance properties
  501. * are incorrect.
  502. * WBEM_S_NO_ERROR if instance is properly deleted.
  503. *
  504. * COMMENTS : TO DO: If you don't intend to support deleting instances or are
  505. * creating a 'method only' provider, remove this method.
  506. *
  507. *****************************************************************************/
  508. HRESULT CIPPersistedRouteTable :: DeleteInstance (
  509. const CInstance &Instance,
  510. long lFlags
  511. )
  512. {
  513. HRESULT hr = WBEM_E_FAILED ;
  514. CHString t_Dest ;
  515. CHString t_Mask ;
  516. CHString t_NextHop ;
  517. long t_Metric1 = 1;
  518. Instance.GetCHString ( RouteDestination , t_Dest ) ;
  519. Instance.GetCHString ( RouteMask , t_Mask ) ;
  520. Instance.GetCHString ( RouteNextHop , t_NextHop ) ;
  521. Instance.GetDWORD ( RouteMetric1 , (DWORD&)t_Metric1 ) ;
  522. CRegistry t_Reg;
  523. DWORD dwError = ERROR_SUCCESS;
  524. if ( ( dwError = t_Reg.Open( HKEY_LOCAL_MACHINE, TCIP_PERSISTENT_REG, KEY_ALL_ACCESS) ) == ERROR_SUCCESS)
  525. {
  526. WCHAR buff [ 20 ];
  527. buff[0] = L'\0' ;
  528. _ultow( t_Metric1 , buff , 10 ) ;
  529. CHString t_ValName = t_Dest + PERSITENT_ROUTE_SEP + t_Mask + PERSITENT_ROUTE_SEP + t_NextHop + PERSITENT_ROUTE_SEP + buff ;
  530. if ( t_Reg.DeleteCurrentKeyValue(t_ValName) == ERROR_SUCCESS )
  531. {
  532. hr = S_OK ;
  533. }
  534. t_Reg.Close();
  535. }
  536. else
  537. {
  538. if ( ERROR_ACCESS_DENIED == dwError )
  539. {
  540. hr = WBEM_E_ACCESS_DENIED ;
  541. }
  542. }
  543. return hr ;
  544. }
  545. /*****************************************************************************
  546. *
  547. * FUNCTION : CIPPersistedRouteTable::ExecMethod
  548. *
  549. * DESCRIPTION : Override this function to provide support for methods.
  550. * A method is an entry point for the user of your provider
  551. * to request your class perform some function above and
  552. * beyond a change of state. (A change of state should be
  553. * handled by PutInstance() )
  554. *
  555. * INPUTS : A pointer to a CInstance containing the instance the method was executed against.
  556. * A string containing the method name
  557. * A pointer to the CInstance which contains the IN parameters.
  558. * A pointer to the CInstance to contain the OUT parameters.
  559. * A set of specialized method flags
  560. *
  561. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if not implemented for this class
  562. * WBEM_S_NO_ERROR if method executes successfully
  563. * WBEM_E_FAILED if error occurs executing method
  564. *
  565. * COMMENTS : TO DO: If you don't intend to support Methods, remove this method.
  566. *
  567. *****************************************************************************/
  568. HRESULT CIPPersistedRouteTable :: ExecMethod (
  569. const CInstance &Instance,
  570. const BSTR bstrMethodName,
  571. CInstance *pInParams,
  572. CInstance *pOutParams,
  573. long lFlags
  574. )
  575. {
  576. // For non-static methods, use the CInstance Get functions (for example,
  577. // call GetCHString(L"Name", sTemp)) against Instance to see the key
  578. // values the client requested.
  579. return WBEM_E_PROVIDER_NOT_CAPABLE ;
  580. }
  581. BOOL CIPPersistedRouteTable :: Parse (
  582. LPWSTR a_InStr ,
  583. CHString &a_Dest ,
  584. CHString &a_Mask ,
  585. CHString &a_NextHop ,
  586. long &a_Metric
  587. )
  588. {
  589. BOOL t_RetVal = FALSE ;
  590. if ( a_InStr && ( wcslen ( a_InStr ) > 0 ) )
  591. {
  592. LPWSTR t_Str = a_InStr ;
  593. LPWSTR t_Addr = t_Str ;
  594. a_Metric = 1 ;
  595. DWORD t_count = 0;
  596. while ( *t_Str != L'\0' )
  597. {
  598. if ( *t_Str != PERSITENT_ROUTE_SEP )
  599. {
  600. t_Str++ ;
  601. }
  602. else
  603. {
  604. *t_Str = L'\0';
  605. ProvIpAddressType t_Address ( t_Addr ) ;
  606. if ( t_Address.IsValid () )
  607. {
  608. t_count++ ;
  609. t_RetVal = TRUE ;
  610. switch ( t_count )
  611. {
  612. case 1 :
  613. {
  614. a_Dest = t_Addr ;
  615. }
  616. break ;
  617. case 2 :
  618. {
  619. a_Mask = t_Addr ;
  620. }
  621. break ;
  622. case 3 :
  623. {
  624. a_NextHop = t_Addr ;
  625. }
  626. break ;
  627. default :
  628. {
  629. t_RetVal = FALSE ;
  630. }
  631. }
  632. if ( t_RetVal )
  633. {
  634. *t_Str = PERSITENT_ROUTE_SEP ;
  635. t_Str++ ;
  636. t_Addr = t_Str ;
  637. }
  638. else
  639. {
  640. break ;
  641. }
  642. }
  643. else
  644. {
  645. t_RetVal = FALSE ;
  646. break ;
  647. }
  648. }
  649. }
  650. if ( ( t_count == 3 ) && t_RetVal )
  651. {
  652. //get the metric
  653. if (t_Addr != t_Str)
  654. {
  655. a_Metric = _wtoi ( t_Addr ) ;
  656. if ( a_Metric < 1 )
  657. {
  658. t_RetVal = FALSE ;
  659. }
  660. }
  661. }
  662. else
  663. {
  664. t_RetVal = FALSE ;
  665. }
  666. }
  667. return t_RetVal;
  668. }
  669. void CIPPersistedRouteTable :: SetInheritedProperties (
  670. LPCWSTR a_dest ,
  671. LPCWSTR a_gateway ,
  672. LPCWSTR a_mask ,
  673. long a_metric ,
  674. CInstance &a_Instance
  675. )
  676. {
  677. CHString t_temp( a_dest ) ;
  678. a_Instance.SetCHString ( RouteName, t_temp ) ;
  679. a_Instance.SetCHString ( RouteCaption, t_temp ) ;
  680. WCHAR t_buff [ 20 ] ;
  681. t_buff[0] = L'\0' ;
  682. _ultow( a_metric , t_buff , 10 ) ;
  683. t_temp = t_temp + PERSITENT_ROUTE_SEP + a_mask + PERSITENT_ROUTE_SEP + a_gateway + PERSITENT_ROUTE_SEP + t_buff ;
  684. a_Instance.SetCHString ( RouteDescription, t_temp ) ;
  685. }