--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>pcep-subsystem</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pcep-ietf-stateful07</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>pcep-spi-config</artifactId>
+ </dependency>
+ <!--test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-manager</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-manager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-util</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>pcep-spi-config</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
package org.opendaylight.protocol.pcep.lsp.setup.type01;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00SrpObjectParser;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
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.srp.object.srp.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
@Override
public void addTlv(SrpBuilder builder, Tlv tlv) {
super.addTlv(builder, tlv);
- final Tlvs8Builder tlvBuilder = new Tlvs8Builder();
+ final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
if (builder.getTlvs() != null) {
- if (builder.getTlvs().getAugmentation(Tlvs8.class) != null) {
- final Tlvs8 t = builder.getTlvs().getAugmentation(Tlvs8.class);
+ if (builder.getTlvs().getAugmentation(Tlvs7.class) != null) {
+ final Tlvs7 t = builder.getTlvs().getAugmentation(Tlvs7.class);
if (t.getPathSetupType() != null) {
tlvBuilder.setPathSetupType(t.getPathSetupType());
}
if (tlv instanceof PathSetupType) {
tlvBuilder.setPathSetupType((PathSetupType) tlv);
}
- builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs8.class, tlvBuilder.build()).build());
+ builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs7.class, tlvBuilder.build()).build());
}
@Override
return;
}
super.serializeTlvs(tlvs, body);
- if (tlvs.getAugmentation(Tlvs8.class) != null) {
- final Tlvs8 nameTlvs = tlvs.getAugmentation(Tlvs8.class);
- if (nameTlvs.getPathSetupType() != null) {
- serializeTlv(nameTlvs.getPathSetupType(), body);
- }
+ if (tlvs.getAugmentation(Tlvs5.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs5.class), body);
+ } else if (tlvs.getAugmentation(Tlvs6.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs6.class), body);
+ } else if (tlvs.getAugmentation(Tlvs7.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs7.class), body);
+ } else if (tlvs.getAugmentation(Tlvs8.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs8.class), body);
+ }
+ }
+
+ private void serializePathSetupType(final PathSetupTypeTlv pstTlv, final ByteBuf body) {
+ if (pstTlv.getPathSetupType() != null) {
+ serializeTlv(pstTlv.getPathSetupType(), body);
}
}
}
package org.opendaylight.protocol.pcep.lsp.setup.type01;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
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.rp.object.RpBuilder;
}
super.serializeTlvs(tlvs, body);
if (tlvs.getAugmentation(Tlvs1.class) != null) {
- final Tlvs1 nameTlvs = tlvs.getAugmentation(Tlvs1.class);
- if (nameTlvs.getPathSetupType() != null) {
- serializeTlv(nameTlvs.getPathSetupType(), body);
- }
+ serializePathSetupType(tlvs.getAugmentation(Tlvs1.class), body);
+ } else if(tlvs.getAugmentation(Tlvs2.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs2.class), body);
+ } else if(tlvs.getAugmentation(Tlvs3.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs3.class), body);
+ } else if(tlvs.getAugmentation(Tlvs4.class) != null) {
+ serializePathSetupType(tlvs.getAugmentation(Tlvs4.class), body);
+ }
+ }
+
+ private void serializePathSetupType(final PathSetupTypeTlv pstTlv, final ByteBuf body) {
+ if (pstTlv.getPathSetupType() != null) {
+ serializeTlv(pstTlv.getPathSetupType(), body);
}
}
}
import com.google.common.collect.Lists;
import java.util.List;
+import org.opendaylight.protocol.pcep.lsp.setup.type01.CInitiated00SrpObjectWithPstTlvParser;
import org.opendaylight.protocol.pcep.lsp.setup.type01.PathSetupTypeTlvParser;
+import org.opendaylight.protocol.pcep.lsp.setup.type01.PcepRpObjectWithPstTlvParser;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
+import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
+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.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
+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.types.rev131005.open.object.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActivator {
protected List<AutoCloseable> startImpl(PCEPExtensionProviderContext context) {
final List<AutoCloseable> regs = Lists.newArrayList();
+ /* Tlvs */
regs.add(context.registerTlvParser(SrPceCapabilityTlvParser.TYPE, new SrPceCapabilityTlvParser()));
regs.add(context.registerTlvSerializer(SrPceCapability.class, new SrPceCapabilityTlvParser()));
regs.add(context.registerTlvParser(PathSetupTypeTlvParser.TYPE, new PathSetupTypeTlvParser()));
regs.add(context.registerTlvSerializer(PathSetupType.class, new PathSetupTypeTlvParser()));
+
+ /* Subobjects */
+ regs.add(context.registerEROSubobjectParser(SrEroSubobjectParser.TYPE, new SrEroSubobjectParser()));
+ regs.add(context.registerEROSubobjectSerializer(SrEroType.class, new SrEroSubobjectParser()));
+
+ /* Objects */
+ final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
+ regs.add(context.registerObjectParser(CInitiated00SrpObjectWithPstTlvParser.CLASS, CInitiated00SrpObjectWithPstTlvParser.TYPE, new CInitiated00SrpObjectWithPstTlvParser(tlvReg)));
+ regs.add(context.registerObjectParser(PcepRpObjectWithPstTlvParser.CLASS, PcepRpObjectWithPstTlvParser.TYPE, new PcepRpObjectWithPstTlvParser(tlvReg)));
+ regs.add(context.registerObjectParser(PcepOpenObjectWithSpcTlvParser.CLASS, PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg)));
+
+ regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectWithPstTlvParser(tlvReg)));
+ regs.add(context.registerObjectSerializer(Rp.class, new PcepRpObjectWithPstTlvParser(tlvReg)));
+ regs.add(context.registerObjectSerializer(Open.class, new PcepOpenObjectWithSpcTlvParser(tlvReg)));
return regs;
}
}
--- /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.Preconditions;
+import com.google.common.primitives.UnsignedBytes;
+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.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 SID_LENGTH = 4;
+ private static final int FLAGS_OFFSET = 1;
+ private static final int HEADER_LENGTH = FLAGS_OFFSET + 1;
+ private static final int MINIMAL_LENGTH = SID_LENGTH + HEADER_LENGTH;
+
+ 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(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);
+ body.writeByte(UnsignedBytes.checkedCast(srEroSubobject.getSidType().getIntValue()) << 4);
+
+ final Flags flags = srEroSubobject.getFlags();
+ final BitSet bits = new BitSet();
+ 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());
+ body.writeByte(ByteArray.bitSetToBytes(bits, FLAGS_OFFSET)[0]);
+
+ if(srEroSubobject.getSid() != null) {
+ body.writeInt(srEroSubobject.getSid().intValue());
+ }
+
+ final Nai nai = srEroSubobject.getNai();
+ if(nai != null) {
+ switch (srEroSubobject.getSidType()) {
+ case Ipv4NodeId:
+ body.writeBytes(Ipv4Util.bytesForAddress(((IpNodeId)nai).getIpAddress().getIpv4Address()));
+ break;
+ case Ipv6NodeId:
+ body.writeBytes(Ipv6Util.bytesForAddress(((IpNodeId)nai).getIpAddress().getIpv6Address()));
+ break;
+ case Ipv4Adjacency:
+ body.writeBytes(Ipv4Util.bytesForAddress(((IpAdjacency)nai).getLocalIpAddress().getIpv4Address()));
+ body.writeBytes(Ipv4Util.bytesForAddress(((IpAdjacency)nai).getRemoteIpAddress().getIpv4Address()));
+ break;
+ case Ipv6Adjacency:
+ body.writeBytes(Ipv6Util.bytesForAddress(((IpAdjacency)nai).getLocalIpAddress().getIpv6Address()));
+ body.writeBytes(Ipv6Util.bytesForAddress(((IpAdjacency)nai).getRemoteIpAddress().getIpv6Address()));
+ break;
+ case Unnumbered:
+ final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency)nai;
+ body.writeInt(unnumbered.getLocalNodeId().intValue());
+ body.writeInt(unnumbered.getLocalInterfaceId().intValue());
+ body.writeInt(unnumbered.getRemoteNodeId().intValue());
+ body.writeInt(unnumbered.getRemoteInterfaceId().intValue());
+ break;
+ }
+ }
+ EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
+ }
+
+ @Override
+ public Subobject parseSubobject(ByteBuf buffer, 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() >> 4;
+ final SidType sidType = SidType.forValue(sidTypeByte);
+ srEroSubobjectBuilder.setSidType(sidType);
+
+ 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);
+
+ final long sid = buffer.readUnsignedInt();
+ srEroSubobjectBuilder.setSid(sid);
+ if(sidType != null) {
+ 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;
+ }
+ }
+ final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
+ subobjectBuilder.setLoose(loose);
+ subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
+ return subobjectBuilder.build();
+ }
+
+}
\ No newline at end of file
import odl-pcep-ietf-stateful07 { prefix stateful; revision-date 2013-12-22; }
import odl-pcep-ietf-initiated00 { prefix crabbe; revision-date 2013-11-26; }
import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+ import yang-ext { prefix ext; revision-date 2013-07-09; }
organization "Cisco Systems, Inc.";
contact "Milos Fabian <milfabia@cisco.com>";
augment "/msg:pcreq/msg:pcreq-message/msg:requests/msg:rp/msg:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-1;
}
augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:rp/msg:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-2;
}
augment "/msg:pcntf/msg:pcntf-message/msg:notifications/msg:rps/msg:rp/msg:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-3;
}
augment "/msg:pcerr/msg:pcerr-message/msg:error-type/msg:request-case/msg:request/msg:rps/msg:rp/msg:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-4;
}
augment "/crabbe:pcinitiate/crabbe:pcinitiate-message/crabbe:requests/crabbe:srp/crabbe:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-5;
}
augment "/stateful:pcupd/stateful:pcupd-message/stateful:updates/stateful:srp/stateful:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-6;
}
augment "/stateful:pcrpt/stateful:pcrpt-message/stateful:reports/stateful:srp/stateful:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-7;
}
augment "/msg:pcerr/msg:pcerr-message/msg:error-type/stateful:stateful-case/stateful:stateful/stateful:srps/stateful:srp/stateful:tlvs" {
reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
uses path-setup-type-tlv;
+ ext:augment-identifier tlvs-8;
}
}
\ No newline at end of file
import network-topology { prefix nt; revision-date 2013-10-21; }
import network-topology-pcep { prefix pn; revision-date 2013-10-24; }
import odl-pcep-lsp-setup-type01 { prefix lst01; revision-date 2014-05-07; }
+ 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>";
}
}
- grouping sr-ero-object {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3";
- container sr-ero {
- uses pcep:object;
- list subobject {
- order-by user;
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3.1";
- leaf loose {
- type boolean;
+ grouping sr-ero-subobject {
+ reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#section-5.3.1";
+ 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";
+ type uint32;
+ }
+
+ choice nai {
+ reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#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'";
+ description "IP Node ID";
+ leaf ip-address {
+ type inet:ip-address;
mandatory true;
}
- leaf sid-type {
- type sid-type;
+ }
+ case ip-adjacency {
+ when "../sid-type = 'ipv4-adjacency' or ../sid-type = 'ipv6-adjacency'";
+ description "IP Adjacency";
+ leaf local-ip-address {
+ type inet:ip-address;
+ mandatory true;
}
- leaf flags {
- type bits {
- bit m {
- position 31;
- }
- bit c {
- position 30;
- }
- bit s {
- position 29;
- }
- bit f {
- position 28;
- }
- }
+ leaf remote-ip-address {
+ type inet:ip-address;
mandatory true;
}
-
- leaf sid {
- description "Segment Identifier";
+ }
+ case unnumbered-adjacency {
+ when "../sid-type = 'unnumbered'";
+ description "Unnumbered Adjacency with IPv4 NodeIDs";
+ leaf local-node-id {
type uint32;
+ mandatory true;
}
-
- choice nai {
- reference "http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-02#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'";
- description "IP Node ID";
- leaf ip-address {
- type inet:ip-address;
- mandatory true;
- }
- }
- case ip-adjacency {
- when "../sid-type = 'ipv4-adjacency' or ../sid-type = 'ipv6-adjacency'";
- description "IP Adjacency";
- leaf local-ip-address {
- type inet:ip-address;
- mandatory true;
- }
- leaf remote-ip-address {
- type inet:ip-address;
- mandatory true;
- }
- }
- case unnumbered-adjacency {
- when "../sid-type = 'unnumbered'";
- description "Unnumbered Adjacency with IPv4 NodeIDs";
- leaf local-node-id {
- type uint32;
- mandatory true;
- }
- leaf local-interface-id {
- type uint32;
- mandatory true;
- }
- leaf remote-node-id {
- type uint32;
- mandatory true;
- }
- leaf remote-interface-id {
- type uint32;
- mandatory true;
- }
- }
+ leaf local-interface-id {
+ type uint32;
+ mandatory true;
+ }
+ leaf remote-node-id {
+ type uint32;
+ mandatory true;
+ }
+ leaf remote-interface-id {
+ type uint32;
+ mandatory true;
}
}
}
}
- augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:result/msg:success-case/msg:success/msg:paths" {
+ 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";
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
+ }
}
//stateful07
- augment "/crabbe:pcinitiate/crabbe:pcinitiate-message/crabbe:requests" {
+ 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";
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
+ }
}
- augment "/stateful:pcrpt/stateful:pcrpt-message/stateful:reports" {
+ 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";
- container sr-te-path {
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
}
}
- augment "/stateful:pcupd/stateful:pcupd-message/stateful:updates" {
+ 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";
- container sr-te-path {
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
}
}
//nt-pcep
- augment "/pn:add-lsp/pn:input/pn:arguments" {
+ 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";
- container sr-te-path {
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
}
}
- augment "/pn:update-lsp/pn:input/pn:arguments" {
+ 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";
- container sr-te-path {
- uses sr-ero-object;
+ 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" {
+ 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";
- uses sr-ero-object;
+ case sr-ero-type {
+ uses sr-ero-subobject;
+ }
}
}
\ No newline at end of file
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.segment.routing02.SegmentRoutingActivator;
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.lsp.setup.type._01.rev140507.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
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.rp.object.RpBuilder;
final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
assertEquals(builder.build(),
parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
- ByteBuf buf = Unpooled.buffer();
+ final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(rpObjectWithPstTlvBytes,ByteArray.getAllBytes(buf));
}
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().addAugmentation(Tlvs8.class,
- new Tlvs8Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().addAugmentation(Tlvs7.class,
+ new Tlvs7Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
.build());
final ByteBuf result = Unpooled.wrappedBuffer(srpObjectWithPstTlvBytes);
assertEquals(builder.build(),
parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
- ByteBuf buf = Unpooled.buffer();
+ final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(srpObjectWithPstTlvBytes,ByteArray.getAllBytes(buf));
}
+++ /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 io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.protocol.util.ByteArray;
-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.types.rev131005.ProtocolVersion;
-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;
-
-public class PcepObjectParserTest {
-
- private static final byte[] openObjectBytes = { 0x01, 0x10, 0x00, 0x10, 0x20, 0x1e, 0x78, 0x01,
- /* sr-capability-tlv */
- 0x0, 0x1a, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
-
- private TlvRegistry tlvRegistry;
-
- private SimplePCEPExtensionProviderContext ctx;
- private SegmentRoutingActivator act;
-
- @Before
- public void setUp() {
- this.ctx = new SimplePCEPExtensionProviderContext();
- this.act = new SegmentRoutingActivator();
- this.act.start(this.ctx);
- this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
- }
-
- @Test
- public void testOpenObjectWithSpcTlv() throws PCEPDeserializerException {
- final PcepOpenObjectWithSpcTlvParser parser = new PcepOpenObjectWithSpcTlvParser(this.tlvRegistry);
-
- final OpenBuilder builder = new OpenBuilder();
- builder.setProcessingRule(false);
- builder.setIgnore(false);
- builder.setVersion(new ProtocolVersion((short) 1));
- builder.setKeepalive((short) 30);
- builder.setDeadTimer((short) 120);
- builder.setSessionId((short) 1);
-
- Tlvs1 tlv = new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 1).build())
- .build();
- builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class, tlv).build());
-
- final ByteBuf result = Unpooled.wrappedBuffer(openObjectBytes);
- assertEquals(builder.build(),
- parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
- ByteBuf buf = Unpooled.buffer();
- parser.serializeObject(builder.build(), buf);
- assertArrayEquals(openObjectBytes,ByteArray.getAllBytes(buf));
- }
-
-}
--- /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 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._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.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
+
+public class SrEroSubobjectParserTest {
+
+ private static final byte[] srEroSubobjectWithIpv4NodeID = {
+ 0x05,0x0c,(byte) 0x10,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+
+ private static final byte[] srEroSubobjectWithIpv6NodeID = {
+ 0x05,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[] srEroSubobjectWithIpv4Adjacency = {
+ 0x05,0x10,(byte) 0x30,0x00,
+ 0x00,0x01,(byte) 0xe2,0x40,
+ 0x4A,0x7D,0x2b,0x63,
+ 0x4A,0x7D,0x2b,0x64,
+ };
+
+ private static final byte[] srEroSubobjectWithIpv6Adjacency = {
+ 0x05,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[] srEroSubobjectWithUnnumbered = {
+ 0x05,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 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 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.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(srEroSubobjectWithIpv4NodeID, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithIpv4NodeID, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ 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.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6NodeID, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ 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.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);
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv4Adjacency, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithIpv4Adjacency, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ 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.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);
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6Adjacency, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithIpv6Adjacency, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ 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.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
+
+ assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithUnnumbered, 2)), false));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeSubobject(subobjBuilder.build(), buffer);
+ assertArrayEquals(srEroSubobjectWithUnnumbered, 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.routing02;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import com.google.common.collect.Lists;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+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.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.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;
+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.open.object.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+public class SrObjectParserTest {
+
+ private static final byte[] openObjectBytes = {
+ 0x01,0x10,0x00,0x10,
+ 0x20,0x1e,0x78,0x01,
+ /* sr-capability-tlv */
+ 0x00,0x1a,0x00,0x04,
+ 0x00,0x00,0x00,0x01};
+
+ private static final byte[] srEroObjectBytes = {
+ 0x07,0x10,0x00,0x10,
+ /* ero-subobject */
+ 0x05,0x0c,(byte) 0x10,0x00,
+ 0x00,0x01,(byte)0xe2,0x40,
+ 0x4A,0x7D,0x2b,0x63,
+ };
+
+ private TlvRegistry tlvRegistry;
+
+ private SimplePCEPExtensionProviderContext ctx;
+ private SegmentRoutingActivator act;
+
+ @Before
+ public void setUp() {
+ this.ctx = new SimplePCEPExtensionProviderContext();
+ this.act = new SegmentRoutingActivator();
+ this.act.start(this.ctx);
+ this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
+ }
+
+ @Test
+ public void testOpenObjectWithSpcTlv() throws PCEPDeserializerException {
+ final PcepOpenObjectWithSpcTlvParser parser = new PcepOpenObjectWithSpcTlvParser(tlvRegistry);
+
+ final OpenBuilder builder = new OpenBuilder();
+ builder.setProcessingRule(false);
+ builder.setIgnore(false);
+ builder.setVersion(new ProtocolVersion((short) 1));
+ builder.setKeepalive((short) 30);
+ builder.setDeadTimer((short) 120);
+ builder.setSessionId((short) 1);
+
+ final Tlvs1 tlv = new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 1).build())
+ .build();
+ builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class, tlv).build());
+
+ final ByteBuf result = Unpooled.wrappedBuffer(openObjectBytes);
+ assertEquals(builder.build(),
+ parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeObject(builder.build(), buffer);
+ assertArrayEquals(openObjectBytes, ByteArray.getAllBytes(buffer));
+ }
+
+ @Test
+ public void testSrEroObjectWithSubobjects() throws PCEPDeserializerException {
+ final PCEPExplicitRouteObjectParser parser = new PCEPExplicitRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+
+ final EroBuilder builder = new EroBuilder();
+ builder.setProcessingRule(false);
+ builder.setIgnore(false);
+ final List<Subobject> subobjects = Lists.newArrayList();
+
+ final SrEroTypeBuilder srEroSubBuilder = new SrEroTypeBuilder();
+ srEroSubBuilder.setFlags(new Flags(false, false, false, false));
+ srEroSubBuilder.setSidType(SidType.Ipv4NodeId);
+ srEroSubBuilder.setSid(123456L);
+ srEroSubBuilder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
+ final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroSubBuilder.build()).setLoose(false);
+ subobjects.add(subobjBuilder.build());
+
+ builder.setSubobject(subobjects);
+
+ final ByteBuf result = Unpooled.wrappedBuffer(srEroObjectBytes);
+ assertEquals(builder.build(),
+ parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
+ final ByteBuf buffer = Unpooled.buffer();
+ parser.serializeObject(builder.build(), buffer);
+ assertArrayEquals(srEroObjectBytes, ByteArray.getAllBytes(buffer));
+ }
+
+}
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;
-public class PcepTlvParserTest {
+public class SrTlvParserTest {
private static final byte[] spcTlvBytes = { 0x0, 0x1a, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };