Search in sources :

Example 71 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.

the class PCEPMonitoringObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Monitoring, "Wrong instance of PCEPObject. Passed %s. Needed MonitoringObject.", object.getClass());
    final Monitoring monitoring = (Monitoring) object;
    final ByteBuf body = Unpooled.buffer();
    body.writeZero(RESERVED);
    final Flags flags = monitoring.getFlags();
    final BitArray flagBits = new BitArray(FLAGS_SIZE);
    flagBits.set(I_FLAG_POS, flags.isIncomplete());
    flagBits.set(C_FLAG_POS, flags.isOverload());
    flagBits.set(P_FLAG_POS, flags.isProcessingTime());
    flagBits.set(G_FLAG_POS, flags.isGeneral());
    flagBits.set(L_FLAG_POS, flags.isLiveness());
    flagBits.toByteBuf(body);
    ByteBufWriteUtil.writeUnsignedInt(monitoring.getMonitoringId(), body);
    serializeTlvs(monitoring.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)

Example 72 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.

the class PCEPMonitoringObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final MonitoringBuilder builder = new MonitoringBuilder();
    buffer.readBytes(RESERVED);
    final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE);
    final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS), flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS));
    builder.setFlags(flags);
    builder.setMonitoringId(buffer.readUnsignedInt());
    final TlvsBuilder tbuilder = new TlvsBuilder();
    parseTlvs(tbuilder, buffer.slice());
    builder.setTlvs(tbuilder.build());
    return builder.build();
}
Also used : MonitoringBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.MonitoringBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.monitoring.TlvsBuilder) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags)

Example 73 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.

the class PCEPNoPathObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
    final NoPath nPObj = (NoPath) object;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
    writeUnsignedByte(nPObj.getNatureOfIssue(), body);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
    flags.toByteBuf(body);
    body.writeZero(RESERVED_F_LENGTH);
    serializeTlvs(nPObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 74 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.

the class PCEPNotificationObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof CNotification, "Wrong instance of PCEPObject. Passed %s. Needed CNotificationObject.", object.getClass());
    final CNotification notObj = (CNotification) object;
    final ByteBuf body = Unpooled.buffer();
    body.writeZero(NT_F_OFFSET);
    Preconditions.checkArgument(notObj.getType() != null, "Type is mandatory.");
    writeUnsignedByte(notObj.getType(), body);
    Preconditions.checkArgument(notObj.getValue() != null, "Value is mandatory.");
    writeUnsignedByte(notObj.getValue(), body);
    serializeTlvs(notObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification)

Example 75 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.

the class PCEPOpenObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
    final OpenBuilder builder = new OpenBuilder();
    builder.setVersion(new ProtocolVersion((short) versionValue));
    builder.setProcessingRule(header.isProcessingRule());
    builder.setIgnore(header.isIgnore());
    final short keepalive = bytes.readUnsignedByte();
    builder.setKeepalive(keepalive);
    final short deadTimer = bytes.readUnsignedByte();
    if (keepalive == 0) {
        builder.setDeadTimer((short) 0);
    } else {
        builder.setDeadTimer(deadTimer);
    }
    builder.setSessionId(bytes.readUnsignedByte());
    final TlvsBuilder tbuilder = new TlvsBuilder();
    parseTlvs(tbuilder, bytes.slice());
    builder.setTlvs(tbuilder.build());
    final Open obj = builder.build();
    if (versionValue != PCEP_VERSION) {
        // TODO: Should we move this check into the negotiator
        LOG.debug("Unsupported PCEP version {}", versionValue);
        return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
    }
    return obj;
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)72 Test (org.junit.Test)60 ArrayList (java.util.ArrayList)46 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)28 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)18 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)16 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)15 BigInteger (java.math.BigInteger)14 Preconditions (com.google.common.base.Preconditions)13 HashMap (java.util.HashMap)13 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)13 List (java.util.List)12 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)10 BitArray (org.opendaylight.protocol.util.BitArray)9 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)9