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.

112 lines
2.7 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. // For some reason, the SDOs call Shutdown on uninitialized components.
  46. if (getState() != STATE_UNINITIALIZED)
  47. {
  48. Auditor::Shutdown();
  49. info.finalize();
  50. }
  51. return S_OK;
  52. }
  53. STDMETHODIMP InfoBase::PutProperty(LONG, VARIANT*)
  54. {
  55. // Just use this as an opportunity to reset the counter.
  56. info.onReset();
  57. return S_OK;
  58. }
  59. STDMETHODIMP InfoBase::AuditEvent(ULONG ulEventID,
  60. ULONG ulNumStrings,
  61. ULONG,
  62. wchar_t** aszStrings,
  63. byte*)
  64. {
  65. //////////
  66. // Try to find a counter map entry.
  67. //////////
  68. RadiusCounterMap* entry = (RadiusCounterMap*)
  69. bsearch(&ulEventID,
  70. &theCounterMap,
  71. sizeof(theCounterMap)/sizeof(RadiusCounterMap),
  72. sizeof(RadiusCounterMap),
  73. counterMapCompare);
  74. // No entry means this event doesn't trigger a counter, so we're done.
  75. if (entry == NULL) { return S_OK; }
  76. if (entry->type == SERVER_COUNTER)
  77. {
  78. RadiusServerEntry* pse = info.getServerEntry();
  79. if (pse)
  80. {
  81. InterlockedIncrement((long*)(pse->dwCounters + entry->serverCounter));
  82. }
  83. }
  84. else if (ulNumStrings > 0) // Can't log client data without the address
  85. {
  86. _ASSERT(aszStrings != NULL);
  87. _ASSERT(*aszStrings != NULL);
  88. RadiusClientEntry* pce = info.findClientEntry(*aszStrings);
  89. if (pce)
  90. {
  91. InterlockedIncrement((long*)(pce->dwCounters + entry->clientCounter));
  92. }
  93. }
  94. return S_OK;
  95. }