2 * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.mode.spi;
11 import static java.util.Objects.requireNonNull;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.protocol.bgp.mode.api.BestPath;
15 import org.opendaylight.protocol.bgp.mode.api.RouteEntry;
16 import org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker;
17 import org.opendaylight.protocol.bgp.rib.spi.Peer;
18 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
25 public abstract class AbstractRouteEntry<T extends BestPath> implements RouteEntry {
26 protected static final Attributes[] EMPTY_ATTRIBUTES = new Attributes[0];
27 protected static final Route[] EMPTY_VALUES = new Route[0];
28 protected final BGPPeerTracker peerTracker;
30 public AbstractRouteEntry(final BGPPeerTracker peerTracker) {
31 this.peerTracker = requireNonNull(peerTracker);
35 * Create new Route with route jey created from passed parameters.
37 public abstract Route createRoute(@Nonnull RIBSupport ribSup, @Nonnull String routeKey, long pathId, T path);
40 * Returns true if route can be send.
42 protected boolean filterRoutes(final PeerId fromPeer, final Peer toPeer, final TablesKey localTK) {
43 return !(toPeer == null
44 || !toPeer.supportsTable(localTK)
45 || PeerRole.Internal.equals(toPeer.getRole()))
46 && !fromPeer.equals(toPeer.getPeerId());