@Override
 public void serializeExtendedCommunity(
     final ExtendedCommunities exCommunities, final ByteBuf buffer) {
   final ExtendedCommunity ex = exCommunities.getExtendedCommunity();
   if (ex instanceof TrafficRateExtendedCommunityCase) {
     final TrafficRateExtendedCommunity trafficRate =
         ((TrafficRateExtendedCommunityCase) ex).getTrafficRateExtendedCommunity();
     ByteBufWriteUtil.writeShort(trafficRate.getInformativeAs().getValue().shortValue(), buffer);
     buffer.writeBytes(trafficRate.getLocalAdministrator().getValue());
   } else if (ex instanceof TrafficActionExtendedCommunityCase) {
     final TrafficActionExtendedCommunity trafficAction =
         ((TrafficActionExtendedCommunityCase) ex).getTrafficActionExtendedCommunity();
     buffer.writeZero(RESERVED);
     final BitArray flags = new BitArray(FLAGS_SIZE);
     flags.set(SAMPLE_BIT, trafficAction.isSample());
     flags.set(TERMINAL_BIT, trafficAction.isTerminalAction());
     flags.toByteBuf(buffer);
   } else if (ex instanceof RedirectExtendedCommunityCase) {
     final RedirectExtendedCommunity redirect =
         ((RedirectExtendedCommunityCase) ex).getRedirectExtendedCommunity();
     ByteBufWriteUtil.writeUnsignedShort(
         redirect.getGlobalAdministrator().getValue().intValue(), buffer);
     buffer.writeBytes(redirect.getLocalAdministrator());
   } else if (ex instanceof TrafficMarkingExtendedCommunityCase) {
     final TrafficMarkingExtendedCommunity trafficMarking =
         ((TrafficMarkingExtendedCommunityCase) ex).getTrafficMarkingExtendedCommunity();
     buffer.writeZero(RESERVED);
     ByteBufWriteUtil.writeUnsignedByte(
         trafficMarking.getGlobalAdministrator().getValue().shortValue(), buffer);
   } else {
     super.serializeExtendedCommunity(exCommunities, buffer);
   }
 }
Ejemplo n.º 2
0
 @Override
 public void serializeTlv(final Tlv tlv, final ByteBuf output) {
   Preconditions.checkArgument(
       tlv instanceof PerAfiSafiLocRibTlv, "PerAfiSafiLocRibInTlv is mandatory.");
   final ByteBuf buffer = Unpooled.buffer();
   ByteBufWriteUtil.writeUnsignedShort(
       this.afiRegistry.numberForClass(((PerAfiSafiLocRibTlv) tlv).getAfi()), buffer);
   ByteBufWriteUtil.writeUnsignedByte(
       this.safiRegistry.numberForClass(((PerAfiSafiLocRibTlv) tlv).getSafi()).shortValue(),
       buffer);
   ByteBufWriteUtil.writeUnsignedLong(((PerAfiSafiLocRibTlv) tlv).getCount().getValue(), buffer);
   TlvUtil.formatTlv(TYPE, buffer, output);
 }