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 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 EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (!header.isProcessingRule()) {
LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, builder.build());
}
if (bytes.readableBytes() != Ipv6Util.IPV6_LENGTH * 2) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final Ipv6Builder b = new Ipv6Builder();
b.setSourceIpv6Address(Ipv6Util.addressForByteBuf(bytes));
b.setDestinationIpv6Address(Ipv6Util.addressForByteBuf(bytes));
builder.setAddressFamily(new Ipv6CaseBuilder().setIpv6(b.build()).build());
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 PCEPErrorObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof ErrorObject, "Wrong instance of PCEPObject. Passed %s. Needed ErrorObject.", object.getClass());
final ErrorObject errObj = (ErrorObject) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_F_LENGTH + RESERVED);
Preconditions.checkArgument(errObj.getType() != null, "Type is mandatory.");
writeUnsignedByte(errObj.getType(), body);
Preconditions.checkArgument(errObj.getValue() != null, "Value is mandatory.");
writeUnsignedByte(errObj.getValue(), body);
serializeTlvs(errObj.getTlvs(), 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 PCEPExistingBandwidthObjectParser 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 ReoptimizationBandwidth, "Wrong instance of PCEPObject. Passed " + "%s. Needed ReoptimizationBandwidthObject.", object.getClass());
final ByteBuf body = Unpooled.buffer();
writeFloat32(((ReoptimizationBandwidth) object).getBandwidth(), 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 PCEPIncludeRouteObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Iro, "Wrong instance of PCEPObject. Passed %s. Needed IroObject.", object.getClass());
final Iro iro = ((Iro) object);
final ByteBuf body = Unpooled.buffer();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject> subs = new ArrayList<>();
for (final Subobject s : iro.getSubobject()) {
subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setLoose(s.isLoose()).setSubobjectType(s.getSubobjectType()).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 PCEPLspaObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
final Lspa lspaObj = (Lspa) object;
final ByteBuf body = Unpooled.buffer();
writeAttributeFilter(lspaObj.getExcludeAny(), body);
writeAttributeFilter(lspaObj.getIncludeAny(), body);
writeAttributeFilter(lspaObj.getIncludeAll(), body);
writeUnsignedByte(lspaObj.getSetupPriority(), body);
writeUnsignedByte(lspaObj.getHoldPriority(), body);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(L_FLAG_OFFSET, lspaObj.isLocalProtectionDesired());
flags.toByteBuf(body);
body.writeZero(RESERVED);
serializeTlvs(lspaObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Aggregations