List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParser.java
License:Open Source License
@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); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.esi.types.RouterIdParser.java
License:Open Source License
@Override public void serializeBody(final Esi esi, final ByteBuf body) { Preconditions.checkArgument(esi instanceof RouterIdGeneratedCase, "Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi.getClass()); final RouterIdGenerated routerID = ((RouterIdGeneratedCase) esi).getRouterIdGenerated(); ByteBufWriteUtil.writeIpv4Address(routerID.getRouterId(), body); ByteBufWriteUtil.writeUnsignedInt(routerID.getLocalDiscriminator(), body); body.writeZero(ZERO_BYTE); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.extended.communities.DefaultGatewayExtCom.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof DefaultGatewayExtendedCommunityCase, "The extended community %s is not DefaultGatewayExtendedCommunityCase type.", extendedCommunity); byteAggregator.writeZero(RESERVED); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.extended.communities.ESILabelExtCom.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof EsiLabelExtendedCommunityCase, "The extended community %s is not EsiLabelExtendedCommunityCaseCase type.", extendedCommunity); final EsiLabelExtendedCommunity extCom = ((EsiLabelExtendedCommunityCase) extendedCommunity) .getEsiLabelExtendedCommunity(); byteAggregator.writeBoolean(extCom.isSingleActiveMode()); byteAggregator.writeZero(RESERVED); byteAggregator.writeBytes(byteBufForMplsLabel(extCom.getEsiLabel())); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.extended.communities.Layer2AttributesExtCom.java
License:Open Source License
@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);//from w w w. j a v a 2s .c o m ByteBufWriteUtil.writeUnsignedShort(extCom.getL2Mtu(), body); body.writeZero(RESERVED); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.extended.communities.MACMobExtCom.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(extendedCommunity instanceof MacMobilityExtendedCommunityCase, "The extended community %s is not MacMobilityExtendedCommunityCase type.", extendedCommunity); final MacMobilityExtendedCommunity extCom = ((MacMobilityExtendedCommunityCase) extendedCommunity) .getMacMobilityExtendedCommunity(); byteAggregator.writeBoolean(extCom.isStatic()); byteAggregator.writeZero(RESERVED); byteAggregator.writeInt(extCom.getSeqNumber().intValue()); }
From source file:org.opendaylight.protocol.bgp.evpn.impl.nlri.EthSegRParser.java
License:Open Source License
static ByteBuf serializeOrigRouteIp(final IpAddress origRouteIp) { final ByteBuf body = Unpooled.buffer(); if (origRouteIp.getIpv4Address() != null) { body.writeByte(Ipv4Util.IP4_BITS_LENGTH); body.writeBytes(Ipv4Util.bytesForAddress(origRouteIp.getIpv4Address())); } else if (origRouteIp.getIpv6Address() != null) { body.writeByte(Ipv6Util.IPV6_BITS_LENGTH); body.writeBytes(Ipv6Util.bytesForAddress(origRouteIp.getIpv6Address())); } else {//from w ww.ja va2 s .c om body.writeZero(ZERO_BYTE); } return body; }
From source file:org.opendaylight.protocol.bgp.evpn.impl.nlri.MACIpAdvRParser.java
License:Open Source License
private static ByteBuf serializeIp(final IpAddress ipAddress) { final ByteBuf body = Unpooled.buffer(); if (ipAddress != null) { if (ipAddress.getIpv4Address() != null) { body.writeByte(Ipv4Util.IP4_BITS_LENGTH); body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address())); } else if (ipAddress.getIpv6Address() != null) { body.writeByte(Ipv6Util.IPV6_BITS_LENGTH); body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address())); } else {//from w ww .ja va2s. com body.writeZero(ZERO_BYTE); } } else { body.writeZero(ZERO_BYTE); } return body; }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.TrafficActionEcHandler.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(/*from w w w. j a va 2 s . c o m*/ extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.TrafficActionExtendedCommunity, "The extended community %s is not TrafficActionExtendedCommunityCase type.", extendedCommunity); final TrafficActionExtendedCommunity trafficAction = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.TrafficActionExtendedCommunity) extendedCommunity) .getTrafficActionExtendedCommunity(); byteAggregator.writeZero(RESERVED); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(SAMPLE_BIT, trafficAction.isSample()); flags.set(TERMINAL_BIT, trafficAction.isTerminalAction()); flags.toByteBuf(byteAggregator); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.TrafficMarkingEcHandler.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) { Preconditions.checkArgument(/*from w w w . j a v a2s . c o m*/ extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.TrafficMarkingExtendedCommunity, "The extended community %s is not TrafficMarkingExtendedCommunity type.", extendedCommunity); final TrafficMarkingExtendedCommunity trafficMarking = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.TrafficMarkingExtendedCommunity) extendedCommunity) .getTrafficMarkingExtendedCommunity(); byteAggregator.writeZero(RESERVED); ByteBufWriteUtil.writeUnsignedByte(trafficMarking.getGlobalAdministrator().getValue().shortValue(), byteAggregator); }