Migrate to use MD-SAL's uint24 type 51/87051/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 20 Jan 2020 11:26:30 +0000 (12:26 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 20 Jan 2020 11:49:59 +0000 (12:49 +0100)
MDSAL is providing the type and related utilities, make sure we
pick them up.

Change-Id: I6305b6003502a3cae7a09e1a88de04f6d9fb45ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
bgp/extensions/evpn/pom.xml
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java
bgp/extensions/labeled-unicast/pom.xml
bgp/extensions/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/OriginatorSrgbTlvParser.java
bgp/extensions/linkstate/pom.xml
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/SrNodeAttributesParser.java
bgp/openconfig-api/pom.xml
bgp/parser-api/pom.xml
bgp/parser-impl/pom.xml
bgp/rib-impl/pom.xml
concepts/pom.xml
concepts/src/main/yang/uint24.yang [deleted file]
features/bgp/odl-bgpcep-bgp-evpn/pom.xml
features/bgp/odl-bgpcep-bgp-labeled-unicast/pom.xml
features/bgp/odl-bgpcep-bgp-linkstate/pom.xml
features/concepts/odl-bgpcep-concepts/pom.xml
util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java [deleted file]

index 41a6390d310765a5ba157f28149d75108c68a176..56023dab8740a98180250172c9f866e1416f6e49 100644 (file)
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-yang-types</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-uint24-netty</artifactId>
+        </dependency>
 
         <!-- test scope dependencies -->
         <dependency>
index 100fbe49b293cb21b55143729506f879b6c2cdaf..a781edbd08384290e58dd6e8f41ab2076b227cf8 100644 (file)
@@ -12,8 +12,8 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.extractUint24LD;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.mdsal.uint24.netty.Uint24ByteBufUtils;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
@@ -31,7 +31,7 @@ final class MacParser extends AbstractEsiType {
             "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
         final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated();
         body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(macAuto.getSystemMacAddress()));
-        body.writeMedium(macAuto.getLocalDiscriminator().getValue().intValue());
+        Uint24ByteBufUtils.writeUint24(body, macAuto.getLocalDiscriminator());
         return body;
     }
 
@@ -56,7 +56,7 @@ final class MacParser extends AbstractEsiType {
                 .setMacAutoGenerated(new MacAutoGeneratedBuilder()
                     .setSystemMacAddress(IetfYangUtil.INSTANCE.macAddressFor(
                         ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
-                    .setLocalDiscriminator(ByteBufUtils.readUint24(buffer))
+                    .setLocalDiscriminator(Uint24ByteBufUtils.readUint24(buffer))
                     .build())
                 .build();
     }
index d20bf67c4c84042bef8fa2f55d54f30d2e0109f2..501cec4a62f37947dea1004b1379535be0f481b9 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-common-netty</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-uint24-netty</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
index a0f49eef992a6761f47f4e67b60b4b833e33fb5e..79dd750a07b08eebd9911c5ee9f6d44b9ef1d6f1 100644 (file)
@@ -11,9 +11,9 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
+import org.opendaylight.mdsal.uint24.netty.Uint24ByteBufUtils;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvParser;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvSerializer;
-import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.Srgb;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValueBuilder;
@@ -39,8 +39,8 @@ final class OriginatorSrgbTlvParser implements BgpPrefixSidTlvParser, BgpPrefixS
                 "Number of SRGBs does not fit available bytes.");
         final List<SrgbValue> ret = new ArrayList<>();
         while (buffer.isReadable()) {
-            ret.add(new SrgbValueBuilder().setBase(new Srgb(ByteBufUtils.readUint24(buffer)))
-                .setRange(new Srgb(ByteBufUtils.readUint24(buffer))).build());
+            ret.add(new SrgbValueBuilder().setBase(new Srgb(Uint24ByteBufUtils.readUint24(buffer)))
+                .setRange(new Srgb(Uint24ByteBufUtils.readUint24(buffer))).build());
         }
         return ret;
     }
@@ -51,8 +51,8 @@ final class OriginatorSrgbTlvParser implements BgpPrefixSidTlvParser, BgpPrefixS
         final LuOriginatorSrgbTlv luTlv = (LuOriginatorSrgbTlv) tlv;
         valueBuf.writeZero(ORIGINATOR_FLAGS_BYTES);
         for (final SrgbValue val : luTlv.getSrgbValue()) {
-            valueBuf.writeMedium(val.getBase().getValue().intValue());
-            valueBuf.writeMedium(val.getRange().getValue().intValue());
+            Uint24ByteBufUtils.writeUint24(valueBuf, val.getBase());
+            Uint24ByteBufUtils.writeUint24(valueBuf, val.getRange());
         }
     }
 
index bcdc8f7582d476130660ac063967ee907e73af0f..49422988776adf08dd8b67724b00a4db50804e5d 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-impl</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-uint24-netty</artifactId>
+        </dependency>
 
         <!-- test scope dependencies -->
         <dependency>
