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.

257 lines
7.0 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. typedef BOOL (*CheckBindingForDestructionFn)(
  27. IN MTSyntaxBinding *Binding,
  28. IN void *CallbackContext
  29. );
  30. /*++
  31. Routine Description:
  32. Gives caller the oportunity to check the binding.
  33. Arguments:
  34. Binding - the binding to check.
  35. CallbackContext - the value that was supplied as context by
  36. the caller.
  37. Return Value:
  38. non-zero - the binding may have been destroyed. Caller should not
  39. touch the binding.
  40. zero - ok to continue processing the binding.
  41. --*/
  42. // a class containing a particular binding (presentation context)
  43. // on the client side. The class is aware of multiple transfer
  44. // syntaxes (hence MTSyntax)
  45. class MTSyntaxBinding
  46. {
  47. private:
  48. RPC_SYNTAX_IDENTIFIER InterfaceId;
  49. TRANSFER_SYNTAX_INFO_ATOM TransferSyntaxInfo;
  50. // points to the next binding which has all
  51. // information same as this one, except for the transfer syntax
  52. // (i.e. same binding, but different transfer syntax). If none,
  53. // it will be NULL
  54. MTSyntaxBinding *NextBinding;
  55. int PresentationContext;
  56. // differentiate b/n bitmaps belonging to interfaces with different
  57. // capabilities. The currently defined flags are:
  58. // SyntaxBindingCapabilityNDR20
  59. // SyntaxBindingCapabilityNDR64
  60. // SyntaxBindingCapabilityNDRTest
  61. int CapabilitiesBitmap;
  62. public:
  63. const static int SyntaxBindingCapabilityInvalid = 0;
  64. const static int SyntaxBindingCapabilityNDR20 = 1;
  65. const static int SyntaxBindingCapabilityNDR64 = 2;
  66. const static int SyntaxBindingCapabilityNDRTest = 4;
  67. MTSyntaxBinding::MTSyntaxBinding (
  68. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  69. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  70. IN int CapabilitiesBitmap
  71. )
  72. {
  73. RpcpMemoryCopy(&this->InterfaceId, InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER));
  74. this->TransferSyntaxInfo.Init(TransferSyntaxInfo);
  75. NextBinding = NULL;
  76. this->CapabilitiesBitmap = CapabilitiesBitmap;
  77. }
  78. static RPC_STATUS
  79. FindOrCreateBinding (
  80. IN PRPC_CLIENT_INTERFACE RpcInterfaceInformation,
  81. IN RPC_MESSAGE *Message,
  82. IN SIMPLE_DICT *BindingsDict,
  83. IN CreateBindingFn CreateBinding,
  84. IN CheckBindingForDestructionFn CheckBinding, OPTIONAL
  85. IN void *CallbackContext, OPTIONAL
  86. OUT int *NumberOfBindings,
  87. IN OUT MTSyntaxBinding *BindingsForThisInterface[],
  88. IN OUT BOOL BindingCreated[]
  89. );
  90. inline int
  91. MTSyntaxBinding::CompareWithRpcInterfaceInformation (
  92. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  93. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  94. IN int CapabilitiesBitmap
  95. );
  96. inline int CompareWithTransferSyntax (IN const RPC_SYNTAX_IDENTIFIER *TransferSyntax)
  97. {
  98. return RpcpMemoryCompare(TransferSyntax, &TransferSyntaxInfo.TransferSyntax,
  99. sizeof(RPC_SYNTAX_IDENTIFIER));
  100. }
  101. RPC_SYNTAX_IDENTIFIER *GetInterfaceId(void)
  102. {
  103. return &InterfaceId;
  104. }
  105. RPC_SYNTAX_IDENTIFIER *GetTransferSyntaxId(void)
  106. {
  107. return &(TransferSyntaxInfo.TransferSyntax);
  108. }
  109. inline BOOL IsTransferSyntaxServerPreferred(void)
  110. {
  111. return TransferSyntaxInfo.IsTransferSyntaxServerPreferred();
  112. }
  113. inline void TransferSyntaxIsServerPreferred(void)
  114. {
  115. TransferSyntaxInfo.TransferSyntaxIsServerPreferred();
  116. }
  117. inline void TransferSyntaxIsNotServerPreferred(void)
  118. {
  119. TransferSyntaxInfo.TransferSyntaxIsNotServerPreferred();
  120. }
  121. inline void TransferSyntaxIsListStart(void)
  122. {
  123. TransferSyntaxInfo.TransferSyntaxIsListStart();
  124. }
  125. inline BOOL IsTransferSyntaxListStart(void)
  126. {
  127. return TransferSyntaxInfo.IsTransferSyntaxListStart();
  128. }
  129. inline void SetNextBinding(MTSyntaxBinding *Next)
  130. {
  131. NextBinding = Next;
  132. }
  133. inline MTSyntaxBinding *GetNextBinding(void)
  134. {
  135. return (NextBinding);
  136. }
  137. inline PRPC_DISPATCH_TABLE GetDispatchTable(void)
  138. {
  139. return TransferSyntaxInfo.DispatchTable;
  140. }
  141. inline unsigned short GetOnTheWirePresentationContext(void)
  142. {
  143. return (unsigned short)PresentationContext;
  144. }
  145. inline void SetPresentationContextFromPacket(unsigned short PresentContext)
  146. {
  147. PresentationContext = (int) PresentContext;
  148. }
  149. inline int GetPresentationContext (void)
  150. {
  151. return PresentationContext;
  152. }
  153. inline void SetPresentationContext (int PresentContext)
  154. {
  155. PresentationContext = PresentContext;
  156. }
  157. inline void ResetCapabilityBitmap (
  158. void
  159. )
  160. {
  161. CapabilitiesBitmap = 0;
  162. }
  163. inline BOOL IsCapabilityBitmapReset (
  164. void
  165. )
  166. {
  167. return (CapabilitiesBitmap == 0);
  168. }
  169. };
  170. inline int
  171. MTSyntaxBinding::CompareWithRpcInterfaceInformation (
  172. IN RPC_SYNTAX_IDENTIFIER *InterfaceId,
  173. IN TRANSFER_SYNTAX_STUB_INFO *TransferSyntaxInfo,
  174. IN int CapabilitiesBitmap
  175. )
  176. /*++
  177. Routine Description:
  178. We compare the specified interface information to the the interface
  179. information in this. This method is used to search a dictionary.
  180. Arguments:
  181. InterfaceId - supplies the interface ID to compare against
  182. TransferSyntaxInfo - supplies the transfer syntax information
  183. CapabilitiesBitmap - the capabilities of the interface we're looking
  184. for encoded as a bitmap. This allows us to negotiate separate
  185. transfer syntaxes for interfaces with different capabilities.
  186. Return Value:
  187. Zero will be returned if they are equal; otherwise, non-zero will
  188. be returned.
  189. --*/
  190. {
  191. if (RpcpMemoryCompare(&this->InterfaceId, InterfaceId,
  192. sizeof(RPC_SYNTAX_IDENTIFIER)) != 0)
  193. {
  194. return 1;
  195. }
  196. if (CapabilitiesBitmap != this->CapabilitiesBitmap)
  197. return 1;
  198. return CompareWithTransferSyntax (&TransferSyntaxInfo->TransferSyntax);
  199. }
  200. #endif // __PROTBIND_HXX__