@Override public void serializeTlvBody(final TopologyIdentifier tlv, final ByteBuf body) { ByteBufWriteUtil.writeUnsignedShort(tlv.getValue(), body); }
private static void serializeTunnelIdAndLspId(final ByteBuf buffer, final TeLspCase teLSP) { ByteBufWriteUtil.writeUnsignedShort(teLSP.getTunnelId().getValue(), buffer); ByteBufWriteUtil.writeUnsignedShort(teLSP.getLspId().getValue().intValue(), buffer); } }
@Override public void serializeTlv(final Tlv tlv, final ByteBuf buffer) { Preconditions.checkArgument(tlv instanceof OfList, "OFListTlv is mandatory."); final OfList oft = (OfList) tlv; final ByteBuf body = Unpooled.buffer(); final List<OfId> ofCodes = oft.getCodes(); for (OfId id : ofCodes) { writeUnsignedShort(id.getValue(), body); } TlvUtil.formatTlv(TYPE, body, buffer); } }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof RouteTargetExtendedCommunityCase, "The extended community %s is not RouteTargetExtendedCommunityCase type.", extendedCommunity); final RouteTargetExtendedCommunity routeTarget = ((RouteTargetExtendedCommunityCase) extendedCommunity).getRouteTargetExtendedCommunity(); ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeTarget.getGlobalAdministrator().getValue()), byteAggregator); byteAggregator.writeBytes(routeTarget.getLocalAdministrator()); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectExtendedCommunity, "The extended community %s is not RedirectExtendedCommunityCase type.", extendedCommunity); final RedirectExtendedCommunity redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectExtendedCommunity) extendedCommunity).getRedirectExtendedCommunity(); ByteBufWriteUtil.writeUnsignedShort(redirect.getGlobalAdministrator().getValue().intValue(), byteAggregator); byteAggregator.writeBytes(redirect.getLocalAdministrator()); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof AsSpecificExtendedCommunityCase, "The extended community %s is not AsSpecificExtendedCommunity type.", extendedCommunity); final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity).getAsSpecificExtendedCommunity(); ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(asSpecific.getGlobalAdministrator().getValue()), byteAggregator); byteAggregator.writeBytes(asSpecific.getLocalAdministrator()); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof RouteOriginExtendedCommunityCase, "The extended community %s is not RouteOriginExtendedCommunity type.", extendedCommunity); final RouteOriginExtendedCommunity routeOrigin = ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity(); ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeOrigin.getGlobalAdministrator().getValue()), byteAggregator); byteAggregator.writeBytes(routeOrigin.getLocalAdministrator()); }
@Override public void serializeBody(final Esi esi, final ByteBuf body) { Preconditions.checkArgument(esi instanceof LanAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi.getClass()); final LanAutoGenerated lan = ((LanAutoGeneratedCase) esi).getLanAutoGenerated(); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lan.getRootBridgeMacAddress())); ByteBufWriteUtil.writeUnsignedShort(lan.getRootBridgePriority(), body); body.writeZero(ZERO_BYTE); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof RedirectIpv6ExtendedCommunity, "The extended community %s is not RedirectIpv6ExtendedCommunity type.", extendedCommunity); final RedirectIpv6 redirectIpv6 = ((RedirectIpv6ExtendedCommunity) extendedCommunity).getRedirectIpv6(); byteAggregator.writeBytes(Ipv6Util.byteBufForAddress(redirectIpv6.getGlobalAdministrator())); ByteBufWriteUtil.writeUnsignedShort(redirectIpv6.getLocalAdministrator(), byteAggregator); }
@Override public void serializeBody(final Esi esi, final ByteBuf body) { Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass()); final LacpAutoGenerated lacp = ((LacpAutoGeneratedCase) esi).getLacpAutoGenerated(); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lacp.getCeLacpMacAddress())); ByteBufWriteUtil.writeUnsignedShort(lacp.getCeLacpPortKey(), body); body.writeZero(ZERO_BYTE); }
@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 serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof RouteTargetIpv4Case, "The extended community %s is not RouteTargetAsTwoOctetCase type.", extendedCommunity); final RouteTargetIpv4 routeTarget = ((RouteTargetIpv4Case) extendedCommunity).getRouteTargetIpv4(); ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator); ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpv4ExtendedCommunity, "The extended community %s is not RedirectIpv4ExtendedCommunityCase type.", extendedCommunity); final RedirectIpv4 redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpv4ExtendedCommunity) extendedCommunity).getRedirectIpv4(); ByteBufWriteUtil.writeIpv4Address(redirect.getGlobalAdministrator(), byteAggregator); ByteBufWriteUtil.writeUnsignedShort(redirect.getLocalAdministrator(), byteAggregator); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof RouteOriginIpv4Case, "The extended community %s is not RouteOriginIpv4Case type.", extendedCommunity); final RouteOriginIpv4 routeTarget = ((RouteOriginIpv4Case) extendedCommunity).getRouteOriginIpv4(); ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator); ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator); }
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass()); final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey(); final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory."); writeUnsignedShort(pk.getPathKey().getValue(), body); Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory."); body.writeBytes(pk.getPceId().getBinary()); XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), 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 serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectAs4ExtendedCommunity, "The extended community %s is not RedirectAs4ExtendedCommunityCase type.", extendedCommunity); final RedirectAs4 redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectAs4ExtendedCommunity) extendedCommunity).getRedirectAs4(); ByteBufWriteUtil.writeUnsignedInt(redirect.getGlobalAdministrator().getValue(), byteAggregator); ByteBufWriteUtil.writeUnsignedShort(redirect.getLocalAdministrator(), byteAggregator); }
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType(); final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects .subobject.type.path.key._case.PathKey pk = pkcase.getPathKey(); final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory."); writeUnsignedShort(pk.getPathKey().getValue(), body); Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory."); body.writeBytes(pk.getPceId().getBinary()); RROSubobjectUtil.formatSubobject(TYPE, body, buffer); } }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpNhExtendedCommunity, "The extended community %s is not RedirectIpNhExtendedCommunityCase type.", extendedCommunity); final RedirectIpNhExtendedCommunity redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.RedirectIpNhExtendedCommunity) extendedCommunity).getRedirectIpNhExtendedCommunity(); final IpAddress nextHopAddress = redirect.getNextHopAddress(); if (nextHopAddress.getIpv4Address() != null) { ByteBufWriteUtil.writeIpv4Address(nextHopAddress.getIpv4Address(), byteAggregator); } else { ByteBufWriteUtil.writeIpv6Address(nextHopAddress.getIpv6Address(), byteAggregator); } ByteBufWriteUtil.writeUnsignedShort((redirect.isCopy() == null || !redirect.isCopy()) ? 0 : 1, byteAggregator); }
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) { Preconditions.checkArgument(extendedCommunity instanceof Layer2AttributesExtendedCommunityCase, "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity); final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity).getLayer2AttributesExtendedCommunity(); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(PRIMARY_PE_OFFSET, extCom.isPrimaryPe()); flags.set(BACKUP_PE_OFFSET, extCom.isBackupPe()); flags.set(CONTROL_WORD_OFFSET, extCom.isControlWord()); flags.toByteBuf(body); ByteBufWriteUtil.writeUnsignedShort(extCom.getL2Mtu(), body); body.writeZero(RESERVED); }