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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
20 import org.opendaylight.yangtools.yang.binding.DataObject;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
23 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
25 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
26 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
27 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
28 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
29 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
32 * Interface implemented for AFI/SAFI-specific RIB extensions. The extensions need
33 * to register an implementation of this class and the RIB core then calls into it
34 * to inquire about details specific to that particular model.
36 public interface RIBSupport extends AddPathRibSupport {
38 * Return the table-type-specific empty routes container, as augmented into the
39 * bgp-rib model under /rib/tables/routes choice node. This needs to include all
40 * the skeleton nodes under which the individual routes will be stored.
42 * @return Protocol-specific case in the routes choice, may not be null.
44 @Nonnull ChoiceNode emptyRoutes();
47 * Return the localized identifier of the attributes route member, as expanded
48 * from the route grouping in the specific augmentation of the base routes choice.
50 * @return The attributes identifier, may not be null.
52 @Nonnull NodeIdentifier routeAttributesIdentifier();
55 * Return class object of the Routes Case statement.
59 @Nonnull Class<? extends Routes> routesCaseClass();
62 * Return class object of the Routes Container statement.
66 @Nonnull Class<? extends DataObject> routesContainerClass();
69 * Return class object of the Routes List statement.
73 @Nonnull Class<? extends Route> routesListClass();
75 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
76 @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
79 * Given the NLRI as ContainerNode, this method should extract withdrawn routes
80 * from the DOM model and delete them from RIBs.
82 * @param tx DOMDataWriteTransaction
83 * @param tablePath YangInstanceIdentifier
84 * @param nlri ContainerNode DOM representation of NLRI in Update message
86 void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri);
90 * Given the NLRI as ContainerNode, this method should extract withdrawn routes
91 * from the DOM model and delete them from RIBs.
93 * Use this method when removing routes stored in RIBs out of the "bgp-rib" module.
94 * Provide {@link NodeIdentifier} with customized "routes" QName.
95 * For default "bgp-rib" RIBs use {@link #deleteRoutes}
98 * @param tx DOMDataWriteTransaction
99 * @param tablePath YangInstanceIdentifier
100 * @param nlri ContainerNode DOM representation of NLRI in Update message
101 * @param routesNodeId NodeIdentifier of "routes" data node
103 void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull NodeIdentifier routesNodeId);
106 * Given the NLRI as ContainerNode, this method should extract advertised routes
107 * from the DOM model and put them into RIBs.
109 * @param tx DOMDataWriteTransaction
110 * @param tablePath YangInstanceIdentifier
111 * @param nlri ContainerNode DOM representation of NLRI in Update message
112 * @param attributes ContainerNode
114 void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
117 * Given the NLRI as ContainerNode, this method should extract advertised routes
118 * from the DOM model and put them into RIBs.
120 * Use this method when putting routes stored in RIBs out of the "bgp-rib" module.
121 * Provide {@link NodeIdentifier} with customized "routes" QName.
122 * For default "bgp-rib" RIBs use {@link #putRoutes}
125 * @param tx DOMDataWriteTransaction
126 * @param tablePath YangInstanceIdentifier
127 * @param nlri ContainerNode DOM representation of NLRI in Update message
128 * @param attributes ContainerNode
129 * @param routesNodeId NodeIdentifier of "routes" data node
131 void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri,
132 @Nonnull ContainerNode attributes, @Nonnull NodeIdentifier routesNodeId);
135 * Returns routes that were modified within this RIB support instance.
137 * @param routes DataTreeCandidateNode
138 * @return collection of modified nodes or empty collection if no node was modified
140 @Nonnull Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
143 * Constructs an instance identifier path to routeId.
145 * @param routesPath YangInstanceIdentifier base path
146 * @param routeId PathArgument leaf path
147 * @return YangInstanceIdentifier with routesPath + specific RIB support routes path + routeId
149 @Nonnull YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath, @Nonnull PathArgument routeId);
152 * Indicate whether this AFI/SAFI combination is a complex route. Simple routes are those which
153 * only have their key and attributes, complex routes are those which include more structured data.
155 * @return True if this is a complex route, false otherwise.
157 boolean isComplexRoute();
160 * To send routes out, we'd need to transform the DOM representation of route to
161 * binding-aware format. This needs to be done per each AFI/SAFI.
163 * @param advertised Collection of advertised routes in DOM format
164 * @param withdrawn Collection of withdrawn routes in DOM format
165 * @param attr Attributes MpReach is part of Attributes so we need to pass
166 * it as argument, create new AttributesBuilder with existing
167 * attributes and add MpReach
168 * @return Update message ready to be sent out
170 @Nonnull Update buildUpdate(@Nonnull Collection<MapEntryNode> advertised, @Nonnull Collection<MapEntryNode> withdrawn, @Nonnull Attributes attr);
172 @Nonnull Class<? extends AddressFamily> getAfi();
174 @Nonnull Class<? extends SubsequentAddressFamily> getSafi();
176 interface ApplyRoute {
177 void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route,
178 ContainerNode attributes);