<type>xml</type>
</dependency>
+ <!-- uint24 support -->
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-uint24</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-uint24-netty</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ </dependency>
+
<!-- MODELS -->
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-mdsal-model-odl-uint24</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-uint24-netty</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
<!-- Documentation -->
<dependency>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>dom-parent</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <relativePath>../../dom/dom-parent</relativePath>
+ </parent>
+
+ <artifactId>mdsal-uint24-netty</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common-netty</artifactId>
+ </dependency>
+ <dependency>
+ <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.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Automatic-Module-Name>org.opendaylight.mdsal.uint24.netty</Automatic-Module-Name>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:git:http://git.opendaylight.org/gerrit/mdsal.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/MD-SAL:Main</url>
+ </scm>
+</project>
--- /dev/null
+/*
+ * 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.mdsal.uint24.netty;
+
+import com.google.common.annotations.Beta;
+import io.netty.buffer.ByteBuf;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.uint24.rev200104.Uint24;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+@Beta
+public final class Uint24ByteBufUtils {
+ private Uint24ByteBufUtils() {
+ // Hidden on purpose
+ }
+
+ /**
+ * Read a {@link Uint24} from specified buffer.
+ *
+ * @param buf buffer
+ * @return A {@link Uint24}
+ * @throws NullPointerException if {@code buf} is null
+ * @throws IndexOutOfBoundsException if {@code buf} does not have enough data
+ */
+ public static @NonNull Uint24 readUint24(final ByteBuf buf) {
+ return new Uint24(Uint32.fromIntBits(buf.readMedium()));
+ }
+
+ /**
+ * Write a {@link Uint24} to specified buffer.
+ *
+ * @param buf buffer
+ * @param value A {@link Uint24}
+ * @throws NullPointerException if any argument is null
+ */
+ public static void writeUint24(final ByteBuf buf, final Uint24 value) {
+ buf.writeMedium(value.getValue().intValue());
+ }
+
+ /**
+ * Write a {@link Uint24} property to specified buffer. If the {@code value} is known to be non-null, prefer to use
+ * {@link #writeUint24(ByteBuf, Uint24)} instead of this method.
+ *
+ * @param buf buffer
+ * @param value A {@link Uint24}
+ * @param name Property name for error reporting purposes
+ * @throws NullPointerException if {@code buf} is null
+ * @throws IllegalArgumentException if {@code value} is null
+ */
+ public static void writeMandatoryUint24(final ByteBuf buf, final Uint24 value, final String name) {
+ if (value == null) {
+ throw new IllegalArgumentException(name + " is mandatory");
+ }
+ writeUint24(buf, value);
+ }
+
+ /**
+ * Write a {@link Uint24} value to specified buffer if it is not null.
+ *
+ * @param buf buffer
+ * @param value A {@link Uint24}
+ * @throws NullPointerException if {@code buf} is null
+ */
+ public static void writeOptionalUint24(final ByteBuf buf, final @Nullable Uint24 value) {
+ if (value != null) {
+ writeUint24(buf, value);
+ }
+ }
+
+ /**
+ * Write a {@link Uint24} value to specified buffer if it is not null, otherwise write three zero bytes.
+ *
+ * @param buf buffer
+ * @param value A {@link Uint24}
+ * @throws NullPointerException if {@code buf} is null
+ */
+ public static void writeUint24OrZero(final ByteBuf buf, final @Nullable Uint24 value) {
+ buf.writeMedium(value != null ? value.getValue().intValue() : 0);
+ }
+}
--- /dev/null
+/*
+ * 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.mdsal.uint24.netty;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.uint24.rev200104.Uint24;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+public class Uint24ByteBufUtilsTest {
+ private static final Uint24 ONE_TWO_THREE = new Uint24(Uint32.valueOf(0x010203));
+
+ @Test
+ public void testRead() {
+ final ByteBuf buf = Unpooled.buffer().writeMedium(0x010203);
+ assertEquals(ONE_TWO_THREE, Uint24ByteBufUtils.readUint24(buf));
+ assertEquals(0, buf.readableBytes());
+ }
+
+ @Test
+ public void testWrite() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeUint24(buf, ONE_TWO_THREE);
+ assertMedium(buf);
+ }
+
+ @Test
+ public void testWriteMandatory() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeMandatoryUint24(buf, ONE_TWO_THREE, "foo");
+ assertMedium(buf);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testWriteMandatoryNull() {
+ Uint24ByteBufUtils.writeMandatoryUint24(Unpooled.buffer(), null, "foo");
+ }
+
+ @Test
+ public void testWriteOptional() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeOptionalUint24(buf, ONE_TWO_THREE);
+ assertMedium(buf);
+ }
+
+ @Test
+ public void testWriteOptionalNull() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeOptionalUint24(buf, null);
+ assertEquals(0, buf.readableBytes());
+ }
+
+ @Test
+ public void testWriteOrZero() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeUint24OrZero(buf, ONE_TWO_THREE);
+ assertMedium(buf);
+ }
+
+ @Test
+ public void testWriteOrZeroNull() {
+ final ByteBuf buf = Unpooled.buffer();
+ Uint24ByteBufUtils.writeUint24OrZero(buf, null);
+ assertMedium(buf, 0);
+ }
+
+ private static void assertMedium(final ByteBuf buf) {
+ assertMedium(buf, 0x010203);
+ }
+
+ private static void assertMedium(final ByteBuf buf, final int value) {
+ assertEquals(3, buf.readableBytes());
+ assertEquals(value, buf.readMedium());
+ }
+}
<modules>
<module>mdsal-common-api</module>
<module>mdsal-common-util</module>
+ <module>mdsal-uint24-netty</module>
</modules>
<properties>
<artifactId>mdsal-yanglib-rfc8525</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.opendaylight.mdsal.model</groupId>
<artifactId>opendaylight-l2-types</artifactId>
<type>xml</type>
</dependency>
+ <!-- uint24 support -->
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-mdsal-model-odl-uint24</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-uint24-netty</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+
<!-- Models -->
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 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
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>feature-parent</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <relativePath>../feature-parent</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-mdsal-model-odl-uint24</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+ <name>OpenDaylight :: MD-SAL :: Model :: OpenDaylight uint24 type</name>
+ <description>OpenDaylight-specific model of uint24</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-binding-base</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>odl-uint24</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 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
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>feature-parent</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <relativePath>../feature-parent</relativePath>
+ </parent>
+
+ <artifactId>odl-mdsal-uint24-netty</artifactId>
+ <packaging>feature</packaging>
+ <name>OpenDaylight :: MD-SAL :: uint24 :: Netty</name>
+ <description>Netty support for uint24</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>odl-yangtools-netty</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-mdsal-model-odl-uint24</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-uint24-netty</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-uint24-netty">
+ <feature name="odl-mdsal-uint24-netty">
+ <feature version="[4,5)">odl-yangtools-netty</feature>
+ </feature>
+</features>
<module>odl-mdsal-exp-yanglib-rfc7895</module>
<module>odl-mdsal-exp-yanglib-rfc8525</module>
+ <!-- uint24 support -->
+ <module>odl-mdsal-model-odl-uint24</module>
+ <module>odl-mdsal-uint24-netty</module>
+
<!-- Models -->
<!-- Standards -->
<module>odl-mdsal-model-rfc6991</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <relativePath>../../binding/binding-parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-uint24</artifactId>
+ <packaging>bundle</packaging>
+</project>
--- /dev/null
+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.";
+ }
+}
<module>ietf</module>
<module>l2-types</module>
<module>general-entity</module>
+ <module>odl-uint24</module>
</modules>
<properties>