use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes 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.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class L3vpnMcastIpv4NlriHandler method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (routes != null && routes.getDestinationType() instanceof DestinationL3vpnMcastIpv4AdvertizedCase) {
final DestinationL3vpnMcastIpv4AdvertizedCase reach = (DestinationL3vpnMcastIpv4AdvertizedCase) routes.getDestinationType();
L3vpnMcastNlriSerializer.serializeNlri(reach.getDestinationIpv4L3vpnMcast().getL3vpnMcastDestination(), byteAggregator);
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof DestinationL3vpnMcastIpv4WithdrawnCase) {
final DestinationL3vpnMcastIpv4WithdrawnCase reach = (DestinationL3vpnMcastIpv4WithdrawnCase) withdrawnRoutes.getDestinationType();
L3vpnMcastNlriSerializer.serializeNlri(reach.getDestinationIpv4L3vpnMcast().getL3vpnMcastDestination(), byteAggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class L3vpnMcastIpv4RIBSupportTest method testBuildMpReachNlriUpdate.
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MCAST_L3VPN_ROUTES);
final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class VpnIpv6RIBSupportTest method testBuildMpReachNlriUpdate.
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class RouteTargetConstrainNlriHandler method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (routes != null && routes.getDestinationType() instanceof DestinationRouteTargetConstrainAdvertizedCase) {
final DestinationRouteTargetConstrainAdvertizedCase reach = (DestinationRouteTargetConstrainAdvertizedCase) routes.getDestinationType();
byteAggregator.writeBytes(serializeNlriDestinations(reach.getDestinationRouteTargetConstrain().getRouteTargetConstrainDestination()));
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof DestinationRouteTargetConstrainWithdrawnCase) {
final DestinationRouteTargetConstrainWithdrawnCase reach = (DestinationRouteTargetConstrainWithdrawnCase) withdrawnRoutes.getDestinationType();
byteAggregator.writeBytes(serializeNlriDestinations(reach.getDestinationRouteTargetConstrain().getRouteTargetConstrainDestination()));
}
}
}
Aggregations