2 * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
8 package org.opendaylight.protocol.bgp.rib.spi;
10 import com.google.common.collect.ImmutableCollection;
11 import java.util.Collection;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
22 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
23 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
24 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
25 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
28 * Interface implemented for AFI/SAFI-specific RIB extensions. The extensions need
29 * to register an implementation of this class and the RIB core then calls into it
30 * to inquire about details specific to that particular model.
32 public interface RIBSupport {
34 * Return the table-type-specific empty routes container, as augmented into the
35 * bgp-rib model under /rib/tables/routes choice node. This needs to include all
36 * the skeleton nodes under which the individual routes will be stored.
38 * @return Protocol-specific case in the routes choice, may not be null.
40 @Nonnull ChoiceNode emptyRoutes();
43 * Return the localized identifier of the attributes route member, as expanded
44 * from the route grouping in the specific augmentation of the base routes choice.
46 * @return The attributes identifier, may not be null.
48 @Nonnull NodeIdentifier routeAttributesIdentifier();
51 * Return class object of the Routes Case statement.
55 @Nonnull Class<? extends Routes> routesCaseClass();
58 * Return class object of the Routes Container statement.
62 @Nonnull Class<? extends DataObject> routesContainerClass();
65 * Return class object of the Routes List statement.
69 @Nonnull Class<? extends Route> routesListClass();
71 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
72 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
75 * Given the NLRI as ContainerNode, this method should extract withdrawn routes
76 * from the DOM model and delete them from RIBs.
78 * @param tx DOMDataWriteTransaction
79 * @param tablePath YangInstanceIdentifier
80 * @param nlri ContainerNode DOM representation of NLRI in Update message
82 void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri);
85 * Given the NLRI as ContainerNode, this method should extract advertised routes
86 * from the DOM model and put them into RIBs.
88 * @param tx DOMDataWriteTransaction
89 * @param tablePath YangInstanceIdentifier
90 * @param nlri ContainerNode DOM representation of NLRI in Update message
91 * @param attributes ContainerNode
93 void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
96 * Returns routes that were modified within this RIB support instance.
98 * @param routes DataTreeCandidateNode
99 * @return collection of modified nodes or empty collection if no node was modified
101 @Nonnull Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
104 * Constructs an instance identifier path to routeId.
106 * @param routesPath YangInstanceIdentifier base path
107 * @param routeId PathArgument leaf path
108 * @return YangInstanceIdentifier with routesPath + specific RIB support routes path + routeId
110 @Nonnull YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath, @Nonnull PathArgument routeId);
113 * Indicate whether this AFI/SAFI combination is a complex route. Simple routes are those which
114 * only have their key and attributes, complex routes are those which include more structured data.
116 * @return True if this is a complex route, false otherwise.
118 boolean isComplexRoute();
121 * To send routes out, we'd need to transform the DOM representation of route to
122 * binding-aware format. This needs to be done per each AFI/SAFI.
124 * @param advertised Collection of advertised routes in DOM format
125 * @param withdrawn Collection of withdrawn routes in DOM format
126 * @param attr Attributes MpReach is part of Attributes so we need to pass
127 * it as argument, create new AttributesBuilder with existing
128 * attributes and add MpReach
129 * @return Update message ready to be sent out
131 @Nonnull Update buildUpdate(@Nonnull Collection<MapEntryNode> advertised, @Nonnull Collection<MapEntryNode> withdrawn, @Nonnull Attributes attr);