private void processSupportedSendReceiveTables(final DataTreeCandidateNode sendReceiveModChild, final PeerId peerId) { if (sendReceiveModChild != null) { if (sendReceiveModChild.getModificationType().equals(ModificationType.DELETE)) { final Optional<NormalizedNode<?, ?>> sendReceiveNode = sendReceiveModChild.getDataBefore(); if (sendReceiveNode.isPresent()) { final SendReceive sendReceiveValue = SendReceive.valueOf(BindingMapping.getClassName((String) sendReceiveNode.get().getValue())); this.peerAddPathTables.remove(peerId); LOG.debug("Supported Add BestPath table {} removed to peer {}", sendReceiveValue, peerId); } } else { final Optional<NormalizedNode<?, ?>> sendReceiveNode = sendReceiveModChild.getDataAfter(); if (sendReceiveNode.isPresent()) { final SendReceive sendReceiveValue = SendReceive.valueOf(BindingMapping.getClassName((String) sendReceiveNode.get().getValue())); this.peerAddPathTables.put(peerId, sendReceiveValue); LOG.debug("Supported Add BestPath table {} added to peer {}", sendReceiveValue, peerId); } } } }
@Override public void serializeCapability(final CParameters capability, final ByteBuf byteAggregator) { if ( (capability.getAugmentation(CParameters1.class) == null) || (capability.getAugmentation(CParameters1.class).getAddPathCapability() == null) ) { return; } final AddPathCapability addPathCap = capability.getAugmentation(CParameters1.class).getAddPathCapability(); final List<AddressFamilies> families = addPathCap.getAddressFamilies(); if (families != null) { final ByteBuf capBuffer = Unpooled.buffer(families.size() * TRIPLET_BYTE_SIZE); for (final AddressFamilies addressFamily : families) { final Class<? extends AddressFamily> afi = addressFamily.getAfi(); final Integer afival = this.afiReg.numberForClass(afi); Preconditions.checkArgument(afival != null, "Unhandled address family " + afi); capBuffer.writeShort(afival); final Class<? extends SubsequentAddressFamily> safi = addressFamily.getSafi(); final Integer safival = this.safiReg.numberForClass(safi); Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi); capBuffer.writeByte(safival); final SendReceive sendReceive = addressFamily.getSendReceive(); Preconditions.checkArgument(sendReceive != null, "Unhandled Send/Receive value"); capBuffer.writeByte(sendReceive.getIntValue()); } CapabilityUtil.formatCapability(CODE, capBuffer, byteAggregator); } }
private void installAdjRibsOutTables(final YangInstanceIdentifier newPeerPath, final RIBSupportContext rs, final NodeIdentifierWithPredicates instanceIdentifierKey, final TablesKey tableKey, final SendReceive sendReceive, final DOMDataWriteTransaction tx) { if (!isAnnounceNone(this.simpleRoutingPolicy)) { final NodeIdentifierWithPredicates supTablesKey = RibSupportUtils.toYangKey(SupportedTables.QNAME, tableKey); final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> tt = Builders.mapEntryBuilder().withNodeIdentifier(supTablesKey); for (final Entry<QName, Object> e : supTablesKey.getKeyValues().entrySet()) { tt.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue())); } if(sendReceive != null) { tt.withChild(ImmutableNodes.leafNode(SEND_RECEIVE, sendReceive.toString().toLowerCase())); } tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath.node(PEER_TABLES).node(supTablesKey), tt.build()); rs.createEmptyTableStructure(tx, newPeerPath.node(EMPTY_ADJRIBOUT.getIdentifier()).node(TABLES).node(instanceIdentifierKey)); } }
@Override public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException { final List<AddressFamilies> families = new ArrayList<>(); while (buffer.isReadable()) { final int afiVal = buffer.readUnsignedShort(); final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afiVal); if (afi == null) { throw new BGPParsingException("Address Family Identifier: '" + afiVal + "' not supported."); } final int safiVal = buffer.readUnsignedByte(); final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safiVal); if (safi == null) { throw new BGPParsingException("Subsequent Address Family Identifier: '" + safiVal + "' not supported."); } final SendReceive sendReceive = SendReceive.forValue(buffer.readUnsignedByte()); if (sendReceive != null) { families.add(new AddressFamiliesBuilder().setAfi(afi).setSafi(safi).setSendReceive(sendReceive).build()); } } return new CParametersBuilder().addAugmentation(CParameters1.class,new CParameters1Builder().setAddPathCapability( new AddPathCapabilityBuilder().setAddressFamilies(families).build()).build()).build(); }