Search in sources :

Example 61 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 PCEPProcTimeObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof ProcTime, "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass());
    final ProcTime procTime = (ProcTime) object;
    final ByteBuf body = Unpooled.buffer(BODY_SIZE);
    body.writeZero(RESERVED);
    final BitArray flagBits = new BitArray(FLAGS);
    flagBits.set(E_FLAG_POSITION, procTime.isEstimated());
    flagBits.toByteBuf(body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getCurrentProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getMinProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getMaxProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getAverageProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getVarianceProcTime(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : ProcTime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.proc.time.object.ProcTime) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 62 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 PCEPReportedRouteObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Rro, "Wrong instance of PCEPObject. Passed %s. Needed RroObject.", object.getClass());
    final Rro obj = (Rro) object;
    final ByteBuf body = Unpooled.buffer();
    serializeSubobject(obj.getSubobject(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro)

Example 63 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 PCEPRequestParameterObjectParser 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 BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    final RpBuilder builder = new RpBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    short priority = 0;
    priority |= flags.get(PRI_SF_OFFSET + 2) ? 1 : 0;
    priority |= (flags.get(PRI_SF_OFFSET + 1) ? 1 : 0) << 1;
    priority |= (flags.get(PRI_SF_OFFSET) ? 1 : 0) << 2;
    if (priority != 0) {
        builder.setPriority(priority);
    }
    builder.setFragmentation(flags.get(F_FLAG_OFFSET));
    builder.setP2mp(flags.get(N_FLAG_OFFSET));
    builder.setEroCompression(flags.get(E_FLAG_OFFSET));
    builder.setMakeBeforeBreak(flags.get(M_FLAG_OFFSET));
    builder.setOrder(flags.get(D_FLAG_OFFSET));
    builder.setPathKey(flags.get(P_FLAG_OFFSET));
    builder.setSupplyOf(flags.get(S_FLAG_OFFSET));
    builder.setLoose(flags.get(O_FLAG_OFFSET));
    builder.setBiDirectional(flags.get(B_FLAG_OFFSET));
    builder.setReoptimization(flags.get(R_FLAG_OFFSET));
    builder.setRequestId(new RequestId(bytes.readUnsignedInt()));
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    builder.setTlvs(tlvsBuilder.build());
    return builder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 64 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 PCEPSvecObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.", object.getClass());
    final Svec svecObj = (Svec) object;
    final ByteBuf body = Unpooled.buffer();
    body.writeZero(FLAGS_F_OFFSET);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(L_FLAG_OFFSET, svecObj.isLinkDiverse());
    flags.set(N_FLAG_OFFSET, svecObj.isNodeDiverse());
    flags.set(S_FLAG_OFFSET, svecObj.isSrlgDiverse());
    flags.toByteBuf(body);
    final List<RequestId> requestIDs = svecObj.getRequestsIds();
    assert !(requestIDs.isEmpty()) : "Empty Svec Object - no request ids.";
    for (final RequestId requestId : requestIDs) {
        writeUnsignedInt(requestId.getValue(), body);
    }
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 65 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 PCEPEndPointsIpv6ObjectParser method serializeObject.

public static void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof EndpointsObj, "Wrong instance of PCEPObject. Passed %s. Needed EndpointsObject.", object.getClass());
    final EndpointsObj ePObj = (EndpointsObj) object;
    final AddressFamily afi = ePObj.getAddressFamily();
    Preconditions.checkArgument(afi instanceof Ipv6Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv6", afi.getClass());
    final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH);
    final Ipv6 ipv6 = ((Ipv6Case) afi).getIpv6();
    Preconditions.checkArgument(ipv6.getSourceIpv6Address() != null, "SourceIpv6Address is mandatory.");
    writeIpv6Address(ipv6.getSourceIpv6Address(), body);
    Preconditions.checkArgument(ipv6.getDestinationIpv6Address() != null, "DestinationIpv6Address is mandatory.");
    writeIpv6Address(ipv6.getDestinationIpv6Address(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Ipv6Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv6Case) Ipv6(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv6._case.Ipv6) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.AddressFamily) ByteBuf(io.netty.buffer.ByteBuf)

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