ib_cs.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "udp_address.h"
  3. #include "block_chain.h"
  4. #include "net_request.h"
  5. #include <util/generic/guid.h>
  6. #include <util/system/hp_timer.h>
  7. namespace NNetliba {
  8. struct TIBConnectInfo {
  9. TGUID SocketId;
  10. ui64 Subnet, Interface;
  11. int LID;
  12. int QPN;
  13. };
  14. struct TRCQueuePairHandshake {
  15. int QPN, PSN;
  16. };
  17. using TIBMsgHandle = i64;
  18. struct TIBSendResult {
  19. TIBMsgHandle Handle;
  20. bool Success;
  21. TIBSendResult()
  22. : Handle(0)
  23. , Success(false)
  24. {
  25. }
  26. TIBSendResult(TIBMsgHandle handle, bool success)
  27. : Handle(handle)
  28. , Success(success)
  29. {
  30. }
  31. };
  32. struct IIBPeer: public TThrRefBase {
  33. enum EState {
  34. CONNECTING,
  35. OK,
  36. FAILED,
  37. };
  38. virtual EState GetState() = 0;
  39. };
  40. struct IIBClientServer: public TThrRefBase {
  41. virtual TRequest* GetRequest() = 0;
  42. virtual TIBMsgHandle Send(TPtrArg<IIBPeer> peer, TRopeDataPacket* data, const TGUID& packetGuid) = 0;
  43. virtual bool GetSendResult(TIBSendResult* res) = 0;
  44. virtual bool Step(NHPTimer::STime tCurrent) = 0;
  45. virtual IIBPeer* ConnectPeer(const TIBConnectInfo& info, const TUdpAddress& peerAddr, const TUdpAddress& myAddr) = 0;
  46. virtual const TIBConnectInfo& GetConnectInfo() = 0;
  47. };
  48. IIBClientServer* CreateIBClientServer();
  49. }