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.NodeIdentifierWithPredicates;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
23 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
24 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
25 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
26 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
27 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
30 * Interface implemented for AFI/SAFI-specific RIB extensions. The extensions need
31 * to register an implementation of this class and the RIB core then calls into it
32 * to inquire about details specific to that particular model.
34 public interface RIBSupport extends AddPathRibSupport {
36 * Return the table-type-specific empty routes container, as augmented into the
37 * bgp-rib model under /rib/tables/routes choice node. This needs to include all
38 * the skeleton nodes under which the individual routes will be stored.
40 * @return Protocol-specific case in the routes choice, may not be null.
42 @Nonnull ChoiceNode emptyRoutes();
45 * Return the localized identifier of the attributes route member, as expanded
46 * from the route grouping in the specific augmentation of the base routes choice.
48 * @return The attributes identifier, may not be null.
50 @Nonnull NodeIdentifier routeAttributesIdentifier();
53 * Return class object of the Routes Case statement.
57 @Nonnull Class<? extends Routes> routesCaseClass();
60 * Return class object of the Routes Container statement.
64 @Nonnull Class<? extends DataObject> routesContainerClass();
67 * Return class object of the Routes List statement.
71 @Nonnull Class<? extends Route> routesListClass();
73 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
74 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
77 * Given the NLRI as ContainerNode, this method should extract withdrawn routes
78 * from the DOM model and delete them from RIBs.
80 * @param tx DOMDataWriteTransaction
81 * @param tablePath YangInstanceIdentifier
82 * @param nlri ContainerNode DOM representation of NLRI in Update message
84 void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri);
88 * Given the NLRI as ContainerNode, this method should extract withdrawn routes
89 * from the DOM model and delete them from RIBs.
91 * Use this method when removing routes stored in RIBs out of the "bgp-rib" module.
92 * Provide {@link NodeIdentifier} with customized "routes" QName.
93 * For default "bgp-rib" RIBs use {@link #deleteRoutes}
96 * @param tx DOMDataWriteTransaction
97 * @param tablePath YangInstanceIdentifier
98 * @param nlri ContainerNode DOM representation of NLRI in Update message
99 * @param routesNodeId NodeIdentifier of "routes" data node
101 void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull NodeIdentifier routesNodeId);
104 * Given the NLRI as ContainerNode, this method should extract advertised routes
105 * from the DOM model and put them into RIBs.
107 * @param tx DOMDataWriteTransaction
108 * @param tablePath YangInstanceIdentifier
109 * @param nlri ContainerNode DOM representation of NLRI in Update message
110 * @param attributes ContainerNode
112 void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
115 * Given the NLRI as ContainerNode, this method should extract advertised routes
116 * from the DOM model and put them into RIBs.
118 * Use this method when putting routes stored in RIBs out of the "bgp-rib" module.
119 * Provide {@link NodeIdentifier} with customized "routes" QName.
120 * For default "bgp-rib" RIBs use {@link #putRoutes}
123 * @param tx DOMDataWriteTransaction
124 * @param tablePath YangInstanceIdentifier
125 * @param nlri ContainerNode DOM representation of NLRI in Update message
126 * @param attributes ContainerNode
127 * @param routesNodeId NodeIdentifier of "routes" data node
129 void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri,
130 @Nonnull ContainerNode attributes, @Nonnull NodeIdentifier routesNodeId);
133 * Returns routes that were modified within this RIB support instance.
135 * @param routes DataTreeCandidateNode
136 * @return collection of modified nodes or empty collection if no node was modified
138 @Nonnull Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
141 * Constructs an instance identifier path to routeId.
143 * @param routesPath YangInstanceIdentifier base path
144 * @param routeId PathArgument leaf path
145 * @return YangInstanceIdentifier with routesPath + specific RIB support routes path + routeId
147 @Nonnull YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath, @Nonnull PathArgument routeId);
150 * Indicate whether this AFI/SAFI combination is a complex route. Simple routes are those which
151 * only have their key and attributes, complex routes are those which include more structured data.
153 * @return True if this is a complex route, false otherwise.
155 boolean isComplexRoute();
158 * To send routes out, we'd need to transform the DOM representation of route to
159 * binding-aware format. This needs to be done per each AFI/SAFI.
161 * @param advertised Collection of advertised routes in DOM format
162 * @param withdrawn Collection of withdrawn routes in DOM format
163 * @param attr Attributes MpReach is part of Attributes so we need to pass
164 * it as argument, create new AttributesBuilder with existing
165 * attributes and add MpReach
166 * @return Update message ready to be sent out
168 @Nonnull Update buildUpdate(@Nonnull Collection<MapEntryNode> advertised, @Nonnull Collection<MapEntryNode> withdrawn, @Nonnull Attributes attr);
171 interface ApplyRoute {
172 void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route,
173 ContainerNode attributes);