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();
}
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);
}
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);
}
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();
}
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);
}
Aggregations