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.

244 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. Mid.hxx
  5. Abstract:
  6. Class representing string bindings and security bindings for a particular
  7. machine. Provides a mapping between the bindings and a local machine
  8. unique ID for that machine.
  9. Author:
  10. Mario Goertzel [MarioGo]
  11. Revision History:
  12. MarioGo 12-13-95 Bits 'n pieces
  13. MarioGo 02-01-96 Move binding handles out of mid.
  14. --*/
  15. #ifndef __MID_HXX
  16. #define __MID_HXX
  17. #include <memapi.hxx>
  18. class CMidKey : public CTableKey
  19. {
  20. public:
  21. CMidKey(DUALSTRINGARRAY *pdsa) : _pdsa(pdsa) {}
  22. DWORD
  23. Hash() {
  24. return(dsaHash(_pdsa));
  25. }
  26. BOOL
  27. Compare(CTableKey &tk) {
  28. CMidKey &mk = (CMidKey &)tk;
  29. return(dsaCompare(mk._pdsa, _pdsa));
  30. }
  31. BOOL operator==(DUALSTRINGARRAY &dsa){
  32. return(dsaCompare(_pdsa, &dsa));
  33. }
  34. private:
  35. DUALSTRINGARRAY *_pdsa;
  36. };
  37. class CMid : public CTableElement
  38. /*++
  39. Class Description:
  40. Represents the local and remote machines. Each unique (different)
  41. set of string bindings and security bindings are assigned a unique
  42. local ID. This ID is used along with the OID and OXID of the remote
  43. machine objects index these objects locally. Instances of this class
  44. are referenced by CClientSets which are referenced by CClientOids.
  45. This class is indexed by string and security bindings. There is no
  46. index by MID.
  47. Members:
  48. _id - The locally unique ID of this set of bindings.
  49. _iStringBinding - Index into _dsa->aStringArray of the
  50. compressed string binding used to create _hMachine.
  51. _fLocal - TRUE if these are bindings for the local machine.
  52. _fStale - TRUE if this mid represents out-of-date bindings for
  53. the local machine.
  54. _fSecure - TRUE if not local and both machines share an authentication
  55. service.
  56. _fDynamic - TRUE if we believe the remote machine's OR
  57. is not running in the endpoint mapper process.
  58. _dsa - The set of compressed bindings.
  59. _wAuthnSvc -- the authentication service used to talk to the machine
  60. that this CMid represents
  61. --*/
  62. {
  63. public:
  64. CMid(DUALSTRINGARRAY *pdsa,
  65. BOOL fLocal,
  66. ID Mid,
  67. BOOL* pfInitOkay);
  68. ~CMid() {
  69. ASSERT(gpClientLock->HeldExclusive());
  70. gpMidTable->Remove(this);
  71. if (_pdsaValidStringBindings)
  72. {
  73. PrivMemFree(_pdsaValidStringBindings);
  74. }
  75. ASSERT(
  76. ((_ulMarshaledTargetInfoLength == 0) && (_pMarshaledTargetInfo == NULL)) ||
  77. ((_ulMarshaledTargetInfoLength != 0) && (_pMarshaledTargetInfo != NULL))
  78. );
  79. if (_ulMarshaledTargetInfoLength)
  80. {
  81. MIDL_user_free(_pMarshaledTargetInfo);
  82. }
  83. }
  84. virtual DWORD
  85. Hash() {
  86. return(dsaHash(&_dsa));
  87. }
  88. virtual BOOL
  89. Compare(CTableKey &tk) {
  90. CMidKey &mk = (CMidKey &)tk;
  91. return( mk == _dsa );
  92. }
  93. virtual BOOL
  94. Compare(CONST CTableElement *pte) {
  95. CMid *pmid = (CMid *)pte;
  96. return(dsaCompare(&_dsa, &pmid->_dsa));
  97. }
  98. const DUALSTRINGARRAY *
  99. GetStrings() {
  100. // Must be treated as read-only.
  101. return(&_dsa);
  102. }
  103. BOOL IsSecure() {
  104. return(!_fLocal && _fSecure);
  105. }
  106. USHORT GetAuthnSvc() { return _wAuthnSvc; }
  107. void SetAuthnSvc( USHORT wAuthnSvc ) { _wAuthnSvc = wAuthnSvc; }
  108. ORSTATUS SetMarshaledTargetInfo(unsigned long ulMarshaledTargetInfoLength, unsigned char *pMarshaledTargetInfo);
  109. ORSTATUS GetMarshaledTargetInfo(unsigned long *pulMarshaledTargetInfoLength, unsigned char **pucMarshaledTargetInfo);
  110. RPC_BINDING_HANDLE GetBinding();
  111. BOOL IsLocal() {
  112. return(_fLocal);
  113. }
  114. void MarkStale(BOOL fStale) {
  115. // Only local mids can be "stale"
  116. ASSERT(IsLocal());
  117. _fStale = fStale;
  118. }
  119. BOOL IsStale() {
  120. // nobody should be asking this question of remote mids
  121. ASSERT(IsLocal());
  122. return _fStale;
  123. }
  124. ID Id() {
  125. return(_id);
  126. }
  127. PWSTR GetStringBinding() {return _StringBinding; }
  128. void SecurityFailed() {
  129. // A call using security failed with a security related error
  130. // and a futher call w/o security succeeded. Turn off security
  131. // to this machine.
  132. _fSecure = FALSE;
  133. }
  134. #if DBG
  135. PWSTR PrintableName()
  136. {
  137. if (_fLocal)
  138. {
  139. return L"LOCAL";
  140. }
  141. else
  142. {
  143. if (_StringBinding)
  144. return(_StringBinding + 1);
  145. else
  146. return L"REMOTE (no bindings)";
  147. }
  148. }
  149. #endif
  150. RPC_BINDING_HANDLE MakeBinding(WCHAR *pwstrBinding=NULL);
  151. private:
  152. ID _id;
  153. WCHAR *_StringBinding;
  154. USHORT _wAuthnSvc;
  155. BOOL _fSecure:1;
  156. BOOL _fLocal:1;
  157. BOOL _fStale:1;
  158. BOOL _fDynamic:1;
  159. BOOL _fInitialized:1;
  160. DUALSTRINGARRAY *_pdsaValidStringBindings;
  161. unsigned long _ulMarshaledTargetInfoLength;
  162. unsigned char * _pMarshaledTargetInfo;
  163. DUALSTRINGARRAY _dsa;
  164. };
  165. #endif // __MID_HXX