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.

110 lines
2.7 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: reg.cpp
  14. Written By: B.Rajeev
  15. ----------------------------------------------------------*/
  16. #include "precomp.h"
  17. #include "common.h"
  18. #include "sync.h"
  19. #include "message.h"
  20. #include "dummy.h"
  21. #include "reg.h"
  22. #include "idmap.h"
  23. #include "vblist.h"
  24. #include "sec.h"
  25. #include "pdu.h"
  26. #include "flow.h"
  27. #include "frame.h"
  28. #include "timer.h"
  29. #include "ssent.h"
  30. #include "opreg.h"
  31. #include "session.h"
  32. RequestId MessageRegistry::next_request_id = 1 ;
  33. RequestId MessageRegistry::GenerateRequestId(
  34. IN WaitingMessage &waiting_message)
  35. {
  36. RequestId request_id = next_request_id++;
  37. if (next_request_id == ILLEGAL_REQUEST_ID)
  38. next_request_id++;
  39. mapping[request_id] = &waiting_message;
  40. return request_id;
  41. }
  42. // used by the event handler to notify the message registry
  43. // of a message receipt
  44. // it must receive the message and notify the concerned
  45. // waiting message of the event
  46. void MessageRegistry::MessageArrivalNotification(IN SnmpPdu &snmp_pdu)
  47. {
  48. // determine the concerned waiting message and pass it the SnmpPdu
  49. RequestId request_id ;
  50. session->m_EncodeDecode.GetRequestId(snmp_pdu,request_id);
  51. // if failed, return, as there is no use going any further
  52. if ( request_id == ILLEGAL_REQUEST_ID )
  53. return;
  54. WaitingMessage *waiting_message;
  55. BOOL found = mapping.Lookup(request_id, waiting_message);
  56. // if no such waiting message, return
  57. if ( !found )
  58. return;
  59. // check if still waiting for the SentFrameEvent on
  60. // this waiting message
  61. SessionFrameId session_frame_id = waiting_message->GetMessage()->GetSessionFrameId();
  62. // if not waiting for the sent frame event
  63. // let the waiting message receive the reply
  64. // else buffer the snmp pdu
  65. if ( waiting_message->GetSentMessageProcessed() == TRUE )
  66. waiting_message->ReceiveReply(&snmp_pdu);
  67. else
  68. waiting_message->BufferReply(snmp_pdu);
  69. }
  70. // delete (request_id, waiting_message) pair
  71. void MessageRegistry::RemoveMessage(IN RequestId request_id)
  72. {
  73. if ( !mapping.RemoveKey(request_id) )
  74. throw GeneralException(Snmp_Error, Snmp_Local_Error,__FILE__,__LINE__);
  75. }
  76. MessageRegistry::~MessageRegistry(void)
  77. {
  78. mapping.RemoveAll();
  79. }