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.

1346 lines
46 KiB

  1. /******************************************************************
  2. SrvFn.cpp -- Properties action functions (GET/SET)
  3. MODULE:
  4. DhcpProv.dll
  5. DESCRIPTION:
  6. Contains the definition for the action functions associated to
  7. each manageable property from the class CDHCP_Server
  8. REVISION:
  9. 08/03/98 - created
  10. ******************************************************************/
  11. #include <stdafx.h>
  12. #include "SrvScal.h" // needed for DHCP_Server_Property[] (for retrieving the property's name, for SET's)
  13. #include "SrvFn.h" // own header
  14. /*****************************************************************
  15. * The definition of the class CDHCP_Server_Parameters
  16. *****************************************************************/
  17. // by default, all the data structures are NULL (and dw variables are 0'ed)
  18. // those values indicates that no data is cached from the server.
  19. CDHCP_Server_Parameters::CDHCP_Server_Parameters()
  20. {
  21. m_pMibInfo = NULL;
  22. m_dwMajor = 0;
  23. m_dwMinor = 0;
  24. m_dwConfigInfoV4Flags = 0;
  25. m_pConfigInfoV4 = NULL;
  26. }
  27. // the DHCP API calls are allocating memory for which the caller is responsible
  28. // to release. We are releasing this memory upon the destruction of this object's instance.
  29. CDHCP_Server_Parameters::~CDHCP_Server_Parameters()
  30. {
  31. if (m_pMibInfo != NULL)
  32. {
  33. if (m_pMibInfo->ScopeInfo != NULL)
  34. DhcpRpcFreeMemory(m_pMibInfo->ScopeInfo);
  35. DhcpRpcFreeMemory(m_pMibInfo);
  36. m_pMibInfo = NULL;
  37. }
  38. // LPDHCP_CONFIG_INFO_V4 contains pointers to memory allocated by the DHCP server and
  39. // which should be released by the caller.
  40. if (m_pConfigInfoV4!= NULL)
  41. {
  42. if (m_pConfigInfoV4->DatabaseName != NULL)
  43. DhcpRpcFreeMemory(m_pConfigInfoV4->DatabaseName);
  44. if (m_pConfigInfoV4->DatabasePath != NULL)
  45. DhcpRpcFreeMemory(m_pConfigInfoV4->DatabasePath);
  46. if (m_pConfigInfoV4->BackupPath != NULL)
  47. DhcpRpcFreeMemory(m_pConfigInfoV4->BackupPath);
  48. if (m_pConfigInfoV4->wszBootTableString != NULL)
  49. DhcpRpcFreeMemory(m_pConfigInfoV4->wszBootTableString );
  50. DhcpRpcFreeMemory(m_pConfigInfoV4);
  51. m_pConfigInfoV4 = NULL;
  52. }
  53. }
  54. // DESCRIPTION:
  55. // Checks the m_pConfigInfoV4 pointer to insure it points to a valid buffer.
  56. // It allocates the DHCP_SERVER_CONFIG_INFO_V4 if needed, which case it resets the m_dwConfigInfoV4Flags member
  57. BOOL CDHCP_Server_Parameters::CheckExistsConfigPtr()
  58. {
  59. if (m_pConfigInfoV4 != NULL)
  60. return TRUE;
  61. m_pConfigInfoV4 = (LPDHCP_SERVER_CONFIG_INFO_V4)MIDL_user_allocate(sizeof(DHCP_SERVER_CONFIG_INFO_V4));
  62. if (m_pConfigInfoV4 != NULL)
  63. {
  64. m_dwConfigInfoV4Flags = 0;
  65. return TRUE;
  66. }
  67. return FALSE;
  68. }
  69. // DESCRIPTION:
  70. // Provides the data structure filled in through the DhcpGetMibInfo API
  71. // If this data is cached and the caller is not forcing the refresh,
  72. // returns the internal cache.
  73. BOOL CDHCP_Server_Parameters::GetMibInfo(LPDHCP_MIB_INFO& MibInfo, BOOL fRefresh)
  74. {
  75. if (m_pMibInfo == NULL)
  76. fRefresh = TRUE;
  77. if (fRefresh)
  78. {
  79. MibInfo = NULL;
  80. if (DhcpGetMibInfo(SERVER_IP_ADDRESS, &MibInfo) != ERROR_SUCCESS)
  81. return FALSE;
  82. if (m_pMibInfo != NULL)
  83. DhcpRpcFreeMemory(m_pMibInfo);
  84. m_pMibInfo = MibInfo;
  85. }
  86. else
  87. MibInfo = m_pMibInfo;
  88. return TRUE;
  89. }
  90. // DESCRIPTION:
  91. // Provides the data structure filled in through the DhcpGetVersion API
  92. // If this data is cached and the caller is not forcing the refresh,
  93. // returns the internal cache.
  94. BOOL CDHCP_Server_Parameters::GetVersion(DWORD &Major, DWORD& Minor, BOOL fRefresh)
  95. {
  96. if (m_dwMajor == 0 && m_dwMinor == 0)
  97. fRefresh = TRUE;
  98. if (fRefresh)
  99. {
  100. if (DhcpGetVersion(SERVER_IP_ADDRESS,&Major,&Minor) != ERROR_SUCCESS)
  101. return FALSE;
  102. m_dwMajor = Major;
  103. m_dwMinor = Minor;
  104. }
  105. else
  106. {
  107. Major = m_dwMajor;
  108. Minor = m_dwMinor;
  109. }
  110. return TRUE;
  111. }
  112. // DESCRIPTION:
  113. // Provides the data structure filled in through the DhcpServerGetConfigInfoV4 API
  114. // If this data is cached and the caller is not forcing the refresh,
  115. // return the internal cache. Otherwise, the internal cache is refreshed as well.
  116. BOOL CDHCP_Server_Parameters::GetServerConfigInfoV4(LPDHCP_SERVER_CONFIG_INFO_V4& ServerConfigInfoV4, BOOL fRefresh)
  117. {
  118. if (m_pConfigInfoV4 == NULL)
  119. fRefresh = TRUE;
  120. if (fRefresh)
  121. {
  122. ServerConfigInfoV4 = NULL;
  123. if (DhcpServerGetConfigV4(SERVER_IP_ADDRESS, &ServerConfigInfoV4) != ERROR_SUCCESS)
  124. return FALSE;
  125. if (m_pConfigInfoV4 != NULL)
  126. DhcpRpcFreeMemory(m_pConfigInfoV4);
  127. m_pConfigInfoV4 = ServerConfigInfoV4;
  128. }
  129. else
  130. ServerConfigInfoV4 = m_pConfigInfoV4;
  131. return TRUE;
  132. }
  133. // DESCRIPTION:
  134. // Assumes that the internal pointers to the server configuration structures are valid, and filled with
  135. // the data to be set. Calls the underlying API and returns TRUE (on success) or FALSE (on failure)
  136. BOOL CDHCP_Server_Parameters::CommitSet(DWORD &returnCode)
  137. {
  138. if (m_pConfigInfoV4 == NULL)
  139. return FALSE;
  140. returnCode = DhcpServerSetConfigV4(
  141. SERVER_IP_ADDRESS,
  142. m_dwConfigInfoV4Flags,
  143. m_pConfigInfoV4 );
  144. return returnCode == ERROR_SUCCESS;
  145. }
  146. /*****************************************************************
  147. * For all the calls below, is the callers responsibility to release the allocated memory by
  148. * properly destructing the pServerParams objects. If this param is NULL, the functions will
  149. * use the static parameter which will be destroyed upon the DLL unload.
  150. *****************************************************************/
  151. static CDHCP_Server_Parameters backupParameters;
  152. // for any of the functions below, if the caller does not specify a DHCP_Server_Parameters object
  153. // the static 'backupParameters' object will be used instead. In this case, the info is automatically
  154. // retrieved from the lower levels, regardless the cache.
  155. // the macro also convert the generic (void *) pParams to (CDHCP_Server_Parameters *)pServerParams;
  156. #define ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh) \
  157. if (pParams == NULL) \
  158. { \
  159. pServerParams = &backupParameters; \
  160. fRefresh = TRUE; \
  161. } \
  162. else \
  163. { \
  164. pServerParams = (CDHCP_Server_Parameters *)pParams; \
  165. fRefresh = FALSE; \
  166. }
  167. MFN_PROPERTY_ACTION_DEFN(fnSrvGetStartTime, pParams, pIn, pOut)
  168. {
  169. LPDHCP_MIB_INFO pMibInfo;
  170. BOOL fRefresh;
  171. CDHCP_Server_Parameters *pServerParams;
  172. if (pOut == NULL)
  173. return FALSE;
  174. // after this call, pServerParams will surely be not-NULL
  175. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  176. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  177. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  178. {
  179. SYSTEMTIME sysTime;
  180. wchar_t wchBuffer [32];
  181. // convert the server startup time to a string (UTC) representation.
  182. _tzset () ;
  183. // timezone is offset from UTC in seconds, _daylight is 1 or 0 regarding the DST period
  184. LONG t_Offset = _timezone / 60 - _daylight * 60;
  185. char chOffset = t_Offset < 0 ? '+' : '-';
  186. // take the absolute value from t_Offset
  187. LONG t_absOffset = (1 - ((t_Offset < 0)<<1)) * t_Offset;
  188. FileTimeToSystemTime((FILETIME *)&(pMibInfo->ServerStartTime), &sysTime);
  189. // should ensure we have a valid date format (even if inf.)
  190. if (sysTime.wYear > 9999)
  191. {
  192. sysTime.wYear = 9999;
  193. sysTime.wMonth = 12;
  194. sysTime.wDay = 31;
  195. sysTime.wHour = 23;
  196. sysTime.wMinute = 59;
  197. sysTime.wSecond = 59;
  198. sysTime.wMilliseconds = 0;
  199. }
  200. swprintf (
  201. wchBuffer ,
  202. L"%04ld%02ld%02ld%02ld%02ld%02ld.%06ld%c%03ld" ,
  203. sysTime.wYear,
  204. sysTime.wMonth,
  205. sysTime.wDay,
  206. sysTime.wHour,
  207. sysTime.wMinute,
  208. sysTime.wSecond,
  209. sysTime.wMilliseconds,
  210. chOffset,
  211. t_absOffset
  212. );
  213. // set the value of the property into the (CInstance*)pOut
  214. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_StartTime].m_wsPropName, wchBuffer);
  215. return TRUE;
  216. }
  217. // the API call failed
  218. return FALSE;
  219. }
  220. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfAcks, pParams, pIn, pOut)
  221. {
  222. LPDHCP_MIB_INFO pMibInfo;
  223. BOOL fRefresh;
  224. CDHCP_Server_Parameters *pServerParams;
  225. if (pOut == NULL)
  226. return FALSE;
  227. // after this call, pServerParams will surely be not-NULL
  228. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  229. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  230. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  231. {
  232. // set the value of the property into the (CInstance*)pOut
  233. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfAcks].m_wsPropName, pMibInfo->Acks);
  234. return TRUE;
  235. }
  236. return FALSE;
  237. }
  238. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfDeclines, pParams, pIn, pOut)
  239. {
  240. LPDHCP_MIB_INFO pMibInfo;
  241. BOOL fRefresh;
  242. CDHCP_Server_Parameters *pServerParams;
  243. if (pOut == NULL)
  244. return FALSE;
  245. // after this call, pServerParams will surely be not-NULL
  246. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  247. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  248. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  249. {
  250. // set the value of the property into the (CInstance*)pOut
  251. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfDeclines].m_wsPropName, pMibInfo->Declines);
  252. return TRUE;
  253. }
  254. return FALSE;
  255. }
  256. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfDiscovers, pParams, pIn, pOut)
  257. {
  258. LPDHCP_MIB_INFO pMibInfo;
  259. BOOL fRefresh;
  260. CDHCP_Server_Parameters *pServerParams;
  261. if (pOut == NULL)
  262. return FALSE;
  263. // after this call, pServerParams will surely be not-NULL
  264. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  265. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  266. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  267. {
  268. // set the value of the property into the (CInstance*)pOut
  269. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfDiscovers].m_wsPropName, pMibInfo->Discovers);
  270. return TRUE;
  271. }
  272. return FALSE;
  273. }
  274. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfNacks, pParams, pIn, pOut)
  275. {
  276. LPDHCP_MIB_INFO pMibInfo;
  277. BOOL fRefresh;
  278. CDHCP_Server_Parameters *pServerParams;
  279. if (pOut == NULL)
  280. return FALSE;
  281. // after this call, pServerParams will surely be not-NULL
  282. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  283. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  284. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  285. {
  286. // set the value of the property into the (CInstance*)pOut
  287. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfNacks].m_wsPropName, pMibInfo->Naks);
  288. return TRUE;
  289. }
  290. return FALSE;
  291. }
  292. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfOffers, pParams, pIn, pOut)
  293. {
  294. LPDHCP_MIB_INFO pMibInfo;
  295. BOOL fRefresh;
  296. CDHCP_Server_Parameters *pServerParams;
  297. if (pOut == NULL)
  298. return FALSE;
  299. // after this call, pServerParams will surely be not-NULL
  300. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  301. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  302. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  303. {
  304. // set the value of the property into the (CInstance*)pOut
  305. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfOffers].m_wsPropName, pMibInfo->Offers);
  306. return TRUE;
  307. }
  308. return FALSE;
  309. }
  310. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfReleases, pParams, pIn, pOut)
  311. {
  312. LPDHCP_MIB_INFO pMibInfo;
  313. BOOL fRefresh;
  314. CDHCP_Server_Parameters *pServerParams;
  315. if (pOut == NULL)
  316. return FALSE;
  317. // after this call, pServerParams will surely be not-NULL
  318. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  319. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  320. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  321. {
  322. // set the value of the property into the (CInstance*)pOut
  323. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfReleases].m_wsPropName, pMibInfo->Releases);
  324. return TRUE;
  325. }
  326. return FALSE;
  327. }
  328. MFN_PROPERTY_ACTION_DEFN(fnSrvGetTotalNoOfRequests, pParams, pIn, pOut)
  329. {
  330. LPDHCP_MIB_INFO pMibInfo;
  331. BOOL fRefresh;
  332. CDHCP_Server_Parameters *pServerParams;
  333. if (pOut == NULL)
  334. return FALSE;
  335. // after this call, pServerParams will surely be not-NULL
  336. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  337. // call the DHCP api through the DHCP_Server_Parameter::GetMibInfo
  338. if (pServerParams->GetMibInfo(pMibInfo, fRefresh))
  339. {
  340. // set the value of the property into the (CInstance*)pOut
  341. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_TotalNoOfRequests].m_wsPropName, pMibInfo->Requests);
  342. return TRUE;
  343. }
  344. return FALSE;
  345. }
  346. MFN_PROPERTY_ACTION_DEFN(fnSrvGetServerVersion, pParams, pIn, pOut)
  347. {
  348. DWORD Major, Minor;
  349. BOOL fRefresh;
  350. CDHCP_Server_Parameters *pServerParams;
  351. if (pOut == NULL)
  352. return FALSE;
  353. // after this call, pServerParams will surely be not-NULL
  354. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  355. // call the DHCP api through the DHCP_Server_Parameter::GetVersion
  356. if (pServerParams->GetVersion(Major, Minor, fRefresh))
  357. {
  358. wchar_t wchBuffer [16];
  359. // convert the two DWORD version numbers
  360. // to a "Major.Minor" string representation
  361. swprintf (
  362. wchBuffer,
  363. L"%lu.%lu",
  364. Major,
  365. Minor
  366. );
  367. // set the value of the property into the (CInstance*)pOut
  368. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_ServerVersion].m_wsPropName, wchBuffer);
  369. return TRUE;
  370. }
  371. return FALSE;
  372. }
  373. MFN_PROPERTY_ACTION_DEFN(fnSrvGetAPIProtocol, pParams, pIn, pOut)
  374. {
  375. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  376. BOOL fRefresh;
  377. CDHCP_Server_Parameters *pServerParams;
  378. if (pOut == NULL)
  379. return FALSE;
  380. // after this call, pServerParams will surely be not-NULL
  381. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  382. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  383. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  384. {
  385. // set the value of the property into the (CInstance*)pOut
  386. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_APIProtocol].m_wsPropName, serverConfig->APIProtocolSupport);
  387. return TRUE;
  388. }
  389. return FALSE;
  390. }
  391. MFN_PROPERTY_ACTION_DEFN(fnSrvSetAPIProtocol, pParams, pIn, pOut)
  392. {
  393. BOOL fRefresh;
  394. DWORD newAPIProtocol;
  395. CDHCP_Server_Parameters *pServerParams;
  396. // somehow the property we are expecting does not exist in CInstance *pIn
  397. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_APIProtocol].m_wsPropName, newAPIProtocol))
  398. return FALSE;
  399. // after this call, pServerParams will surely be not-NULL
  400. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  401. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  402. if (!pServerParams->CheckExistsConfigPtr())
  403. return FALSE;
  404. pServerParams->m_pConfigInfoV4->APIProtocolSupport = newAPIProtocol;
  405. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  406. if (fRefresh)
  407. {
  408. DWORD returnCode;
  409. // this is the only field we are changing.
  410. pServerParams->m_dwConfigInfoV4Flags = Set_APIProtocolSupport;
  411. // commit the changes now!
  412. pServerParams->CommitSet(returnCode);
  413. // save the output parameter
  414. if (pOut != NULL)
  415. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  416. }
  417. else
  418. {
  419. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  420. // we only add the parameter to the fields that are going to be commited.
  421. pServerParams->m_dwConfigInfoV4Flags |= Set_APIProtocolSupport;
  422. }
  423. return TRUE;
  424. }
  425. MFN_PROPERTY_ACTION_DEFN(fnSrvGetDatabaseName, pParams, pIn, pOut)
  426. {
  427. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  428. BOOL fRefresh;
  429. CDHCP_Server_Parameters *pServerParams;
  430. if (pOut == NULL)
  431. return FALSE;
  432. // after this call, pServerParams will surely be not-NULL
  433. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  434. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  435. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  436. {
  437. // set the value of the property into the (CInstance*)pOut
  438. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_DatabaseName].m_wsPropName, serverConfig->DatabaseName);
  439. return TRUE;
  440. }
  441. return FALSE;
  442. }
  443. MFN_PROPERTY_ACTION_DEFN(fnSrvSetDatabaseName, pParams, pIn, pOut)
  444. {
  445. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  446. BOOL fRefresh;
  447. CHString newDatabaseName;
  448. CDHCP_Server_Parameters *pServerParams;
  449. // somehow the property we are expecting does not exist in CInstance *pIn
  450. if (pIn == NULL || !pIn->GetCHString(DHCP_Server_Property[IDX_SRV_DatabaseName].m_wsPropName, newDatabaseName))
  451. return FALSE;
  452. // after this call, pServerParams will surely be not-NULL
  453. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  454. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  455. if (!pServerParams->CheckExistsConfigPtr())
  456. return FALSE;
  457. serverConfig = pServerParams->m_pConfigInfoV4;
  458. // if there is any allocated memory for the DatabaseName, just release it.
  459. if (serverConfig->DatabaseName != NULL)
  460. DhcpRpcFreeMemory(serverConfig->DatabaseName);
  461. // allocate memory for the new database name. It has to fit the WCHAR string size.
  462. serverConfig->DatabaseName = (WCHAR*)MIDL_user_allocate(sizeof(WCHAR)*newDatabaseName.GetLength()+sizeof(WCHAR));
  463. if (serverConfig->DatabaseName == NULL)
  464. return FALSE;
  465. //copy the new database name to server param. It has to be translated to WCHAR
  466. #ifdef _UNICODE
  467. wcscpy(serverConfig->DatabaseName, newDatabaseName);
  468. #else
  469. swprintf(serverConfig->DatabaseName, L"%S", newDatabaseName);
  470. #endif
  471. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  472. if (fRefresh)
  473. {
  474. DWORD returnCode;
  475. // this is the only field we are changing.
  476. pServerParams->m_dwConfigInfoV4Flags = Set_DatabaseName;
  477. // commit the changes now!
  478. pServerParams->CommitSet(returnCode);
  479. // save the output parameter
  480. if (pOut != NULL)
  481. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  482. }
  483. else
  484. {
  485. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  486. // we only add the DatabaseName to the fields that are going to be commited.
  487. pServerParams->m_dwConfigInfoV4Flags |= Set_DatabaseName;
  488. }
  489. return TRUE;
  490. }
  491. MFN_PROPERTY_ACTION_DEFN(fnSrvGetDatabasePath, pParams, pIn, pOut)
  492. {
  493. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  494. BOOL fRefresh;
  495. CDHCP_Server_Parameters *pServerParams;
  496. if (pOut == NULL)
  497. return FALSE;
  498. // after this call, pServerParams will surely be not-NULL
  499. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  500. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  501. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  502. {
  503. // set the value of the property into the (CInstance*)pOut
  504. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_DatabasePath].m_wsPropName, serverConfig->DatabasePath);
  505. return TRUE;
  506. }
  507. return FALSE;
  508. }
  509. MFN_PROPERTY_ACTION_DEFN(fnSrvSetDatabasePath, pParams, pIn, pOut)
  510. {
  511. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  512. BOOL fRefresh;
  513. CHString newDatabasePath;
  514. CDHCP_Server_Parameters *pServerParams;
  515. // somehow the property we are expecting does not exist in CInstance *pIn
  516. if (pIn == NULL || !pIn->GetCHString(DHCP_Server_Property[IDX_SRV_DatabasePath].m_wsPropName, newDatabasePath))
  517. return FALSE;
  518. // after this call, pServerParams will surely be not-NULL
  519. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  520. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  521. if (!pServerParams->CheckExistsConfigPtr())
  522. return FALSE;
  523. serverConfig = pServerParams->m_pConfigInfoV4;
  524. // if there is any allocated memory for the DatabasePath, just release it.
  525. if (serverConfig->DatabasePath != NULL)
  526. DhcpRpcFreeMemory(serverConfig->DatabasePath);
  527. // allocate memory for the new database path. It has to fit the WCHAR string size.
  528. serverConfig->DatabasePath = (WCHAR*)MIDL_user_allocate(sizeof(WCHAR)*newDatabasePath.GetLength()+sizeof(WCHAR));
  529. if (serverConfig->DatabasePath == NULL)
  530. return FALSE;
  531. //copy the new database path to server param. It has to be translated to WCHAR
  532. #ifdef _UNICODE
  533. wcscpy(serverConfig->DatabasePath, newDatabasePath);
  534. #else
  535. swprintf(serverConfig->DatabasePath, L"%S", newDatabasePath);
  536. #endif
  537. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  538. if (fRefresh)
  539. {
  540. DWORD returnCode;
  541. // this is the only field we are changing.
  542. pServerParams->m_dwConfigInfoV4Flags = Set_DatabasePath;
  543. // commit the changes now!
  544. pServerParams->CommitSet(returnCode);
  545. // save the output parameter
  546. if (pOut != NULL)
  547. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  548. }
  549. else
  550. {
  551. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  552. // we only add the DatabasePath to the fields that are going to be commited.
  553. pServerParams->m_dwConfigInfoV4Flags |= Set_DatabasePath;
  554. }
  555. return TRUE;
  556. }
  557. MFN_PROPERTY_ACTION_DEFN(fnSrvGetBackupPath, pParams, pIn, pOut)
  558. {
  559. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  560. BOOL fRefresh;
  561. CDHCP_Server_Parameters *pServerParams;
  562. if (pOut == NULL)
  563. return FALSE;
  564. // after this call, pServerParams will surely be not-NULL
  565. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  566. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  567. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  568. {
  569. // set the value of the property into the (CInstance*)pOut
  570. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_BackupPath].m_wsPropName, serverConfig->BackupPath);
  571. return TRUE;
  572. }
  573. return FALSE;
  574. }
  575. MFN_PROPERTY_ACTION_DEFN(fnSrvSetBackupPath, pParams, pIn, pOut)
  576. {
  577. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  578. BOOL fRefresh;
  579. CHString newBackupPath;
  580. CDHCP_Server_Parameters *pServerParams;
  581. // somehow the property we are expecting does not exist in CInstance *pIn
  582. if (pIn == NULL || !pIn->GetCHString(DHCP_Server_Property[IDX_SRV_BackupPath].m_wsPropName, newBackupPath))
  583. return FALSE;
  584. // after this call, pServerParams will surely be not-NULL
  585. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  586. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  587. if (!pServerParams->CheckExistsConfigPtr())
  588. return FALSE;
  589. serverConfig = pServerParams->m_pConfigInfoV4;
  590. // if there is any allocated memory for the BackupPath, just release it.
  591. if (serverConfig->BackupPath != NULL)
  592. DhcpRpcFreeMemory(serverConfig->BackupPath);
  593. // allocate memory for the new database path. It has to fit the WCHAR string size.
  594. serverConfig->BackupPath = (WCHAR*)MIDL_user_allocate(sizeof(WCHAR)*newBackupPath.GetLength()+sizeof(WCHAR));
  595. if (serverConfig->BackupPath == NULL)
  596. return FALSE;
  597. //copy the new database path to server param. It has to be translated to WCHAR
  598. #ifdef _UNICODE
  599. wcscpy(serverConfig->BackupPath, newBackupPath);
  600. #else
  601. swprintf(serverConfig->BackupPath, L"%S", newBackupPath);
  602. #endif
  603. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  604. if (fRefresh)
  605. {
  606. DWORD returnCode;
  607. // this is the only field we are changing.
  608. pServerParams->m_dwConfigInfoV4Flags = Set_BackupPath;
  609. // commit the changes now!
  610. pServerParams->CommitSet(returnCode);
  611. // save the output parameter
  612. if (pOut != NULL)
  613. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  614. }
  615. else
  616. {
  617. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  618. // we only add the BackupPath to the fields that are going to be commited.
  619. pServerParams->m_dwConfigInfoV4Flags |= Set_BackupPath;
  620. }
  621. return TRUE;
  622. }
  623. MFN_PROPERTY_ACTION_DEFN(fnSrvGetBackupInterval, pParams, pIn, pOut)
  624. {
  625. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  626. BOOL fRefresh;
  627. CDHCP_Server_Parameters *pServerParams;
  628. if (pOut == NULL)
  629. return FALSE;
  630. // after this call, pServerParams will surely be not-NULL
  631. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  632. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  633. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  634. {
  635. // set the value of the property into the (CInstance*)pOut
  636. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_BackupInterval].m_wsPropName, serverConfig->BackupInterval);
  637. return TRUE;
  638. }
  639. return FALSE;
  640. }
  641. MFN_PROPERTY_ACTION_DEFN(fnSrvSetBackupInterval, pParams, pIn, pOut)
  642. {
  643. BOOL fRefresh;
  644. DWORD newBackupInterval;
  645. CDHCP_Server_Parameters *pServerParams;
  646. // somehow the property we are expecting does not exist in CInstance *pIn
  647. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_BackupInterval].m_wsPropName, newBackupInterval))
  648. return FALSE;
  649. // after this call, pServerParams will surely be not-NULL
  650. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  651. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  652. if (!pServerParams->CheckExistsConfigPtr())
  653. return FALSE;
  654. pServerParams->m_pConfigInfoV4->BackupInterval = newBackupInterval;
  655. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  656. if (fRefresh)
  657. {
  658. DWORD returnCode;
  659. // this is the only field we are changing.
  660. pServerParams->m_dwConfigInfoV4Flags = Set_BackupInterval;
  661. // commit the changes now!
  662. pServerParams->CommitSet(returnCode);
  663. // save the output parameter
  664. if (pOut != NULL)
  665. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  666. }
  667. else
  668. {
  669. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  670. // we only add the parameter to the fields that are going to be commited.
  671. pServerParams->m_dwConfigInfoV4Flags |= Set_BackupInterval;
  672. }
  673. return TRUE;
  674. }
  675. MFN_PROPERTY_ACTION_DEFN(fnSrvGetDatabaseLoggingFlag, pParams, pIn, pOut)
  676. {
  677. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  678. BOOL fRefresh;
  679. CDHCP_Server_Parameters *pServerParams;
  680. if (pOut == NULL)
  681. return FALSE;
  682. // after this call, pServerParams will surely be not-NULL
  683. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  684. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  685. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  686. {
  687. // set the value of the property into the (CInstance*)pOut
  688. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_DatabaseLoggingFlag].m_wsPropName, serverConfig->DatabaseLoggingFlag);
  689. return TRUE;
  690. }
  691. return FALSE;
  692. }
  693. MFN_PROPERTY_ACTION_DEFN(fnSrvSetDatabaseLoggingFlag, pParams, pIn, pOut)
  694. {
  695. BOOL fRefresh;
  696. DWORD newDatabaseLoggingFlag;
  697. CDHCP_Server_Parameters *pServerParams;
  698. // somehow the property we are expecting does not exist in CInstance *pIn
  699. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_DatabaseLoggingFlag].m_wsPropName, newDatabaseLoggingFlag))
  700. return FALSE;
  701. // after this call, pServerParams will surely be not-NULL
  702. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  703. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  704. if (!pServerParams->CheckExistsConfigPtr())
  705. return FALSE;
  706. pServerParams->m_pConfigInfoV4->DatabaseLoggingFlag = newDatabaseLoggingFlag;
  707. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  708. if (fRefresh)
  709. {
  710. DWORD returnCode;
  711. // this is the only field we are changing.
  712. pServerParams->m_dwConfigInfoV4Flags = Set_DatabaseLoggingFlag;
  713. // commit the changes now!
  714. pServerParams->CommitSet(returnCode);
  715. // save the output parameter
  716. if (pOut != NULL)
  717. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  718. }
  719. else
  720. {
  721. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  722. // we only add the parameter to the fields that are going to be commited.
  723. pServerParams->m_dwConfigInfoV4Flags |= Set_DatabaseLoggingFlag;
  724. }
  725. return TRUE;
  726. }
  727. MFN_PROPERTY_ACTION_DEFN(fnSrvGetRestoreFlag, pParams, pIn, pOut)
  728. {
  729. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  730. BOOL fRefresh;
  731. CDHCP_Server_Parameters *pServerParams;
  732. if (pOut == NULL)
  733. return FALSE;
  734. // after this call, pServerParams will surely be not-NULL
  735. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  736. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  737. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  738. {
  739. // set the value of the property into the (CInstance*)pOut
  740. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_RestoreFlag].m_wsPropName, serverConfig->RestoreFlag);
  741. return TRUE;
  742. }
  743. return FALSE;
  744. }
  745. MFN_PROPERTY_ACTION_DEFN(fnSrvSetRestoreFlag, pParams, pIn, pOut)
  746. {
  747. BOOL fRefresh;
  748. DWORD newRestoreFlag;
  749. CDHCP_Server_Parameters *pServerParams;
  750. // somehow the property we are expecting does not exist in CInstance *pIn
  751. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_RestoreFlag].m_wsPropName, newRestoreFlag))
  752. return FALSE;
  753. // after this call, pServerParams will surely be not-NULL
  754. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  755. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  756. if (!pServerParams->CheckExistsConfigPtr())
  757. return FALSE;
  758. pServerParams->m_pConfigInfoV4->RestoreFlag = newRestoreFlag;
  759. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  760. if (fRefresh)
  761. {
  762. DWORD returnCode;
  763. // this is the only field we are changing.
  764. pServerParams->m_dwConfigInfoV4Flags = Set_RestoreFlag;
  765. // commit the changes now!
  766. pServerParams->CommitSet(returnCode);
  767. // save the output parameter
  768. if (pOut != NULL)
  769. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  770. }
  771. else
  772. {
  773. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  774. // we only add the parameter to the fields that are going to be commited.
  775. pServerParams->m_dwConfigInfoV4Flags |= Set_RestoreFlag;
  776. }
  777. return TRUE;
  778. }
  779. MFN_PROPERTY_ACTION_DEFN(fnSrvGetDatabaseCleanupInterval, pParams, pIn, pOut)
  780. {
  781. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  782. BOOL fRefresh;
  783. CDHCP_Server_Parameters *pServerParams;
  784. if (pOut == NULL)
  785. return FALSE;
  786. // after this call, pServerParams will surely be not-NULL
  787. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  788. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  789. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  790. {
  791. // set the value of the property into the (CInstance*)pOut
  792. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_DatabaseCleanupInterval].m_wsPropName, serverConfig->DatabaseCleanupInterval);
  793. return TRUE;
  794. }
  795. return FALSE;
  796. }
  797. MFN_PROPERTY_ACTION_DEFN(fnSrvSetDatabaseCleanupInterval, pParams, pIn, pOut)
  798. {
  799. BOOL fRefresh;
  800. DWORD newDatabaseCleanupInterval;
  801. CDHCP_Server_Parameters *pServerParams;
  802. // somehow the property we are expecting does not exist in CInstance *pIn
  803. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_DatabaseCleanupInterval].m_wsPropName, newDatabaseCleanupInterval))
  804. return FALSE;
  805. // after this call, pServerParams will surely be not-NULL
  806. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  807. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  808. if (!pServerParams->CheckExistsConfigPtr())
  809. return FALSE;
  810. pServerParams->m_pConfigInfoV4->DatabaseCleanupInterval = newDatabaseCleanupInterval;
  811. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  812. if (fRefresh)
  813. {
  814. DWORD returnCode;
  815. // this is the only field we are changing.
  816. pServerParams->m_dwConfigInfoV4Flags = Set_DatabaseCleanupInterval;
  817. // commit the changes now!
  818. pServerParams->CommitSet(returnCode);
  819. // save the output parameter
  820. if (pOut != NULL)
  821. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  822. }
  823. else
  824. {
  825. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  826. // we only add the parameter to the fields that are going to be commited.
  827. pServerParams->m_dwConfigInfoV4Flags |= Set_DatabaseCleanupInterval;
  828. }
  829. return TRUE;
  830. }
  831. MFN_PROPERTY_ACTION_DEFN(fnSrvGetDebugFlag, pParams, pIn, pOut)
  832. {
  833. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  834. BOOL fRefresh;
  835. CDHCP_Server_Parameters *pServerParams;
  836. if (pOut == NULL)
  837. return FALSE;
  838. // after this call, pServerParams will surely be not-NULL
  839. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  840. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  841. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  842. {
  843. // set the value of the property into the (CInstance*)pOut
  844. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_DebugFlag].m_wsPropName, serverConfig->DebugFlag);
  845. return TRUE;
  846. }
  847. return FALSE;
  848. }
  849. MFN_PROPERTY_ACTION_DEFN(fnSrvSetDebugFlag, pParams, pIn, pOut)
  850. {
  851. BOOL fRefresh;
  852. DWORD newDebugFlag;
  853. CDHCP_Server_Parameters *pServerParams;
  854. // somehow the property we are expecting does not exist in CInstance *pIn
  855. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_DebugFlag].m_wsPropName, newDebugFlag))
  856. return FALSE;
  857. // after this call, pServerParams will surely be not-NULL
  858. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  859. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  860. if (!pServerParams->CheckExistsConfigPtr())
  861. return FALSE;
  862. pServerParams->m_pConfigInfoV4->DebugFlag = newDebugFlag;
  863. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  864. if (fRefresh)
  865. {
  866. DWORD returnCode;
  867. // this is the only field we are changing.
  868. pServerParams->m_dwConfigInfoV4Flags = Set_DebugFlag;
  869. // commit the changes now!
  870. pServerParams->CommitSet(returnCode);
  871. // save the output parameter
  872. if (pOut != NULL)
  873. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  874. }
  875. else
  876. {
  877. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  878. // we only add the parameter to the fields that are going to be commited.
  879. pServerParams->m_dwConfigInfoV4Flags |= Set_DebugFlag;
  880. }
  881. return TRUE;
  882. }
  883. MFN_PROPERTY_ACTION_DEFN(fnSrvGetPingRetries, pParams, pIn, pOut)
  884. {
  885. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  886. BOOL fRefresh;
  887. CDHCP_Server_Parameters *pServerParams;
  888. if (pOut == NULL)
  889. return FALSE;
  890. // after this call, pServerParams will surely be not-NULL
  891. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  892. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  893. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  894. {
  895. // set the value of the property into the (CInstance*)pOut
  896. pOut->SetDWORD(DHCP_Server_Property[IDX_SRV_PingRetries].m_wsPropName, serverConfig->dwPingRetries);
  897. return TRUE;
  898. }
  899. return FALSE;
  900. }
  901. MFN_PROPERTY_ACTION_DEFN(fnSrvSetPingRetries, pParams, pIn, pOut)
  902. {
  903. BOOL fRefresh;
  904. DWORD newPingRetries;
  905. CDHCP_Server_Parameters *pServerParams;
  906. // somehow the property we are expecting does not exist in CInstance *pIn
  907. if (pIn == NULL || !pIn->GetDWORD(DHCP_Server_Property[IDX_SRV_PingRetries].m_wsPropName, newPingRetries))
  908. return FALSE;
  909. // after this call, pServerParams will surely be not-NULL
  910. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  911. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  912. if (!pServerParams->CheckExistsConfigPtr())
  913. return FALSE;
  914. pServerParams->m_pConfigInfoV4->dwPingRetries = newPingRetries;
  915. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  916. if (fRefresh)
  917. {
  918. DWORD returnCode;
  919. // this is the only field we are changing.
  920. pServerParams->m_dwConfigInfoV4Flags = Set_PingRetries;
  921. // commit the changes now!
  922. pServerParams->CommitSet(returnCode);
  923. // save the output parameter
  924. if (pOut != NULL)
  925. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  926. }
  927. else
  928. {
  929. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  930. // we only add the parameter to the fields that are going to be commited.
  931. pServerParams->m_dwConfigInfoV4Flags |= Set_PingRetries;
  932. }
  933. return TRUE;
  934. }
  935. MFN_PROPERTY_ACTION_DEFN(fnSrvGetBootFileTable, pParams, pIn, pOut)
  936. {
  937. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  938. BOOL fRefresh;
  939. CDHCP_Server_Parameters *pServerParams;
  940. if (pOut == NULL)
  941. return FALSE;
  942. // after this call, pServerParams will surely be not-NULL
  943. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  944. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  945. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  946. {
  947. WCHAR *wcpTemp = serverConfig->wszBootTableString;
  948. DWORD dwTemp = serverConfig->cbBootTableString / sizeof(WCHAR);
  949. // convert the BootFileTable string array to one single array
  950. while(dwTemp--)
  951. {
  952. if (dwTemp != 0 && *wcpTemp == L'\0')
  953. *wcpTemp = L';';
  954. wcpTemp++;
  955. }
  956. // set the value of the property into the (CInstance*)pOut
  957. pOut->SetCHString(DHCP_Server_Property[IDX_SRV_BootFileTable].m_wsPropName, serverConfig->wszBootTableString);
  958. // convert back the single string to BootFileTable string array (less costy than alloc/copy/free)
  959. dwTemp = serverConfig->cbBootTableString;
  960. wcpTemp = serverConfig->wszBootTableString;
  961. while(dwTemp--)
  962. {
  963. if (dwTemp != 0 && *wcpTemp == L';')
  964. *wcpTemp = L'\0';
  965. wcpTemp++;
  966. }
  967. return TRUE;
  968. }
  969. return FALSE;
  970. }
  971. MFN_PROPERTY_ACTION_DEFN(fnSrvSetBootFileTable, pParams, pIn, pOut)
  972. {
  973. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  974. BOOL fRefresh;
  975. CDHCP_Server_Parameters *pServerParams;
  976. CHString newBootFileTable;
  977. DWORD dwTemp;
  978. WCHAR *wcpTemp;
  979. // somehow the property we are expecting does not exist in CInstance *pIn
  980. if (pIn == NULL || !pIn->GetCHString(DHCP_Server_Property[IDX_SRV_BootFileTable].m_wsPropName, newBootFileTable))
  981. return FALSE;
  982. // after this call, pServerParams will surely be not-NULL
  983. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  984. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  985. if (!pServerParams->CheckExistsConfigPtr())
  986. return FALSE;
  987. serverConfig = pServerParams->m_pConfigInfoV4;
  988. // if there is any allocated memory for the BackupPath, just release it.
  989. if (serverConfig->wszBootTableString != NULL)
  990. DhcpRpcFreeMemory(serverConfig->wszBootTableString);
  991. // allocate memory for the new database path. It has to fit the WCHAR string size.
  992. serverConfig->wszBootTableString = (WCHAR*)MIDL_user_allocate(sizeof(WCHAR)*newBootFileTable.GetLength()+sizeof(WCHAR));
  993. if (serverConfig->wszBootTableString == NULL)
  994. return FALSE;
  995. //copy the new database path to server param. It has to be translated to WCHAR
  996. #ifdef _UNICODE
  997. wcscpy(serverConfig->wszBootTableString, newBootFileTable);
  998. #else
  999. swprintf(serverConfig->wszBootTableString, L"%S", newBootFileTable);
  1000. #endif
  1001. dwTemp = wcslen(serverConfig->wszBootTableString) + 1;
  1002. wcpTemp = serverConfig->wszBootTableString;
  1003. serverConfig->cbBootTableString = dwTemp * sizeof(WCHAR);
  1004. // convert the one single string to the BootTableString array
  1005. while(dwTemp--)
  1006. {
  1007. if (dwTemp && *wcpTemp == L';')
  1008. *wcpTemp = L'\0';
  1009. wcpTemp++;
  1010. }
  1011. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  1012. if (fRefresh)
  1013. {
  1014. DWORD returnCode;
  1015. // this is the only field we are changing.
  1016. pServerParams->m_dwConfigInfoV4Flags = Set_BootFileTable;
  1017. // commit the changes now!
  1018. pServerParams->CommitSet(returnCode);
  1019. // save the output parameter
  1020. if (pOut != NULL)
  1021. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  1022. }
  1023. else
  1024. {
  1025. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  1026. // we only add the BackupPath to the fields that are going to be commited.
  1027. pServerParams->m_dwConfigInfoV4Flags |= Set_BootFileTable;
  1028. }
  1029. return TRUE;
  1030. }
  1031. MFN_PROPERTY_ACTION_DEFN(fnSrvGetAuditLog, pParams, pIn, pOut)
  1032. {
  1033. LPDHCP_SERVER_CONFIG_INFO_V4 serverConfig;
  1034. BOOL fRefresh;
  1035. CDHCP_Server_Parameters *pServerParams;
  1036. if (pOut == NULL)
  1037. return FALSE;
  1038. // after this call, pServerParams will surely be not-NULL
  1039. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  1040. // call the DHCP api through the DHCP_Server_Parameter::GetServerConfigInfoV4
  1041. if (pServerParams->GetServerConfigInfoV4(serverConfig, fRefresh))
  1042. {
  1043. // set the value of the property into the (CInstance*)pOut
  1044. pOut->Setbool(DHCP_Server_Property[IDX_SRV_AuditLog].m_wsPropName, serverConfig->fAuditLog);
  1045. return TRUE;
  1046. }
  1047. return FALSE;
  1048. }
  1049. MFN_PROPERTY_ACTION_DEFN(fnSrvSetAuditLog, pParams, pIn, pOut)
  1050. {
  1051. BOOL fRefresh;
  1052. bool newAuditLog;
  1053. CDHCP_Server_Parameters *pServerParams;
  1054. // somehow the property we are expecting does not exist in CInstance *pIn
  1055. if (pIn == NULL || !pIn->Getbool(DHCP_Server_Property[IDX_SRV_AuditLog].m_wsPropName, newAuditLog))
  1056. return FALSE;
  1057. // after this call, pServerParams will surely be not-NULL
  1058. ADJUST_SERVER_PARAMS(pParams, pServerParams, fRefresh);
  1059. // if there isn't any ConfigInfoV4 structure in the pServerParams, just allocate one, and reset the m_pConfigInfoV4Flags
  1060. if (!pServerParams->CheckExistsConfigPtr())
  1061. return FALSE;
  1062. pServerParams->m_pConfigInfoV4->fAuditLog = newAuditLog;
  1063. // if fRefresh -> working on backupParameters -> we are going to commit the changes
  1064. if (fRefresh)
  1065. {
  1066. DWORD returnCode;
  1067. // this is the only field we are changing.
  1068. pServerParams->m_dwConfigInfoV4Flags = Set_AuditLogState;
  1069. // commit the changes now!
  1070. pServerParams->CommitSet(returnCode);
  1071. // save the output parameter
  1072. if (pOut != NULL)
  1073. pOut->SetDWORD(RETURN_CODE_PROPERTY_NAME, returnCode);
  1074. }
  1075. else
  1076. {
  1077. // we are working on supplied DHCP_Server_Parameter -> changes are commited by the caller,
  1078. // we only add the parameter to the fields that are going to be commited.
  1079. pServerParams->m_dwConfigInfoV4Flags |= Set_AuditLogState;
  1080. }
  1081. return TRUE;
  1082. }