X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Futils%2FNetUtils.java;h=6b303f09f11955a053f7bcf740bf9f647b5df2ce;hb=5aa8f995feede44d69bc26e70a67e6c44b01c758;hp=e94021119d14f11e7581d5e68b6e096921a07725;hpb=28b610000f621ce31cca004165a963eafb6ae430;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java index e94021119d..6b303f09f1 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -355,9 +355,7 @@ public abstract class NetUtils { */ public static boolean isMulticastMACAddr(byte[] MACAddress) { if (MACAddress.length == MACAddrLengthInBytes && !isBroadcastMACAddr(MACAddress)) { - if (MACAddress[0] % 2 == 1) { - return true; - } + return (MACAddress[0] & 1) != 0; } return false; } @@ -482,7 +480,7 @@ public abstract class NetUtils { * @return the int variable containing the unsigned byte value */ public static int getUnsignedByte(byte b) { - return (b > 0) ? (int) b : (b & 0x7F | 0x80); + return b & 0xFF; } /** @@ -493,7 +491,7 @@ public abstract class NetUtils { * @return the int variable containing the unsigned short value */ public static int getUnsignedShort(short s) { - return (s > 0) ? (int) s : (s & 0x7FFF | 0x8000); + return s & 0xFFFF; } /** @@ -515,10 +513,9 @@ public abstract class NetUtils { /** * Returns Broadcast MAC Address * - * @return the byte array containing broadcaset mac address + * @return the byte array containing broadcast mac address */ public static byte[] getBroadcastMACAddr() { return Arrays.copyOf(BroadcastMACAddr, BroadcastMACAddr.length); } - }