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.

231 lines
6.5 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: reportevent.cpp
  4. //
  5. // Synopsis: Implementation of CReportEvent class methods
  6. // The class is responsible for logging the
  7. // appropriate events
  8. //
  9. //
  10. // History: 1/29/98 MKarki Created
  11. //
  12. // Copyright (C) 1997-98 Microsoft Corporation
  13. // All rights reserved.
  14. //
  15. //----------------------------------------------------------------
  16. #include "radcommon.h"
  17. #include "radpkt.h"
  18. #include "reportevent.h"
  19. #include "iasradius.h"
  20. #include "iasutil.h"
  21. #define NUMBER_OF_EVENT_STRINGS 2
  22. //
  23. // this array holds the information to map RADIUSLOGTYPEs to
  24. // IAS logs
  25. //
  26. static DWORD g_ReportEvent [MAX_RADIUSLOGTYPE +1][MAX_PACKET_TYPE +1];
  27. //++--------------------------------------------------------------
  28. //
  29. // Function: CReportEvent
  30. //
  31. // Synopsis: This is CReportEvent class constructor
  32. //
  33. // Arguments: NONE
  34. //
  35. // Returns: NONE
  36. //
  37. //
  38. // History: MKarki Created 1/29/98
  39. //
  40. //----------------------------------------------------------------
  41. CReportEvent::CReportEvent (
  42. VOID
  43. )
  44. :m_bLogMalformed (FALSE),
  45. m_bLogAcct (FALSE),
  46. m_bLogAuth (FALSE),
  47. m_bLogAll (FALSE)
  48. {
  49. //
  50. // initalize the global array
  51. //
  52. g_ReportEvent[RADIUS_DROPPED_PACKET][ACCESS_REQUEST] =
  53. IAS_EVENT_RADIUS_AUTH_DROPPED_PACKET;
  54. g_ReportEvent[RADIUS_DROPPED_PACKET][ACCOUNTING_REQUEST] =
  55. IAS_EVENT_RADIUS_ACCT_DROPPED_PACKET;
  56. g_ReportEvent[RADIUS_MALFORMED_PACKET][ACCESS_REQUEST] =
  57. IAS_EVENT_RADIUS_AUTH_MALFORMED_PACKET;
  58. g_ReportEvent[RADIUS_MALFORMED_PACKET][ACCOUNTING_REQUEST] =
  59. IAS_EVENT_RADIUS_ACCT_MALFORMED_PACKET;
  60. g_ReportEvent[RADIUS_INVALID_CLIENT][ACCESS_REQUEST] =
  61. IAS_EVENT_RADIUS_AUTH_INVALID_CLIENT;
  62. g_ReportEvent[RADIUS_INVALID_CLIENT][ACCOUNTING_REQUEST] =
  63. IAS_EVENT_RADIUS_ACCT_INVALID_CLIENT;
  64. g_ReportEvent[RADIUS_LOG_PACKET][ACCESS_REQUEST] =
  65. IAS_EVENT_RADIUS_AUTH_ACCESS_REQUEST;
  66. g_ReportEvent[RADIUS_LOG_PACKET][ACCESS_ACCEPT] =
  67. IAS_EVENT_RADIUS_AUTH_ACCESS_ACCEPT;
  68. g_ReportEvent[RADIUS_LOG_PACKET][ACCESS_REJECT] =
  69. IAS_EVENT_RADIUS_AUTH_ACCESS_REJECT;
  70. g_ReportEvent[RADIUS_LOG_PACKET][ACCOUNTING_REQUEST] =
  71. IAS_EVENT_RADIUS_ACCT_REQUEST;
  72. g_ReportEvent[RADIUS_LOG_PACKET][ACCOUNTING_RESPONSE] =
  73. IAS_EVENT_RADIUS_ACCT_RESPONSE;
  74. g_ReportEvent[RADIUS_LOG_PACKET][ACCESS_CHALLENGE] =
  75. IAS_EVENT_RADIUS_AUTH_ACCESS_CHALLENGE;
  76. g_ReportEvent[RADIUS_BAD_AUTHENTICATOR][ACCESS_REQUEST] =
  77. IAS_EVENT_RADIUS_AUTH_BAD_AUTHENTICATOR;
  78. g_ReportEvent[RADIUS_BAD_AUTHENTICATOR][ACCOUNTING_REQUEST] =
  79. IAS_EVENT_RADIUS_ACCT_BAD_AUTHENTICATOR;
  80. g_ReportEvent[RADIUS_UNKNOWN_TYPE][ACCESS_REQUEST] =
  81. IAS_EVENT_RADIUS_AUTH_UNKNOWN_TYPE;
  82. g_ReportEvent[RADIUS_UNKNOWN_TYPE][ACCOUNTING_REQUEST] =
  83. IAS_EVENT_RADIUS_ACCT_UNKNOWN_TYPE;
  84. g_ReportEvent[RADIUS_NO_RECORD][ACCESS_REQUEST] =
  85. IAS_EVENT_RADIUS_AUTH_DROPPED_PACKET;
  86. g_ReportEvent[RADIUS_NO_RECORD][ACCOUNTING_REQUEST] =
  87. IAS_EVENT_RADIUS_ACCT_NO_RECORD;
  88. } // end of CReportEvent class constructor
  89. //++--------------------------------------------------------------
  90. //
  91. // Function: ~CReportEvent
  92. //
  93. // Synopsis: This is CReportEvent class destructor
  94. //
  95. // Arguments: NONE
  96. //
  97. // Returns: NONE
  98. //
  99. //
  100. // History: MKarki Created 1/29/98
  101. //
  102. //----------------------------------------------------------------
  103. CReportEvent::~CReportEvent (
  104. VOID
  105. )
  106. {
  107. } // end of CReportEvent class constructor
  108. //++--------------------------------------------------------------
  109. //
  110. // Function: SetLogType
  111. //
  112. // Synopsis: This is CReportEvent class responsible
  113. // for setting the logging type
  114. //
  115. // Arguments:
  116. // [in] DWORD - log id
  117. // [in] BOOL - log value
  118. //
  119. // Returns: VOID
  120. //
  121. // History: MKarki Created 1/29/98
  122. //
  123. //----------------------------------------------------------------
  124. VOID
  125. CReportEvent::SetLogType (
  126. DWORD dwLogSwitches,
  127. BOOL bLogValue
  128. )
  129. {
  130. return;
  131. } // end of CReportEvent::SetLogType method
  132. //++--------------------------------------------------------------
  133. //
  134. // Function: Process
  135. //
  136. // Synopsis: This is CReportEvent class responsible for
  137. // actually logging the event to the Audit channel
  138. //
  139. // Arguments: NONE
  140. //
  141. // Returns: NONE
  142. //
  143. //
  144. // History: MKarki Created 1/29/98
  145. //
  146. //----------------------------------------------------------------
  147. VOID
  148. CReportEvent::Process (
  149. RADIUSLOGTYPE radLogType,
  150. PACKETTYPE radPacketType,
  151. DWORD dwDataSize,
  152. DWORD dwIPAddress,
  153. LPCWSTR szInString,
  154. LPVOID pRawData
  155. )
  156. {
  157. HRESULT hr = S_OK;
  158. LPCWSTR pStrArray[NUMBER_OF_EVENT_STRINGS];
  159. WCHAR wszIPAddress[16];
  160. BOOL bLogPacket = FALSE;
  161. //
  162. // the values should be in array range
  163. //
  164. _ASSERT (MAX_RADIUSLOGTYPE >= radLogType);
  165. //
  166. // as we might get incorrect values for packettype,
  167. // we need to correct this
  168. //
  169. if (MAX_PACKET_TYPE < radPacketType) { return;}
  170. //
  171. // get the IP address in dotted octed format
  172. // and put in as a string
  173. //
  174. ias_inet_htow(dwIPAddress, wszIPAddress);
  175. //
  176. // put the strings in the array
  177. //
  178. pStrArray[0] = wszIPAddress;
  179. pStrArray[1] = szInString;
  180. //
  181. // log the event now
  182. //
  183. hr = ::IASReportEvent (
  184. g_ReportEvent [radLogType][radPacketType],
  185. (DWORD) NUMBER_OF_EVENT_STRINGS,
  186. dwDataSize,
  187. pStrArray,
  188. pRawData
  189. );
  190. if (FAILED (hr))
  191. {
  192. IASTracePrintf (
  193. "Unable to report event from Radius Component"
  194. );
  195. }
  196. } // end of CReportEvent::Process method