grouping overload-duration-tlv {
description "OVERLOAD-DURATION TLV";
reference "https://tools.ietf.org/html/rfc5440#section-7.14";
-
- uses tlv;
- leaf duration {
- type uint32;
- units seconds;
+ container overload-duration {
+ uses tlv;
+ leaf duration {
+ type uint32;
+ units seconds;
+ }
}
}
grouping req-missing-tlv {
description "REQ-MISSING TLV";
reference "https://tools.ietf.org/html/rfc5440#section-7.5";
-
- uses tlv;
- leaf request-id {
- type request-id;
+ container req-missing {
+ uses tlv;
+ leaf request-id {
+ type request-id;
+ }
}
}
uses object;
container "tlvs" {
- container overload-duration {
- when "../type = 2 and ../value = 1";
+ when "../type = 2 and ../value = 1";
- uses overload-duration-tlv;
- }
+ uses overload-duration-tlv;
}
leaf type {
uses object;
container "tlvs" {
- container req-missing {
- when "../type = 7";
- uses req-missing-tlv;
- }
+ when "../type = 7";
+ uses req-missing-tlv;
}
leaf type {
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.OrderTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeySubobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
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.ReqMissingTlv;
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.RsvpErrorSpecTlv;
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.SymbolicPathNameTlv;
+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.req.missing.tlv.ReqMissing;
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;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LabelSubobject;
context.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
context.registerTlvSerializer(NoPathVectorTlv.class, new NoPathVectorTlvParser());
- context.registerTlvSerializer(OverloadDurationTlv.class, new OverloadedDurationTlvParser());
- context.registerTlvSerializer(ReqMissingTlv.class, new ReqMissingTlvParser());
+ context.registerTlvSerializer(OverloadDuration.class, new OverloadedDurationTlvParser());
+ context.registerTlvSerializer(ReqMissing.class, new ReqMissingTlvParser());
context.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
context.registerTlvSerializer(OrderTlv.class, new OrderTlvParser());
context.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_LENGTH_F_LENGTH));
byteOffset += TLV_LENGTH_F_LENGTH;
- if (TLV_HEADER_LENGTH + length > bytes.length - byteOffset) {
+ if (TLV_HEADER_LENGTH + length > bytes.length) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + (TLV_HEADER_LENGTH + length) + "; Expected: <= "
+ (bytes.length - byteOffset) + ".");
}
logger.trace("Attempt to parse tlv from bytes: {}", ByteArray.bytesToHexString(tlvBytes));
final Tlv tlv = this.tlvReg.getTlvParser(type).parseTlv(tlvBytes);
- logger.trace("Tlv was parsed. {}", tlv);
+ logger.debug("Tlv was parsed. {}", tlv);
addTlv(builder, tlv);
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.PcepErrorObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
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.pcep.error.object.Tlvs;
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.pcep.error.object.tlvs.ReqMissingBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
+
+import com.google.common.primitives.UnsignedBytes;
/**
* Parser for {@link org.opendaylight.protocol.pcep.object.PCEPErrorObject PCEPErrorObject}
public static final int TYPE = 1;
- public static final int FLAGS_F_LENGTH = 1;
- public static final int ET_F_LENGTH = 1;
- public static final int EV_F_LENGTH = 1;
+ private static final int FLAGS_F_LENGTH = 1;
+ private static final int ET_F_LENGTH = 1;
+ private static final int EV_F_LENGTH = 1;
- public static final int FLAGS_F_OFFSET = 1; // added reserved field of size 1 byte
- public static final int ET_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
- public static final int EV_F_OFFSET = ET_F_OFFSET + ET_F_LENGTH;
- public static final int TLVS_OFFSET = EV_F_OFFSET + EV_F_LENGTH;
+ private static final int FLAGS_F_OFFSET = 1;
+ private static final int ET_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
+ private static final int EV_F_OFFSET = ET_F_OFFSET + ET_F_LENGTH;
+ private static final int TLVS_OFFSET = EV_F_OFFSET + EV_F_LENGTH;
public PCEPErrorObjectParser(final TlvHandlerRegistry tlvReg) {
super(tlvReg);
}
final ErrorsBuilder builder = new ErrorsBuilder();
-
- parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
-
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
-
- builder.setType((short) (bytes[ET_F_OFFSET] & 0xFF));
- builder.setValue((short) (bytes[EV_F_OFFSET] & 0xFF));
-
+ builder.setType((short) UnsignedBytes.toInt(bytes[ET_F_OFFSET]));
+ builder.setValue((short) UnsignedBytes.toInt(bytes[EV_F_OFFSET]));
+ parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
return builder.build();
}
@Override
public void addTlv(final ErrorsBuilder builder, final Tlv tlv) {
- if (tlv instanceof ReqMissingTlv && builder.getType() == 7) {
- builder.setTlvs(new TlvsBuilder().setReqMissing(
- new ReqMissingBuilder().setRequestId(((ReqMissingTlv) tlv).getRequestId()).build()).build());
+ if (tlv instanceof ReqMissing && builder.getType() == 7) {
+ builder.setTlvs(new TlvsBuilder().setReqMissing((ReqMissing) tlv).build());
}
}
if (!(object instanceof PcepErrorObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PcepErrorObject.");
}
-
final PcepErrorObject errObj = (PcepErrorObject) object;
final byte[] tlvs = serializeTlvs(((Errors) errObj).getTlvs());
- int tlvsLength = 0;
- if (tlvs != null) {
- tlvsLength = tlvs.length;
- }
- final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null) {
+ final byte[] retBytes = new byte[TLVS_OFFSET + tlvs.length + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
+ if (tlvs.length != 0) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
}
-
- retBytes[ET_F_OFFSET] = ByteArray.shortToBytes(errObj.getType())[1];
- retBytes[EV_F_OFFSET] = ByteArray.shortToBytes(errObj.getValue())[1];
-
+ retBytes[ET_F_OFFSET] = UnsignedBytes.checkedCast(errObj.getType());
+ retBytes[EV_F_OFFSET] = UnsignedBytes.checkedCast(errObj.getValue());
return retBytes;
}
public byte[] serializeTlvs(final Tlvs tlvs) {
- if (tlvs.getReqMissing() != null) {
- return serializeTlv(new ReqMissingBuilder().setRequestId(tlvs.getReqMissing().getRequestId()).build());
+ if (tlvs == null) {
+ return new byte[0];
+ } else if (tlvs.getReqMissing() != null) {
+ return serializeTlv(tlvs.getReqMissing());
}
- return null;
+ return new byte[0];
}
@Override
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.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.OverloadDurationTlv;
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.notification.object.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.tlvs.OverloadDurationBuilder;
+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.pcntf.message.pcntf.message.notifications.NotificationsBuilder;
+import com.google.common.primitives.UnsignedBytes;
+
/**
* Parser for {@link NotificationObject}
*/
/*
* lengths of fields
*/
- public static final int FLAGS_F_LENGTH = 1;
- public static final int NT_F_LENGTH = 1;
- public static final int NV_F_LENGTH = 1;
+ private static final int FLAGS_F_LENGTH = 1;
+ private static final int NT_F_LENGTH = 1;
+ private static final int NV_F_LENGTH = 1;
/*
* offsets of fields
*/
- public static final int FLAGS_F_OFFSET = 1; // added reserved filed of size 1
- public static final int NT_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
- public static final int NV_F_OFFSET = NT_F_OFFSET + NT_F_LENGTH;
- public static final int TLVS_OFFSET = NV_F_OFFSET + NV_F_LENGTH;
+ private static final int FLAGS_F_OFFSET = 1;
+ private static final int NT_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
+ private static final int NV_F_OFFSET = NT_F_OFFSET + NT_F_LENGTH;
+ private static final int TLVS_OFFSET = NV_F_OFFSET + NV_F_LENGTH;
public PCEPNotificationObjectParser(final TlvHandlerRegistry tlvReg) {
super(tlvReg);
if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
}
-
final NotificationsBuilder builder = new NotificationsBuilder();
-
- parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
-
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
-
- builder.setType((short) (bytes[NT_F_OFFSET] & 0xFF));
- builder.setValue((short) (bytes[NV_F_OFFSET] & 0xFF));
-
+ builder.setType((short) UnsignedBytes.toInt(bytes[NT_F_OFFSET]));
+ builder.setValue((short) UnsignedBytes.toInt(bytes[NV_F_OFFSET]));
+ parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
return builder.build();
}
@Override
public void addTlv(final NotificationsBuilder builder, final Tlv tlv) {
- if (tlv instanceof OverloadDurationTlv && builder.getType() == 2 && builder.getValue() == 1) {
- builder.setTlvs(new TlvsBuilder().setOverloadDuration(
- new OverloadDurationBuilder().setDuration(((OverloadDurationTlv) tlv).getDuration()).build()).build());
+ if (tlv instanceof OverloadDuration && builder.getType() == 2 && builder.getValue() == 1) {
+ builder.setTlvs(new TlvsBuilder().setOverloadDuration((OverloadDuration) tlv).build());
}
}
if (!(object instanceof NotificationObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NotificationObject.");
}
-
final NotificationObject notObj = (NotificationObject) object;
final byte[] tlvs = serializeTlvs(notObj.getTlvs());
- int tlvsLength = 0;
- if (tlvs != null) {
- tlvsLength = tlvs.length;
- }
- final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null) {
+ final byte[] retBytes = new byte[TLVS_OFFSET + tlvs.length + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
+ if (tlvs.length != 0) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
}
-
- retBytes[NT_F_OFFSET] = ByteArray.shortToBytes(notObj.getType())[1];
- retBytes[NV_F_OFFSET] = ByteArray.shortToBytes(notObj.getValue())[1];
-
+ retBytes[NT_F_OFFSET] = UnsignedBytes.checkedCast(notObj.getType());
+ retBytes[NV_F_OFFSET] = UnsignedBytes.checkedCast(notObj.getValue());
return retBytes;
}
public byte[] serializeTlvs(final Tlvs tlvs) {
- if (tlvs.getOverloadDuration() != null) {
- // FIXME : add
- // return serializeTlv(new NoPathVectorBuilder().setFlags(tlvs.getNoPathVector()).build());
+ if (tlvs == null) {
+ return new byte[0];
+ } else if (tlvs.getOverloadDuration() != null) {
+ return serializeTlv(tlvs.getOverloadDuration());
}
- return null;
+ return new byte[0];
}
@Override
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.OverloadDurationTlv;
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.notification.object.tlvs.OverloadDurationBuilder;
+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;
/**
- * Parser for {@link OverloadDurationTlv}
+ * Parser for {@link OverloadDuration}
*/
public class OverloadedDurationTlvParser implements TlvParser, TlvSerializer {
private static final int OVERLOADED_DURATION_LENGTH = 4;
@Override
- public OverloadDurationTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
- final long l = ByteArray.bytesToInt(ByteArray.subByte(buffer, 0, OVERLOADED_DURATION_LENGTH));
- return new OverloadDurationBuilder().setDuration(l).build();
+ public OverloadDuration parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+ return new OverloadDurationBuilder().setDuration(ByteArray.bytesToLong(ByteArray.subByte(buffer, 0, OVERLOADED_DURATION_LENGTH))).build();
}
@Override
if (tlv == null) {
throw new IllegalArgumentException("OverloadedTlv is mandatory.");
}
- final OverloadDurationTlv odt = (OverloadDurationTlv) tlv;
+ final OverloadDuration odt = (OverloadDuration) tlv;
return ByteArray.subByte(ByteArray.longToBytes(odt.getDuration()), OVERLOADED_DURATION_LENGTH, OVERLOADED_DURATION_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.ReqMissingTlv;
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.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.tlvs.ReqMissingBuilder;
+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;
/**
- * Parser {@link ReqMissingTlv}
+ * Parser {@link ReqMissing}
*/
public class ReqMissingTlvParser implements TlvParser, TlvSerializer {
private static final int REQ_ID_LENGTH = 4;
@Override
- public ReqMissingTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+ public ReqMissing parseTlv(final byte[] buffer) throws PCEPDeserializerException {
return new ReqMissingBuilder().setRequestId(new RequestId(ByteArray.bytesToLong(ByteArray.subByte(buffer, 0, REQ_ID_LENGTH)))).build();
}
if (tlv == null) {
throw new IllegalArgumentException("ReqMissingTlv is mandatory.");
}
- final ReqMissingTlv req = (ReqMissingTlv) tlv;
+ final ReqMissing req = (ReqMissing) tlv;
return ByteArray.subByte(ByteArray.longToBytes(req.getRequestId().getValue()), REQ_ID_LENGTH, REQ_ID_LENGTH);
}
import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
+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.OfId;
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.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.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.pcerr.message.pcerr.message.ErrorsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.EndpointsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.SrpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.SvecBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.LoadBalancingBuilder;
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.req.missing.tlv.ReqMissingBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
import com.google.common.collect.Lists;
assertArrayEquals(result, parser.serializeObject(builder.build()));
}
- //
- // /**
- // * Test of Serialization/Deserialization of PCEPErrorObjectParser.<br/>
- // * <br/>
- // * Used resources:<br/>
- // * - PCEPErrorObject1.bin<br/>
- // * - PCEPErrorObject3.bin<br/>
- // *
- // * @throws PCEPDeserializerException
- // * @throws IOException
- // * @throws PCEPDocumentedException
- // */
- // @Test
- // public void testErrorObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
- // PCEPDocumentedException {
- // serDeserTest("src/test/resources/PCEPErrorObject1.bin", new PCEPErrorObject(PCEPErrors.NON_OR_INVALID_OPEN_MSG));
- // serDeserTest("src/test/resources/PCEPErrorObject3.bin", new
- // PCEPErrorObject(PCEPErrors.CAPABILITY_NOT_SUPPORTED));
- // }
- //
- // /**
- // * Test of validity of PCEPErrorObjectParser. Expect throwed NoSuchElementException.<br/>
- // * <br/>
- // * Used resources:<br/>
- // * - PCEPErrorObject2Invalid.bin<br/>
- // *
- // * @throws NoSuchElementException
- // * @throws IOException
- // * @throws PCEPDocumentedException
- // */
- // @Test(expected = PCEPDeserializerException.class)
- // public void testUnknownError() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject2Invalid.bin")).get(0);
- // }
- //
+ @Test
+ public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+ final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry);
+ byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin");
+
+ final ErrorsBuilder builder = new ErrorsBuilder();
+ builder.setProcessingRule(true);
+ builder.setIgnore(true);
+ builder.setType((short) 1);
+ builder.setValue((short) 1);
+
+ assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
+ assertArrayEquals(result, parser.serializeObject(builder.build()));
+
+ result = ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin");
+
+ builder.setType((short) 7);
+ builder.setValue((short) 0);
+ builder.setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L)).build()).build());
+
+ assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
+ assertArrayEquals(result, parser.serializeObject(builder.build()));
+ }
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
// assertArrayEquals(bytesFromFile, bytesActual);
// }
- //
- // /**
- // * Specific test with/without tlvs (Ser/Deser)<br/>
- // * Used resources:<br/>
- // * - PCEPNotificationObject1WithTlv.bin - PCEPNotificationObject2WithoutTlv.bin
- // *
- // * @throws PCEPDeserializerException
- // * @throws IOException
- // * @throws PCEPDocumentedException
- // */
- // @Test
- // public void testNotifyObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
- // PCEPDocumentedException {
- // // FINAL LIST<PCEPTLV> TLVS = NEW ARRAYLIST<PCEPTLV>(1);
- // // TLVS.ADD(NEW OVERLOADEDDURATIONTLV(0XFF0000A2));
- // // SERDESERTEST("src/test/resources/PCEPNotificationObject1WithTlv.bin", new PCEPNotificationObject((short) 1,
- // (short) 1, tlvs));
- // serDeserTest("src/test/resources/PCEPNotificationObject2WithoutTlv.bin", new PCEPNotificationObject((short) 0xFF,
- // (short) 0xFF));
- // }
+ @Test
+ public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+ final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry);
+ byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin");
+
+ final NotificationsBuilder builder = new NotificationsBuilder();
+ builder.setProcessingRule(true);
+ builder.setIgnore(true);
+ builder.setType((short) 0xff);
+ builder.setValue((short) 0xff);
+
+ assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
+ assertArrayEquals(result, parser.serializeObject(builder.build()));
+
+ result = ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin");
+
+ builder.setType((short) 2);
+ builder.setValue((short) 1);
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.TlvsBuilder().setOverloadDuration(
+ new OverloadDurationBuilder().setDuration(0xff0000a2L).build()).build());
+
+ final NotificationObject t = parser.parseObject(new ObjectHeaderImpl(true, true), result);
+ assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
+ assertArrayEquals(result, parser.serializeObject(builder.build()));
+ }
+
//
// /**
// * Standard ser deser test<br/>
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.OrderTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
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.ReqMissingTlv;
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.RsvpErrorSpecTlv;
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.lsp.object.tlvs.LspIdentifiersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.tlvs.RsvpErrorSpecBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.tlvs.SymbolicPathNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.tlvs.OverloadDurationBuilder;
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.pcep.error.object.tlvs.ReqMissingBuilder;
+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.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.rp.object.tlvs.OrderBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.error.type.RsvpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.error.type.UserBuilder;
private static final byte[] statefulBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 };
private static final byte[] DbVersionBytes = { (byte) 0xff, (byte) 0x00, (byte) 0xff, (byte) 0xaa, (byte) 0xb2, (byte) 0xf5,
- (byte) 0xf2, (byte) 0xcf };
+ (byte) 0xf2, (byte) 0xcf };
private static final byte[] noPathVectorBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xa7 };
private static final byte[] overloadedBytes = { (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff };
private static final byte[] symbolicNameBytes = { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65,
- (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d,
- (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d,
- (byte) 0x65 };
+ (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d,
+ (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d,
+ (byte) 0x65 };
private static final byte[] lspUpdateErrorBytes = { (byte) 0x25, (byte) 0x68, (byte) 0x95, (byte) 0x03 };
private static final byte[] lspIdentifiers4Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0xFF, (byte) 0xFF,
- (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
+ (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
private static final byte[] lspIdentifiers6Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC,
- (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE,
- (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0xFF, (byte) 0xFF, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
- (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01,
- (byte) 0x23, (byte) 0x45, (byte) 0x67 };
+ (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE,
+ (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0xFF, (byte) 0xFF, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
+ (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01,
+ (byte) 0x23, (byte) 0x45, (byte) 0x67 };
private static final byte[] rsvpErrorBytes = { (byte) 0x06, (byte) 0x01, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
- (byte) 0x02, (byte) 0x92, (byte) 0x16, (byte) 0x02 };
+ (byte) 0x02, (byte) 0x92, (byte) 0x16, (byte) 0x02 };
private static final byte[] rsvpError6Bytes = { (byte) 0x06, (byte) 0x02, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
- (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
- (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x02, (byte) 0xd5, (byte) 0xc5, (byte) 0xd9 };
+ (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
+ (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x02, (byte) 0xd5, (byte) 0xc5, (byte) 0xd9 };
private static final byte[] userErrorBytes = { (byte) 0xc2, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x30, (byte) 0x39,
- (byte) 0x05, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x72, (byte) 0x20,
- (byte) 0x64, (byte) 0x65, (byte) 0x73, (byte) 0x63 };
+ (byte) 0x05, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x72, (byte) 0x20,
+ (byte) 0x64, (byte) 0x65, (byte) 0x73, (byte) 0x63 };
private static final byte[] reqMissingBytes = { (byte) 0xF7, (byte) 0x82, (byte) 0x35, (byte) 0x17 };
private static final byte[] orderBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x01 };
+ (byte) 0x01 };
private static final byte[] ofListBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
private static final byte[] predundancyBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
@Test
public void testOverloadedDurationTlv() throws PCEPDeserializerException {
final OverloadedDurationTlvParser parser = new OverloadedDurationTlvParser();
- final OverloadDurationTlv tlv = new OverloadDurationBuilder().setDuration(0x7FFFFFFFL).build();
+ final OverloadDuration tlv = new OverloadDurationBuilder().setDuration(0x7FFFFFFFL).build();
assertEquals(tlv, parser.parseTlv(overloadedBytes));
assertArrayEquals(overloadedBytes, parser.serializeTlv(tlv));
}
@Test
public void testSymbolicNameTlv() throws PCEPDeserializerException {
final LspSymbolicNameTlvParser parser = new LspSymbolicNameTlvParser();
- final SymbolicPathNameTlv tlv = new SymbolicPathNameBuilder().setPathName(new SymbolicPathName("Med test of symbolic name".getBytes())).build();
+ final SymbolicPathNameTlv tlv = new SymbolicPathNameBuilder().setPathName(
+ new SymbolicPathName("Med test of symbolic name".getBytes())).build();
assertEquals(tlv, parser.parseTlv(symbolicNameBytes));
assertArrayEquals(symbolicNameBytes, parser.serializeTlv(tlv));
}
@Test
public void testReqMissingTlv() throws PCEPDeserializerException {
final ReqMissingTlvParser parser = new ReqMissingTlvParser();
- final ReqMissingTlv tlv = new ReqMissingBuilder().setRequestId(new RequestId(0xF7823517L)).build();
+ final ReqMissing tlv = new ReqMissingBuilder().setRequestId(new RequestId(0xF7823517L)).build();
assertEquals(tlv, parser.parseTlv(reqMissingBytes));
assertArrayEquals(reqMissingBytes, parser.serializeTlv(tlv));
}