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.

230 lines
4.5 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 OldMid = 0);
  67. ~CMid() {
  68. ASSERT(gpClientLock->HeldExclusive());
  69. gpMidTable->Remove(this);
  70. if (_pdsaValidStringBindings)
  71. {
  72. PrivMemFree(_pdsaValidStringBindings);
  73. }
  74. }
  75. virtual DWORD
  76. Hash() {
  77. return(dsaHash(&_dsa));
  78. }
  79. virtual BOOL
  80. Compare(CTableKey &tk) {
  81. CMidKey &mk = (CMidKey &)tk;
  82. return( mk == _dsa );
  83. }
  84. virtual BOOL
  85. Compare(CONST CTableElement *pte) {
  86. CMid *pmid = (CMid *)pte;
  87. return(dsaCompare(&_dsa, &pmid->_dsa));
  88. }
  89. const DUALSTRINGARRAY *
  90. GetStrings() {
  91. // Must be treated as read-only.
  92. return(&_dsa);
  93. }
  94. BOOL IsSecure() {
  95. return(!_fLocal && _fSecure);
  96. }
  97. USHORT GetAuthnSvc() { return _wAuthnSvc; }
  98. void SetAuthnSvc( USHORT wAuthnSvc ) { _wAuthnSvc = wAuthnSvc; }
  99. RPC_BINDING_HANDLE GetBinding();
  100. BOOL IsLocal() {
  101. return(_fLocal);
  102. }
  103. void MarkStale(BOOL fStale) {
  104. // Only local mids can be "stale"
  105. ASSERT(IsLocal());
  106. _fStale = fStale;
  107. }
  108. BOOL IsStale() {
  109. // nobody should be asking this question of remote mids
  110. ASSERT(IsLocal());
  111. return _fStale;
  112. }
  113. ID Id() {
  114. return(_id);
  115. }
  116. PWSTR GetStringBinding() {return _StringBinding; }
  117. void SecurityFailed() {
  118. // A call using security failed with a security related error
  119. // and a futher call w/o security succeeded. Turn off security
  120. // to this machine.
  121. _fSecure = FALSE;
  122. }
  123. #if DBG
  124. PWSTR PrintableName()
  125. {
  126. if (_fLocal)
  127. {
  128. return L"LOCAL";
  129. }
  130. else
  131. {
  132. if (_StringBinding)
  133. return(_StringBinding + 1);
  134. else
  135. return L"REMOTE (no bindings)";
  136. }
  137. }
  138. #endif
  139. RPC_BINDING_HANDLE MakeBinding(WCHAR *pwstrBinding=NULL);
  140. private:
  141. ID _id;
  142. WCHAR *_StringBinding;
  143. USHORT _wAuthnSvc;
  144. BOOL _fSecure:1;
  145. BOOL _fLocal:1;
  146. BOOL _fStale:1;
  147. BOOL _fDynamic:1;
  148. BOOL _fInitialized:1;
  149. DUALSTRINGARRAY *_pdsaValidStringBindings;
  150. DUALSTRINGARRAY _dsa;
  151. };
  152. #endif // __MID_HXX