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