Provide Add Path support for all AFI/SAFI
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / impl / add / all / paths / SimpleRouteEntry.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.mode.impl.add.all.paths;
10
11 import com.google.common.primitives.UnsignedInteger;
12 import org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath;
13 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
14 import org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker;
15 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route;
17 import org.opendaylight.yangtools.yang.binding.Identifier;
18
19 final class SimpleRouteEntry extends AbstractAllPathsRouteEntry {
20     SimpleRouteEntry(final BGPPeerTracker peerTracker) {
21         super(peerTracker);
22     }
23
24     @Override
25     public boolean removeRoute(final UnsignedInteger routerId, final long remotePathId) {
26         final RouteKey key = new RouteKey(routerId, remotePathId);
27         return removeRoute(key, getOffsets().offsetOf(key));
28     }
29
30     @Override
31     public Route createRoute(final RIBSupport ribSup, final Identifier routeKey, final long pathId,
32             final AddPathBestPath path) {
33         return ribSup.createRoute(null, routeKey, pathId, path.getAttributes());
34     }
35
36     @Override
37     public int addRoute(final UnsignedInteger routerId, final long remotePathId, final Route route) {
38         return addRoute(new RouteKey(routerId, remotePathId), route.getAttributes());
39     }
40 }