cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaanHoogland <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...
Date Sat, 23 May 2015 08:26:32 GMT
Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943135
  
    --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
    @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress address) {
             return sb.toString();
         }
     
    -    public static long getMacAddressAsLong(InetAddress address) {
    +    public static long getMacAddressAsLong(final InetAddress address) {
             long macAddressAsLong = 0;
             try {
    -            NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    -            byte[] mac = ni.getHardwareAddress();
    +            final NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    +            final byte[] mac = ni.getHardwareAddress();
     
                 for (int i = 0; i < mac.length; i++) {
    -                macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length -
i - 1) * 8);
    +                macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length -
i - 1) * 8;
                 }
     
    -        } catch (SocketException e) {
    +        } catch (final SocketException e) {
                 s_logger.error("SocketException when trying to retrieve MAC address", e);
             }
     
             return macAddressAsLong;
         }
     
    -    public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2,
String endIp2) {
    -        long startIp1Long = ip2Long(startIp1);
    +    public static boolean ipRangesOverlap(final String startIp1, final String endIp1,
final String startIp2, final String endIp2) {
    +        final long startIp1Long = ip2Long(startIp1);
             long endIp1Long = startIp1Long;
             if (endIp1 != null) {
                 endIp1Long = ip2Long(endIp1);
             }
    -        long startIp2Long = ip2Long(startIp2);
    +        final long startIp2Long = ip2Long(startIp2);
             long endIp2Long = startIp2Long;
             if (endIp2 != null) {
                 endIp2Long = ip2Long(endIp2);
             }
     
    +        // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    +        //     GW              Netmask         Stat IP        End IP
    +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    +        // https://tools.ietf.org/html/rfc3021
    +        // Added by Wilder Rodrigues
    +        final int ip31bitPrefixOffSet = 1;
    +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet))
{
    --- End diff --
    
    isn't this condition true for all range2 with any /31 range1?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message