2 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.bgp.l3vpn.mcast.nlri;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
13 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
14 import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupportUtil;
15 import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
16 import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
17 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationL3vpnMcastIpv6AdvertizedCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationL3vpnMcastIpv6AdvertizedCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.l3vpn.mcast.ipv6.advertized._case.DestinationIpv6L3vpnMcastBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationL3vpnMcastIpv6WithdrawnCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationL3vpnMcastIpv6WithdrawnCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlriBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlriBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
34 * https://tools.ietf.org/html/rfc6514#section-4.
36 * @author Claudio D. Gasparini
38 public final class L3vpnMcastIpv6NlriHandler implements NlriParser, NlriSerializer {
40 public void parseNlri(
42 final MpReachNlriBuilder builder,
43 final PeerSpecificParserConstraint constraint) throws BGPParsingException {
44 if (!nlri.isReadable()) {
47 final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
48 new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
50 builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
51 new DestinationL3vpnMcastIpv6AdvertizedCaseBuilder().setDestinationIpv6L3vpnMcast(
52 new DestinationIpv6L3vpnMcastBuilder().setL3vpnMcastDestination(
53 L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
58 public void parseNlri(
60 final MpUnreachNlriBuilder builder,
61 final PeerSpecificParserConstraint constraint) throws BGPParsingException {
62 if (!nlri.isReadable()) {
65 final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
66 new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
67 builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder()
68 .setDestinationType(new DestinationL3vpnMcastIpv6WithdrawnCaseBuilder().setDestinationIpv6L3vpnMcast(
69 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417
70 .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.l3vpn
71 .mcast.ipv6.withdrawn._case.DestinationIpv6L3vpnMcastBuilder()
72 .setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported))
73 .build()).build()).build());
77 public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
78 final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class);
79 final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class);
80 if (pathAttributes1 != null) {
81 final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
82 if (routes != null && routes.getDestinationType() instanceof DestinationL3vpnMcastIpv6AdvertizedCase) {
83 final DestinationL3vpnMcastIpv6AdvertizedCase reach
84 = (DestinationL3vpnMcastIpv6AdvertizedCase) routes.getDestinationType();
85 L3vpnMcastNlriSerializer.serializeNlri(reach.getDestinationIpv6L3vpnMcast().getL3vpnMcastDestination(),
88 } else if (pathAttributes2 != null) {
89 final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
90 if (withdrawnRoutes != null
91 && withdrawnRoutes.getDestinationType() instanceof DestinationL3vpnMcastIpv6WithdrawnCase) {
92 final DestinationL3vpnMcastIpv6WithdrawnCase reach
93 = (DestinationL3vpnMcastIpv6WithdrawnCase) withdrawnRoutes.getDestinationType();
94 L3vpnMcastNlriSerializer.serializeNlri(reach.getDestinationIpv6L3vpnMcast().getL3vpnMcastDestination(),