X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pcep%2Fbase-parser%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fpcep%2Fparser%2Fsubobject%2FRROIpv6PrefixSubobjectParser.java;fp=pcep%2Fbase-parser%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fpcep%2Fparser%2Fsubobject%2FRROIpv6PrefixSubobjectParser.java;h=d82c3fce73f1540ce22c86d46d0d02f7b02a4b42;hb=12b06012259c6609c4b40488c8611a9431a39643;hp=dc48654f28c2829cb87543348ceb24d3b7f20a81;hpb=57c64bf6cae32b18b36956b33a3c956d9f0328e4;p=bgpcep.git diff --git a/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROIpv6PrefixSubobjectParser.java b/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROIpv6PrefixSubobjectParser.java index dc48654f28..d82c3fce73 100644 --- a/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROIpv6PrefixSubobjectParser.java +++ b/pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROIpv6PrefixSubobjectParser.java @@ -7,9 +7,8 @@ */ package org.opendaylight.protocol.pcep.parser.subobject; -import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Prefix; +import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException; @@ -20,6 +19,7 @@ import org.opendaylight.protocol.util.BitArray; import org.opendaylight.protocol.util.ByteArray; import org.opendaylight.protocol.util.Ipv6Util; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject; @@ -46,8 +46,7 @@ public class RROIpv6PrefixSubobjectParser implements RROSubobjectParser, RROSubo @Override public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException { - Preconditions.checkArgument(buffer != null && buffer.isReadable(), - "Array of bytes is mandatory. Can't be null or empty."); + checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (buffer.readableBytes() != CONTENT_LENGTH) { throw new PCEPDeserializerException( "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";"); @@ -66,16 +65,20 @@ public class RROIpv6PrefixSubobjectParser implements RROSubobjectParser, RROSubo @Override public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { - Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, + checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass()); final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix(); - final IpPrefix prefix = specObj.getIpPrefix(); + final Ipv6Prefix ipv6Prefix = specObj.getIpPrefix().getIpv6Prefix(); + checkArgument(ipv6Prefix != null, "Ipv6Prefix is mandatory."); + serializeSubobject(buffer, subobject, ipv6Prefix); + } + + static void serializeSubobject(final ByteBuf buffer, final Subobject subobject, final Ipv6Prefix ipv6prefix) { final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable()); flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse()); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); - Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory."); - writeIpv6Prefix(prefix.getIpv6Prefix(), body); + Ipv6Util.writeIpv6Prefix(ipv6prefix, body); flags.toByteBuf(body); RROSubobjectUtil.formatSubobject(TYPE, body, buffer); }