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.

145 lines
3.6 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: packetreceiver.h
  4. //
  5. // Synopsis: This file holds the declarations of the
  6. // CPacketReceiver class
  7. //
  8. //
  9. // History: 9/23/97 MKarki Created
  10. //
  11. // Copyright (C) 1997-98 Microsoft Corporation
  12. // All rights reserved.
  13. //
  14. //----------------------------------------------------------------
  15. #ifndef _PACKETRECEIVER_H_
  16. #define _PACKETRECEIVER_H_
  17. #include "mempool.h"
  18. #include "packetio.h"
  19. #include "packetradius.h"
  20. #include "prevalidator.h"
  21. #include "reportevent.h"
  22. #include "clients.h"
  23. #include "sockevt.h"
  24. #include "radcommon.h"
  25. #include "regex.h"
  26. class CHashMD5;
  27. class CHashHmacMD5;
  28. class CDictionary;
  29. class CPacketReceiver : public CPacketIo
  30. {
  31. public:
  32. //
  33. // initializes the CPacketReceiver class object
  34. //
  35. BOOL Init (
  36. /*[in]*/ CDictionary *pCDictionary,
  37. /*[in]*/ CPreValidator *pCPreValidator,
  38. /*[in]*/ CHashMD5 *pCHashMD5,
  39. /*[in]*/ CHashHmacMD5 *pCHashHmacMD5,
  40. /*[in]*/ CClients *pCClients,
  41. /*[in]*/ CReportEvent *pCReportEvent
  42. );
  43. //
  44. // start processing of the new packet received
  45. //
  46. HRESULT ReceivePacket (
  47. /*[in]*/ PBYTE pInBuffer,
  48. /*[in]*/ DWORD dwSize,
  49. /*[in]*/ DWORD dwIPaddress,
  50. /*[in]*/ WORD wPort,
  51. /*[in]*/ SOCKET sock,
  52. /*[in]*/ PORTTYPE portType
  53. );
  54. // The receiver thread worker routine. Returns 'true' if the function should
  55. // be called again because the worker was unable to schedule a replacement.
  56. // The caller should continue to call WorkerRoutine until it returns false.
  57. bool WorkerRoutine(DWORD dwInfo) throw ();
  58. //
  59. // initate the processing of inbound data
  60. //
  61. BOOL StartProcessing (
  62. fd_set& AuthSet,
  63. fd_set& AcctSet
  64. );
  65. //
  66. // stop processing of inbound data
  67. //
  68. BOOL StopProcessing (
  69. VOID
  70. );
  71. //
  72. // constructor
  73. //
  74. CPacketReceiver(VOID);
  75. //
  76. // destructor
  77. //
  78. virtual ~CPacketReceiver(VOID);
  79. private:
  80. // State passed to the receiver thread.
  81. struct ReceiverCallback : IAS_CALLBACK
  82. {
  83. CPacketReceiver* self;
  84. DWORD dwInfo;
  85. };
  86. // Thread start routine for the receiver thread.
  87. static void WINAPI CallbackRoutine(IAS_CALLBACK* context) throw ();
  88. BOOL StartThreadIfNeeded (
  89. /*[in]*/ DWORD dwHandle
  90. );
  91. void ProcessInvalidPacketSize(
  92. /*in*/ DWORD dwInfo,
  93. /*in*/ const void* pBuffer,
  94. /*in*/ DWORD address
  95. );
  96. BSTR pingPattern;
  97. RegularExpression regexp;
  98. CPreValidator *m_pCPreValidator;
  99. CHashMD5 *m_pCHashMD5;
  100. CHashHmacMD5 *m_pCHashHmacMD5;
  101. CDictionary *m_pCDictionary;
  102. CClients *m_pCClients;
  103. CReportEvent *m_pCReportEvent;
  104. //
  105. // memory pool for UDP in request
  106. //
  107. memory_pool <MAX_PACKET_SIZE, task_allocator> m_InBufferPool;
  108. //
  109. // socket sets
  110. //
  111. fd_set m_AuthSet;
  112. fd_set m_AcctSet;
  113. // Used for knocking threads out of select.
  114. SocketEvent m_AuthEvent;
  115. SocketEvent m_AcctEvent;
  116. };
  117. #endif // infndef _PACKETRECEIVER_H_