index 33e9714d1df1fccfb81675a1aa008be8b5b13136..402f7e76a3805e709f5c3e7d65caab8503102cd5 100644 (file)
@@ -12,9 +12,9 @@ import static org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.
 import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
+import org.opendaylight.mdsal.uint24.netty.Uint24ByteBufUtils;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
-import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrAlgorithm;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrAlgorithmBuilder;
@@ -40,7 +40,7 @@ public final class SrNodeAttributesParser {
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
         setFlags(flags, protocol, builder);
         buffer.skipBytes(RESERVERED);
-        builder.setRangeSize(ByteBufUtils.readUint24(buffer));
+        builder.setRangeSize(Uint24ByteBufUtils.readUint24(buffer));
         builder.setSidLabelIndex(SidLabelIndexParser.parseSidSubTlv(buffer));
         return builder.build();
     }
@@ -64,7 +64,7 @@ public final class SrNodeAttributesParser {
         bs.set(SR_IPV6, caps.isSrIpv6());
         bs.toByteBuf(buffer);
         buffer.writeZero(RESERVERED);
-        buffer.writeMedium(caps.getRangeSize().getValue().intValue());
+        Uint24ByteBufUtils.writeUint24(buffer, caps.getRangeSize());
         TlvUtil.writeTLV(SID_TYPE, SidLabelIndexParser.serializeSidValue(caps.getSidLabelIndex()), buffer);
     }
 
index 5855fb894f27613b91664f3f2cc60fcf8936ae1e..0608c082af0e6c65bf00a5fbcd06c7a25e82a378 100644 (file)
         </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.model</groupId>
-            <artifactId>yang-ext</artifactId>
+            <artifactId>odl-uint24</artifactId>
         </dependency>
         <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>concepts</artifactId>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>yang-ext</artifactId>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
index 8ffcfabfbae042412f306bd6b49fb82b735c958c..e70f39db396e82b597834d97b4e3978c7dc2300e 100644 (file)
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-inet-types</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.model</groupId>
             <artifactId>yang-ext</artifactId>
index 2869b200950ff6260e721082eecb3384f4a71ebb..d1e4be8429b432ce60836c977e6a6f0f09c17b18 100644 (file)
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>yang-binding</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-inet-types</artifactId>
index 7e1df6f3e3b9ede42bad068478fac1934ee66f70..8d5801fdd8d421b3a16d542ff4863e942fd8a396 100644 (file)
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-generator-impl</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-inet-types</artifactId>
index 0a065b9d6360a401dafc6565096053beef20f6a6..f9e35d0637dff018d0c53ec778bcd6ddaa27507c 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-uint24</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-inet-types</artifactId>
diff --git a/concepts/src/main/yang/uint24.yang b/concepts/src/main/yang/uint24.yang
deleted file mode 100644 (file)
index 24cf836..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-module odl-uint24 {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:uint24";
-    prefix "uint24";
-
-    organization "OpenDaylight";
-    contact "Robert Varga <robert.varga@pantheon.tech>";
-
-    description
-        "This module contains the definition of uint24, an uint32 restricted
-         to 24 bits.
-
-         Copyright (c)2019 PANTHEON.tech, s.r.o 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, and is available at
-         http://www.eclipse.org/legal/epl-v10.html";
-
-    revision "2020-01-04" {
-        description "Initial revision.";
-    }
-
-    typedef uint24 {
-        type uint32 {
-            range "0..16777215";
-        }
-        description "24-bit unsigned integer.";
-    }
-}
index 9dee3904050451f9a7b256296d55b637c1b303f9..c0f1602043973d5ea06017bec34ca5a478981cb3 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>odl-mdsal-uint24-netty</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
 </project>
index bbf50d5b187b79256fe32048a18ab1736d849f30..f89baee3bb7bcb1f713d1ce61a53f0e32cc030ff 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>odl-mdsal-uint24-netty</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
 </project>
index 77ca8c175e31c54a29720c6a4904886442061f0f..04f8cf76489ac82dbb1d31154ce6c8c5e92bc0ce 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>odl-mdsal-uint24-netty</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
 </project>
index af2b05d5313e4de0846b0838aa7392315e7b65ef..92285b58168a0335a0a9860119532297a43b120b 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-mdsal-model-odl-uint24</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
 </project>
diff --git a/util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java
deleted file mode 100644 (file)
index 54aef0e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.util;
-
-import io.netty.buffer.ByteBuf;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.uint24.rev200104.Uint24;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-/**
- * Utility methods for interacting with {@link ByteBuf}s. These add a number of methods for reading and writing various
- * data types from/to ByteBufs.
- */
-public final class ByteBufUtils {
-    private ByteBufUtils() {
-
-    }
-
-    public static @NonNull Uint24 readUint24(final ByteBuf buf) {
-        return new Uint24(Uint32.fromIntBits(buf.readMedium()));
-    }
-}