Branch Node Object 18/77818/10
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 12 Nov 2018 14:49:20 +0000 (15:49 +0100)
committerRobert Varga <nite@hq.sk>
Sun, 9 Dec 2018 19:00:58 +0000 (19:00 +0000)
https://tools.ietf.org/html/rfc8306#section-3.11.1

JIRA: BGPCEP-406
Change-Id: I3ae8105f1ec4ec5afbbf94fc34b86f16a8b8f5f6
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
pcep/api/src/main/yang/pcep-types.yang
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/BaseParserExtensionActivator.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BNCUtil.java [new file with mode: 0644]
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BranchNodeListObjectParser.java [new file with mode: 0644]
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/NonBranchNodeListObjectParser.java [new file with mode: 0644]
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java

index 94021f76993c2661e4f6a53e3412c2609266a984..51b549c96d8dd8d3efbb446bd151278c388a8a80 100644 (file)
@@ -474,6 +474,49 @@ module pcep-types {
         }
     }
 
+    grouping bnc {
+        uses object;
+        // No possibility of TLVs
+        list subobject {
+            leaf loose {
+                type boolean;
+                mandatory true;
+            }
+
+            uses rsvp:ip-prefix-subobject;
+            ordered-by user;
+        }
+    }
+
+    grouping branch-node-object {
+        description "Branch Node Object";
+        reference "https://tools.ietf.org/html/rfc8306#section-3.11.1";
+
+        container branch-node-list {
+            uses bnc;
+        }
+    }
+
+    grouping non-branch-node-object {
+        description "Branch Node Object";
+        reference "https://tools.ietf.org/html/rfc8306#section-3.11.1";
+
+        container non-branch-node-list {
+            uses bnc;
+        }
+    }
+
+    grouping bnc-object {
+        choice branch-node-type {
+            case branch-node-case {
+                uses branch-node-object;
+            }
+            case non-branch-node-case {
+                uses non-branch-node-object;
+            }
+        }
+    }
+
     grouping bandwidth {
         // No possibility to carry TLVs
         leaf bandwidth {
index 5d0908c860524a756b38cb9acbd32473ad14d688..ec7747a3ad42f0b5e11c2fd53e876cbca9f0b83d 100644 (file)
@@ -22,6 +22,8 @@ import org.opendaylight.protocol.pcep.parser.message.PCEPStartTLSMessageParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPCloseObjectParser;
+import org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser;
+import org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv6ObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer;
@@ -100,6 +102,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.mes
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Starttls;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CClose;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj;
@@ -111,6 +114,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of;
@@ -231,6 +235,15 @@ public final class BaseParserExtensionActivator extends AbstractPCEPExtensionPro
         final PCEPP2MPEndPointsIpv6ObjectParser endpoints6Pp2mparser = new PCEPP2MPEndPointsIpv6ObjectParser();
         regs.add(context.registerObjectParser(endpoints6Pp2mparser));
 
+        final EROSubobjectRegistry subRegistry = context.getEROSubobjectHandlerRegistry();
+
+        final BranchNodeListObjectParser bncPArser = new BranchNodeListObjectParser(subRegistry);
+        regs.add(context.registerObjectParser(bncPArser));
+        regs.add(context.registerObjectSerializer(BranchNodeList.class, bncPArser));
+
+        final NonBranchNodeListObjectParser nonBncPArser = new NonBranchNodeListObjectParser(subRegistry);
+        regs.add(context.registerObjectParser(nonBncPArser));
+
         final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser();
         final PCEPExistingBandwidthObjectParser bwExistingParser = new PCEPExistingBandwidthObjectParser();
         regs.add(context.registerObjectParser(bwParser));
diff --git a/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BNCUtil.java b/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BNCUtil.java
new file mode 100644 (file)
index 0000000..ff7e1c7
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.pcep.parser.object.bnc;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.SubobjectBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
+
+public final class BNCUtil {
+    private BNCUtil() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static List<Subobject> toBncSubobject(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
+        .ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> subobject) {
+        return subobject.stream()
+            .map(sob -> {
+                final SubobjectType type = sob.getSubobjectType();
+                Preconditions.checkArgument(type instanceof IpPrefixCase,
+                    "Wrong instance of PCEPObject. Passed %s. Needed IpPrefixCase.", type.getClass());
+                return new SubobjectBuilder().setIpPrefix(((IpPrefixCase) type).getIpPrefix().getIpPrefix())
+                    .setLoose(sob.isLoose()).build();
+            }).collect(Collectors.toList());
+    }
+
+    public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+        .route.object.ero.Subobject> toIroSubject(final List<Subobject> subobject) {
+        return subobject.stream()
+            .map(sob -> {
+                final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit
+                    .route.subobjects.subobject.type.ip.prefix._case.IpPrefix prefix = new IpPrefixBuilder()
+                    .setIpPrefix(sob.getIpPrefix()).build();
+                final IpPrefixCase subObjType = new IpPrefixCaseBuilder().setIpPrefix(prefix).build();
+                return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+                    .explicit.route.object.ero.SubobjectBuilder()
+                    .setSubobjectType(subObjType)
+                    .setLoose(sob.isLoose())
+                    .build();
+            }).collect(Collectors.toList());
+    }
+}
diff --git a/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BranchNodeListObjectParser.java b/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/BranchNodeListObjectParser.java
new file mode 100644 (file)
index 0000000..a22925d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.pcep.parser.object.bnc;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.opendaylight.protocol.pcep.parser.object.AbstractEROWithSubobjectsParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectUtil;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder;
+
+public final class BranchNodeListObjectParser extends AbstractEROWithSubobjectsParser {
+
+    private static final int CLASS = 31;
+    private static final int TYPE = 1;
+
+    public BranchNodeListObjectParser(final EROSubobjectRegistry subobjReg) {
+        super(subobjReg, CLASS, TYPE);
+    }
+
+    @Override
+    public BranchNodeList parseObject(final ObjectHeader header, final ByteBuf bytes)
+        throws PCEPDeserializerException {
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
+        final BranchNodeListBuilder builder = new BranchNodeListBuilder();
+        builder.setIgnore(header.isIgnore());
+        builder.setProcessingRule(header.isProcessingRule());
+        builder.setSubobject(BNCUtil.toBncSubobject(parseSubobjects(bytes))).build();
+        return builder.build();
+    }
+
+    @Override
+    public void serializeObject(final Object object, final ByteBuf buffer) {
+        Preconditions.checkArgument(object instanceof BranchNodeList,
+            "Wrong instance of PCEPObject. Passed %s. Needed BranchNodeList.", object.getClass());
+        final BranchNodeList nbnc = ((BranchNodeList) object);
+        final ByteBuf body = Unpooled.buffer();
+        serializeSubobject(BNCUtil.toIroSubject(nbnc.getSubobject()), body);
+        ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+    }
+}
diff --git a/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/NonBranchNodeListObjectParser.java b/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/bnc/NonBranchNodeListObjectParser.java
new file mode 100644 (file)
index 0000000..6d67ee0
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.pcep.parser.object.bnc;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.opendaylight.protocol.pcep.parser.object.AbstractEROWithSubobjectsParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectUtil;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeListBuilder;
+
+public final class NonBranchNodeListObjectParser extends AbstractEROWithSubobjectsParser {
+    private static final int CLASS = 31;
+    private static final int TYPE = 2;
+
+    public NonBranchNodeListObjectParser(final EROSubobjectRegistry subobjReg) {
+        super(subobjReg, CLASS, TYPE);
+    }
+
+    @Override
+    public NonBranchNodeList parseObject(final ObjectHeader header, final ByteBuf bytes)
+        throws PCEPDeserializerException {
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
+        final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
+        builder.setIgnore(header.isIgnore());
+        builder.setProcessingRule(header.isProcessingRule());
+        builder.setSubobject(BNCUtil.toBncSubobject(parseSubobjects(bytes)));
+        return builder.build();
+    }
+
+    @Override
+    public void serializeObject(final Object object, final ByteBuf buffer) {
+        Preconditions.checkArgument(object instanceof NonBranchNodeList,
+            "Wrong instance of PCEPObject. Passed %s. Needed NonBranchNodeList.", object.getClass());
+        final NonBranchNodeList nbnc = ((NonBranchNodeList) object);
+        final ByteBuf body = Unpooled.buffer();
+        serializeSubobject(BNCUtil.toIroSubject(nbnc.getSubobject()), body);
+        ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+    }
+}
index bdb239a1a46e66151ebdbf77500b8a7e4047eb44..2058ab89b2222ad05518c3d6f0e4b2390fbfe8d8 100644 (file)
@@ -52,6 +52,9 @@ import org.opendaylight.protocol.pcep.parser.object.PCEPProcTimeObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser;
+import org.opendaylight.protocol.pcep.parser.object.bnc.BNCUtil;
+import org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser;
+import org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv6ObjectParser;
 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer;
@@ -82,6 +85,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder;
@@ -106,6 +110,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotificationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.OfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
@@ -1412,4 +1417,82 @@ public class PCEPObjectParserTest {
         parser.serializeObject(builder.build(), buf);
         assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
     }
+
+    @Test
+    public void testBranchNodeListObject() throws Exception {
+        final byte[] expected = {
+            0x1f, 0x10, 0x0, 0xc,
+            (byte) 0x81, 0x8,
+            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
+        };
+
+        final BranchNodeListObjectParser parser
+            = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+        final ByteBuf result = Unpooled.wrappedBuffer(expected);
+
+        final BranchNodeListBuilder builder = new BranchNodeListBuilder();
+        builder.setProcessingRule(false);
+        builder.setIgnore(false);
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+            .route.object.ero.Subobject> subs = Lists.newArrayList();
+        subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+            .route.object.ero.SubobjectBuilder()
+            .setLoose(true)
+            .setSubobjectType(new IpPrefixCaseBuilder()
+                .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
+                    new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
+        builder.setSubobject(BNCUtil.toBncSubobject(subs));
+
+        assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
+            result.slice(4, result.readableBytes() - 4)));
+        final ByteBuf buf = Unpooled.buffer();
+        parser.serializeObject(builder.build(), buf);
+        assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
+
+        try {
+            parser.parseObject(new ObjectHeaderImpl(true, true), null);
+            fail();
+        } catch (final IllegalArgumentException e) {
+            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+        }
+    }
+
+    @Test
+    public void testNonBranchNodeListObject() throws Exception {
+        final byte[] expected = {
+            0x1f, 0x20, 0x0, 0xc,
+            (byte) 0x81, 0x8,
+            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
+        };
+
+        final NonBranchNodeListObjectParser parser
+            = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+        final ByteBuf result = Unpooled.wrappedBuffer(expected);
+
+        final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
+        builder.setProcessingRule(false);
+        builder.setIgnore(false);
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+            .route.object.ero.Subobject> subs = Lists.newArrayList();
+        subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+            .route.object.ero.SubobjectBuilder()
+            .setLoose(true)
+            .setSubobjectType(new IpPrefixCaseBuilder()
+                .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
+                    new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
+        builder.setSubobject(BNCUtil.toBncSubobject(subs));
+
+        assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
+            result.slice(4, result.readableBytes() - 4)));
+        final ByteBuf buf = Unpooled.buffer();
+        parser.serializeObject(builder.build(), buf);
+        assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
+
+        try {
+            parser.parseObject(new ObjectHeaderImpl(true, true), null);
+            fail();
+        } catch (final IllegalArgumentException e) {
+            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+        }
+    }
 }