floodlight/floodlight — pull request #467 by shao-you (2014-11-30 16:20:24+00:00)
Title: fix matching problems of IP wildcarding

* fix problems same as [#462](https://github.com/floodlight/floodlight/pull/462) in LoadBalancer.java
* fix match comparison function:
Two OFMatch instances (says A, B) are compared to check if one of either can be matched by the other one.
If dstmasklen is "0" (networkDestination should be "0" as well), it means dst-ip of A is a wildcard field. That is, any dst-ip matched by B should be matched by A.
However, "(1 << (32 - dstmasklen))" would be "1", not "0" and make dstmask be "-1".
(The reason is that an int variable shifted by 32 bits will return the same value. [See.](http://stackoverflow.com/questions/14817639/java-bit-operations-shift))

int dstmask = ~((1 << (32 - dstmasklen)) - 1);

Finally, it may fail to pass the comparison if "toCompare.getNetworkDestination()" is not 0.

if (dstmasklen < 32 &&
(networkDestination & dstmask) != (toCompare.getNetworkDestination() & dstmask))
return false;