@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())); }
private static ByteBuf serializeBody(final MacIpAdvRouteCase evpnCase) { final ByteBuf body = Unpooled.buffer(); final MacIpAdvRoute evpn = evpnCase.getMacIpAdvRoute(); final Esi esi = evpn.getEsi(); if (esi != null) { SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); } ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); final MacAddress mac = evpn.getMacAddress(); body.writeByte(MAC_ADDRESS_LENGTH * BITS_SIZE); body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(mac)); final ByteBuf ipAddress = serializeIp(evpn.getIpAddress()); Preconditions.checkArgument(ipAddress.readableBytes() > 0); body.writeBytes(ipAddress); final MplsLabel mpls1 = evpn.getMplsLabel1(); if (mpls1 != null) { body.writeBytes(byteBufForMplsLabel(mpls1)); } final MplsLabel mpls2 = evpn.getMplsLabel2(); if (mpls2 != null) { body.writeBytes(byteBufForMplsLabel(mpls2)); } return body; }
private static ByteBuf serializeBody(final EthernetADRoute evpn) { final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body); ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body); final MplsLabel mpls = evpn.getMplsLabel(); if (mpls != null) { body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel())); } return body; } }