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.

186 lines
4.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 -99 **/
  4. /**********************************************************************/
  5. /*
  6. IPNamePr.cpp
  7. Comment goes here
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "ipnamepr.h"
  12. //
  13. // Compare two ip/name pairs. Return
  14. // 0 if the same, 1 otherwise. fBoth
  15. // indicates if both addresses need to
  16. // match, or if a match in either
  17. // produces a match.
  18. //
  19. int
  20. CIpNamePair::Compare(
  21. const CIpNamePair& inpTarget,
  22. BOOL fBoth
  23. ) const
  24. {
  25. if (fBoth)
  26. {
  27. if (((LONG)inpTarget.m_iaIpAddress == (LONG)m_iaIpAddress) &&
  28. ((LONG)inpTarget.m_strNetBIOSName.CompareNoCase(m_strNetBIOSName) == 0))
  29. {
  30. return 0;
  31. }
  32. return 1;
  33. }
  34. //
  35. // Match if either matches
  36. //
  37. if (((LONG)inpTarget.m_iaIpAddress == (LONG)m_iaIpAddress) ||
  38. ((LONG)inpTarget.m_strNetBIOSName.CompareNoCase(m_strNetBIOSName) == 0))
  39. {
  40. return 0;
  41. }
  42. return 1;
  43. }
  44. //
  45. // Sort helper function
  46. //
  47. int
  48. CIpNamePair::OrderByName (
  49. const CObjectPlus * pobMapping
  50. ) const
  51. {
  52. return ((CIpNamePair *)pobMapping)->m_strNetBIOSName.CompareNoCase(m_strNetBIOSName);
  53. }
  54. //
  55. // Sort helper function
  56. //
  57. int
  58. CIpNamePair::OrderByIp (
  59. const CObjectPlus * pobMapping
  60. ) const
  61. {
  62. LONG l1 = (LONG)m_iaIpAddress;
  63. LONG l2 = (LONG)((CIpNamePair *)pobMapping)->m_iaIpAddress;
  64. return l2 > l1 ? -1 : l2 == l1 ? 0 : +1;
  65. }
  66. CIpNamePair::CIpNamePair()
  67. {
  68. }
  69. CIpNamePair::CIpNamePair(const CIpAddress& ia, const CString& str)
  70. : m_iaIpAddress(ia), m_strNetBIOSName(str)
  71. {
  72. m_nNameLength = str.GetLength();
  73. }
  74. CIpNamePair::CIpNamePair(const CIpNamePair& inpAddress)
  75. : m_iaIpAddress(inpAddress.m_iaIpAddress),
  76. m_strNetBIOSName(inpAddress.m_strNetBIOSName),
  77. m_nNameLength(inpAddress.m_nNameLength)
  78. {
  79. }
  80. //CWinsServerObj::CWinsServerObj(): CIpNamePair(),m_iaPrimaryAddress()
  81. CWinsServerObj::CWinsServerObj():CIpNamePair(),m_iaPrimaryAddress()
  82. {
  83. m_fPushInitially = m_fPush = FALSE;
  84. m_fPullInitially = m_fPull = FALSE;
  85. }
  86. //
  87. // For both constructors below, we initially set
  88. // the primary ip address to the initial ip address
  89. // Use SetPrimaryIpAddress to change
  90. //
  91. CWinsServerObj::CWinsServerObj(
  92. const CIpAddress& ia,
  93. const CString& str,
  94. BOOL fPush,
  95. BOOL fPull,
  96. CIntlNumber inPushUpdateCount,
  97. CIntlNumber inPullReplicationInterval,
  98. CIntlTime itmPullStartTime
  99. )
  100. : CIpNamePair(ia, str),
  101. m_inPushUpdateCount(inPushUpdateCount),
  102. m_inPullReplicationInterval(inPullReplicationInterval),
  103. m_itmPullStartTime(itmPullStartTime),
  104. m_iaPrimaryAddress(ia)
  105. {
  106. m_fPushInitially = m_fPush = fPush;
  107. m_fPullInitially = m_fPull = fPull;
  108. }
  109. CWinsServerObj::CWinsServerObj(
  110. const CIpNamePair& inpAddress,
  111. BOOL fPush,
  112. BOOL fPull,
  113. CIntlNumber inPushUpdateCount,
  114. CIntlNumber inPullReplicationInterval,
  115. CIntlTime itmPullStartTime
  116. )
  117. : CIpNamePair(inpAddress),
  118. m_inPushUpdateCount(inPushUpdateCount),
  119. m_inPullReplicationInterval(inPullReplicationInterval),
  120. m_itmPullStartTime(itmPullStartTime),
  121. m_iaPrimaryAddress(inpAddress.QueryIpAddress())
  122. {
  123. m_fPushInitially = m_fPush = fPush;
  124. m_fPullInitially = m_fPull = fPull;
  125. }
  126. CWinsServerObj::CWinsServerObj(
  127. const CWinsServerObj& wsServer
  128. )
  129. : CIpNamePair(wsServer),
  130. m_inPushUpdateCount(wsServer.m_inPushUpdateCount),
  131. m_inPullReplicationInterval(wsServer.m_inPullReplicationInterval),
  132. m_itmPullStartTime(wsServer.m_itmPullStartTime)
  133. {
  134. m_fPushInitially = m_fPush = wsServer.IsPush();
  135. m_fPullInitially = m_fPull = wsServer.IsPull();
  136. m_fPullPersistence = wsServer.m_fPullPersistence;
  137. m_fPushPersistence = wsServer.m_fPushPersistence;
  138. m_strIPAddress = wsServer.m_strIPAddress;
  139. }
  140. CWinsServerObj &
  141. CWinsServerObj::operator=(
  142. const CWinsServerObj& wsNew
  143. )
  144. {
  145. m_iaIpAddress = wsNew.m_iaIpAddress;
  146. m_strNetBIOSName = wsNew.m_strNetBIOSName;
  147. m_inPushUpdateCount = wsNew.m_inPushUpdateCount;
  148. m_inPullReplicationInterval = wsNew.m_inPullReplicationInterval;
  149. m_itmPullStartTime = wsNew.m_itmPullStartTime;
  150. m_fPull = wsNew.m_fPull;
  151. m_fPush = wsNew.m_fPush;
  152. m_fPullInitially = wsNew.m_fPullInitially;
  153. m_fPushInitially = wsNew.m_fPullInitially;
  154. m_strIPAddress = wsNew.m_strIPAddress;
  155. m_fPullPersistence = wsNew.m_fPullPersistence;
  156. m_fPushPersistence = wsNew.m_fPushPersistence;
  157. return *this;
  158. }