grouping rp-object {
description "RP Object";
reference "https://tools.ietf.org/html/rfc5440#section-7.4";
-
- uses object;
- container "tlvs" {
- uses order-tlv;
- }
-
- leaf priority {
- type uint8 {
- range 1..7;
+ container rp {
+ uses object;
+ container "tlvs" {
+ uses order-tlv;
+ }
+
+ leaf priority {
+ type uint8 {
+ range 1..7;
+ }
+ }
+
+ leaf request-id {
+ type request-id;
+ mandatory true;
+ }
+
+ leaf reoptimization {
+ type boolean;
+ default false;
+ }
+
+ leaf bi-directional {
+ type boolean;
+ default false;
+ }
+
+ leaf loose {
+ type boolean;
+ default false;
+ }
+
+ leaf path-key {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc5520#section-3.2.1";
+ }
+
+ leaf fragmentation {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+ }
+
+ leaf p2mp {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+ }
+
+ leaf ero-compression {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+ }
+
+ leaf supply-of {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc5541#section-3.3";
+ }
+
+ leaf order {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc5557#section-5.3";
+ }
+
+ leaf make-before-break {
+ type boolean;
+ default false;
+ reference "https://tools.ietf.org/html/rfc5557#section-5.3";
}
- }
-
- leaf request-id {
- type request-id;
- mandatory true;
- }
-
- leaf reoptimization {
- type boolean;
- default false;
- }
-
- leaf bi-directional {
- type boolean;
- default false;
- }
-
- leaf loose {
- type boolean;
- default false;
- }
-
- leaf path-key {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc5520#section-3.2.1";
- }
-
- leaf fragmentation {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
- }
-
- leaf p2mp {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
- }
-
- leaf ero-compression {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
- }
-
- leaf supply-of {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc5541#section-3.3";
- }
-
- leaf order {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc5557#section-5.3";
- }
-
- leaf make-before-break {
- type boolean;
- default false;
- reference "https://tools.ietf.org/html/rfc5557#section-5.3";
}
}
grouping notification-object {
description "NOTIFICATION Object";
reference "https://tools.ietf.org/html/rfc5440#section-7.14";
-
- uses object;
- container "tlvs" {
- when "../type = 2 and ../value = 1";
-
- uses overload-duration-tlv;
- }
-
- leaf type {
- type uint8;
- mandatory true;
- }
-
- leaf value {
- type uint8;
- mandatory true;
+ container c-notification {
+ uses object;
+ container "tlvs" {
+ when "../type = 2 and ../value = 1";
+
+ uses overload-duration-tlv;
+ }
+
+ leaf type {
+ type uint8;
+ mandatory true;
+ }
+
+ leaf value {
+ type uint8;
+ mandatory true;
+ }
}
}
uses message-header;
list requests {
- container rp {
- uses rp-object;
- }
+ uses rp-object;
container path-key-expansion {
when "rp/path-key = true";
uses message-header;
list replies {
- container rp {
- uses rp-object;
- }
+ uses rp-object;
container lsp {
reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-6.5";
package org.opendaylight.protocol.pcep.impl;
-import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
+ COMMON_OBJECT_HEADER_LENGTH + ".");
}
- final int objClass = UnsignedBytes.toInt(bytes[OC_F_OFFSET]);
+ final int objClass = UnsignedBytes.toInt(bytes[offset]);
- final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(bytes[OT_FLAGS_MF_OFFSET], OT_SF_OFFSET, OT_SF_LENGTH));
+ offset += OC_F_LENGTH;
- final int objLength = ByteArray.bytesToInt(Arrays.copyOfRange(bytes, OBJ_LENGTH_F_OFFSET, OBJ_LENGTH_F_OFFSET
- + OBJ_LENGTH_F_LENGTH));
+ final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(bytes[offset], OT_SF_OFFSET, OT_SF_LENGTH));
- final byte[] flagsBytes = { ByteArray.copyBitsRange(bytes[OT_FLAGS_MF_OFFSET], FLAGS_SF_OFFSET, FLAGS_SF_LENGTH) };
+ final byte[] flagsBytes = { ByteArray.copyBitsRange(bytes[offset], FLAGS_SF_OFFSET, FLAGS_SF_LENGTH) };
final BitSet flags = ByteArray.bytesToBitSet(flagsBytes);
- if (bytes.length - offset < objLength) {
+ offset += OT_FLAGS_MF_LENGTH;
+
+ final int objLength = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset, OBJ_LENGTH_F_LENGTH));
+
+ if (bytes.length - offset < objLength - COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
+ objLength + ".");
}
+ offset += OBJ_LENGTH_F_LENGTH;
+
// copy bytes for deeper parsing
- final byte[] bytesToPass = ByteArray.subByte(bytes, offset + COMMON_OBJECT_HEADER_LENGTH, objLength
- - COMMON_OBJECT_HEADER_LENGTH);
+ final byte[] bytesToPass = ByteArray.subByte(bytes, offset, objLength - COMMON_OBJECT_HEADER_LENGTH);
- offset += objLength;
+ offset += objLength - COMMON_OBJECT_HEADER_LENGTH;
final ObjectParser parser = this.registry.getObjectParser(objClass, objType);
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.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.PathKeyObject;
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.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.SvecObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose;
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.notification.object.CNotification;
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.object.Open;
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.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.rp.object.Rp;
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;
new PCEPExcludeRouteObjectParser(xroSubReg));
context.registerObjectSerializer(Open.class, new PCEPOpenObjectParser(tlvReg));
- context.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(tlvReg));
+ context.registerObjectSerializer(Rp.class, new PCEPRequestParameterObjectParser(tlvReg));
context.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(tlvReg));
context.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(tlvReg));
context.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(tlvReg));
context.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(tlvReg));
context.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(eroSubReg));
context.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(tlvReg));
- context.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(tlvReg));
+ context.registerObjectSerializer(CNotification.class, new PCEPNotificationObjectParser(tlvReg));
context.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(tlvReg));
context.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(tlvReg));
context.registerObjectSerializer(CClose.class, new PCEPCloseObjectParser(tlvReg));
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.PcepErrorObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
-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.open.object.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.Session;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request.Rps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request.RpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
import com.google.common.collect.Lists;
if (err.getErrorType() instanceof Request) {
final List<Rps> rps = ((Request) err.getErrorType()).getRps();
for (final Rps r : rps) {
- buffer.writeBytes(serializeObject(r));
+ buffer.writeBytes(serializeObject(r.getRp()));
}
}
switch (state) {
case 1:
state = 2;
- if (obj instanceof RpObject) {
- final RpObject o = ((RpObject) obj);
+ if (obj instanceof Rp) {
+ final Rp o = ((Rp) obj);
if (o.isProcessingRule()) {
throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
}
- requestParameters.add((Rps) o);
+ requestParameters.add(new RpsBuilder().setRp(o).build());
state = 1;
break;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
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.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.PcntfMessage;
-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.notification.object.CNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications;
+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.pcntf.message.pcntf.message.notifications.Rps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
import com.google.common.collect.Lists;
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications n : msg.getNotifications()) {
if (n.getRps() != null && !n.getRps().isEmpty()) {
for (final Rps rps : n.getRps()) {
- buffer.writeBytes(serializeObject(rps));
+ buffer.writeBytes(serializeObject(rps.getRp()));
}
}
if (n.getNotifications() == null || n.getNotifications().isEmpty()) {
throw new IllegalArgumentException("Message must contain at least one notification object");
} else {
for (final Notifications not : n.getNotifications()) {
- buffer.writeBytes(serializeObject(not));
+ buffer.writeBytes(serializeObject(not.getCNotification()));
}
}
}
}
if (compositeNotifications.isEmpty()) {
- throw new PCEPDeserializerException("Atleast one CompositeNotifiObject is mandatory.");
+ throw new PCEPDeserializerException("Atleast one Notifications is mandatory.");
}
if (!objects.isEmpty()) {
switch (state) {
case 1:
state = 2;
- if (obj instanceof RpObject) {
- final RpObject rp = (RpObject) obj;
+ if (obj instanceof Rp) {
+ final Rp rp = (Rp) obj;
if (rp.isProcessingRule()) {
throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
}
- requestParameters.add((Rps) rp);
+ requestParameters.add(new RpsBuilder().setRp(rp).build());
state = 1;
break;
}
case 2:
- if (obj instanceof NotificationObject) {
- final NotificationObject n = (NotificationObject) obj;
- notifications.add((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications) n);
+ if (obj instanceof CNotification) {
+ final CNotification n = (CNotification) obj;
+ notifications.add(new NotificationsBuilder().setCNotification(n).build());
state = 2;
break;
}
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
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.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.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.CNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder;
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}
+ * Parser for {@link CNotification}
*/
-public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<NotificationsBuilder> {
+public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<CNotificationBuilder> {
public static final int CLASS = 12;
}
@Override
- public NotificationObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
+ public CNotification parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
PCEPDocumentedException {
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();
+ final CNotificationBuilder builder = new CNotificationBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setType((short) UnsignedBytes.toInt(bytes[NT_F_OFFSET]));
}
@Override
- public void addTlv(final NotificationsBuilder builder, final Tlv tlv) {
+ public void addTlv(final CNotificationBuilder builder, final Tlv tlv) {
if (tlv instanceof OverloadDuration && builder.getType() == 2 && builder.getValue() == 1) {
builder.setTlvs(new TlvsBuilder().setOverloadDuration((OverloadDuration) tlv).build());
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof NotificationObject)) {
+ if (!(object instanceof CNotification)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NotificationObject.");
}
- final NotificationObject notObj = (NotificationObject) object;
+ final CNotification notObj = (CNotification) object;
final byte[] tlvs = serializeTlvs(notObj.getTlvs());
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.RequestId;
-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.Tlv;
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.pcreq.message.pcreq.message.requests.RpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder;
/**
- * Parser for {@link RpObject}
+ * Parser for {@link Rp}
*/
public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<RpBuilder> {
}
@Override
- public RpObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
+ public Rp parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof RpObject)) {
+ if (!(object instanceof Rp)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed RpObject.");
}
- final RpObject rPObj = (RpObject) object;
+ final Rp rPObj = (Rp) object;
final BitSet flags = new BitSet(FLAGS_PRI_MF_LENGTH * Byte.SIZE);
flags.set(R_FLAG_OFFSET, rPObj.isReoptimization());
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.notification.object.CNotificationBuilder;
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.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.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.LspBuilder;
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.pcrep.message.pcrep.message.replies.result.failure.NoPathBuilder;
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.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.RpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.path.key.expansion.PathKeyBuilder;
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.ReportedRouteBuilder;
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.rp.object.RpBuilder;
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;
final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry);
byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin");
- final NotificationsBuilder builder = new NotificationsBuilder();
+ final CNotificationBuilder builder = new CNotificationBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setType((short) 0xff);
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(
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder().setOverloadDuration(
new OverloadDurationBuilder().setDuration(0xff0000a2L).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
b.setDelete(0xffffffffL);
b.setSetup(1L);
- builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.TlvsBuilder().setOrder(
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setOrder(
b.build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
import java.io.IOException;
import java.math.BigInteger;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
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.close.message.CCloseMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
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.notification.object.CNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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 com.google.common.collect.Lists;
+
public class PCEPValidatorTest {
private ObjectHandlerRegistry objectRegistry;
+ private Rp rp;
+
@Before
public void setUp() throws Exception {
this.objectRegistry = PCEPExtensionProviderContextImpl.create().getObjectHandlerRegistry();
+ final RpBuilder rpBuilder = new RpBuilder();
+ rpBuilder.setProcessingRule(false);
+ rpBuilder.setIgnore(false);
+ rpBuilder.setReoptimization(false);
+ rpBuilder.setBiDirectional(false);
+ rpBuilder.setLoose(true);
+ rpBuilder.setMakeBeforeBreak(false);
+ rpBuilder.setOrder(false);
+ rpBuilder.setSupplyOf(false);
+ rpBuilder.setFragmentation(false);
+ rpBuilder.setP2mp(false);
+ rpBuilder.setEroCompression(false);
+ rpBuilder.setPriority((short) 1);
+ rpBuilder.setRequestId(new RequestId(10L));
+ this.rp = rpBuilder.build();
}
// private static final LspaObject lspa = new PCEPLspaObject(0L, 0L, 0L, (short) 0, (short) 0, false, false, false,
//
@Test
- public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
- PCEPDeserializerException {
+ public void testOpenMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin");
final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.objectRegistry);
final OpenMessageBuilder builder = new OpenMessageBuilder();
}
@Test
- public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ public void testKeepAliveMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final byte[] result = new byte[] { 0, 0, 0, 0 };
final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
final KeepaliveBuilder builder = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build());
}
@Test
- public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
- DocumentedException {
+ public void testCloseMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin");
final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result, buf.array());
}
+
// @Test
// public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException,
// PCEPDocumentedException,
// asList((Message) msg).toString());
// }
//
- // @Test
- // public void testNotificationValidatorFromBin() throws IOException, PCEPDeserializerException,
- // PCEPDocumentedException,
- // DeserializerException, DocumentedException {
- // List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>();
- // List<PCEPNotificationObject> notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // notifications.add(new CompositeNotifyObject(notificationsList));
- // PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
- // assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
- //
- // notifications = new ArrayList<CompositeNotifyObject>();
- // notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // List<PCEPRequestParameterObject> requestsList = new ArrayList<PCEPRequestParameterObject>();
- // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3,
- // 1, false, false));
- // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
- // specMessage = new PCEPNotificationMessage(notifications);
- // assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
- //
- // notifications = new ArrayList<CompositeNotifyObject>();
- // notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // requestsList = new ArrayList<PCEPRequestParameterObject>();
- // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
- // 10, false, false));
- // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
- // specMessage = new PCEPNotificationMessage(notifications);
- // assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
- //
- // notifications = new ArrayList<CompositeNotifyObject>();
- // notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 2));
- // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 1));
- // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
- // notifications.add(new CompositeNotifyObject(notificationsList));
- // specMessage = new PCEPNotificationMessage(notifications);
- // assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
- //
- // notifications = new ArrayList<CompositeNotifyObject>();
- // notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // requestsList = new ArrayList<PCEPRequestParameterObject>();
- // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
- // 10, false, false));
- // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
- // notificationsList = new ArrayList<PCEPNotificationObject>();
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
- // requestsList = new ArrayList<PCEPRequestParameterObject>();
- // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
- // 10, false, false));
- // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
- // 10, false, false));
- // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
- // specMessage = new PCEPNotificationMessage(notifications);
- // assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
- // }
+ @Test
+ public void testNotificationMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ final CNotification cn1 = new CNotificationBuilder().setIgnore(false).setProcessingRule(false).setType((short) 1).setValue(
+ (short) 1).build();
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot = Lists.newArrayList();
+ innerNot.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
+ cn1).build());
+ final List<Rps> rps = Lists.newArrayList();
+ rps.add(new RpsBuilder().setRp(this.rp).build());
+
+ final byte[] result = ByteArray.fileToBytes("src/test/resources/PCNtf.5.bin");
+
+ final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(this.objectRegistry);
+ final PcntfMessageBuilder builder = new PcntfMessageBuilder();
+
+ final List<Notifications> nots = Lists.newArrayList();
+ final NotificationsBuilder b = new NotificationsBuilder();
+ b.setNotifications(innerNot);
+ b.setRps(rps);
+ nots.add(b.build());
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot1 = Lists.newArrayList();
+ innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
+ cn1).build());
+ innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
+ cn1).build());
+ final List<Rps> rps1 = Lists.newArrayList();
+ rps1.add(new RpsBuilder().setRp(this.rp).build());
+ rps1.add(new RpsBuilder().setRp(this.rp).build());
+
+ b.setNotifications(innerNot1);
+ b.setRps(rps1);
+ nots.add(b.build());
+ builder.setNotifications(nots);
+
+ assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result));
+ final ByteBuf buf = Unpooled.buffer(result.length);
+ parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
+ assertArrayEquals(result, buf.array());
+ }
//
// @Test
// public void testErrorMessageValidatoinFromBin() throws IOException, PCEPDeserializerException,