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.

135 lines
3.6 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. /*-----------------------------------------------------------------
  13. Filename: address.hpp
  14. Written By: B.Rajeev
  15. Purpose: Provides a flow control mechanism for the SnmpImpSession.
  16. -----------------------------------------------------------------*/
  17. #ifndef __FLOW_CONTROL__
  18. #define __FLOW_CONTROL__
  19. #include "forward.h"
  20. #include "common.h"
  21. /*--------------------------------------------------
  22. Overview:
  23. --------
  24. MessageStore: Provides queue like access to a store of messages.
  25. In addition to the Enqueue, Dequeue primites, it also enables
  26. deletion of specified messages from the queue.
  27. FlowControlMechanism: It encapsulates the flow control
  28. mechanism for the session. Once the window is full, incoming
  29. messages are buffered. A reply triggers off further message
  30. transmission until the window is full. If we give up on a
  31. message after retrying a specified number of times, the flow
  32. control mechanism must be informed of it. It signals FlowControl
  33. On/Off (through callback methods), when the window limits are reached
  34. --------------------------------------------------*/
  35. // a CList is used to implement the message store
  36. typedef CList<Message *, Message *> CListStore;
  37. class MessageStore : private CListStore
  38. {
  39. #ifdef WANT_MFC
  40. DECLARE_DYNAMIC(MessageStore);
  41. #endif
  42. public:
  43. // Add to the end of the queue.
  44. void Enqueue( Message &new_message );
  45. // Remove and return the first element in the Store
  46. Message* Dequeue(void);
  47. // checks if the queue is empty
  48. BOOL IsEmpty(void)
  49. {
  50. return CListStore::IsEmpty();
  51. }
  52. // remove the message possessing the session_frame_id and return it
  53. Message *DeleteMessage(SessionFrameId session_frame_id);
  54. ~MessageStore(void);
  55. };
  56. class FlowControlMechanism
  57. {
  58. // the session providing the context for flow control
  59. SnmpImpSession *session;
  60. UINT outstanding_messages;
  61. // this value is specified by the session on creation
  62. UINT window_size;
  63. // provides queue like access to a store of messages
  64. MessageStore message_store;
  65. // obtains lock on the session CriticalSection before
  66. // calling TransmitMessage
  67. void TransmitMessageUnderProtection(Message *message);
  68. // creates a waiting message, registers it with the message
  69. // registry and lets it transmit
  70. void TransmitMessage(Message *message);
  71. // transmits messages in message store as long as
  72. // the window is open
  73. void ClearMessageStore(void);
  74. public:
  75. // initializes the private variable
  76. FlowControlMechanism(SnmpImpSession &session, UINT window_size);
  77. // sends message if within the flow control window
  78. // else Stores it up
  79. void SendMessage(Message &message);
  80. // It removes the message frame from its message_Store
  81. void DeleteMessage(SessionFrameId session_frame_id);
  82. // this is called by a waiting_message indicating arrival
  83. // or by the message registry
  84. void NotifyReceipt(WaitingMessage &waiting_message,
  85. IN const SnmpPdu *snmp_pdu,
  86. SnmpErrorReport &error_report);
  87. // this is called when the session does not need
  88. // to be informed, but the flow control window
  89. // must advance (such as frame cancellation)
  90. // also destroys the waiting_message
  91. void AdvanceWindow(WaitingMessage &waiting_message);
  92. };
  93. #endif // __FLOW_CONTROL__