<capability>urn:opendaylight:params:xml:ns:yang:controller:netty?module=netty&revision=2013-11-19</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:impl?module=odl-pcep-impl-cfg&revision=2013-06-27</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:spi?module=odl-pcep-spi-cfg&revision=2013-11-15</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:sr02:cfg?module=odl-pcep-segment-routing02-cfg&revision=2014-06-09</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg?module=odl-pcep-segment-routing-cfg&revision=2014-06-09</capability>
</required-capabilities>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <!--<module>
+ <module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">prefix:pcep-extensions-impl</type>
<name>global-pcep-extensions</name>
<extension>
<type xmlns:pcepspi="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">pcepspi:extension</type>
- <name>pcep-parser-segment-routing02</name>
+ <name>pcep-parser-segment-routing</name>
</extension>
- </module> -->
+ </module>
<module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr02:cfg">prefix:pcep-parser-segment-routing02</type>
- <name>pcep-parser-segment-routing02</name>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-parser-segment-routing</type>
+ <name>pcep-parser-segment-routing</name>
</module>
<module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr02:cfg">prefix:pcep-session-proposal-factory-sr02</type>
- <name>pcep-session-proposal-factory-sr02</name>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-session-proposal-factory-sr</type>
+ <name>pcep-session-proposal-factory-sr</name>
</module>
- <!--<module>
+ <module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-dispatcher-impl</type>
<name>global-pcep-dispatcher</name>
<pcep-extensions>
</pcep-extensions>
<pcep-session-proposal-factory>
<type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
- <name>pcep-session-proposal-factory-sr02</name>
+ <name>pcep-session-proposal-factory-sr</name>
</pcep-session-proposal-factory>
<boss-group>
<type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
<type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
<name>global-worker-group</name>
</worker-group>
- </module> -->
+ </module>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<service>
<type xmlns:pcepspi="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">pcepspi:extension</type>
<instance>
- <name>pcep-parser-segment-routing02</name>
- <provider>/config/modules/module[name='pcep-parser-segment-routing02']/instance[name='pcep-parser-segment-routing02']</provider>
+ <name>pcep-parser-segment-routing</name>
+ <provider>/config/modules/module[name='pcep-parser-segment-routing']/instance[name='pcep-parser-segment-routing']</provider>
</instance>
</service>
<service>
<type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
<instance>
- <name>pcep-session-proposal-factory-sr02</name>
- <provider>/config/modules/module[name='pcep-session-proposal-factory-sr02']/instance[name='pcep-session-proposal-factory-sr02']</provider>
+ <name>pcep-session-proposal-factory-sr</name>
+ <provider>/config/modules/module[name='pcep-session-proposal-factory-sr']/instance[name='pcep-session-proposal-factory-sr']</provider>
</instance>
</service>
</services>
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
+
+import org.opendaylight.protocol.pcep.segment.routing.SegmentRoutingActivator;
+
+public class SegmentRoutingPCEPParserModule extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSegmentRoutingPCEPParserModule {
+ public SegmentRoutingPCEPParserModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public SegmentRoutingPCEPParserModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.pcep.sr.cfg.SegmentRoutingPCEPParserModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new SegmentRoutingActivator();
+ }
+
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
-public class SegmentRouting02PCEPParserModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr02.cfg.AbstractSegmentRouting02PCEPParserModuleFactory {
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
+public class SegmentRoutingPCEPParserModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSegmentRoutingPCEPParserModuleFactory {
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
import com.google.common.base.Preconditions;
import java.net.InetSocketAddress;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.segment.routing02.SegmentRouting02SessionProposalFactory;
+import org.opendaylight.protocol.pcep.segment.routing.SegmentRoutingSessionProposalFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class Sr02PCEPSessionProposalFactoryModule extends org.opendaylight.controller.config.yang.pcep.sr02.cfg.AbstractSr02PCEPSessionProposalFactoryModule {
+public class SrPCEPSessionProposalFactoryModule extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSrPCEPSessionProposalFactoryModule {
private static final String VALUE_IS_NOT_SET = "value is not set.";
private static final int DEADTIMER_KEEPALIVE_RATIO = 4;
- private static final Logger LOG = LoggerFactory.getLogger(Sr02PCEPSessionProposalFactoryModule.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SrPCEPSessionProposalFactoryModule.class);
- public Sr02PCEPSessionProposalFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public SrPCEPSessionProposalFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public Sr02PCEPSessionProposalFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.pcep.sr02.cfg.Sr02PCEPSessionProposalFactoryModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public SrPCEPSessionProposalFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.pcep.sr.cfg.SrPCEPSessionProposalFactoryModule oldModule, java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
- final SegmentRouting02SessionProposalFactory inner = new SegmentRouting02SessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(), getActive(), getInitiated(), getSrCapable());
+ final SegmentRoutingSessionProposalFactory inner = new SegmentRoutingSessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(), getActive(), getInitiated(), getSrCapable());
return new PCEPSessionProposalFactoryCloseable(inner);
}
private static final class PCEPSessionProposalFactoryCloseable implements PCEPSessionProposalFactory, AutoCloseable {
- private final SegmentRouting02SessionProposalFactory inner;
+ private final SegmentRoutingSessionProposalFactory inner;
- public PCEPSessionProposalFactoryCloseable(final SegmentRouting02SessionProposalFactory inner) {
+ public PCEPSessionProposalFactoryCloseable(final SegmentRoutingSessionProposalFactory inner) {
this.inner = Preconditions.checkNotNull(inner);
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
-public class Sr02PCEPSessionProposalFactoryModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr02.cfg.AbstractSr02PCEPSessionProposalFactoryModuleFactory {
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
+public class SrPCEPSessionProposalFactoryModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSrPCEPSessionProposalFactoryModuleFactory {
}
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
-
-import org.opendaylight.protocol.pcep.segment.routing02.SegmentRoutingActivator;
-
-public class SegmentRouting02PCEPParserModule extends org.opendaylight.controller.config.yang.pcep.sr02.cfg.AbstractSegmentRouting02PCEPParserModule {
- public SegmentRouting02PCEPParserModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public SegmentRouting02PCEPParserModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.pcep.sr02.cfg.SegmentRouting02PCEPParserModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- return new SegmentRoutingActivator();
- }
-
-}
* 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.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07OpenObjectParser;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapability;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
public class PcepOpenObjectWithSpcTlvParser extends Stateful07OpenObjectParser {
- public PcepOpenObjectWithSpcTlvParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ public PcepOpenObjectWithSpcTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
super(tlvReg, viTlvReg);
}
@Override
- public void addTlv(TlvsBuilder tbuilder, Tlv tlv) {
+ public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
super.addTlv(tbuilder, tlv);
final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
if (tbuilder.getAugmentation(Tlvs1.class) != null) {
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import com.google.common.collect.Lists;
import java.util.List;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Pcinitiate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcrpt;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcupd;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcrep;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapability;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startImpl(PCEPExtensionProviderContext context) {
+ protected List<AutoCloseable> startImpl(final PCEPExtensionProviderContext context) {
final List<AutoCloseable> regs = Lists.newArrayList();
/* Tlvs */
/* Subobjects */
regs.add(context.registerEROSubobjectParser(SrEroSubobjectParser.TYPE, new SrEroSubobjectParser()));
regs.add(context.registerEROSubobjectSerializer(SrEroType.class, new SrEroSubobjectParser()));
+ regs.add(context.registerRROSubobjectParser(SrRroSubobjectParser.TYPE, new SrRroSubobjectParser()));
+ regs.add(context.registerRROSubobjectSerializer(SrRroType.class, new SrRroSubobjectParser()));
/* Objects */
final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
final VendorInformationTlvRegistry viTlvRegistry = context.getVendorInformationTlvRegistry();
regs.add(context.registerObjectParser(PcepOpenObjectWithSpcTlvParser.CLASS,
PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
-
regs.add(context.registerObjectSerializer(Open.class, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
- /* Messages */
- final ObjectRegistry objRegistry = context.getObjectHandlerRegistry();
- final VendorInformationObjectRegistry objReg = context.getVendorInformationObjectRegistry();
- regs.add(context.registerMessageParser(SrPcRepMessageParser.TYPE, new SrPcRepMessageParser(objRegistry, objReg)));
- regs.add(context.registerMessageParser(SrPcInitiateMessageParser.TYPE, new SrPcInitiateMessageParser(
- objRegistry)));
- regs.add(context.registerMessageParser(SrPcRptMessageParser.TYPE, new SrPcRptMessageParser(objRegistry)));
- regs.add(context.registerMessageParser(SrPcUpdMessageParser.TYPE, new SrPcUpdMessageParser(objRegistry)));
-
- regs.add(context.registerMessageSerializer(Pcrep.class, new SrPcRepMessageParser(objRegistry, objReg)));
- regs.add(context.registerMessageSerializer(Pcinitiate.class, new SrPcInitiateMessageParser(objRegistry)));
- regs.add(context.registerMessageSerializer(Pcrpt.class, new SrPcRptMessageParser(objRegistry)));
- regs.add(context.registerMessageSerializer(Pcupd.class, new SrPcUpdMessageParser(objRegistry)));
-
return regs;
}
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import java.net.InetSocketAddress;
import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
-public class SegmentRouting02SessionProposalFactory extends Stateful07SessionProposalFactory {
+public class SegmentRoutingSessionProposalFactory extends Stateful07SessionProposalFactory {
private final boolean isSegmentRoutingCapable;
- public SegmentRouting02SessionProposalFactory(int deadTimer, int keepAlive, boolean stateful, boolean active,
- boolean instant, boolean isSegmentRoutingCapable) {
+ public SegmentRoutingSessionProposalFactory(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
+ final boolean instant, final boolean isSegmentRoutingCapable) {
super(deadTimer, keepAlive, stateful, active, instant);
this.isSegmentRoutingCapable = isSegmentRoutingCapable;
}
@Override
- protected void addTlvs(InetSocketAddress address, TlvsBuilder builder) {
+ protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
super.addTlvs(address, builder);
if (this.isSegmentRoutingCapable) {
builder.addAugmentation(Tlvs1.class,
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import static org.opendaylight.protocol.pcep.segment.routing.SrSubobjectParserUtil.BITSET_LENGTH;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import java.util.BitSet;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrEroSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
+
+public class SrEroSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
+
+ public static final int TYPE = 5;
+
+ private static final int M_FLAG_POSITION = 7;
+ private static final int C_FLAG_POSITION = 6;
+ private static final int S_FLAG_POSITION = 5;
+ private static final int F_FLAG_POSITION = 4;
+ private static final int MPLS_LABEL_OFFSET = 12;
+
+ @Override
+ public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
+ Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrEroSubobject,
+ "Unknown subobject instance. Passed %s. Needed SrEroSubobject.", subobject.getSubobjectType()
+ .getClass());
+
+ final SrEroSubobject srEroSubobject = (SrEroSubobject) subobject.getSubobjectType();
+ final SrEroTypeBuilder builder = new SrEroTypeBuilder(srEroSubobject);
+ if (srEroSubobject.isMFlag() != null && srEroSubobject.isMFlag() && srEroSubobject.getSid() != null) {
+ builder.setSid(srEroSubobject.getSid() << MPLS_LABEL_OFFSET);
+ }
+
+ final BitSet bits = new BitSet(BITSET_LENGTH);
+ if (srEroSubobject.isMFlag() != null) {
+ bits.set(M_FLAG_POSITION, srEroSubobject.isMFlag());
+ }
+ if (srEroSubobject.isCFlags() != null) {
+ bits.set(C_FLAG_POSITION, srEroSubobject.isCFlags());
+ }
+ if (srEroSubobject.getSid() == null) {
+ bits.set(S_FLAG_POSITION);
+ }
+ if (srEroSubobject.getNai() == null) {
+ bits.set(F_FLAG_POSITION);
+ }
+ final ByteBuf body = SrSubobjectParserUtil.serializeSrSubobject(builder.build(), bits);
+ EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
+ }
+
+ @Override
+ public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
+ if (buffer.readableBytes() <= SrSubobjectParserUtil.MINIMAL_LENGTH) {
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
+ }
+
+ final BitSet flags = new BitSet(BITSET_LENGTH);
+ final SrSubobject srSubobject = SrSubobjectParserUtil.parseSrSubobject(buffer, new Function<BitSet, Void>() {
+ @Override
+ public Void apply(final BitSet input) {
+ flags.set(C_FLAG_POSITION, input.get(C_FLAG_POSITION));
+ flags.set(M_FLAG_POSITION, input.get(M_FLAG_POSITION));
+ return null;
+ }
+ }, F_FLAG_POSITION, S_FLAG_POSITION);
+ final SrEroTypeBuilder srEroSubobjectBuilder = new SrEroTypeBuilder(srSubobject);
+ srEroSubobjectBuilder.setCFlags(flags.get(C_FLAG_POSITION));
+ srEroSubobjectBuilder.setMFlag(flags.get(M_FLAG_POSITION));
+ if (srEroSubobjectBuilder.isMFlag() != null && srEroSubobjectBuilder.isMFlag() && srEroSubobjectBuilder.getSid() != null) {
+ srEroSubobjectBuilder.setSid(srEroSubobjectBuilder.getSid() >> MPLS_LABEL_OFFSET);
+ }
+
+ final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
+ subobjectBuilder.setLoose(loose);
+ subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
+ return subobjectBuilder.build();
+ }
+
+}
\ No newline at end of file
* 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.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrEroSubobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
public final class SrEroUtil {
return PCEPErrors.NON_IDENTICAL_ERO_SUBOBJECTS;
}
final SrEroSubobject srEroSubobject = (SrEroSubobject) subobject.getSubobjectType();
- if (srEroSubobject.getFlags() != null && srEroSubobject.getFlags().isM() && srEroSubobject.getSid() < MPLS_LABEL_MIN_VALUE) {
+ if (srEroSubobject.isMFlag() != null && srEroSubobject.isMFlag() && srEroSubobject.getSid() < MPLS_LABEL_MIN_VALUE) {
return PCEPErrors.BAD_LABEL_VALUE;
}
}
return false;
}
- protected static boolean isSegmentRoutingPath(final Rp rp) {
- if (rp != null && rp.getTlvs() != null && isSrTePst(rp.getTlvs().getPathSetupType())) {
- return true;
- }
- return false;
- }
-
- protected static boolean isSegmentRoutingPath(final Ero ero) {
- if (ero != null && ero.getSubobject() != null && !ero.getSubobject().isEmpty()) {
- for (final Subobject subobject : ero.getSubobject()) {
- if (!(subobject.getSubobjectType() instanceof SrEroSubobject)) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
private static boolean isSrTePst(final PathSetupType tlv) {
if (tlv != null && tlv.getPst() == 1) {
return true;
* 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.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import org.opendaylight.protocol.pcep.impl.tlv.PathSetupTypeTlvParser;
* 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.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.pcep.spi.TlvUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
public class SrPceCapabilityTlvParser implements TlvParser, TlvSerializer {
}
@Override
- public Tlv parseTlv(ByteBuf buffer) throws PCEPDeserializerException {
+ public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import static org.opendaylight.protocol.pcep.segment.routing.SrSubobjectParserUtil.BITSET_LENGTH;
+import static org.opendaylight.protocol.pcep.segment.routing.SrSubobjectParserUtil.MINIMAL_LENGTH;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import java.util.BitSet;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrRroSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder;
+
+public class SrRroSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
+
+ public static final int TYPE = 6;
+
+ private static final int S_FLAG_POSITION = 7;
+ private static final int F_FLAG_POSITION = 6;
+
+ @Override
+ public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
+ Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrRroSubobject,
+ "Unknown subobject instance. Passed %s. Needed SrRroSubobject.", subobject.getSubobjectType()
+ .getClass());
+
+ final SrRroSubobject srRroSubobject = (SrRroSubobject) subobject.getSubobjectType();
+ final BitSet bits = new BitSet(BITSET_LENGTH);
+ if (srRroSubobject.getSid() == null) {
+ bits.set(S_FLAG_POSITION);
+ }
+ if (srRroSubobject.getNai() == null) {
+ bits.set(F_FLAG_POSITION);
+ }
+ final ByteBuf body = SrSubobjectParserUtil.serializeSrSubobject(srRroSubobject, bits);
+ RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
+ }
+
+ @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.");
+ if (buffer.readableBytes() <= MINIMAL_LENGTH) {
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
+ }
+
+ final SrSubobject srSubobject = SrSubobjectParserUtil.parseSrSubobject(buffer, new Function<BitSet, Void>() {
+ @Override
+ public Void apply(final BitSet input) {
+ return null;
+ }
+ }, F_FLAG_POSITION, S_FLAG_POSITION);
+ final SrRroTypeBuilder srRroSubobjectBuilder = new SrRroTypeBuilder(srSubobject);
+
+ final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
+ subobjectBuilder.setSubobjectType(srRroSubobjectBuilder.build());
+ return subobjectBuilder.build();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Address;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.BitSet;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
+import org.opendaylight.protocol.util.Ipv4Util;
+import org.opendaylight.protocol.util.Ipv6Util;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SrSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.Nai;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpAdjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+class SrSubobjectParserUtil {
+
+ public static final int MINIMAL_LENGTH = 4;
+ public static final int BITSET_LENGTH = 8;
+
+ private static final int FLAGS_OFFSET = 1;
+ private static final int SID_TYPE_BITS_OFFSET = 4;
+
+ private SrSubobjectParserUtil() {
+ throw new UnsupportedOperationException();
+ }
+
+ public static ByteBuf serializeSrSubobject(final SrSubobject srSubobject, final BitSet bits) {
+ Preconditions.checkArgument(srSubobject.getNai() != null || srSubobject.getSid() != null,
+ "Both SID and NAI are absent in SR subobject.");
+ final ByteBuf body = Unpooled.buffer(MINIMAL_LENGTH);
+ writeUnsignedByte((short)(srSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), body);
+
+ writeBitSet(bits, FLAGS_OFFSET, body);
+
+ if (srSubobject.getSid() != null) {
+ writeUnsignedInt(srSubobject.getSid(), body);
+ }
+ final Nai nai = srSubobject.getNai();
+ if (nai != null) {
+ switch (srSubobject.getSidType()) {
+ case Ipv4NodeId:
+ writeIpv4Address(((IpNodeId) nai).getIpAddress().getIpv4Address(), body);
+ break;
+ case Ipv6NodeId:
+ writeIpv6Address(((IpNodeId) nai).getIpAddress().getIpv6Address(), body);
+ break;
+ case Ipv4Adjacency:
+ writeIpv4Address(((IpAdjacency) nai).getLocalIpAddress().getIpv4Address(), body);
+ writeIpv4Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv4Address(), body);
+ break;
+ case Ipv6Adjacency:
+ writeIpv6Address(((IpAdjacency) nai).getLocalIpAddress().getIpv6Address(), body);
+ writeIpv6Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv6Address(), body);
+ break;
+ case Unnumbered:
+ final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency) nai;
+ ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalNodeId(), body);
+ ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalInterfaceId(), body);
+ ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteNodeId(), body);
+ ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteInterfaceId(), body);
+ break;
+ default:
+ break;
+ }
+ }
+ return body;
+ }
+
+ public static SrSubobject parseSrSubobject(final ByteBuf buffer, final Function<BitSet, Void> getFlags, final int fPosition, final int sPosition)
+ throws PCEPDeserializerException {
+ final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
+ final SidType sidType = SidType.forValue(sidTypeByte);
+
+ final BitSet bitSet = ByteArray.bytesToBitSet(new byte[] { buffer.readByte() });
+ getFlags.apply(bitSet);
+ final boolean f = bitSet.get(fPosition);
+ final boolean s = bitSet.get(sPosition);
+
+ if (f && s) {
+ throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
+ }
+ final Long sid;
+ if (!s) {
+ sid = buffer.readUnsignedInt();
+ } else {
+ sid = null;
+ }
+
+ final Nai nai;
+
+ if (sidType != null && !f) {
+ switch (sidType) {
+ case Ipv4NodeId:
+ nai = new IpNodeIdBuilder().setIpAddress(
+ new IpAddress(new Ipv4Address(Ipv4Util.addressForByteBuf(buffer)))).build();
+ break;
+ case Ipv6NodeId:
+ nai = new IpNodeIdBuilder().setIpAddress(
+ new IpAddress(Ipv6Util.addressForByteBuf(buffer))).build();
+ break;
+ case Ipv4Adjacency:
+ nai = new IpAdjacencyBuilder()
+ .setLocalIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer)))
+ .setRemoteIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer))).build();
+ break;
+ case Ipv6Adjacency:
+ nai = new IpAdjacencyBuilder()
+ .setLocalIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer)))
+ .setRemoteIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer))).build();
+ break;
+ case Unnumbered:
+ nai = new UnnumberedAdjacencyBuilder().setLocalNodeId(buffer.readUnsignedInt())
+ .setLocalInterfaceId(buffer.readUnsignedInt()).setRemoteNodeId(buffer.readUnsignedInt())
+ .setRemoteInterfaceId(buffer.readUnsignedInt()).build();
+ break;
+ default:
+ nai = null;
+ break;
+ }
+ } else {
+ nai = null;
+ }
+
+ return new SrSubobject() {
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return SrSubobject.class;
+ }
+
+ @Override
+ public SidType getSidType() {
+ return sidType;
+ }
+
+ @Override
+ public Long getSid() {
+ return sid;
+ }
+
+ @Override
+ public Nai getNai() {
+ return nai;
+ }
+ };
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Address;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
-
-import com.google.common.base.Preconditions;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import java.util.BitSet;
-import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
-import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
-import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
-import org.opendaylight.protocol.util.Ipv4Util;
-import org.opendaylight.protocol.util.Ipv6Util;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.Nai;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpAdjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpAdjacencyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.UnnumberedAdjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.UnnumberedAdjacencyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
-
-public class SrEroSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
-
- public static final int TYPE = 5;
-
- private static final int FLAGS_OFFSET = 1;
- private static final int SID_TYPE_BITS_OFFSET = 4;
- private static final int MINIMAL_LENGTH = 4;
-
- private static final int M_FLAG_POSITION = 7;
- private static final int C_FLAG_POSITION = 6;
- private static final int S_FLAG_POSITION = 5;
- private static final int F_FLAG_POSITION = 4;
-
- @Override
- public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
- Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrEroSubobject,
- "Unknown subobject instance. Passed %s. Needed SrEroSubobject.", subobject.getSubobjectType()
- .getClass());
-
- final SrEroSubobject srEroSubobject = (SrEroSubobject) subobject.getSubobjectType();
- final ByteBuf body = Unpooled.buffer(MINIMAL_LENGTH);
- writeUnsignedByte((short)(srEroSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), body);
-
- final Flags flags = srEroSubobject.getFlags();
- final BitSet bits = new BitSet();
- if (flags != null) {
- bits.set(M_FLAG_POSITION, flags.isM());
- bits.set(C_FLAG_POSITION, flags.isC());
- bits.set(S_FLAG_POSITION, flags.isS());
- bits.set(F_FLAG_POSITION, flags.isF());
- }
- writeBitSet(bits, FLAGS_OFFSET, body);
-
- if (srEroSubobject.getSid() != null && !flags.isS()) {
- writeUnsignedInt(srEroSubobject.getSid(), body);
- }
- final Nai nai = srEroSubobject.getNai();
- if (nai != null && !flags.isF()) {
- switch (srEroSubobject.getSidType()) {
- case Ipv4NodeId:
- writeIpv4Address(((IpNodeId) nai).getIpAddress().getIpv4Address(), body);
- break;
- case Ipv6NodeId:
- writeIpv6Address(((IpNodeId) nai).getIpAddress().getIpv6Address(), body);
- break;
- case Ipv4Adjacency:
- writeIpv4Address(((IpAdjacency) nai).getLocalIpAddress().getIpv4Address(), body);
- writeIpv4Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv4Address(), body);
- break;
- case Ipv6Adjacency:
- writeIpv6Address(((IpAdjacency) nai).getLocalIpAddress().getIpv6Address(), body);
- writeIpv6Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv6Address(), body);
- break;
- case Unnumbered:
- final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency) nai;
- ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalNodeId(), body);
- ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalInterfaceId(), body);
- ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteNodeId(), body);
- ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteInterfaceId(), body);
- break;
- default:
- break;
- }
- }
- EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
- }
-
- @Override
- public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(),
- "Array of bytes is mandatory. Can't be null or empty.");
- if (buffer.readableBytes() <= MINIMAL_LENGTH) {
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
- }
-
- final SrEroTypeBuilder srEroSubobjectBuilder = new SrEroTypeBuilder();
- final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
- final SidType sidType = SidType.forValue(sidTypeByte);
- srEroSubobjectBuilder.setSidType(sidType);
-
- final BitSet bitSet = ByteArray.bytesToBitSet(new byte[] { buffer.readByte() });
- final boolean f = bitSet.get(F_FLAG_POSITION);
- final boolean s = bitSet.get(S_FLAG_POSITION);
- final boolean c = bitSet.get(C_FLAG_POSITION);
- final boolean m = bitSet.get(M_FLAG_POSITION);
- final Flags flags = new Flags(c, f, m, s);
- srEroSubobjectBuilder.setFlags(flags);
-
- if (!flags.isS()) {
- final long sid = buffer.readUnsignedInt();
- srEroSubobjectBuilder.setSid(sid);
- }
- if (sidType != null && !flags.isF()) {
- switch (sidType) {
- case Ipv4NodeId:
- srEroSubobjectBuilder.setNai(new IpNodeIdBuilder().setIpAddress(
- new IpAddress(new Ipv4Address(Ipv4Util.addressForByteBuf(buffer)))).build());
- break;
- case Ipv6NodeId:
- srEroSubobjectBuilder.setNai(new IpNodeIdBuilder().setIpAddress(
- new IpAddress(Ipv6Util.addressForByteBuf(buffer))).build());
- break;
- case Ipv4Adjacency:
- srEroSubobjectBuilder.setNai(new IpAdjacencyBuilder()
- .setLocalIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer)))
- .setRemoteIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer))).build());
- break;
- case Ipv6Adjacency:
- srEroSubobjectBuilder.setNai(new IpAdjacencyBuilder()
- .setLocalIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer)))
- .setRemoteIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer))).build());
- break;
- case Unnumbered:
- srEroSubobjectBuilder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(buffer.readUnsignedInt())
- .setLocalInterfaceId(buffer.readUnsignedInt()).setRemoteNodeId(buffer.readUnsignedInt())
- .setRemoteInterfaceId(buffer.readUnsignedInt()).build());
- break;
- default:
- break;
- }
- }
- final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
- subobjectBuilder.setLoose(loose);
- subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
- return subobjectBuilder.build();
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import io.netty.buffer.ByteBuf;
-import java.util.List;
-import org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00PCInitiateMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.Requests;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-
-public class SrPcInitiateMessageParser extends CInitiated00PCInitiateMessageParser {
-
- public SrPcInitiateMessageParser(final ObjectRegistry registry) {
- super(registry);
- }
-
- @Override
- protected void serializeRequest(final Requests req, final ByteBuf buffer) {
- if (SrEroUtil.isSegmentRoutingPath(req.getSrp()) || SrEroUtil.isSegmentRoutingPath(req.getEro())) {
- serializeObject(req.getSrp(), buffer);
- serializeObject(req.getLsp(), buffer);
- serializeObject(req.getEro(), buffer);
- } else {
- super.serializeRequest(req, buffer);
- }
- }
-
- @Override
- protected Requests getValidRequest(final List<Object> objects) {
- final Srp srp = (Srp) objects.get(0);
- if (SrEroUtil.isSegmentRoutingPath(srp)) {
- final RequestsBuilder builder = new RequestsBuilder();
- builder.setSrp(srp);
- objects.remove(0);
- builder.setLsp((Lsp) objects.get(0));
- objects.remove(0);
-
- final Object obj = objects.get(0);
- if (obj instanceof Ero) {
- builder.setEro((Ero) obj);
- objects.remove(0);
- }
- return builder.build();
- }
- return super.getValidRequest(objects);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
-import io.netty.buffer.ByteBuf;
-import java.util.List;
-import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.Replies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
-
-public class SrPcRepMessageParser extends PCEPReplyMessageParser {
-
- public SrPcRepMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- super(registry, viRegistry);
- }
-
- @Override
- protected void serializeReply(Replies reply, ByteBuf buffer) {
- final Rp rp = reply.getRp();
- if (SrEroUtil.isSegmentRoutingPath(rp)) {
- serializeObject(rp, buffer);
- if (reply.getResult() instanceof SuccessCase) {
- final SuccessCase s = (SuccessCase) reply.getResult();
- for (final Paths p : s.getSuccess().getPaths()) {
- final Ero ero = p.getEro();
- serializeObject(ero, buffer);
- }
- }
- } else {
- super.serializeReply(reply, buffer);
- }
- }
-
- @Override
- protected Replies getValidReply(List<Object> objects, List<Message> errors) throws PCEPDeserializerException {
- if (!(objects.get(0) instanceof Rp)) {
- errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.<Rp>absent()));
- return null;
- }
- final Rp rp = (Rp) objects.get(0);
- if (SrEroUtil.isSegmentRoutingPath(rp)) {
- objects.remove(0);
- Result res = null;
- if (objects.get(0) instanceof Ero) {
- final SuccessBuilder builder = new SuccessBuilder();
- final List<Paths> paths = Lists.newArrayList();
- final PathsBuilder pBuilder = new PathsBuilder();
- while (!objects.isEmpty()) {
- final Object object = objects.get(0);
- if (object instanceof Ero) {
- final Ero ero = (Ero) object;
- final PCEPErrors error = SrEroUtil.validateSrEroSubobjects(ero);
- if (error != null) {
- errors.add(createErrorMsg(error, Optional.<Rp>absent()));
- return null;
- } else {
- paths.add(pBuilder.setEro(ero).build());
- }
- }
- objects.remove(0);
- }
- builder.setPaths(paths);
- res = new SuccessCaseBuilder().setSuccess(builder.build()).build();
- }
- return new RepliesBuilder().setRp(rp).setResult(res).build();
- }
- return super.getValidReply(objects, errors);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import com.google.common.base.Optional;
-import io.netty.buffer.ByteBuf;
-import java.util.List;
-import org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
-import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.identifiers.tlv.LspIdentifiersBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.Reports;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.ReportsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.reports.PathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LspId;
-
-public class SrPcRptMessageParser extends Stateful07PCReportMessageParser {
-
- public SrPcRptMessageParser(ObjectRegistry registry) {
- super(registry);
- }
-
- @Override
- protected void serializeReport(Reports report, ByteBuf buffer) {
- if (report.getPath() != null && (SrEroUtil.isSegmentRoutingPath(report.getSrp()) || SrEroUtil.isSegmentRoutingPath(report.getPath().getEro()))) {
- serializeObject(report.getSrp(), buffer);
- serializeObject(report.getLsp(), buffer);
- serializeObject(report.getPath().getEro(), buffer);
- } else {
- super.serializeReport(report, buffer);
- }
- }
-
- @Override
- protected Reports getValidReports(List<Object> objects, List<Message> errors) {
- if (objects.get(0) instanceof Srp) {
- final Srp srp = (Srp) objects.get(0);
- if (SrEroUtil.isSegmentRoutingPath(srp)) {
- boolean isValid = true;
- final ReportsBuilder builder = new ReportsBuilder();
- builder.setSrp(srp);
- objects.remove(0);
- if (objects.get(0) instanceof Lsp) {
- final Lsp lsp = (Lsp) objects.get(0);
- final LspBuilder lspBuilder = new LspBuilder(lsp);
- final TlvsBuilder tlvsBuilder = new TlvsBuilder(lsp.getTlvs());
- tlvsBuilder.setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(lsp.getPlspId().getValue())).build());
- lspBuilder.setTlvs(tlvsBuilder.build());
- builder.setLsp(lspBuilder.build());
- objects.remove(0);
- } else {
- errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.<Rp>absent()));
- isValid = false;
- }
-
- final Object obj = objects.get(0);
- if (obj instanceof Ero) {
- final Ero ero = (Ero) obj;
- final PCEPErrors error = SrEroUtil.validateSrEroSubobjects(ero);
- if (error != null) {
- errors.add(createErrorMsg(error, Optional.<Rp>absent()));
- isValid = false;
- } else {
- builder.setPath(new PathBuilder().setEro(ero).build());
- }
- objects.remove(0);
- } else {
- errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.<Rp>absent()));
- isValid = false;
- }
- if (isValid) {
- return builder.build();
- }
- return null;
- }
- }
- return super.getValidReports(objects, errors);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import com.google.common.base.Optional;
-import io.netty.buffer.ByteBuf;
-import java.util.List;
-import org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCUpdateRequestMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
-import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.Updates;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.UpdatesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
-
-public class SrPcUpdMessageParser extends Stateful07PCUpdateRequestMessageParser {
-
- public SrPcUpdMessageParser(final ObjectRegistry registry) {
- super(registry);
- }
-
- @Override
- protected void serializeUpdate(final Updates update, final ByteBuf buffer) {
- if (update.getPath() != null && (SrEroUtil.isSegmentRoutingPath(update.getSrp()) || SrEroUtil.isSegmentRoutingPath(update.getPath().getEro()))) {
- serializeObject(update.getSrp(), buffer);
- serializeObject(update.getLsp(), buffer);
- serializeObject(update.getPath().getEro(), buffer);
- } else {
- super.serializeUpdate(update, buffer);
- }
- }
-
- @Override
- protected Updates getValidUpdates(final List<Object> objects, final List<Message> errors) {
- if (objects.get(0) instanceof Srp && SrEroUtil.isSegmentRoutingPath((Srp) objects.get(0))) {
- boolean isValid = true;
- final Srp srp = (Srp) objects.get(0);
- final UpdatesBuilder builder = new UpdatesBuilder();
- builder.setSrp(srp);
- objects.remove(0);
- if (objects.get(0) instanceof Lsp) {
- builder.setLsp((Lsp) objects.get(0));
- objects.remove(0);
- } else {
- errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.<Rp>absent()));
- isValid = false;
- }
-
- final Object obj = objects.get(0);
- if (obj instanceof Ero) {
- final Ero ero = (Ero) obj;
- final PCEPErrors error = SrEroUtil.validateSrEroSubobjects(ero);
- if (error != null) {
- errors.add(createErrorMsg(error, Optional.<Rp>absent()));
- isValid = false;
- } else {
- builder.setPath(new PathBuilder().setEro(ero).build());
- objects.remove(0);
- }
- } else {
- errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.<Rp>absent()));
- isValid = false;
- }
- if (isValid) {
- return builder.build();
- }
- return null;
- }
- return super.getValidUpdates(objects, errors);
- }
-
-}
// vi: set smarttab et sw=4 tabstop=4:
-module odl-pcep-segment-routing02-cfg {
+module odl-pcep-segment-routing-cfg {
yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:sr02:cfg";
- prefix "pcep-sr02";
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg";
+ prefix "pcep-sr";
import config { prefix config; revision-date 2013-04-05; }
import odl-pcep-api-cfg { prefix pcep; revision-date 2013-04-09; }
contact "Milos Fabian <milfabia@cisco.com>";
description
- "This module contains the base YANG definitions for
- draft-sivabalan-pce-segment-routing-02 extensions.
+ "This module contains the data model of PCEP Extensions for Segment Routing,
+ draft-ietf-pce-segment-routing-00.
- Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
+ Copyright (c)2014 Cisco Systems, Inc. All rights reserved.
This program and the accompanying materials are made available
under the terms of the Eclipse Public License v1.0 which
"Initial revision.";
}
- identity pcep-parser-segment-routing02 {
+ identity pcep-parser-segment-routing {
base config:module-type;
config:provided-service spi:extension;
- config:java-name-prefix SegmentRouting02PCEPParser;
+ config:java-name-prefix SegmentRoutingPCEPParser;
}
augment "/config:modules/config:module/config:configuration" {
- case pcep-parser-segment-routing02 {
- when "/config:modules/config:module/config:type = 'pcep-parser-segment-routing02'";
+ case pcep-parser-segment-routing {
+ when "/config:modules/config:module/config:type = 'pcep-parser-segment-routing'";
}
}
- identity pcep-session-proposal-factory-sr02 {
+ identity pcep-session-proposal-factory-sr {
base config:module-type;
- config:java-name-prefix "Sr02PCEPSessionProposalFactory";
+ config:java-name-prefix "SrPCEPSessionProposalFactory";
config:provided-service pcep:pcep-session-proposal-factory;
}
augment "/config:modules/config:module/config:configuration" {
- case pcep-session-proposal-factory-sr02 {
- when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-sr02'";
+ case pcep-session-proposal-factory-sr {
+ when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-sr'";
leaf dead-timer-value {
type uint8;
-module odl-pcep-segment-routing02 {
+module odl-pcep-segment-routing {
yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:pcep:segment:routing:02";
- prefix "sr02";
+ namespace "urn:opendaylight:params:xml:ns:yang:pcep:segment:routing";
+ prefix "pcep-sr";
import pcep-types { prefix pcep; revision-date 2013-10-05; }
import pcep-message { prefix msg; revision-date 2013-10-07; }
import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
import network-topology { prefix nt; revision-date 2013-10-21; }
import network-topology-pcep { prefix pn; revision-date 2013-10-24; }
- import rsvp { prefix rsvp; revision-date 2013-08-20; }
- import yang-ext { prefix ext; revision-date 2013-07-09; }
organization "Cisco Systems, Inc.";
contact "Milos Fabian <milfabia@cisco.com>";
description
"This module contains the data model of PCEP Extensions for Segment Routing,
- draft-sivabalan-pce-segment-routing-02.
+ draft-ietf-pce-segment-routing-00.
- Copyright (c)2014 Cisco Systems, Inc. All rights reserved.
+ Copyright (c)2015 Cisco Systems, Inc. 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 "2014-05-06" {
+ revision "2015-01-12" {
description
- "Initial revision.";
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02";
+ "Upgrade from draft-sivabalan-pce-segment-routing-02.";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00";
}
grouping sr-pce-capability-tlv {
description "SR-PCE-CAPABILITY TLV";
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.1.1";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.1.1";
container sr-pce-capability {
uses pcep:tlv;
}
augment "/msg:open/msg:open-message/msg:open/msg:tlvs" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.1";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.1";
uses sr-pce-capability-tlv;
}
augment "/msg:pcerr/msg:pcerr-message/msg:error-type/msg:session-case/msg:session/msg:open/msg:tlvs" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.1";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.1";
uses sr-pce-capability-tlv;
}
typedef sid-type {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3.1";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.3.1";
type enumeration {
enum ipv4-node-id {
value 1;
}
}
- grouping sr-ero-subobject {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3.1";
+ grouping sr-subobject {
leaf sid-type {
type sid-type;
}
- leaf flags {
- type bits {
- bit m {
- position 31;
- }
- bit c {
- position 30;
- }
- bit s {
- position 29;
- }
- bit f {
- position 28;
- }
- }
- mandatory true;
- }
leaf sid {
description "Segment Identifier";
}
choice nai {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3.2";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.3.2";
description "Node or Adjacency Identifier";
case ip-node-id {
when "../sid-type = 'ipv4-node-id' or ../sid-type = 'ipv6-node-id'";
}
}
+ grouping sr-ero-subobject {
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.3.1";
+ leaf c-flags {
+ type boolean;
+ default false;
+ }
+ leaf m-flag {
+ type boolean;
+ default false;
+ }
+ uses sr-subobject;
+ }
+
+ grouping sr-rro-subobject {
+ reference "http://tools.ietf.org/html/draft-ietf-pce-segment-routing-00#section-5.4";
+ uses sr-subobject;
+ }
+
+ //ERO augmentations
augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:result/msg:success-case/msg:success/msg:paths/msg:ero/msg:subobject/msg:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.2";
case sr-ero-type {
uses sr-ero-subobject;
}
//stateful07
augment "/crabbe:pcinitiate/crabbe:pcinitiate-message/crabbe:requests/crabbe:ero/crabbe:subobject/crabbe:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.3";
case sr-ero-type {
uses sr-ero-subobject;
}
}
augment "/stateful:pcrpt/stateful:pcrpt-message/stateful:reports/stateful:path/stateful:ero/stateful:subobject/stateful:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.4";
case sr-ero-type {
uses sr-ero-subobject;
}
}
augment "/stateful:pcupd/stateful:pcupd-message/stateful:updates/stateful:path/stateful:ero/stateful:subobject/stateful:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.5";
case sr-ero-type {
uses sr-ero-subobject;
}
//nt-pcep
augment "/pn:add-lsp/pn:input/pn:arguments/pn:ero/pn:subobject/pn:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.3";
case sr-ero-type {
uses sr-ero-subobject;
}
}
augment "/pn:update-lsp/pn:input/pn:arguments/pn:ero/pn:subobject/pn:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.5";
case sr-ero-type {
uses sr-ero-subobject;
}
}
augment "/nt:network-topology/nt:topology/nt:node/pn:path-computation-client/pn:reported-lsp/pn:path/pn:ero/pn:subobject/pn:subobject-type" {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-4.4";
case sr-ero-type {
uses sr-ero-subobject;
}
}
-}
\ No newline at end of file
+
+ //RRO augmentations
+ augment "/msg:pcreq/msg:pcreq-message/msg:requests/msg:segment-computation/msg:p2p/msg:reported-route/msg:rro/msg:subobject/msg:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/msg:pcreq/msg:pcreq-message/msg:requests/msg:segment-computation/msg:p2p/msg:rro/msg:subobject/msg:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:result/msg:failure-case/msg:rro/msg:subobject/msg:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:result/msg:success-case/msg:success/msg:paths/msg:rro/msg:subobject/msg:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ //stateful07
+ augment "/crabbe:pcinitiate/crabbe:pcinitiate-message/crabbe:requests/crabbe:rro/crabbe:subobject/crabbe:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/stateful:pcrpt/stateful:pcrpt-message/stateful:reports/stateful:path/stateful:rro/stateful:subobject/stateful:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/stateful:pcupd/stateful:pcupd-message/stateful:updates/stateful:path/stateful:rro/stateful:subobject/stateful:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ //nt-pcep
+ augment "/pn:add-lsp/pn:input/pn:arguments/pn:rro/pn:subobject/pn:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/pn:update-lsp/pn:input/pn:arguments/pn:rro/pn:subobject/pn:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/pn:path-computation-client/pn:reported-lsp/pn:path/pn:rro/pn:subobject/pn:subobject-type" {
+ case sr-rro-type {
+ uses sr-rro-subobject;
+ }
+ }
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
import static org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleTest.createPCEPExtensionsModuleInstance;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
-public class SegmentRouting02PCEPParserModuleTest extends AbstractConfigTest {
+public class SegmentRoutingPCEPParserModuleTest extends AbstractConfigTest {
- private static final String FACTORY_NAME = SegmentRouting02PCEPParserModuleFactory.NAME;
+ private static final String FACTORY_NAME = SegmentRoutingPCEPParserModuleFactory.NAME;
private static final String INSTANCE_NAME = "pcep-parser-sr02-instance";
@Before
public void setUp() {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new SegmentRouting02PCEPParserModuleFactory(), new SimplePCEPExtensionProviderContextModuleFactory()));
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new SegmentRoutingPCEPParserModuleFactory(), new SimplePCEPExtensionProviderContextModuleFactory()));
}
@Test
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.config.yang.pcep.sr02.cfg;
+package org.opendaylight.controller.config.yang.pcep.sr.cfg;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleMXBean;
-public class Sr02PCEPSessionProposalFactoryModuleTest extends AbstractConfigTest {
+public class SrPCEPSessionProposalFactoryModuleTest extends AbstractConfigTest {
private static final String INSTANCE_NAME = "sr02-session-proposal";
- private static final String FACTORY_NAME = Sr02PCEPSessionProposalFactoryModuleFactory.NAME;
+ private static final String FACTORY_NAME = SrPCEPSessionProposalFactoryModuleFactory.NAME;
@Before
public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new Sr02PCEPSessionProposalFactoryModuleFactory()));
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new SrPCEPSessionProposalFactoryModuleFactory()));
}
@Test
private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Short deadTimer, final Short keepAlive,
final Boolean stateful, final Boolean active, final Boolean instant, final Boolean srCapable) throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final Sr02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
- Sr02PCEPSessionProposalFactoryModuleMXBean.class);
+ final SrPCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
+ SrPCEPSessionProposalFactoryModuleMXBean.class);
mxBean.setActive(active);
mxBean.setDeadTimerValue(deadTimer);
mxBean.setInitiated(instant);
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
.setTlvs(new TlvsBuilder()
.addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder().addAugmentation(Stateful1.class,
new Stateful1Builder().setInitiation(true).build()).setLspUpdateCapability(true).build()).build())
- .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1.class,
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1Builder()
+ .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder()
.setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build()).build())
.build())
.build();
@Test
public void testSegmentRouting02SessionProposalFactory() {
- final SegmentRouting02SessionProposalFactory sspf = new SegmentRouting02SessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, true, true, true, true);
+ final SegmentRoutingSessionProposalFactory sspf = new SegmentRoutingSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, true, true, true, true);
Assert.assertEquals(DEAD_TIMER, sspf.getDeadTimer());
Assert.assertEquals(KEEP_ALIVE, sspf.getKeepAlive());
Assert.assertTrue(sspf.isActive());
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpAdjacencyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.UnnumberedAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
public class SrEroSubobjectParserTest {
0x4A,0x7D,0x2b,0x63,
};
+ private static final byte[] srEroSubobjectWithIpv4NodeIDMFlag = {
+ 0x05,0x0c,(byte) 0x10,0x01,
+ 0x07,0x5B,(byte) 0xCD,0x15,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+ private static final byte[] srEroSubobjectWithIpv4NodeIDMFlagAfter = {
+ 0x05,0x0c,(byte) 0x10,0x01,
+ 0x07,0x5B,(byte) 0xC0,0x00,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+
private SimplePCEPExtensionProviderContext ctx;
private SegmentRoutingActivator act;
public void testSrEroSubobjectIpv4NodeIdNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, false));
builder.setSidType(SidType.Ipv4NodeId);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
public void testSrEroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, false));
builder.setSidType(SidType.Ipv6NodeId);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
public void testSrEroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, false));
builder.setSidType(SidType.Ipv4Adjacency);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddress(new Ipv4Address("74.125.43.99")))
.setRemoteIpAddress(new IpAddress(new Ipv4Address("74.125.43.100"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
public void testSrEroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, false));
builder.setSidType(SidType.Ipv6Adjacency);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c")))
.setRemoteIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729d"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
public void testSrEroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, false));
builder.setSidType(SidType.Unnumbered);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
public void testSrEroSubobjectWithoutNAI() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, true, false, false));
builder.setSidType(SidType.Ipv4NodeId);
builder.setSid(123456L);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithoutNAI, 2)), false));
public void testSrEroSubobjectWithoutBody() throws PCEPDeserializerException {
final SrEroSubobjectParser parser = new SrEroSubobjectParser();
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
- builder.setFlags(new Flags(false, false, false, true));
builder.setSidType(SidType.Ipv4NodeId);
+ builder.setCFlags(false);
+ builder.setMFlag(false);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithoutSID, ByteArray.getAllBytes(buffer));
}
+
+ @Test
+ public void testSrEroSubobjectIpv4NodeIdNAIMFlag() throws PCEPDeserializerException {
+ final SrEroSubobjectParser parser = new SrEroSubobjectParser();
+ final SrEroTypeBuilder builder = new SrEroTypeBuilder();
+ builder.setCFlags(false);
+ builder.setMFlag(true);
+ builder.setSidType(SidType.Ipv4NodeId);
+ builder.setSid(30140L);
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv4NodeIDMFlag, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithIpv4NodeIDMFlagAfter, ByteArray.getAllBytes(buffer));
+ }
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import com.google.common.collect.Lists;
import java.lang.reflect.Constructor;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.pcinitiate.pcinitiate.message.requests.ero.subobject.subobject.type.SrEroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.pcinitiate.pcinitiate.message.requests.ero.subobject.subobject.type.SrEroTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
c.setAccessible(true);
try {
c.newInstance();
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw e.getCause();
}
}
- @Test
- public void testIsSegmentRoutingPath() {
- Assert.assertTrue(SrEroUtil.isSegmentRoutingPath(createEro(Lists.newArrayList(createSRSubobject()))));
- Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(Collections.<Subobject>emptyList())));
- Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(null)));
- Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(Lists.newArrayList(createIpPrefixSubobject()))));
- }
-
@Test
public void testValidateSrEroSubobjects() {
Assert.assertNull(SrEroUtil.validateSrEroSubobjects(createEro(Lists.newArrayList(createSRSubobject()))));
private Subobject createSRSubobject(final long sid, final boolean isM) {
final SubobjectBuilder builder = new SubobjectBuilder();
- builder.setSubobjectType(new SrEroTypeBuilder().setFlags(new Flags(false, false, isM, false)).setSid(sid).build());
+ builder.setSubobjectType(new SrEroTypeBuilder().setMFlag(isM).setSid(sid).build());
return builder.build();
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
final List<Subobject> subobjects = Lists.newArrayList();
final SrEroTypeBuilder srEroSubBuilder = new SrEroTypeBuilder();
- srEroSubBuilder.setFlags(new Flags(false, false, false, false));
+ srEroSubBuilder.setCFlags(false);
+ srEroSubBuilder.setMFlag(false);
srEroSubBuilder.setSidType(SidType.Ipv4NodeId);
srEroSubBuilder.setSid(123456L);
srEroSubBuilder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder;
+
+public class SrRroSubobjectParserTest {
+
+ private static final byte[] srRroSubobjectWithIpv4NodeID = {
+ 0x06,0x0c,(byte) 0x10,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+
+ private static final byte[] srRroSubobjectWithIpv6NodeID = {
+ 0x06,0x18,(byte) 0x20,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ (byte) 0xFE,(byte) 0x80,(byte) 0xCD,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x21,0x1E,0x72,(byte) 0x9C,
+ };
+
+ private static final byte[] srRroSubobjectWithIpv4Adjacency = {
+ 0x06,0x10,(byte) 0x30,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ 0x4A,0x7D,0x2b,0x63,
+ 0x4A,0x7D,0x2b,0x64,
+ };
+
+ private static final byte[] srRroSubobjectWithIpv6Adjacency = {
+ 0x06,0x28,(byte) 0x40,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ (byte) 0xFE,(byte) 0x80,(byte) 0xCD,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x21,0x1E,0x72,(byte) 0x9C,
+ (byte) 0xFE,(byte) 0x80,(byte) 0xCD,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,
+ 0x21,0x1E,0x72,(byte) 0x9D,
+ };
+
+ private static final byte[] srRroSubobjectWithUnnumbered = {
+ 0x06,0x18,(byte) 0x50,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x02,
+ 0x00,0x00,0x00,0x03,
+ 0x00,0x00,0x00,0x04
+ };
+
+ private static final byte[] srRroSubobjectWithoutNAI = {
+ 0x06,0x08,(byte) 0x10,0x02,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ };
+
+ private static final byte[] srRroSubobjectWithoutSID = {
+ 0x06,0x08,(byte) 0x10,0x01,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+
+ private SimplePCEPExtensionProviderContext ctx;
+ private SegmentRoutingActivator act;
+
+ @Before
+ public void setUp() {
+ this.ctx = new SimplePCEPExtensionProviderContext();
+ this.act = new SegmentRoutingActivator();
+ this.act.start(this.ctx);
+ }
+
+ @Test
+ public void testSrRroSubobjectIpv4NodeIdNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv4NodeId);
+ builder.setSid(123456L);
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4NodeID, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithIpv4NodeID, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv6NodeId);
+ builder.setSid(123456L);
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6NodeID, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv4Adjacency);
+ builder.setSid(123456L);
+ builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddress(new Ipv4Address("74.125.43.99")))
+ .setRemoteIpAddress(new IpAddress(new Ipv4Address("74.125.43.100"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4Adjacency, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithIpv4Adjacency, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv6Adjacency);
+ builder.setSid(123456L);
+ builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c")))
+ .setRemoteIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729d"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6Adjacency, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithIpv6Adjacency, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Unnumbered);
+ builder.setSid(123456L);
+ builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithUnnumbered, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithUnnumbered, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectWithoutNAI() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv4NodeId);
+ builder.setSid(123456L);
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutNAI, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithoutNAI, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrRroSubobjectWithoutBody() throws PCEPDeserializerException {
+ final SrRroSubobjectParser parser = new SrRroSubobjectParser();
+ final SrRroTypeBuilder builder = new SrRroTypeBuilder();
+ builder.setSidType(SidType.Ipv4NodeId);
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutSID, 2))));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srRroSubobjectWithoutSID, ByteArray.getAllBytes(buffer));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Test;
+
+public class SrSubobjectParserUtilTest {
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testPrivateConstructor() throws Throwable {
+ final Constructor<SrSubobjectParserUtil> c = SrSubobjectParserUtil.class.getDeclaredConstructor();
+ c.setAccessible(true);
+ try {
+ c.newInstance();
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ }
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.protocol.pcep.segment.routing02;
+package org.opendaylight.protocol.pcep.segment.routing;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.reports.PathBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.network.topology.topology.node.path.computation.client.reported.lsp.path.ero.subobject.subobject.type.SrEroType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.pcrpt.pcrpt.message.reports.path.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.network.topology.topology.node.path.computation.client.reported.lsp.path.ero.subobject.subobject.type.SrEroType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.pcrpt.pcrpt.message.reports.path.ero.subobject.subobject.type.SrEroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
private AbstractTopologySessionListener<SrpIdNumber, PlspId> listener;
+ @Override
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
private static Ero createSrEroObject(final String nai) {
final SrEroTypeBuilder srEroBuilder = new SrEroTypeBuilder();
- srEroBuilder.setFlags(new Flags(false, false, false, false));
+ srEroBuilder.setCFlags(false);
+ srEroBuilder.setMFlag(false);
srEroBuilder.setSidType(SidType.Ipv4NodeId);
srEroBuilder.setSid(123456L);
srEroBuilder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address(nai))).build());
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing02;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import com.google.common.collect.Lists;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator;
-import org.opendaylight.protocol.pcep.impl.Activator;
-import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.PcinitiateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.PcinitiateMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.OperationalStatus;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcrptBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcupdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PlspId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SrpIdNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.identifiers.tlv.LspIdentifiersBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.PcrptMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.ReportsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.PcupdMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.UpdatesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.ero.subobject.nai.IpNodeIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.PcrepMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.Replies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LspId;
-
-public class SrMessageParserTest {
-
- private SimplePCEPExtensionProviderContext ctx;
- private SegmentRoutingActivator srActivator;
- private Activator activator;
- private StatefulActivator statefulActivator;
- private ObjectRegistry objectRegistry;
- private VendorInformationObjectRegistry viObjReg;
-
- @Before
- public void setup() {
- this.ctx = new SimplePCEPExtensionProviderContext();
- this.activator = new Activator();
- this.activator.start(this.ctx);
- this.statefulActivator = new StatefulActivator();
- this.statefulActivator.start(this.ctx);
- this.srActivator = new SegmentRoutingActivator();
- this.srActivator.start(this.ctx);
- this.objectRegistry = this.ctx.getObjectHandlerRegistry();
- this.viObjReg = this.ctx.getVendorInformationObjectRegistry();
- }
-
- @Test
- public void testReplyMsg() throws IOException, PCEPDeserializerException {
- byte[] replyMsgBytes = {
- 0x20,0x04,0x00,0x28,
- /* rp-object */
- 0x02,0x10,0x00,0x14,
- 0x00,0x00,0x04,0x2d,
- (byte)0xde,(byte)0xad,(byte)0xbe,(byte)0xef,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x10,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x00,
- 0x00,0x01,(byte) 0xe2,0x40,
- 0x4A,0x7D,0x2b,0x63};
-
- final SrPcRepMessageParser parser = new SrPcRepMessageParser(this.objectRegistry, this.viObjReg);
-
- final PcrepMessageBuilder builder = new PcrepMessageBuilder();
- final RepliesBuilder rBuilder = new RepliesBuilder();
-
- final List<Replies> replies = Lists.newArrayList();
- rBuilder.setRp(createRpObject());
-
- final List<Paths> paths = Lists.newArrayList();
- final PathsBuilder paBuilder = new PathsBuilder();
-
- paBuilder.setEro(createSrEroObject());
-
- paths.add(paBuilder.build());
- rBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
- replies.add(rBuilder.build());
- builder.setReplies(replies);
-
- ByteBuf buf = Unpooled.wrappedBuffer(replyMsgBytes);
- assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(buf.slice(4,
- buf.readableBytes() - 4), Collections.<Message> emptyList()));
-
- buf = Unpooled.buffer(replyMsgBytes.length);
- parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
- assertArrayEquals(replyMsgBytes, buf.array());
- }
-
- @Test
- public void testInitiateMsg() throws PCEPDeserializerException {
-
- final byte[] statefulMsg= {
- 0x20,0x0C,0x00,0x30,
- /* srp-object */
- 0x21,0x10,0x00,0x14,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* lsp-object */
- 0x20,0x10,0x00,0x08,
- 0x00,0x00,0x00,0x00,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x10,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x00,
- 0x00,0x01,(byte) 0xe2,0x40,
- 0x4A,0x7D,0x2b,0x63
- };
-
- final SrPcInitiateMessageParser parser = new SrPcInitiateMessageParser(objectRegistry);
-
- final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
- final RequestsBuilder reqBuilder = new RequestsBuilder();
- reqBuilder.setLsp(createLspObject());
- reqBuilder.setSrp(createSrpObject());
-
- reqBuilder.setEro(createSrEroObject());
- builder.setRequests(Lists.newArrayList(reqBuilder.build()));
-
- final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
- assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(buf.slice(4,
- buf.readableBytes() - 4), Collections.<Message> emptyList()));
-
- final ByteBuf buffer = Unpooled.buffer(statefulMsg.length);
- parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buffer);
- assertArrayEquals(statefulMsg, buffer.array());
- }
-
- @Test
- public void testRptMsg() throws PCEPDeserializerException {
- final byte[] statefulMsg= {
- 0x20,0x0A,0x00,0x30,
- /* srp-object */
- 0x21,0x10,0x00,0x14,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* lsp-object */
- 0x20,0x10,0x00,0x08,
- 0x00,0x00,0x00,0x00,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x10,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x00,
- 0x00,0x01,(byte) 0xe2,0x40,
- 0x4A,0x7D,0x2b,0x63};
-
- final SrPcRptMessageParser parser = new SrPcRptMessageParser(objectRegistry);
- final PcrptMessageBuilder builder = new PcrptMessageBuilder();
- final ReportsBuilder rptBuilder = new ReportsBuilder();
- final Lsp lsp = createLspObject();
- final LspBuilder lspBuilder = new LspBuilder(lsp);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder tlvsBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder(lsp.getTlvs());
- tlvsBuilder.setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(0L)).build());
- lspBuilder.setTlvs(tlvsBuilder.build());
- rptBuilder.setLsp(lspBuilder.build());
- rptBuilder.setSrp(createSrpObject());
- rptBuilder.setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(createSrEroObject()).build());
- builder.setReports(Lists.newArrayList(rptBuilder.build()));
-
- final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
- assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(buf.slice(4,
- buf.readableBytes() - 4), Collections.<Message> emptyList()));
-
- final ByteBuf buffer = Unpooled.buffer(statefulMsg.length);
- rptBuilder.setLsp(createLspObject());
- builder.setReports(Lists.newArrayList(rptBuilder.build()));
- parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buffer);
- assertArrayEquals(statefulMsg, buffer.array());
- }
-
- @Test
- public void testUpdMsg() throws PCEPDeserializerException {
- final byte[] statefulMsg= {
- 0x20,0x0B,0x00,0x30,
- /* srp-object */
- 0x21,0x10,0x00,0x14,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* lsp-object */
- 0x20,0x10,0x00,0x08,
- 0x00,0x00,0x00,0x00,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x10,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x00,
- 0x00,0x01,(byte) 0xe2,0x40,
- 0x4A,0x7D,0x2b,0x63};
-
- final SrPcUpdMessageParser parser = new SrPcUpdMessageParser(objectRegistry);
- final PcupdMessageBuilder builder = new PcupdMessageBuilder();
- final UpdatesBuilder updBuilder = new UpdatesBuilder();
- updBuilder.setLsp(createLspObject());
- updBuilder.setSrp(createSrpObject());
- updBuilder.setPath(new PathBuilder().setEro(createSrEroObject()).build());
- builder.setUpdates(Lists.newArrayList(updBuilder.build()));
-
- final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
- assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(buf.slice(4,
- buf.readableBytes() - 4), Collections.<Message> emptyList()));
-
- final ByteBuf buffer = Unpooled.buffer(statefulMsg.length);
- parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buffer);
- assertArrayEquals(statefulMsg, buffer.array());
- }
-
- @Test
- public void testNonIdenticalEroSubobjectError() throws PCEPDeserializerException {
- final byte[] statefulMsg= {
- 0x20,0x0B,0x00,0x30,
- /* srp-object */
- 0x21,0x10,0x00,0x14,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* lsp-object */
- 0x20,0x10,0x00,0x08,
- 0x00,0x00,0x00,0x00,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x18,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x00,
- 0x00,0x01,(byte) 0xe2,0x40,
- 0x4A,0x7D,0x2b,0x63,
- /* ipv4 prefix subobject */
- (byte) 0x81,0x08,(byte) 0xFF,(byte) 0xFF,
- (byte) 0xFF,(byte) 0xFF,0x16,0x00};
-
- final SrPcRptMessageParser parser = new SrPcRptMessageParser(objectRegistry);
-
- final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
- List<Message> errors = Lists.newArrayList();
- parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
-
- assertFalse(errors.isEmpty());
- assertEquals(createErrorMessage((short)10, (short)5), errors.get(0));
- }
-
- @Test
- public void testBadLabelValueError() throws PCEPDeserializerException {
- final byte[] statefulMsg= {
- 0x20,0x0A,0x00,0x30,
- /* srp-object */
- 0x21,0x10,0x00,0x14,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,
- /* pst-tlv */
- 0x00,0x1b,0x00,0x04,
- 0x00,0x00,0x00,0x01,
- /* lsp-object */
- 0x20,0x10,0x00,0x08,
- 0x00,0x00,0x00,0x00,
- /* sr-ero-object */
- 0x07,0x10,0x00,0x10,
- /* sr-ero subobject */
- 0x05,0x0c,(byte) 0x10,0x01,
- 0x00,0x00,0x00,0x03,
- 0x4A,0x7D,0x2b,0x63};
-
- final SrPcRptMessageParser parser = new SrPcRptMessageParser(objectRegistry);
-
- final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
- final List<Message> errors = Lists.newArrayList();
- parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
-
- assertFalse(errors.isEmpty());
- assertEquals(createErrorMessage((short)10, (short)2), errors.get(0));
- }
-
- private Ero createSrEroObject() {
- final SrEroTypeBuilder srEroBuilder = new SrEroTypeBuilder();
- srEroBuilder.setFlags(new Flags(false, false, false, false));
- srEroBuilder.setSidType(SidType.Ipv4NodeId);
- srEroBuilder.setSid(123456L);
- srEroBuilder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
- final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroBuilder.build()).setLoose(false);
-
- final List<Subobject> subobjects = Lists.newArrayList(subobjBuilder.build());
- return new EroBuilder().setProcessingRule(false).setIgnore(false).setSubobject(subobjects).build();
- }
-
- private Lsp createLspObject() {
- final LspBuilder lspBuilder = new LspBuilder();
- lspBuilder.setIgnore(false);
- lspBuilder.setProcessingRule(false);
- lspBuilder.setAdministrative(false);
- lspBuilder.setDelegate(false);
- lspBuilder.setPlspId(new PlspId(0L));
- lspBuilder.setOperational(OperationalStatus.Down);
- lspBuilder.setSync(false);
- lspBuilder.setRemove(false);
- lspBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder().build());
- return lspBuilder.build();
- }
-
- private Rp createRpObject() {
- final RpBuilder rpBuilder = new RpBuilder();
- rpBuilder.setProcessingRule(false);
- rpBuilder.setIgnore(false);
- rpBuilder.setReoptimization(true);
- rpBuilder.setBiDirectional(false);
- rpBuilder.setLoose(true);
- rpBuilder.setMakeBeforeBreak(true);
- rpBuilder.setOrder(false);
- rpBuilder.setPathKey(false);
- rpBuilder.setSupplyOf(false);
- rpBuilder.setFragmentation(false);
- rpBuilder.setP2mp(false);
- rpBuilder.setEroCompression(false);
- rpBuilder.setPriority((short) 5);
- rpBuilder.setRequestId(new RequestId(0xdeadbeefL));
- rpBuilder.setTlvs(new TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 1).build()).build());
- return rpBuilder.build();
- }
-
- private Srp createSrpObject() {
- final SrpBuilder builder = new SrpBuilder();
- builder.setProcessingRule(false);
- builder.setIgnore(false);
- builder.setOperationId(new SrpIdNumber(1L));
- //builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
- builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().setPathSetupType(
- new PathSetupTypeBuilder().setPst((short) 1).build()).build());
- return builder.build();
- }
-
- private Pcerr createErrorMessage(final short type, final short value) {
- final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
- errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(
- new ErrorObjectBuilder().setType(type).setValue(value).build()).build()));
- final PcerrBuilder builder = new PcerrBuilder();
- builder.setPcerrMessage(errMsgBuilder.build());
- return builder.build();
- }
-}
* LSP instantiation error: RSVP signaling error
*/
LSP_RSVP_ERROR(24, 3),
+ /**
+ * Segment Routing error: ERO subobject with invalid SID value
+ */
+ BAD_LABEL_VALUE(10, 2),
+ /**
+ * Segment Routing error: Unsupported number of Segment ERO subobjects
+ */
+ UNSUPPORTED_NUMBER_OF_SR_ERO_SUBOBJECTS(10, 3),
+ /**
+ * Segment Routing error: Bad label format
+ */
+ BAD_LABEL_FORMAT(10, 4),
/**
* Segment Routing error: Non-identical ERO subobjects
*/
NON_IDENTICAL_ERO_SUBOBJECTS(10, 5),
/**
- * Segment Routing error: ERO subobject with invalid SID value;
+ * Segment Routing error: Both SID and NAI are absent in ERO subobject.
*/
- BAD_LABEL_VALUE(10, 2),
+ SID_AND_NAI_ABSENT_IN_ERO(10, 6),
+ /**
+ * Segment Routing error: Both SID and NAI are absent in RRO subobject.
+ */
+ SID_AND_NAI_ABSENT_IN_RRO(10, 7),
/**
* Invalid traffic engineering path setup type: Unsupported path setup type
*/