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.

910 lines
25 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. registry.cpp
  5. Abstract:
  6. Routines for reading registry configuration.
  7. Author:
  8. Nikhil Bobde (NikhilB)
  9. Revision History:
  10. --*/
  11. //
  12. // Include files
  13. //
  14. #include "globals.h"
  15. #include "line.h"
  16. #include "ras.h"
  17. #include "q931obj.h"
  18. //
  19. // Macro definitions
  20. //
  21. #define GK_PORT 1719
  22. #define EVENTLOG_SERVICE_APP_KEY_PATH _T("System\\CurrentControlSet\\Services\\EventLog\\Application")
  23. #define EVENTLOG_MESSAGE_FILE _T("EventMessageFile")
  24. #define EVENTLOG_TYPES_SUPPORTED _T("TypesSupported")
  25. #define EVENT_SOURCE_TYPES_SUPPORTED 7
  26. #define H323_TSP_MODULE_NAME _T("H323.TSP")
  27. //
  28. // Global variables
  29. //
  30. extern Q931_LISTENER Q931Listener;
  31. H323_REGISTRY_SETTINGS g_RegistrySettings;
  32. static HKEY g_RegistryKey = NULL;
  33. static HANDLE g_RegistryNotifyEvent = NULL;
  34. // RTL thread pool wait handle
  35. static HANDLE g_RegistryNotifyWaitHandle = NULL;
  36. static void NTAPI RegistryNotifyCallback (
  37. IN PVOID ContextParameter,
  38. IN BOOLEAN TimerFired);
  39. static BOOL H323GetConfigFromRegistry (void);
  40. //
  41. // Public procedures
  42. //
  43. /*++
  44. Routine Description:
  45. Changes configuration settings back to defaults.
  46. Arguments:
  47. None.
  48. Return Values:
  49. Returns true if successful.
  50. --*/
  51. static BOOL RegistrySetDefaultConfig(void)
  52. {
  53. //initialize alerting timeout to default
  54. g_RegistrySettings.dwQ931AlertingTimeout = CALL_ALERTING_TIMEOUT;
  55. //initialize call signalling port to default
  56. g_RegistrySettings.dwQ931ListenPort= Q931_CALL_PORT;
  57. // success
  58. return TRUE;
  59. }
  60. static LONG RegistryRequestNotify(void)
  61. {
  62. return RegNotifyChangeKeyValue (
  63. g_RegistryKey, // key to watch
  64. FALSE, // do not watch subtree
  65. REG_NOTIFY_CHANGE_LAST_SET, // notify filter
  66. g_RegistryNotifyEvent, // notification event
  67. TRUE); // is asychnronous
  68. }
  69. HRESULT RegistryStart(void)
  70. {
  71. LONG lStatus;
  72. DWORD dwResult;
  73. HKEY regKeyService;
  74. HKEY hKey;
  75. DWORD dwValue;
  76. if( g_RegistryKey != NULL )
  77. {
  78. return TRUE;
  79. }
  80. RegistrySetDefaultConfig();
  81. lStatus = RegCreateKeyEx (
  82. HKEY_LOCAL_MACHINE,
  83. H323_REGKEY_ROOT,
  84. 0, WIN31_CLASS, 0,
  85. KEY_READ, NULL,
  86. &g_RegistryKey, NULL);
  87. if( lStatus != ERROR_SUCCESS )
  88. {
  89. H323DBG(( DEBUG_LEVEL_ERROR,
  90. "configuration registry key could not be opened/created" ));
  91. DumpError (lStatus);
  92. return E_FAIL;
  93. }
  94. // load initial configuration
  95. H323GetConfigFromRegistry();
  96. g_RegistryNotifyEvent = NULL;
  97. g_RegistryNotifyWaitHandle = NULL;
  98. g_RegistryNotifyEvent = H323CreateEvent (NULL, FALSE, FALSE,
  99. _T( "H323TSP_RegistryNotifyEvent" ) );
  100. if( g_RegistryNotifyEvent != NULL )
  101. {
  102. lStatus = RegistryRequestNotify();
  103. if( lStatus == ERROR_SUCCESS )
  104. {
  105. if (RegisterWaitForSingleObject (
  106. &g_RegistryNotifyWaitHandle,
  107. g_RegistryNotifyEvent,
  108. RegistryNotifyCallback,
  109. NULL, INFINITE, WT_EXECUTEDEFAULT))
  110. {
  111. _ASSERTE( g_RegistryNotifyWaitHandle );
  112. // ready
  113. }
  114. else
  115. {
  116. // failed to registry wait
  117. H323DBG(( DEBUG_LEVEL_ERROR,
  118. "failed to callback for registry notification" ));
  119. DumpError (lStatus);
  120. g_RegistryNotifyWaitHandle = NULL;
  121. }
  122. }
  123. else
  124. {
  125. H323DBG(( DEBUG_LEVEL_ERROR,
  126. "failed to request notification on registry changes" ));
  127. DumpError (lStatus);
  128. }
  129. }
  130. else
  131. {
  132. // although this is an error, we continue anyway.
  133. // we just won't be able to receive notification of registry changes.
  134. H323DBG(( DEBUG_LEVEL_ERROR,
  135. "failed to create event, cannot receive registry notification events" ));
  136. }
  137. //Eventlog params
  138. lStatus = RegOpenKeyEx(
  139. HKEY_LOCAL_MACHINE,
  140. EVENTLOG_SERVICE_APP_KEY_PATH,
  141. 0,
  142. KEY_CREATE_SUB_KEY,
  143. &regKeyService );
  144. if( lStatus == ERROR_SUCCESS )
  145. {
  146. lStatus = RegCreateKey(
  147. regKeyService,
  148. H323TSP_EVENT_SOURCE_NAME,
  149. &hKey );
  150. RegCloseKey( regKeyService );
  151. regKeyService = NULL;
  152. if( lStatus == ERROR_SUCCESS )
  153. {
  154. TCHAR wszModulePath[MAX_PATH+1];
  155. dwResult = GetModuleFileName(
  156. GetModuleHandle( H323_TSP_MODULE_NAME ),
  157. wszModulePath, MAX_PATH );
  158. if( dwResult != 0 )
  159. {
  160. // query for registry value
  161. lStatus = RegSetValueEx(
  162. hKey,
  163. EVENTLOG_MESSAGE_FILE,
  164. 0,
  165. REG_SZ,
  166. (LPBYTE)wszModulePath,
  167. H323SizeOfWSZ(wszModulePath) );
  168. // validate return code
  169. if( lStatus == ERROR_SUCCESS )
  170. {
  171. dwValue = EVENT_SOURCE_TYPES_SUPPORTED;
  172. // query for registry value
  173. lStatus = RegSetValueEx(
  174. hKey,
  175. EVENTLOG_TYPES_SUPPORTED,
  176. 0,
  177. REG_DWORD,
  178. (LPBYTE)&dwValue,
  179. sizeof(DWORD) );
  180. if( lStatus == ERROR_SUCCESS )
  181. {
  182. // connect to event logging service
  183. g_hEventLogSource = RegisterEventSource( NULL,
  184. H323TSP_EVENT_SOURCE_NAME );
  185. }
  186. }
  187. }
  188. }
  189. RegCloseKey( hKey );
  190. hKey = NULL;
  191. }
  192. return S_OK;
  193. }
  194. void RegistryStop(void)
  195. {
  196. HKEY hKey;
  197. LONG lStatus;
  198. H323DBG ((DEBUG_LEVEL_TRACE, "RegistryStop Entered"));
  199. if (g_RegistryNotifyWaitHandle)
  200. {
  201. UnregisterWaitEx( g_RegistryNotifyWaitHandle, (HANDLE) -1 );
  202. g_RegistryNotifyWaitHandle = NULL;
  203. }
  204. if (g_RegistryNotifyEvent)
  205. {
  206. CloseHandle (g_RegistryNotifyEvent);
  207. g_RegistryNotifyEvent = NULL;
  208. }
  209. if (g_RegistryKey)
  210. {
  211. RegCloseKey (g_RegistryKey);
  212. g_RegistryKey = NULL;
  213. }
  214. //Eventlog params
  215. lStatus = RegOpenKeyEx (
  216. HKEY_LOCAL_MACHINE,
  217. EVENTLOG_SERVICE_APP_KEY_PATH,
  218. 0,
  219. KEY_CREATE_SUB_KEY,
  220. &hKey );
  221. if( lStatus==ERROR_SUCCESS )
  222. {
  223. RegDeleteKey( hKey, H323TSP_EVENT_SOURCE_NAME);
  224. RegCloseKey( hKey );
  225. hKey = NULL;
  226. }
  227. g_RegistrySettings.dwQ931ListenPort = 0;
  228. H323DBG ((DEBUG_LEVEL_TRACE, "RegistryStop Exited"));
  229. }
  230. static DWORD inet_addrW(
  231. IN LPTSTR String
  232. )
  233. {
  234. CHAR AnsiString [0x21];
  235. INT Length;
  236. Length = WideCharToMultiByte (CP_ACP, 0, String, -1, AnsiString, 0x20, NULL, NULL);
  237. AnsiString [Length] = 0;
  238. return inet_addr (AnsiString);
  239. }
  240. static HOSTENT * gethostbynameW (LPTSTR String)
  241. {
  242. CHAR AnsiString [0x21];
  243. INT Length;
  244. Length = WideCharToMultiByte (CP_ACP, 0, String, -1, AnsiString, 0x20, NULL, NULL);
  245. AnsiString [Length] = 0;
  246. return gethostbyname (AnsiString);
  247. }
  248. static BOOL H323GetConfigFromRegistry (void)
  249. /*++
  250. Routine Description:
  251. Loads registry settings for service provider.
  252. Arguments:
  253. None.
  254. Return Values:
  255. Returns true if successful.
  256. --*/
  257. {
  258. LONG lStatus = ERROR_SUCCESS;
  259. TCHAR szAddr[H323_MAXDESTNAMELEN];
  260. DWORD dwValue;
  261. DWORD dwValueSize;
  262. DWORD dwValueType;
  263. LPTSTR pszValue;
  264. // see if key open
  265. if( g_RegistryKey == NULL )
  266. {
  267. return FALSE;
  268. }
  269. // initialize value name
  270. pszValue = H323_REGVAL_DEBUGLEVEL;
  271. // initialize type
  272. dwValueType = REG_DWORD;
  273. dwValueSize = sizeof(DWORD);
  274. // query for registry value
  275. lStatus = RegQueryValueEx(
  276. g_RegistryKey,
  277. pszValue,
  278. NULL,
  279. &dwValueType,
  280. (LPBYTE)&g_RegistrySettings.dwLogLevel,
  281. &dwValueSize
  282. );
  283. // validate return code
  284. if( lStatus != ERROR_SUCCESS )
  285. {
  286. // copy default value into global settings
  287. g_RegistrySettings.dwLogLevel = DEBUG_LEVEL_FORCE;
  288. }
  289. // initialize value name
  290. pszValue = H323_REGVAL_Q931LISTENPORT;
  291. // initialize type
  292. dwValueType = REG_DWORD;
  293. dwValueSize = sizeof(DWORD);
  294. // query for registry value
  295. lStatus = RegQueryValueEx(
  296. g_RegistryKey,
  297. pszValue,
  298. NULL,
  299. &dwValueType,
  300. (LPBYTE)&g_RegistrySettings.dwQ931ListenPort,
  301. &dwValueSize
  302. );
  303. // validate return code
  304. if( (lStatus == ERROR_SUCCESS) &&
  305. (g_RegistrySettings.dwQ931ListenPort >=1000) &&
  306. (g_RegistrySettings.dwQ931ListenPort <= 32000)
  307. )
  308. {
  309. H323DBG(( DEBUG_LEVEL_VERBOSE,
  310. "using Q931 listen portof %d.",
  311. g_RegistrySettings.dwQ931ListenPort ));
  312. }
  313. else
  314. {
  315. H323DBG(( DEBUG_LEVEL_VERBOSE,
  316. "using default Q931 timeout." ));
  317. // copy default value into global settings
  318. g_RegistrySettings.dwQ931ListenPort = Q931_CALL_PORT;
  319. }
  320. // initialize value name
  321. pszValue = H323_REGVAL_Q931ALERTINGTIMEOUT;
  322. // initialize type
  323. dwValueType = REG_DWORD;
  324. dwValueSize = sizeof(DWORD);
  325. // query for registry value
  326. lStatus = RegQueryValueEx(
  327. g_RegistryKey,
  328. pszValue,
  329. NULL,
  330. &dwValueType,
  331. (LPBYTE)&g_RegistrySettings.dwQ931AlertingTimeout,
  332. &dwValueSize
  333. );
  334. // validate return code
  335. if( (lStatus == ERROR_SUCCESS) &&
  336. (g_RegistrySettings.dwQ931AlertingTimeout >=30000) &&
  337. (g_RegistrySettings.dwQ931AlertingTimeout <= CALL_ALERTING_TIMEOUT)
  338. )
  339. {
  340. H323DBG(( DEBUG_LEVEL_VERBOSE,
  341. "using Q931 timeout of %d milliseconds.",
  342. g_RegistrySettings.dwQ931AlertingTimeout ));
  343. }
  344. else
  345. {
  346. H323DBG(( DEBUG_LEVEL_VERBOSE,
  347. "using default Q931 timeout." ));
  348. // copy default value into global settings
  349. g_RegistrySettings.dwQ931AlertingTimeout = CALL_ALERTING_TIMEOUT;
  350. }
  351. // initialize value name
  352. pszValue = H323_REGVAL_GATEWAYADDR;
  353. // initialize type
  354. dwValueType = REG_SZ;
  355. dwValueSize = sizeof(szAddr);
  356. // initialize ip address
  357. dwValue = INADDR_NONE;
  358. // query for registry value
  359. lStatus = RegQueryValueEx(
  360. g_RegistryKey,
  361. pszValue,
  362. NULL,
  363. &dwValueType,
  364. (unsigned char*)szAddr,
  365. &dwValueSize
  366. );
  367. // validate return code
  368. if (lStatus == ERROR_SUCCESS)
  369. {
  370. // convert ip address
  371. dwValue = inet_addrW(szAddr);
  372. // see if address converted
  373. if( dwValue == INADDR_NONE )
  374. {
  375. struct hostent * pHost;
  376. // attempt to lookup hostname
  377. pHost = gethostbynameW(szAddr);
  378. // validate pointer
  379. if (pHost != NULL)
  380. {
  381. // retrieve host address from structure
  382. dwValue = *(unsigned long *)pHost->h_addr;
  383. }
  384. }
  385. }
  386. // see if address converted and check for null
  387. if ((dwValue > 0) && (dwValue != INADDR_NONE) )
  388. {
  389. // save new gateway address in registry structure
  390. g_RegistrySettings.gatewayAddr.nAddrType = H323_IP_BINARY;
  391. g_RegistrySettings.gatewayAddr.Addr.IP_Binary.dwAddr = ntohl(dwValue);
  392. g_RegistrySettings.gatewayAddr.Addr.IP_Binary.wPort =
  393. LOWORD(g_RegistrySettings.dwQ931ListenPort);
  394. g_RegistrySettings.gatewayAddr.bMulticast =
  395. IN_MULTICAST(g_RegistrySettings.gatewayAddr.Addr.IP_Binary.dwAddr);
  396. H323DBG((
  397. DEBUG_LEVEL_TRACE,
  398. "gateway address resolved to %s.",
  399. H323AddrToString(dwValue)
  400. ));
  401. }
  402. else
  403. {
  404. // clear memory used for gateway address
  405. memset( (PVOID) &g_RegistrySettings.gatewayAddr,0,sizeof(H323_ADDR));
  406. }
  407. // initialize value name
  408. pszValue = H323_REGVAL_GATEWAYENABLED;
  409. // initialize type
  410. dwValueType = REG_DWORD;
  411. dwValueSize = sizeof(DWORD);
  412. // query for registry value
  413. lStatus = RegQueryValueEx(
  414. g_RegistryKey,
  415. pszValue,
  416. NULL,
  417. &dwValueType,
  418. (LPBYTE)&dwValue,
  419. &dwValueSize
  420. );
  421. // validate return code
  422. if (lStatus == ERROR_SUCCESS)
  423. {
  424. // if value non-zero then gateway address enabled
  425. g_RegistrySettings.fIsGatewayEnabled = (dwValue != 0);
  426. }
  427. else
  428. {
  429. // copy default value into settings
  430. g_RegistrySettings.fIsGatewayEnabled = FALSE;
  431. }
  432. // initialize value name
  433. pszValue = H323_REGVAL_PROXYADDR;
  434. // initialize type
  435. dwValueType = REG_SZ;
  436. dwValueSize = sizeof(szAddr);
  437. // initialize ip address
  438. dwValue = INADDR_NONE;
  439. // query for registry value
  440. lStatus = RegQueryValueEx(
  441. g_RegistryKey,
  442. pszValue,
  443. NULL,
  444. &dwValueType,
  445. (unsigned char*)szAddr,
  446. &dwValueSize
  447. );
  448. // validate return code
  449. if (lStatus == ERROR_SUCCESS)
  450. {
  451. // convert ip address
  452. dwValue = inet_addrW(szAddr);
  453. // see if address converted
  454. if( dwValue == INADDR_NONE )
  455. {
  456. struct hostent * pHost;
  457. // attempt to lookup hostname
  458. pHost = gethostbynameW(szAddr);
  459. // validate pointer
  460. if (pHost != NULL)
  461. {
  462. // retrieve host address from structure
  463. dwValue = *(unsigned long *)pHost->h_addr;
  464. }
  465. }
  466. }
  467. // see if address converted
  468. if( (dwValue > 0) && (dwValue != INADDR_NONE) )
  469. {
  470. // save new gateway address in registry structure
  471. g_RegistrySettings.proxyAddr.nAddrType = H323_IP_BINARY;
  472. g_RegistrySettings.proxyAddr.Addr.IP_Binary.dwAddr = ntohl(dwValue);
  473. g_RegistrySettings.proxyAddr.Addr.IP_Binary.wPort =
  474. LOWORD(g_RegistrySettings.dwQ931ListenPort);
  475. g_RegistrySettings.proxyAddr.bMulticast =
  476. IN_MULTICAST(g_RegistrySettings.proxyAddr.Addr.IP_Binary.dwAddr);
  477. H323DBG(( DEBUG_LEVEL_TRACE,
  478. "proxy address resolved to %s.",
  479. H323AddrToString(dwValue) ));
  480. }
  481. else
  482. {
  483. // clear memory used for gateway address
  484. memset( (PVOID)&g_RegistrySettings.proxyAddr,0,sizeof(H323_ADDR));
  485. }
  486. // initialize value name
  487. pszValue = H323_REGVAL_PROXYENABLED;
  488. // initialize type
  489. dwValueType = REG_DWORD;
  490. dwValueSize = sizeof(DWORD);
  491. // query for registry value
  492. lStatus = RegQueryValueEx(
  493. g_RegistryKey,
  494. pszValue,
  495. NULL,
  496. &dwValueType,
  497. (LPBYTE)&dwValue,
  498. &dwValueSize
  499. );
  500. // validate return code
  501. if (lStatus == ERROR_SUCCESS)
  502. {
  503. // if value non-zero then gateway address enabled
  504. g_RegistrySettings.fIsProxyEnabled = (dwValue != 0);
  505. }
  506. else
  507. {
  508. // copy default value into settings
  509. g_RegistrySettings.fIsProxyEnabled = FALSE;
  510. }
  511. /////////////////////////////////////////////////////////////////////////
  512. //Read the GK address
  513. ////////////////////////////////////////////////////////////////////////
  514. // initialize value name
  515. pszValue = H323_REGVAL_GKENABLED;
  516. // initialize type
  517. dwValueType = REG_DWORD;
  518. dwValueSize = sizeof(DWORD);
  519. // query for registry value
  520. lStatus = RegQueryValueEx(
  521. g_RegistryKey,
  522. pszValue,
  523. NULL,
  524. &dwValueType,
  525. (LPBYTE)&dwValue,
  526. &dwValueSize
  527. );
  528. // validate return code
  529. if (lStatus == ERROR_SUCCESS)
  530. {
  531. // if value non-zero then gateway address enabled
  532. g_RegistrySettings.fIsGKEnabled = (dwValue != 0);
  533. }
  534. else
  535. {
  536. // copy default value into settings
  537. g_RegistrySettings.fIsGKEnabled = FALSE;
  538. }
  539. if( g_RegistrySettings.fIsGKEnabled )
  540. {
  541. // initialize value name
  542. pszValue = H323_REGVAL_GKADDR;
  543. // initialize type
  544. dwValueType = REG_SZ;
  545. dwValueSize = sizeof(szAddr);
  546. // initialize ip address
  547. dwValue = INADDR_NONE;
  548. // query for registry value
  549. lStatus = RegQueryValueEx(
  550. g_RegistryKey,
  551. pszValue,
  552. NULL,
  553. &dwValueType,
  554. (unsigned char*)szAddr,
  555. &dwValueSize
  556. );
  557. // validate return code
  558. if (lStatus == ERROR_SUCCESS)
  559. {
  560. //convert ip address
  561. dwValue = inet_addrW(szAddr);
  562. // see if address converted
  563. if( dwValue == INADDR_NONE )
  564. {
  565. struct hostent * pHost;
  566. // attempt to lookup hostname
  567. pHost = gethostbynameW(szAddr);
  568. // validate pointer
  569. if (pHost != NULL)
  570. {
  571. // retrieve host address from structure
  572. dwValue = *(unsigned long *)pHost->h_addr;
  573. }
  574. }
  575. }
  576. // see if address converted and check for null
  577. if( (dwValue > 0) && (dwValue != INADDR_NONE) )
  578. {
  579. // save new gateway address in registry structure
  580. g_RegistrySettings.saGKAddr.sin_family = AF_INET;
  581. g_RegistrySettings.saGKAddr.sin_addr.s_addr = dwValue;
  582. g_RegistrySettings.saGKAddr.sin_port = htons( GK_PORT );
  583. H323DBG(( DEBUG_LEVEL_TRACE,
  584. "gatekeeper address resolved to %s.", H323AddrToString(dwValue) ));
  585. }
  586. else
  587. {
  588. // clear memory used for gateway address
  589. memset( (PVOID) &g_RegistrySettings.saGKAddr,0,sizeof(SOCKADDR_IN));
  590. g_RegistrySettings.fIsGKEnabled = FALSE;
  591. }
  592. }
  593. /////////////////////////////////////////////////////////////////////////
  594. //Read the GK log on phone number
  595. ////////////////////////////////////////////////////////////////////////
  596. // initialize value name
  597. pszValue = H323_REGVAL_GKLOGON_PHONEENABLED;
  598. // initialize type
  599. dwValueType = REG_DWORD;
  600. dwValueSize = sizeof(DWORD);
  601. // query for registry value
  602. lStatus = RegQueryValueEx(
  603. g_RegistryKey,
  604. pszValue,
  605. NULL,
  606. &dwValueType,
  607. (LPBYTE)&dwValue,
  608. &dwValueSize
  609. );
  610. // validate return code
  611. if (lStatus == ERROR_SUCCESS)
  612. {
  613. // if value non-zero then gateway address enabled
  614. g_RegistrySettings.fIsGKLogOnPhoneEnabled = (dwValue != 0);
  615. }
  616. else
  617. {
  618. // copy default value into settings
  619. g_RegistrySettings.fIsGKLogOnPhoneEnabled = FALSE;
  620. }
  621. if( g_RegistrySettings.fIsGKLogOnPhoneEnabled )
  622. {
  623. // initialize value name
  624. pszValue = H323_REGVAL_GKLOGON_PHONE;
  625. // initialize type
  626. dwValueType = REG_SZ;
  627. dwValueSize = H323_MAXDESTNAMELEN * sizeof (TCHAR);
  628. // query for registry value
  629. lStatus = RegQueryValueEx(
  630. g_RegistryKey,
  631. pszValue,
  632. NULL,
  633. &dwValueType,
  634. (LPBYTE) g_RegistrySettings.wszGKLogOnPhone,
  635. &dwValueSize
  636. );
  637. // validate return code
  638. if( (lStatus!=ERROR_SUCCESS) ||
  639. (dwValueSize > sizeof(szAddr)) )
  640. {
  641. memset( (PVOID) g_RegistrySettings.wszGKLogOnPhone, 0,
  642. sizeof(g_RegistrySettings.wszGKLogOnPhone));
  643. g_RegistrySettings.fIsGKLogOnPhoneEnabled = FALSE;
  644. }
  645. else
  646. {
  647. g_RegistrySettings.fIsGKLogOnPhoneEnabled = TRUE;
  648. }
  649. }
  650. /////////////////////////////////////////////////////////////////////////
  651. //Read the GK log on acct name
  652. ////////////////////////////////////////////////////////////////////////
  653. // initialize value name
  654. pszValue = H323_REGVAL_GKLOGON_ACCOUNTENABLED;
  655. // initialize type
  656. dwValueType = REG_DWORD;
  657. dwValueSize = sizeof(DWORD);
  658. // query for registry value
  659. lStatus = RegQueryValueEx(
  660. g_RegistryKey,
  661. pszValue,
  662. NULL,
  663. &dwValueType,
  664. (LPBYTE)&dwValue,
  665. &dwValueSize
  666. );
  667. // validate return code
  668. if (lStatus == ERROR_SUCCESS)
  669. {
  670. // if value non-zero then gateway address enabled
  671. g_RegistrySettings.fIsGKLogOnAccountEnabled = (dwValue != 0);
  672. }
  673. else
  674. {
  675. // copy default value into settings
  676. g_RegistrySettings.fIsGKLogOnAccountEnabled = FALSE;
  677. }
  678. if( g_RegistrySettings.fIsGKLogOnAccountEnabled )
  679. {
  680. // initialize value name
  681. pszValue = H323_REGVAL_GKLOGON_ACCOUNT;
  682. // initialize type
  683. dwValueType = REG_SZ;
  684. dwValueSize = H323_MAXDESTNAMELEN * sizeof (TCHAR);
  685. // initialize ip address
  686. dwValue = INADDR_NONE;
  687. // query for registry value
  688. lStatus = RegQueryValueEx(
  689. g_RegistryKey,
  690. pszValue,
  691. NULL,
  692. &dwValueType,
  693. (LPBYTE) g_RegistrySettings.wszGKLogOnAccount,
  694. &dwValueSize
  695. );
  696. // validate return code
  697. if( (lStatus!=ERROR_SUCCESS) ||
  698. (dwValueSize > sizeof(g_RegistrySettings.wszGKLogOnPhone)) )
  699. {
  700. memset( (PVOID) g_RegistrySettings.wszGKLogOnAccount, 0,
  701. sizeof(g_RegistrySettings.wszGKLogOnAccount));
  702. g_RegistrySettings.fIsGKLogOnAccountEnabled = FALSE;
  703. }
  704. else
  705. {
  706. g_RegistrySettings.fIsGKLogOnAccountEnabled = TRUE;
  707. }
  708. }
  709. // success
  710. return TRUE;
  711. }
  712. static void NTAPI RegistryNotifyCallback (
  713. IN PVOID ContextParameter,
  714. IN BOOLEAN TimerFired
  715. )
  716. {
  717. H323DBG ((DEBUG_LEVEL_TRACE, "registry notify event enter."));
  718. // refresh registry settings
  719. H323GetConfigFromRegistry();
  720. //if the gatekeeper has been enabled or disabled or changed then
  721. //send RRQ and URQ as required
  722. //if the alias list has been changed then update the gatekeeper
  723. //alias list
  724. RasHandleRegistryChange();
  725. //Listen on the new port number if changed.
  726. Q931Listener.HandleRegistryChange();
  727. RegistryRequestNotify();
  728. H323DBG ((DEBUG_LEVEL_TRACE, "registry notify event exit."));
  729. }