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.

244 lines
5.2 KiB

  1. // Copyright (c) Microsoft. All rights reserved.
  2. //
  3. // This is unpublished source code of Microsoft.
  4. // The copyright notice above does not evidence any
  5. // actual or intended publication of such source code.
  6. // OneLiner : Implementation of MNLBPortRule
  7. // DevUnit : wlbstest
  8. // Author : Murtaza Hakim
  9. // include files
  10. #include "MNLBPortRule.h"
  11. // done
  12. // constructor
  13. //
  14. MNLBPortRule::MNLBPortRule( long startPort,
  15. long endPort,
  16. Protocol trafficToHandle )
  17. : _startPort( startPort ),
  18. _endPort( endPort ),
  19. _trafficToHandle( trafficToHandle ),
  20. _key( startPort )
  21. {}
  22. // done
  23. // default constructor
  24. //
  25. MNLBPortRule::MNLBPortRule()
  26. :_startPort( 0 ),
  27. _endPort( 65535 ),
  28. _trafficToHandle( both ),
  29. _key( 0 )
  30. {}
  31. // done
  32. // equality operator
  33. bool
  34. MNLBPortRule::operator==(const MNLBPortRule& objToCompare ) const
  35. {
  36. if( (_startPort == objToCompare._startPort )
  37. &&
  38. (_endPort == objToCompare._endPort )
  39. &&
  40. (_trafficToHandle == objToCompare._trafficToHandle )
  41. )
  42. {
  43. return true;
  44. }
  45. else
  46. {
  47. return false;
  48. }
  49. }
  50. // done
  51. // inequality operator
  52. bool
  53. MNLBPortRule::operator!=(const MNLBPortRule& objToCompare ) const
  54. {
  55. return !( *this == objToCompare );
  56. }
  57. // done
  58. // constructor
  59. //
  60. MNLBPortRuleLoadBalanced::MNLBPortRuleLoadBalanced( long startPort,
  61. long endPort,
  62. Protocol trafficToHandle,
  63. bool isEqualLoadBalanced,
  64. long load,
  65. Affinity affinity ) :
  66. MNLBPortRule( startPort, endPort, trafficToHandle ),
  67. _isEqualLoadBalanced( isEqualLoadBalanced ),
  68. _load( load ),
  69. _affinity( affinity )
  70. {}
  71. // done
  72. // default constructor
  73. //
  74. MNLBPortRuleLoadBalanced::MNLBPortRuleLoadBalanced()
  75. : MNLBPortRule(),
  76. _isEqualLoadBalanced( true ),
  77. _load( 0 ),
  78. _affinity( single )
  79. {}
  80. // equality operator
  81. //
  82. bool
  83. MNLBPortRuleLoadBalanced::operator==(const MNLBPortRuleLoadBalanced& objToCompare ) const
  84. {
  85. bool retVal;
  86. // compare bases.
  87. retVal = MNLBPortRule::operator==( objToCompare );
  88. if( retVal == true )
  89. {
  90. if( ( _isEqualLoadBalanced == objToCompare._isEqualLoadBalanced )
  91. &&
  92. ( _affinity == objToCompare._affinity )
  93. )
  94. {
  95. if( _isEqualLoadBalanced == false )
  96. {
  97. // as it is Unequal load balanced port rule,
  98. // load weight is important.
  99. if( _load == objToCompare._load )
  100. {
  101. return true;
  102. }
  103. else
  104. {
  105. return false;
  106. }
  107. }
  108. else
  109. {
  110. // load weight is not important as it is equal load balanced.
  111. return true;
  112. }
  113. }
  114. else
  115. {
  116. return false;
  117. }
  118. }
  119. else
  120. {
  121. return false;
  122. }
  123. }
  124. // inequality operator
  125. //
  126. bool
  127. MNLBPortRuleLoadBalanced::operator!=(const MNLBPortRuleLoadBalanced& objToCompare ) const
  128. {
  129. return !( (*this) == objToCompare );
  130. }
  131. // constructor
  132. //
  133. MNLBPortRuleFailover::MNLBPortRuleFailover( long startPort,
  134. long endPort,
  135. Protocol trafficToHandle,
  136. long priority )
  137. :
  138. MNLBPortRule( startPort, endPort, trafficToHandle ),
  139. _priority ( priority )
  140. {}
  141. // default constructor
  142. //
  143. MNLBPortRuleFailover::MNLBPortRuleFailover()
  144. :
  145. MNLBPortRule(),
  146. _priority( 1 )
  147. {}
  148. // equality operator
  149. //
  150. bool
  151. MNLBPortRuleFailover::operator==(const MNLBPortRuleFailover& objToCompare ) const
  152. {
  153. bool retVal;
  154. retVal = MNLBPortRule::operator==( objToCompare );
  155. if( retVal == true )
  156. {
  157. if( _priority == objToCompare._priority )
  158. {
  159. return true;
  160. }
  161. else
  162. {
  163. return false;
  164. }
  165. }
  166. else
  167. {
  168. return false;
  169. }
  170. }
  171. // inequality operator
  172. //
  173. bool
  174. MNLBPortRuleFailover::operator!=(const MNLBPortRuleFailover& objToCompare ) const
  175. {
  176. return !( (*this) == objToCompare );
  177. }
  178. // constructor
  179. //
  180. MNLBPortRuleDisabled::MNLBPortRuleDisabled( long startPort,
  181. long endPort,
  182. Protocol trafficToHandle )
  183. :
  184. MNLBPortRule( startPort, endPort, trafficToHandle )
  185. {}
  186. // default constructor
  187. //
  188. MNLBPortRuleDisabled::MNLBPortRuleDisabled()
  189. :
  190. MNLBPortRule()
  191. {}
  192. // equality operator
  193. //
  194. bool
  195. MNLBPortRuleDisabled::operator==(const MNLBPortRuleDisabled& objToCompare ) const
  196. {
  197. bool retVal;
  198. // compare bases.
  199. retVal = MNLBPortRule::operator==( objToCompare );
  200. return retVal;
  201. }
  202. // inequality operator
  203. //
  204. bool
  205. MNLBPortRuleDisabled::operator!=(const MNLBPortRuleDisabled& objToCompare ) const
  206. {
  207. return !( (*this) == objToCompare );
  208. }