*/
package org.opendaylight.protocol.bgp.rib.impl;
-import java.util.EnumMap;
-import java.util.Map;
import javax.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
/**
* Defines the internal hooks invoked when a new route appears.
*/
abstract class AbstractImportPolicy {
- // Invoked on routes which we get from outside of our home AS
- private static final class FromExternalImportPolicy extends AbstractImportPolicy {
- @Override
- ContainerNode effectiveAttributes(final ContainerNode attributes) {
- // FIXME: filter all non-transitive attributes
- // FIXME: but that may end up hurting our informedness
- return attributes;
- }
- }
-
- // Invoked on routes which we get from our normal home AS peers.
- private static class FromInternalImportPolicy extends AbstractImportPolicy {
- @Override
- ContainerNode effectiveAttributes(final ContainerNode attributes) {
- // FIXME: Implement filtering according to <a href="http://tools.ietf.org/html/rfc4456#section-8"/>.
- return attributes;
- }
- }
-
- /**
- * Invoked on routes which we get from our reflector peers. This is a special-case of
- * FromInternalImportPolicy.
- *
- */
- private static final class FromReflectorClientImportPolicy extends FromInternalImportPolicy {
- // FIXME: override if necessary
- }
-
- private static final Map<PeerRole, AbstractImportPolicy> POLICIES;
-
- static {
- final Map<PeerRole, AbstractImportPolicy> p = new EnumMap<PeerRole, AbstractImportPolicy>(PeerRole.class);
- p.put(PeerRole.Ebgp, new FromExternalImportPolicy());
- p.put(PeerRole.Ibgp, new FromInternalImportPolicy());
- p.put(PeerRole.RrClient, new FromReflectorClientImportPolicy());
- POLICIES = p;
- }
-
- static AbstractImportPolicy forRole(final PeerRole peerRole) {
- return POLICIES.get(peerRole);
- }
-
/**
* Transform incoming attributes according to policy.
*
* @param attributes received attributes
* @return Filtered attributes, or null if the advertisement should be ignored.
*/
- abstract @Nullable ContainerNode effectiveAttributes(@Nullable ContainerNode attributes);
+ @Nullable abstract ContainerNode effectiveAttributes(@Nullable ContainerNode attributes);
}
\ No newline at end of file