@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); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Ero, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass()); final Ero ero = ((Ero) object); final ByteBuf body = Unpooled.buffer(); serializeSubobject(ero.getSubobject(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@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); } }
@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); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof BandwidthUsage, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthUsage.", object.getClass()); final List<Bandwidth> bwSample = ((BandwidthUsage) object).getBwSample(); final ByteBuf body = Unpooled.buffer(bwSample.size() * BW_LENGTH); for (final Bandwidth bw : bwSample) { writeFloat32(bw, body); } ObjectUtil.formatSubobject(getType(), CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
@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); }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof ClassType, "Wrong instance of PCEPObject. Passed %s. Needed ClassTypeObject.", object.getClass()); final ByteBuf body = Unpooled.buffer(SIZE); body.writeZero(SIZE -1); final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType classType = ((ClassType) object).getClassType(); Preconditions.checkArgument(classType != null, "ClassType is mandatory."); writeUnsignedByte(classType.getValue(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof CClose, "Wrong instance of PCEPObject. Passed %s. Needed CCloseObject.", object.getClass()); final CClose obj = (CClose) object; final ByteBuf body = Unpooled.buffer(); body.writeZero(RESERVED + FLAGS_F_LENGTH); Preconditions.checkArgument(obj.getReason() != null, "Reason is mandatory."); writeUnsignedByte(obj.getReason(), body); serializeTlvs(obj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
@Override public final void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof VendorInformationObject, "Wrong instance of PCEPObject. Passed %s. Needed VendorInformationObject.", object.getClass()); final ByteBuf body = Unpooled.buffer(); writeUnsignedInt(getEnterpriseNumber().getValue(), body); serializeEnterpriseSpecificInformation(((VendorInformationObject) object).getEnterpriseSpecificInformation(), body); ObjectUtil.formatSubobject(VENDOR_INFORMATION_OBJECT_TYPE, VENDOR_INFORMATION_OBJECT_CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof LoadBalancing, "Wrong instance of PCEPObject. Passed %s. Needed LoadBalancingObject.", object.getClass()); final LoadBalancing specObj = (LoadBalancing) object; final ByteBuf body = Unpooled.buffer(SIZE); body.writeZero(RESERVED + FLAGS_F_LENGTH); writeUnsignedByte(specObj.getMaxLsp(), body); writeFloat32(specObj.getMinBandwidth(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
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); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Of, "Wrong instance of PCEPObject. Passed %s. Needed OfObject.", object.getClass()); final Of specObj = (Of) object; final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(specObj.getCode() != null, "Code is mandatory"); writeUnsignedShort(specObj.getCode().getValue(), body); body.writeZero(RESERVED); serializeTlvs(specObj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
@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); } }
@Override public 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(); if(afi instanceof Ipv6Case) { PCEPEndPointsIpv6ObjectParser.serializeObject(object,buffer); } Preconditions.checkArgument(afi instanceof Ipv4Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv4", afi.getClass()); final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4(); final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH + Ipv4Util.IP4_LENGTH); Preconditions.checkArgument(ipv4.getSourceIpv4Address() != null, "SourceIpv4Address is mandatory."); writeIpv4Address(ipv4.getSourceIpv4Address(), body); Preconditions.checkArgument(ipv4.getDestinationIpv4Address() != null, "DestinationIpv4Address is mandatory."); writeIpv4Address(ipv4.getDestinationIpv4Address(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@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); }
@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); }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Xro, "Wrong instance of PCEPObject. Passed %s. Needed XroObject.", object.getClass()); final Xro obj = (Xro) object; final ByteBuf body = Unpooled.buffer(); body.writeZero(FLAGS_OFFSET); writeBoolean(obj.getFlags() != null ? obj.getFlags().isFail() : null, body); serializeSubobject(obj.getSubobject(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof PceId, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass()); final PceId pceId = (PceId) object; if (pceId.getIpAddress().getIpv4Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH); ByteBufWriteUtil.writeIpv4Address(pceId.getIpAddress().getIpv4Address(), body); ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } else if (pceId.getIpAddress().getIpv6Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH); ByteBufWriteUtil.writeIpv6Address(pceId.getIpAddress().getIpv6Address(), body); ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof PccIdReq, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass()); final PccIdReq pccIdReq = (PccIdReq) object; if (pccIdReq.getIpAddress().getIpv4Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH); ByteBufWriteUtil.writeIpv4Address(pccIdReq.getIpAddress().getIpv4Address(), body); ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } else if (pccIdReq.getIpAddress().getIpv6Address() != null) { final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH); ByteBufWriteUtil.writeIpv6Address(pccIdReq.getIpAddress().getIpv6Address(), body); ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); } } }
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Lsp, "Wrong instance of PCEPObject. Passed %s. Needed LspObject.", object.getClass()); final Lsp specObj = (Lsp) object; final ByteBuf body = Unpooled.buffer(); final PlspId plsp = specObj.getPlspId(); Preconditions.checkArgument(plsp != null, "PLSP-ID not present"); writeMedium(plsp.getValue().intValue() << TWO_B_OFFSET, body); final BitSet flags = new BitSet(2 * Byte.SIZE); if (specObj.isDelegate() != null) { flags.set(DELEGATE_FLAG_OFFSET, specObj.isDelegate()); } if (specObj.isRemove() != null) { flags.set(REMOVE_FLAG_OFFSET, specObj.isRemove()); } if (specObj.isSync() != null) { flags.set(SYNC_FLAG_OFFSET, specObj.isSync()); } if (specObj.isOperational() != null) { flags.set(OPERATIONAL_FLAG_OFFSET, specObj.isOperational()); } body.writeByte(ByteArray.bitSetToBytes(flags, FLAGS_SIZE)[1]); serializeTlvs(specObj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }