BUG-4826: BGP Evpn Nlri's registry
[bgpcep.git] / bgp / evpn / src / main / java / org / opendaylight / protocol / bgp / evpn / impl / BGPActivator.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.bgp.evpn.impl;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.protocol.bgp.evpn.impl.esi.types.ESIActivator;
14 import org.opendaylight.protocol.bgp.evpn.impl.extended.communities.DefaultGatewayExtCom;
15 import org.opendaylight.protocol.bgp.evpn.impl.extended.communities.ESILabelExtCom;
16 import org.opendaylight.protocol.bgp.evpn.impl.extended.communities.ESImpRouteTargetExtCom;
17 import org.opendaylight.protocol.bgp.evpn.impl.extended.communities.MACMobExtCom;
18 import org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriActivator;
19 import org.opendaylight.protocol.bgp.parser.spi.AbstractBGPExtensionProviderActivator;
20 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.EvpnSubsequentAddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.L2vpnAddressFamily;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCase;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.update.attributes.extended.communities.extended.community.EsImportRouteExtendedCommunityCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.update.attributes.extended.communities.extended.community.EsiLabelExtendedCommunityCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.update.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCase;
27
28 public final class BGPActivator extends AbstractBGPExtensionProviderActivator {
29     private static final int L2VPN_AFI = 25;
30     private static final int EVPN_SAFI = 70;
31
32     @Override
33     protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
34         final List<AutoCloseable> regs = new ArrayList<>();
35
36         regs.add(context.registerSubsequentAddressFamily(EvpnSubsequentAddressFamily.class, EVPN_SAFI));
37         regs.add(context.registerAddressFamily(L2vpnAddressFamily.class, L2VPN_AFI));
38
39         NlriActivator.registerNlriParsers(regs);
40         registerExtendedCommunities(context, regs);
41         ESIActivator.registerEsiTypeParsers(regs);
42         return regs;
43     }
44
45     private void registerExtendedCommunities(final BGPExtensionProviderContext context, final List<AutoCloseable> regs) {
46         final DefaultGatewayExtCom defGEC = new DefaultGatewayExtCom();
47         regs.add(context.registerExtendedCommunityParser(defGEC.getType(true), defGEC.getSubType(), defGEC));
48         regs.add(context.registerExtendedCommunitySerializer(DefaultGatewayExtendedCommunityCase.class, defGEC));
49
50         final ESILabelExtCom esiLEC = new ESILabelExtCom();
51         regs.add(context.registerExtendedCommunityParser(esiLEC.getType(true), esiLEC.getSubType(), esiLEC));
52         regs.add(context.registerExtendedCommunitySerializer(EsiLabelExtendedCommunityCase.class, esiLEC));
53
54         final ESImpRouteTargetExtCom esImpEC = new ESImpRouteTargetExtCom();
55         regs.add(context.registerExtendedCommunityParser(esImpEC.getType(true), esImpEC.getSubType(), esImpEC));
56         regs.add(context.registerExtendedCommunitySerializer(EsImportRouteExtendedCommunityCase.class, esImpEC));
57
58         final MACMobExtCom macEC = new MACMobExtCom();
59         regs.add(context.registerExtendedCommunityParser(macEC.getType(true), macEC.getSubType(), macEC));
60         regs.add(context.registerExtendedCommunitySerializer(MacMobilityExtendedCommunityCase.class, macEC));
61     }
62
63
64 }