description "Stateful PCE Capability TLV";
reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.1";
- uses tlv;
- leaf flags {
- type bits {
- bit lsp-update-capability {
- position 31;
- }
- bit include-db-version {
- position 30;
- }
- bit initiation {
- position 29;
+ container stateful {
+ uses tlv;
+ leaf flags {
+ type bits {
+ bit lsp-update-capability {
+ position 31;
+ }
+ bit include-db-version {
+ position 30;
+ }
+ bit initiation {
+ position 29;
+ }
}
+ mandatory true;
}
- mandatory true;
}
}
description "LSP State Database Version TLV";
reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.2";
- uses tlv;
- leaf version {
- type uint64;
- mandatory true;
+ container lsp-db-version {
+ uses tlv;
+ leaf version {
+ type uint64;
+ mandatory true;
+ }
}
}
description "PCE Redundancy Group Identifier TLV";
reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.3";
- uses tlv;
- leaf identifier {
- type binary;
- mandatory true;
+ container predundancy-group-id {
+ uses tlv;
+ leaf identifier {
+ type binary;
+ mandatory true;
+ }
}
}
grouping of-list-tlv {
description "OF-List TLV";
reference "https://tools.ietf.org/html/rfc5541#section-2.1";
-
- uses tlv;
- leaf-list codes {
- type of-id;
+ container of-list {
+ uses tlv;
+ leaf-list codes {
+ type of-id;
+ }
}
}
uses object;
container "tlvs" {
- container of-list {
- uses of-list-tlv;
- }
- container stateful {
- uses stateful-capability-tlv;
- }
+ uses of-list-tlv;
+
+ uses stateful-capability-tlv;
- container predundancy-group-id {
- uses predundancy-group-id-tlv;
- }
+ uses predundancy-group-id-tlv;
- container lsp-db-version {
- uses lsp-db-version-tlv;
- }
+ uses lsp-db-version-tlv;
}
leaf version {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcreqMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.no.path.tlvs.NoPathVector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.RsvpErrorSpec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
context.registerTlvSerializer(NoPathVector.class, new NoPathVectorTlvParser());
context.registerTlvSerializer(OverloadDuration.class, new OverloadedDurationTlvParser());
context.registerTlvSerializer(ReqMissing.class, new ReqMissingTlvParser());
- context.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
+ context.registerTlvSerializer(OfList.class, new OFListTlvParser());
context.registerTlvSerializer(Order.class, new OrderTlvParser());
- context.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
+ context.registerTlvSerializer(Stateful.class, new PCEStatefulCapabilityTlvParser());
context.registerTlvSerializer(SymbolicPathName.class, new LspSymbolicNameTlvParser());
context.registerTlvSerializer(LspIdentifiers.class, new LSPIdentifierTlvParser());
context.registerTlvSerializer(LspErrorCode.class, new LspUpdateErrorTlvParser());
context.registerTlvSerializer(RsvpErrorSpec.class, new RSVPErrorSpecTlvParser());
- context.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
- context.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
+ context.registerTlvSerializer(LspDbVersion.class, new LspDbVersionTlvParser());
+ context.registerTlvSerializer(PredundancyGroupId.class, new PredundancyGroupTlvParser());
final ObjectHandlerRegistry objReg = context.getObjectHandlerRegistry();
context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(tlvReg));
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
public class PCEPSessionProposalFactoryImpl implements PCEPSessionProposalFactory {
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
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.ObjectHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
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.StatefulCapabilityTlv;
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.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.LspDbVersionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.OfListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
import com.google.common.primitives.UnsignedBytes;
* Parser for {@link OpenObject}
*/
-public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuilder> {
+public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 1;
/*
* lengths of fields in bytes
*/
- public static final int VER_FLAGS_MF_LENGTH = 1; // multi-field
- public static final int KEEPALIVE_F_LENGTH = 1;
- public static final int DEAD_TIMER_LENGTH = 1;
- public static final int SID_F_LENGTH = 1;
+ private static final int VER_FLAGS_MF_LENGTH = 1;
+ private static final int KEEPALIVE_F_LENGTH = 1;
+ private static final int DEAD_TIMER_LENGTH = 1;
+ private static final int SID_F_LENGTH = 1;
/*
* lengths of subfields inside multi-field in bits
*/
- public static final int VERSION_SF_LENGTH = 3;
- public static final int FLAGS_SF_LENGTH = 5;
+ private static final int VERSION_SF_LENGTH = 3;
/*
* offsets of field in bytes
*/
-
- public static final int VER_FLAGS_MF_OFFSET = 0;
- public static final int KEEPALIVE_F_OFFSET = VER_FLAGS_MF_OFFSET + VER_FLAGS_MF_LENGTH;
- public static final int DEAD_TIMER_OFFSET = KEEPALIVE_F_OFFSET + KEEPALIVE_F_LENGTH;
- public static final int SID_F_OFFSET = DEAD_TIMER_OFFSET + DEAD_TIMER_LENGTH;
- public static final int TLVS_OFFSET = SID_F_OFFSET + SID_F_LENGTH;
+ private static final int VER_FLAGS_MF_OFFSET = 0;
+ private static final int KEEPALIVE_F_OFFSET = VER_FLAGS_MF_OFFSET + VER_FLAGS_MF_LENGTH;
+ private static final int DEAD_TIMER_OFFSET = KEEPALIVE_F_OFFSET + KEEPALIVE_F_LENGTH;
+ private static final int SID_F_OFFSET = DEAD_TIMER_OFFSET + DEAD_TIMER_LENGTH;
+ private static final int TLVS_OFFSET = SID_F_OFFSET + SID_F_LENGTH;
/*
* offsets of subfields inside multi-field in bits
*/
-
- public static final int VERSION_SF_OFFSET = 0;
- public static final int FLAGS_SF_OFFSET = VERSION_SF_LENGTH + VERSION_SF_OFFSET;
+ private static final int VERSION_SF_OFFSET = 0;
private static final int PCEP_VERSION = 1;
if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
}
-
final int versionValue = ByteArray.copyBitsRange(bytes[VER_FLAGS_MF_OFFSET], VERSION_SF_OFFSET, VERSION_SF_LENGTH);
if (versionValue != PCEP_VERSION) {
throw new PCEPDocumentedException("Unsupported PCEP version " + versionValue, PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
}
-
final OpenBuilder builder = new OpenBuilder();
-
- parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
-
builder.setVersion(new ProtocolVersion((short) versionValue));
builder.setProcessingRule(header.isProcessingRule());
builder.setIgnore(header.isIgnore());
builder.setDeadTimer((short) UnsignedBytes.toInt(bytes[DEAD_TIMER_OFFSET]));
builder.setKeepalive((short) UnsignedBytes.toInt(bytes[KEEPALIVE_F_OFFSET]));
builder.setSessionId((short) UnsignedBytes.toInt(bytes[SID_F_OFFSET]));
+
+ final TlvsBuilder tbuilder = new TlvsBuilder();
+ parseTlvs(tbuilder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
+ builder.setTlvs(tbuilder.build());
return builder.build();
}
@Override
- public void addTlv(final OpenBuilder builder, final Tlv tlv) {
- final TlvsBuilder tbuilder = new TlvsBuilder();
- if (tlv instanceof OfListTlv) {
- tbuilder.setOfList(new OfListBuilder().setCodes(((OfListTlv) tlv).getCodes()).build());
- } else if (tlv instanceof StatefulCapabilityTlv) {
- tbuilder.setStateful(new StatefulBuilder().setFlags(((StatefulCapabilityTlv) tlv).getFlags()).build());
- } else if (tlv instanceof PredundancyGroupIdTlv) {
- tbuilder.setPredundancyGroupId(new PredundancyGroupIdBuilder().setIdentifier(((PredundancyGroupIdTlv) tlv).getIdentifier()).build());
- } else if (tlv instanceof LspDbVersionTlv) {
- tbuilder.setLspDbVersion(new LspDbVersionBuilder().build());
+ public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
+ if (tlv instanceof OfList) {
+ tbuilder.setOfList((OfList) tlv);
+ } else if (tlv instanceof Stateful) {
+ tbuilder.setStateful((Stateful) tlv);
+ } else if (tlv instanceof PredundancyGroupId) {
+ tbuilder.setPredundancyGroupId((PredundancyGroupId) tlv);
+ } else if (tlv instanceof LspDbVersion) {
+ tbuilder.setLspDbVersion((LspDbVersion) tlv);
}
- builder.setTlvs(tbuilder.build());
}
@Override
final byte[] bytes = new byte[TLVS_OFFSET + tlvs.length + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
bytes[VER_FLAGS_MF_OFFSET] = versionFlagMF;
- bytes[KEEPALIVE_F_OFFSET] = ByteArray.shortToBytes(open.getKeepalive())[1];
- bytes[DEAD_TIMER_OFFSET] = ByteArray.shortToBytes(open.getDeadTimer())[1];
- bytes[SID_F_OFFSET] = ByteArray.shortToBytes(open.getSessionId())[1];
- ByteArray.copyWhole(tlvs, bytes, TLVS_OFFSET);
-
+ bytes[KEEPALIVE_F_OFFSET] = UnsignedBytes.checkedCast(open.getKeepalive());
+ bytes[DEAD_TIMER_OFFSET] = UnsignedBytes.checkedCast(open.getDeadTimer());
+ bytes[SID_F_OFFSET] = UnsignedBytes.checkedCast(open.getSessionId());
+ if (tlvs.length != 0) {
+ ByteArray.copyWhole(tlvs, bytes, TLVS_OFFSET);
+ }
return bytes;
}
public byte[] serializeTlvs(final Tlvs tlvs) {
+ if (tlvs == null) {
+ return new byte[0];
+ }
int finalLength = 0;
+ byte[] ofListBytes = null;
+ byte[] statefulBytes = null;
+ byte[] predundancyBytes = null;
+ byte[] lspDbBytes = null;
+ if (tlvs.getOfList() != null) {
+ ofListBytes = serializeTlv(tlvs.getOfList());
+ finalLength += ofListBytes.length;
+ }
+ if (tlvs.getStateful() != null) {
+ statefulBytes = serializeTlv(tlvs.getStateful());
+ finalLength += statefulBytes.length;
+ }
+ if (tlvs.getPredundancyGroupId() != null) {
+ predundancyBytes = serializeTlv(tlvs.getPredundancyGroupId());
+ finalLength += predundancyBytes.length;
+ }
if (tlvs.getLspDbVersion() != null) {
- final byte[] lspDbBytes = serializeTlv(new LspDbVersionBuilder().setVersion(tlvs.getLspDbVersion().getVersion()).build());
- finalLength = lspDbBytes.length;
+ lspDbBytes = serializeTlv(tlvs.getLspDbVersion());
+ finalLength += lspDbBytes.length;
}
- if (tlvs.getOfList() != null) {
- final byte[] ofListBytes = serializeTlv(new OfListBuilder().setCodes(tlvs.getOfList().getCodes()).build());
- finalLength = ofListBytes.length;
+ int offset = 0;
+ final byte[] result = new byte[finalLength];
+ if (ofListBytes != null) {
+ ByteArray.copyWhole(ofListBytes, result, offset);
+ offset += ofListBytes.length;
}
-
- // FIXME: finish
-
- final byte[] bytes = new byte[finalLength];
-
- // FIXME copy result bytes
- return bytes;
+ if (statefulBytes != null) {
+ ByteArray.copyWhole(statefulBytes, result, offset);
+ offset += statefulBytes.length;
+ }
+ if (lspDbBytes != null) {
+ ByteArray.copyWhole(lspDbBytes, result, offset);
+ offset += lspDbBytes.length;
+ }
+ if (predundancyBytes != null) {
+ ByteArray.copyWhole(predundancyBytes, result, offset);
+ offset += predundancyBytes.length;
+ }
+ return result;
}
@Override
package org.opendaylight.protocol.pcep.impl.tlv;
import java.math.BigInteger;
+import java.util.Arrays;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
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.tlvs.LspDbVersionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersionBuilder;
/**
- * Parser for {@link LspDbVersionTlv}
+ * Parser for {@link LspDbVersion}
*/
public class LspDbVersionTlvParser implements TlvParser, TlvSerializer {
private static final int DBV_F_LENGTH = 8;
@Override
- public LspDbVersionTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+ public LspDbVersion parseTlv(final byte[] buffer) throws PCEPDeserializerException {
return new LspDbVersionBuilder().setVersion(BigInteger.valueOf(ByteArray.bytesToLong(ByteArray.subByte(buffer, 0, DBV_F_LENGTH)))).build();
}
if (tlv == null) {
throw new IllegalArgumentException("LspDbVersionTlv is mandatory.");
}
- final LspDbVersionTlv lsp = (LspDbVersionTlv) tlv;
- return ByteArray.subByte(lsp.getVersion().toByteArray(), 0, DBV_F_LENGTH);
+ final LspDbVersion lsp = (LspDbVersion) tlv;
+ final byte[] array = lsp.getVersion().toByteArray();
+ if (array.length > DBV_F_LENGTH) {
+ throw new IllegalArgumentException("LspDBVersion too big.");
+ }
+ final byte[] result = new byte[DBV_F_LENGTH];
+ Arrays.fill(result, (byte) 0);
+ int j = 7;
+ for (int i = array.length - 1; i >= 0; i--) {
+ result[j] |= array[i];
+ j--;
+ }
+ return result;
}
@Override
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
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.tlvs.OfListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfListBuilder;
import com.google.common.collect.Lists;
/**
- * Parser for {@link OfListTlv}
+ * Parser for {@link OfList}
*/
public class OFListTlvParser implements TlvParser, TlvSerializer {
private static final int OF_CODE_ELEMENT_LENGTH = 2;
@Override
- public OfListTlv parseTlv(final byte[] valueBytes) throws PCEPDeserializerException {
+ public OfList parseTlv(final byte[] valueBytes) throws PCEPDeserializerException {
if (valueBytes == null || valueBytes.length == 0) {
throw new IllegalArgumentException("Value bytes array is mandatory. Can't be null or empty.");
}
if (tlv == null) {
throw new IllegalArgumentException("OFListTlv is mandatory.");
}
- final OfListTlv oft = (OfListTlv) tlv;
+ final OfList oft = (OfList) tlv;
final List<OfId> ofCodes = oft.getCodes();
final byte[] retBytes = new byte[ofCodes.size() * OF_CODE_ELEMENT_LENGTH];
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
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.tlvs.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
/**
- * Parser for {@link StatefulCapabilityTlv}
+ * Parser for {@link Stateful}
*/
public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSerializer {
private static final int U_FLAG_OFFSET = 31;
@Override
- public StatefulCapabilityTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+ public Stateful parseTlv(final byte[] buffer) throws PCEPDeserializerException {
if (buffer == null || buffer.length == 0) {
throw new IllegalArgumentException("Value bytes array is mandatory. Can't be null or empty.");
}
if (tlv == null) {
throw new IllegalArgumentException("StatefulCapabilityTlv is mandatory.");
}
- final StatefulCapabilityTlv sct = (StatefulCapabilityTlv) tlv;
+ final Stateful sct = (Stateful) tlv;
final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
flags.set(I_FLAG_OFFSET, sct.getFlags().isInitiation());
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
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.tlvs.PredundancyGroupIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
/**
- * Parser for {@link PredundancyGroupIdTlv}
+ * Parser for {@link PredundancyGroupId}
*/
public class PredundancyGroupTlvParser implements TlvParser, TlvSerializer {
public static final int TYPE = 24;
@Override
- public PredundancyGroupIdTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+ public PredundancyGroupId parseTlv(final byte[] buffer) throws PCEPDeserializerException {
return new PredundancyGroupIdBuilder().setIdentifier(buffer).build();
}
@Override
public byte[] serializeTlv(final Tlv tlv) {
- if (tlv == null)
+ if (tlv == null) {
throw new IllegalArgumentException("PredundancyGroupIdTlv is mandatory.");
- final PredundancyGroupIdTlv pgt = (PredundancyGroupIdTlv) tlv;
+ }
+ final PredundancyGroupId pgt = (PredundancyGroupId) tlv;
return pgt.getIdentifier();
}
import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import java.math.BigInteger;
import java.util.List;
import org.junit.Before;
import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OperationalStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PlspId;
+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.RequestId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpIdNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.c.close.message.CCloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.ClassTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.LspaBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.OfBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.reported.route.BandwidthBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.GcBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.MetricBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
this.tlvRegistry = PCEPExtensionProviderContextImpl.create().getTlvHandlerRegistry();
}
- // @Test
- // @Ignore
- // // FIXME: temporary
- // public void testObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
- // }
+ @Test
+ public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+ final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
+ final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin");
+
+ 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 Stateful tlv1 = new StatefulBuilder().setFlags(new Flags(true, false, true)).build();
+ final LspDbVersion tlv2 = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0x80L)).build();
+ final byte[] predundancyBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde,
+ (byte) 0xf0 };
+ final PredundancyGroupId tlv3 = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
+
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder().setStateful(
+ tlv1).setPredundancyGroupId(tlv3).setLspDbVersion(tlv2).build());
+
+ assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result));
+ assertArrayEquals(result, parser.serializeObject(builder.build()));
+ }
@Test
public void testCloseObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
assertArrayEquals(result, parser.serializeObject(builder.build()));
}
- //
- // /**
- // * Standard ser deser test<br/>
- // * used resources:<br/>
- // * - PCEPOpenObject1.bin
- // *
- // * @throws PCEPDeserializerException
- // * @throws IOException
- // * @throws PCEPDocumentedException
- // */
- // @Test
- // @Ignore
- // // FIXME: temporary
- // public void testOpenObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
- // // tlvs.add(new PCEStatefulCapabilityTlv(false, true, true));
- // // tlvs.add(new LSPStateDBVersionTlv(0x80));
- // // final byte[] valueBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC,
- // (byte) 0xDE, (byte) 0xF0 };
- // // tlvs.add(new NodeIdentifierTlv(valueBytes));
- // // final PCEPOpenObject specObject = new PCEPOpenObject(30, 120, 1, tlvs);
- // //
- // // serDeserTest("src/test/resources/PCEPOpenObject1.bin", specObject);
- // }
- //
- // /**
- // * Specific test for upper bounds and without tlvs<br/>
- // * Used resources:<br/>
- // * - PCEPOpenObject2UpperBoundsNoTlv.bin
- // *
- // * @throws PCEPDeserializerException
- // * @throws IOException
- // * @throws PCEPDocumentedException
- // */
- // @Test
- // public void testOpenObjectBoundsWithoutTlvs() throws IOException, PCEPDeserializerException,
- // PCEPDocumentedException {
- // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
- // // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
- // tlvs));
- // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
- // null));
- // }
- //
-
@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry);
assertArrayEquals(result, parser.serializeObject(builder.build()));
}
- // // FIXME: add at least one test with true value
- // @Test
- // public void openObjectWithTlv() throws PCEPDeserializerException, PCEPDocumentedException {
- // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, false));
- // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, true));
- // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, false));
- // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, true));
- // }
- //
- // // private void testOpenObjectWithSpecTlv(final PCEPTlv tlv) throws PCEPDeserializerException,
- // PCEPDocumentedException {
- // // final List<PCEPObject> objs = new ArrayList<PCEPObject>();
- // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
- // // tlvs.add(tlv);
- // // final PCEPOpenObject oo = new PCEPOpenObject(30, 120, 0, tlvs);
- // // objs.add(oo);
- // // final byte[] bytes = PCEPObjectFactory.put(objs);
- // // final PCEPObject obj = PCEPObjectFactory.parseObjects(bytes).get(0);
- // // assertEquals(oo, obj);
- // // }
- //
- // @Test
- // public void testErrorsMapping() {
- // final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping.getInstance();
- //
- // for (final PCEPErrors error : PCEPErrors.values()) {
- // final PCEPErrorIdentifier errorId = mapper.getFromErrorsEnum(error);
- // assertEquals(error, mapper.getFromErrorIdentifier(errorId));
- // }
- // }
- //
- // @Test
- // public void testSERObjects() throws PCEPDocumentedException, PCEPDeserializerException {
- // final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
- // eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
- // (byte) 168, 1, 8 }), 16), false));
- // eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 192,
- // (byte) 168, 2, 1,
- // (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
- //
- // serDeserTestWithoutBin(new PCEPSecondaryExplicitRouteObject(eroSubobjects, true, false));
- // }
- //
- // @Test
- // public void testSRRObject() throws PCEPDocumentedException, PCEPDeserializerException {
- // final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>();
- // rroSubobjects.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(this.ipv4addr, 16), true, false));
- // rroSubobjects.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(this.ipv6addr, 64), false, true));
- //
- // serDeserTestWithoutBin(new PCEPSecondaryRecordRouteObject(rroSubobjects, true, false));
- // }
}
import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
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.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.LspDbVersionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.OfListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.no.path.tlvs.NoPathVectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.RsvpErrorSpec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp.RsvpErrorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user.UserErrorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.Ipv4ExtendedTunnelId;
@Test
public void testStatefulTlv() throws PCEPDeserializerException {
final PCEStatefulCapabilityTlvParser parser = new PCEStatefulCapabilityTlvParser();
- final StatefulCapabilityTlv tlv = new StatefulBuilder().setFlags(new Flags(true, false, false)).build();
+ final Stateful tlv = new StatefulBuilder().setFlags(new Flags(true, false, false)).build();
assertEquals(tlv, parser.parseTlv(statefulBytes));
assertArrayEquals(statefulBytes, parser.serializeTlv(tlv));
}
@Test
public void testStateDbVersionTlv() throws PCEPDeserializerException {
final LspDbVersionTlvParser parser = new LspDbVersionTlvParser();
- final LspDbVersionTlv tlv = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0xFF00FFAAB2F5F2CFL)).build();
+ final LspDbVersion tlv = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0xFF00FFAAB2F5F2CFL)).build();
assertEquals(tlv, parser.parseTlv(DbVersionBytes));
assertArrayEquals(DbVersionBytes, parser.serializeTlv(tlv));
}
final List<OfId> ids = Lists.newArrayList();
ids.add(new OfId(0x1234));
ids.add(new OfId(0x5678));
- final OfListTlv tlv = new OfListBuilder().setCodes(ids).build();
+ final OfList tlv = new OfListBuilder().setCodes(ids).build();
assertEquals(tlv, parser.parseTlv(ofListBytes));
assertArrayEquals(ofListBytes, parser.serializeTlv(tlv));
}
@Test
public void testPredundancyTlv() throws PCEPDeserializerException {
final PredundancyGroupTlvParser parser = new PredundancyGroupTlvParser();
- final PredundancyGroupIdTlv tlv = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
+ final PredundancyGroupId tlv = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
assertEquals(tlv, parser.parseTlv(predundancyBytes));
assertArrayEquals(predundancyBytes, parser.serializeTlv(tlv));
}
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.open.message.open.message.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
import com.google.common.base.Preconditions;
final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new OpenBuilder().setKeepalive(
(short) 30).setDeadTimer((short) 120).setSessionId((short) 0).setTlvs(builder.build()).build(), 0);
- final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf,
- new PCEPHandlerFactory(PCEPExtensionProviderContextImpl.getSingletonInstance().getMessageHandlerRegistry()),
- new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+ final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(PCEPExtensionProviderContextImpl.getSingletonInstance().getMessageHandlerRegistry()), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
new SessionListenerFactory<PCEPSessionListener>() {
- @Override
- public PCEPSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- }).get();
+ @Override
+ public PCEPSessionListener getSessionListener() {
+ return new SimpleSessionListener();
+ }
+ }).get();
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PlspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.Stateful;
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.pcrpt.message.pcrpt.message.Reports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.pcrpt.message.reports.Lsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PccBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.pcc.Lsps;
final Stateful stateful = tlvs.getStateful();
if (stateful != null) {
// FIXME: rework once groupings can be used in builders
- ServerSessionManager.this.pccBuilder.setStatefulTlv(new StatefulTlvBuilder().setFlags(tlvs.getStateful().getFlags()).build());
+ ServerSessionManager.this.pccBuilder.setStatefulTlv(new StatefulTlvBuilder().setStateful(stateful).build());
ServerSessionManager.this.pccBuilder.setStateSync(PccSyncState.InitialResync);
}