use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class NodeAttributesParser method parseNodeAttributes.
/**
* Parse Node Attributes.
*
* @param attributes key is the tlv type and value is the value of the tlv
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
static LinkStateAttribute parseNodeAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
final List<TopologyIdentifier> topologyMembership = new ArrayList<>();
final List<IsisAreaIdentifier> areaMembership = new ArrayList<>();
final NodeAttributesBuilder builder = new NodeAttributesBuilder();
for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
final int key = entry.getKey();
final ByteBuf value = entry.getValue();
LOG.trace("Node attribute TLV {}", key);
switch(key) {
case TlvUtil.MULTI_TOPOLOGY_ID:
parseTopologyId(topologyMembership, value);
break;
case NODE_FLAG_BITS:
parseNodeFlags(value, builder);
break;
case NODE_OPAQUE:
if (LOG.isDebugEnabled()) {
LOG.debug("Ignoring opaque value: {}.", ByteBufUtil.hexDump(value));
}
break;
case DYNAMIC_HOSTNAME:
builder.setDynamicHostname(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
LOG.debug("Parsed Node Name {}", builder.getDynamicHostname());
break;
case ISIS_AREA_IDENTIFIER:
final IsisAreaIdentifier ai = new IsisAreaIdentifier(ByteArray.readAllBytes(value));
areaMembership.add(ai);
LOG.debug("Parsed AreaIdentifier {}", ai);
break;
case TlvUtil.LOCAL_IPV4_ROUTER_ID:
final Ipv4RouterIdentifier ip4 = new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value));
builder.setIpv4RouterId(ip4);
LOG.debug("Parsed IPv4 Router Identifier {}", ip4);
break;
case TlvUtil.LOCAL_IPV6_ROUTER_ID:
final Ipv6RouterIdentifier ip6 = new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value));
builder.setIpv6RouterId(ip6);
LOG.debug("Parsed IPv6 Router Identifier {}", ip6);
break;
case SR_CAPABILITIES:
final SrCapabilities caps = SrNodeAttributesParser.parseSrCapabilities(value, protocolId);
builder.setSrCapabilities(caps);
LOG.debug("Parsed SR Capabilities {}", caps);
break;
case SR_ALGORITHMS:
final SrAlgorithm algs = SrNodeAttributesParser.parseSrAlgorithms(value);
builder.setSrAlgorithm(algs);
LOG.debug("Parsed SR Algorithms {}", algs);
break;
default:
LOG.warn("TLV {} is not a valid node attribute, ignoring it", key);
}
}
LOG.trace("Finished parsing Node Attributes.");
builder.setTopologyIdentifier(topologyMembership);
builder.setIsisAreaId(areaMembership);
return new NodeAttributesCaseBuilder().setNodeAttributes(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class BGPSessionStateImpl method advertizeCapabilities.
@Override
public synchronized void advertizeCapabilities(final int holdTimerValue, final SocketAddress remoteAddress, final SocketAddress localAddress, final Set<BgpTableType> tableTypes, final List<BgpParameters> bgpParameters) {
if (bgpParameters != null && !bgpParameters.isEmpty()) {
for (final BgpParameters parameters : bgpParameters) {
for (final OptionalCapabilities optionalCapabilities : parameters.getOptionalCapabilities()) {
final CParameters cParam = optionalCapabilities.getCParameters();
final CParameters1 capabilities = cParam.getAugmentation(CParameters1.class);
if (capabilities != null) {
final MultiprotocolCapability mc = capabilities.getMultiprotocolCapability();
if (mc != null) {
this.multiProtocolCapability = true;
}
if (capabilities.getGracefulRestartCapability() != null) {
this.gracefulRestartCapability = true;
}
if (capabilities.getAddPathCapability() != null) {
this.addPathCapability = true;
}
if (capabilities.getRouteRefreshCapability() != null) {
this.routerRefreshCapability = true;
}
}
if (cParam.getAs4BytesCapability() != null) {
this.asn32Capability = true;
}
}
}
}
this.holdTimerValue = holdTimerValue;
this.remoteAddress = StrictBGPPeerRegistry.getIpAddress(remoteAddress);
this.remotePort = new PortNumber(((InetSocketAddress) remoteAddress).getPort());
this.localPort = new PortNumber(((InetSocketAddress) localAddress).getPort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class NeighborUtil method buildCapabilityState.
/**
* Builds Neighbor State containing Capabilities State, session State.
*
* @return Neighbor State
*/
public static NeighborStateAugmentation buildCapabilityState(@Nonnull final BGPSessionState neighbor) {
final List<Class<? extends BgpCapability>> supportedCapabilities = buildSupportedCapabilities(neighbor);
SessionState sessionState = null;
switch(neighbor.getSessionState()) {
case IDLE:
sessionState = SessionState.IDLE;
break;
case UP:
sessionState = SessionState.ESTABLISHED;
break;
case OPEN_CONFIRM:
sessionState = SessionState.OPENCONFIRM;
break;
default:
}
return new NeighborStateAugmentationBuilder().setSupportedCapabilities(supportedCapabilities).setSessionState(sessionState).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.
the class BuildSwitchCapabilitiesOF13 method build.
@Override
public SwitchFeatures build(GetFeaturesOutput features) {
SwitchFeaturesBuilder builderSwFeatures = new SwitchFeaturesBuilder();
builderSwFeatures.setMaxBuffers(features.getBuffers());
builderSwFeatures.setMaxTables(features.getTables());
List<Class<? extends FeatureCapability>> capabilities = new ArrayList<>();
if (features.getCapabilities().isOFPCFLOWSTATS()) {
capabilities.add(FlowFeatureCapabilityFlowStats.class);
}
if (features.getCapabilities().isOFPCGROUPSTATS()) {
capabilities.add(FlowFeatureCapabilityGroupStats.class);
}
if (features.getCapabilities().isOFPCIPREASM()) {
capabilities.add(FlowFeatureCapabilityIpReasm.class);
}
if (features.getCapabilities().isOFPCPORTBLOCKED()) {
capabilities.add(FlowFeatureCapabilityPortBlocked.class);
}
if (features.getCapabilities().isOFPCPORTSTATS()) {
capabilities.add(FlowFeatureCapabilityPortStats.class);
}
if (features.getCapabilities().isOFPCQUEUESTATS()) {
capabilities.add(FlowFeatureCapabilityQueueStats.class);
}
if (features.getCapabilities().isOFPCTABLESTATS()) {
capabilities.add(FlowFeatureCapabilityTableStats.class);
}
builderSwFeatures.setCapabilities(capabilities);
return builderSwFeatures.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.
the class OF10DeviceInitializer method initializeNodeInformation.
@Override
protected Future<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final boolean skipTableFeatures, @Nullable final MultipartWriterProvider multipartWriterProvider, @Nullable final ConvertorExecutor convertorExecutor) {
final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
final DeviceInfo deviceInfo = Preconditions.checkNotNull(deviceContext.getDeviceInfo());
final CapabilitiesV10 capabilitiesV10 = connectionContext.getFeatures().getCapabilitiesV10();
// Set capabilities for this device based on capabilities of connection context
LOG.debug("Setting capabilities for device {}", deviceInfo);
DeviceStateUtil.setDeviceStateBasedOnV10Capabilities(deviceState, capabilitiesV10);
final ListenableFuture<Boolean> future = requestMultipart(MultipartType.OFPMPDESC, deviceContext);
Futures.addCallback(future, new FutureCallback<Boolean>() {
@Override
public void onSuccess(@Nullable final Boolean result) {
if (Boolean.TRUE.equals(result)) {
LOG.debug("Creating empty flow capable node: {}", deviceInfo);
makeEmptyFlowCapableNode(deviceContext, deviceInfo);
LOG.debug("Creating empty tables for {}", deviceInfo);
DeviceInitializationUtil.makeEmptyTables(deviceContext, deviceInfo, deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
}
}
@Override
public void onFailure(@Nonnull final Throwable throwable) {
LOG.warn("Error occurred in preparation node {} for protocol 1.0", deviceInfo);
LOG.trace("Error for node {} : ", deviceInfo, throwable);
}
}, MoreExecutors.directExecutor());
return Futures.transform(future, new Function<Boolean, Void>() {
@Nullable
@Override
public Void apply(@Nullable final Boolean input) {
LOG.debug("Writing physical port information for {}", deviceInfo);
writePhyPortInformation(deviceContext);
return null;
}
}, MoreExecutors.directExecutor());
}
Aggregations