Source code of Windows XP (NT5)
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.

214 lines
5.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1990 - 1999
  6. //
  7. // File: ProtBind.hxx
  8. //
  9. //--------------------------------------------------------------------------
  10. /* --------------------------------------------------------------------
  11. File: ProtBind.hxx
  12. Description:
  13. The classes that support the binding process for connection
  14. oriented and local.
  15. History :
  16. kamenm 10-01-00 Cloned from other files with a face lift and few stitches added
  17. -------------------------------------------------------------------- */
  18. #ifndef __PROTBIND_HXX__
  19. #define __PROTBIND_HXX__
  20. class MTSyntaxBinding; // forward
  21. typedef MTSyntaxBinding *(*CreateBindingFn)(
  22. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  23. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  24. IN int CapabilitiesBitmap
  25. );
  26. // a class containing a particular binding (presentation context)
  27. // on the client side. The class is aware of multiple transfer
  28. // syntaxes (hence MTSyntax)
  29. class MTSyntaxBinding
  30. {
  31. private:
  32. RPC_SYNTAX_IDENTIFIER InterfaceId;
  33. TRANSFER_SYNTAX_INFO_ATOM TransferSyntaxInfo;
  34. // points to the next binding which has all
  35. // information same as this one, except for the transfer syntax
  36. // (i.e. same binding, but different transfer syntax). If none,
  37. // it will be NULL
  38. MTSyntaxBinding *NextBinding;
  39. int PresentationContext;
  40. // differentiate b/n bitmaps belonging to interfaces with different
  41. // capabilities. The currently defined flags are:
  42. // SyntaxBindingCapabilityNDR20
  43. // SyntaxBindingCapabilityNDR64
  44. // SyntaxBindingCapabilityNDRTest
  45. int CapabilitiesBitmap;
  46. public:
  47. const static int SyntaxBindingCapabilityInvalid = 0;
  48. const static int SyntaxBindingCapabilityNDR20 = 1;
  49. const static int SyntaxBindingCapabilityNDR64 = 2;
  50. const static int SyntaxBindingCapabilityNDRTest = 4;
  51. MTSyntaxBinding::MTSyntaxBinding (
  52. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  53. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  54. IN int CapabilitiesBitmap
  55. )
  56. {
  57. RpcpMemoryCopy(&this->InterfaceId, InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER));
  58. this->TransferSyntaxInfo.Init(TransferSyntaxInfo);
  59. NextBinding = NULL;
  60. this->CapabilitiesBitmap = CapabilitiesBitmap;
  61. }
  62. static RPC_STATUS
  63. FindOrCreateBinding (
  64. IN PRPC_CLIENT_INTERFACE RpcInterfaceInformation,
  65. IN RPC_MESSAGE *Message,
  66. IN SIMPLE_DICT *BindingsDict,
  67. IN CreateBindingFn CreateBinding,
  68. OUT int *NumberOfBindings,
  69. IN OUT MTSyntaxBinding *BindingsForThisInterface[],
  70. IN OUT BOOL BindingCreated[]
  71. );
  72. inline int
  73. MTSyntaxBinding::CompareWithRpcInterfaceInformation (
  74. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  75. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  76. IN int CapabilitiesBitmap
  77. );
  78. inline int CompareWithTransferSyntax (IN const RPC_SYNTAX_IDENTIFIER *TransferSyntax)
  79. {
  80. return RpcpMemoryCompare(TransferSyntax, &TransferSyntaxInfo.TransferSyntax,
  81. sizeof(RPC_SYNTAX_IDENTIFIER));
  82. }
  83. RPC_SYNTAX_IDENTIFIER *GetInterfaceId(void)
  84. {
  85. return &InterfaceId;
  86. }
  87. RPC_SYNTAX_IDENTIFIER *GetTransferSyntaxId(void)
  88. {
  89. return &(TransferSyntaxInfo.TransferSyntax);
  90. }
  91. inline BOOL IsTransferSyntaxServerPreferred(void)
  92. {
  93. return TransferSyntaxInfo.IsTransferSyntaxServerPreferred();
  94. }
  95. inline void TransferSyntaxIsServerPreferred(void)
  96. {
  97. TransferSyntaxInfo.TransferSyntaxIsServerPreferred();
  98. }
  99. inline void TransferSyntaxIsNotServerPreferred(void)
  100. {
  101. TransferSyntaxInfo.TransferSyntaxIsNotServerPreferred();
  102. }
  103. inline void TransferSyntaxIsListStart(void)
  104. {
  105. TransferSyntaxInfo.TransferSyntaxIsListStart();
  106. }
  107. inline BOOL IsTransferSyntaxListStart(void)
  108. {
  109. return TransferSyntaxInfo.IsTransferSyntaxListStart();
  110. }
  111. inline void SetNextBinding(MTSyntaxBinding *Next)
  112. {
  113. NextBinding = Next;
  114. }
  115. inline MTSyntaxBinding *GetNextBinding(void)
  116. {
  117. return (NextBinding);
  118. }
  119. inline PRPC_DISPATCH_TABLE GetDispatchTable(void)
  120. {
  121. return TransferSyntaxInfo.DispatchTable;
  122. }
  123. inline unsigned short GetOnTheWirePresentationContext(void)
  124. {
  125. return (unsigned short)PresentationContext;
  126. }
  127. inline void SetPresentationContextFromPacket(unsigned short PresentContext)
  128. {
  129. PresentationContext = (int) PresentContext;
  130. }
  131. inline int GetPresentationContext (void)
  132. {
  133. return PresentationContext;
  134. }
  135. inline void SetPresentationContext (int PresentContext)
  136. {
  137. PresentationContext = PresentContext;
  138. }
  139. };
  140. inline int
  141. MTSyntaxBinding::CompareWithRpcInterfaceInformation (
  142. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  143. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  144. IN int CapabilitiesBitmap
  145. )
  146. /*++
  147. Routine Description:
  148. We compare the specified interface information to the the interface
  149. information in this. This method is used to search a dictionary.
  150. Arguments:
  151. InterfaceId - supplies the interface ID to compare against
  152. TransferSyntaxInfo - supplies the transfer syntax information
  153. CapabilitiesBitmap - the capabilities of the interface we're looking
  154. for encoded as a bitmap. This allows us to negotiate separate
  155. transfer syntaxes for interfaces with different capabilities.
  156. Return Value:
  157. Zero will be returned if they are equal; otherwise, non-zero will
  158. be returned.
  159. --*/
  160. {
  161. if (RpcpMemoryCompare(&this->InterfaceId, InterfaceId,
  162. sizeof(RPC_SYNTAX_IDENTIFIER)) != 0)
  163. {
  164. return 1;
  165. }
  166. if (CapabilitiesBitmap != this->CapabilitiesBitmap)
  167. return 1;
  168. return CompareWithTransferSyntax (&TransferSyntaxInfo->TransferSyntax);
  169. }
  170. #endif // __PROTBIND_HXX__