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.

109 lines
2.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // InfoBase.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file implements the class InfoBase
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 09/09/1997 Original version.
  16. // 09/09/1998 Added PutProperty.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <iascore.h>
  20. #include <InfoBase.h>
  21. #include <CounterMap.h>
  22. STDMETHODIMP InfoBase::Initialize()
  23. {
  24. // Initialize the shared memory.
  25. if (!info.initialize())
  26. {
  27. DWORD error = GetLastError();
  28. return HRESULT_FROM_WIN32(error);
  29. }
  30. // Sort the counter map, so we can use bsearch.
  31. qsort(&theCounterMap,
  32. sizeof(theCounterMap)/sizeof(RadiusCounterMap),
  33. sizeof(RadiusCounterMap),
  34. counterMapCompare);
  35. // Connect to the audit channel.
  36. HRESULT hr = Auditor::Initialize();
  37. if (FAILED(hr))
  38. {
  39. info.finalize();
  40. }
  41. return hr;
  42. }
  43. STDMETHODIMP InfoBase::Shutdown()
  44. {
  45. Auditor::Shutdown();
  46. info.finalize();
  47. return S_OK;
  48. }
  49. STDMETHODIMP InfoBase::PutProperty(LONG, VARIANT*)
  50. {
  51. // Just use this as an opportunity to reset the counter.
  52. info.onReset();
  53. return S_OK;
  54. }
  55. STDMETHODIMP InfoBase::AuditEvent(ULONG ulEventID,
  56. ULONG ulNumStrings,
  57. ULONG,
  58. wchar_t** aszStrings,
  59. byte*)
  60. {
  61. //////////
  62. // Try to find a counter map entry.
  63. //////////
  64. RadiusCounterMap* entry = (RadiusCounterMap*)
  65. bsearch(&ulEventID,
  66. &theCounterMap,
  67. sizeof(theCounterMap)/sizeof(RadiusCounterMap),
  68. sizeof(RadiusCounterMap),
  69. counterMapCompare);
  70. // No entry means this event doesn't trigger a counter, so we're done.
  71. if (entry == NULL) { return S_OK; }
  72. if (entry->type == SERVER_COUNTER)
  73. {
  74. RadiusServerEntry* pse = info.getServerEntry();
  75. if (pse)
  76. {
  77. InterlockedIncrement((long*)(pse->dwCounters + entry->serverCounter));
  78. }
  79. }
  80. else if (ulNumStrings > 0) // Can't log client data without the address
  81. {
  82. _ASSERT(aszStrings != NULL);
  83. _ASSERT(*aszStrings != NULL);
  84. RadiusClientEntry* pce = info.findClientEntry(*aszStrings);
  85. if (pce)
  86. {
  87. InterlockedIncrement((long*)(pce->dwCounters + entry->clientCounter));
  88. }
  89. }
  90. return S_OK;
  91. }