Search in sources :

Example 76 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 PCEPOverloadObjectParser 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 OverloadBuilder builder = new OverloadBuilder();
    buffer.readBytes(RESERVED + FLAGS);
    builder.setDuration(buffer.readUnsignedShort());
    return builder.build();
}
Also used : OverloadBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.OverloadBuilder)

Example 77 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 PCEPOverloadObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Overload, "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
    final Overload overload = (Overload) object;
    final ByteBuf body = Unpooled.buffer(BODY_SIZE);
    body.writeZero(RESERVED + FLAGS);
    ByteBufWriteUtil.writeUnsignedShort(overload.getDuration(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Overload(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.Overload) ByteBuf(io.netty.buffer.ByteBuf)

Example 78 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 PCEPPathKeyObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof PathKey, "Wrong instance of PCEPObject. Passed %s. Needed PathKeyObject.", object.getClass());
    final PathKey pkey = (PathKey) object;
    final ByteBuf body = Unpooled.buffer();
    final List<PathKeys> pk = pkey.getPathKeys();
    final List<Subobject> subs = new ArrayList<>();
    for (final PathKeys p : pk) {
        subs.add(new SubobjectBuilder().setLoose(p.isLoose()).setSubobjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder().setPathKey(p.getPathKey()).setPceId(p.getPceId()).build()).build()).build());
    }
    serializeSubobject(subs, body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject) Preconditions(com.google.common.base.Preconditions) ArrayList(java.util.ArrayList) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKeyBuilder) ByteBuf(io.netty.buffer.ByteBuf) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder) PathKeys(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeys) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey)

Example 79 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 PCEPPccIdReqIPv4ObjectParser 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 PccIdReqBuilder builder = new PccIdReqBuilder();
    builder.setIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
    return builder.build();
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PccIdReqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReqBuilder)

Example 80 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 PCEPBandwidthObjectParser method serializeObject.

@Override
public void serializeObject(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Bandwidth, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthObject.", object.getClass());
    final ByteBuf body = Unpooled.buffer();
    writeFloat32(((Bandwidth) object).getBandwidth(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth) 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