Search in sources :

Example 1 with BgpConditions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions in project bgpcep by opendaylight.

the class BgpConditionsRegistry method matchExportCondition.

@SuppressWarnings("unchecked")
private boolean matchExportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters routeEntryExportParameters, final Attributes attributes, final BgpConditions conditions) {
    if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
        return false;
    }
    if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
        return false;
    }
    if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
        return false;
    }
    if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
        return false;
    }
    if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
        return false;
    }
    final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
    if (matchCond != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
        if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchCond)) {
            return false;
        }
    }
    final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
    if (matchAsPathSet != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
        if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
            return false;
        }
    }
    final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
    if (matchExtCommSet != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchExtCommunitySet.class);
        if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
            return false;
        }
    }
    return true;
}
Also used : BgpConditionsPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy) MatchAsPathSet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchAsPathSet) MatchExtCommunitySet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchExtCommunitySet) MatchCommunitySet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchCommunitySet)

Example 2 with BgpConditions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions in project bgpcep by opendaylight.

the class BgpConditionsRegistry method matchImportCondition.

@SuppressWarnings("unchecked")
private boolean matchImportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryImportParameters routeEntryImportParameters, final Attributes attributes, final BgpConditions conditions) {
    if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
        return false;
    }
    if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
        return false;
    }
    if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
        return false;
    }
    if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
        return false;
    }
    if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
        return false;
    }
    final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
    if (matchCond != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
        if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchCond)) {
            return false;
        }
    }
    final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
    if (matchCond != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
        if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
            return false;
        }
    }
    final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
    if (matchExtCommSet != null) {
        final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
        if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
            return false;
        }
    }
    return true;
}
Also used : BgpConditionsPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy) MatchAsPathSet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchAsPathSet) MatchExtCommunitySet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchExtCommunitySet) MatchCommunitySet(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchCommunitySet)

Example 3 with BgpConditions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions in project bgpcep by opendaylight.

the class BgpConditionsRegistry method matchImportConditions.

public boolean matchImportConditions(final RouteEntryBaseAttributes entryInfo, final BGPRouteEntryImportParameters routeEntryImportParameters, final Attributes attributes, final Conditions conditions) {
    final Conditions1 bgpConditionsAug = conditions.getAugmentation(Conditions1.class);
    if (bgpConditionsAug != null) {
        final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
        synchronized (this) {
            if (!matchImportCondition(entryInfo, routeEntryImportParameters, attributes, bgpConditions)) {
                return false;
            }
        }
        final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpAug = BindingReflections.getAugmentations(bgpConditions);
        for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : bgpAug.entrySet()) {
            final BgpConditionsAugmentationPolicy handler = this.bgpConditionsAugRegistry.get(entry.getKey());
            if (handler == null) {
                continue;
            }
            if (!handler.matchImportCondition(entryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), entry.getValue())) {
                return false;
            }
        }
    }
    return true;
}
Also used : Augmentation(org.opendaylight.yangtools.yang.binding.Augmentation) Conditions1(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.Conditions1) BgpConditions(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions) BgpConditionsAugmentationPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with BgpConditions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions in project bgpcep by opendaylight.

the class BgpConditionsRegistry method matchExportConditions.

@SuppressWarnings("unchecked")
public boolean matchExportConditions(final RouteEntryBaseAttributes entryInfo, final BGPRouteEntryExportParameters routeEntryExportParameters, final Attributes attributes, final Conditions conditions) {
    final Conditions1 bgpConditionsAug = conditions.getAugmentation(Conditions1.class);
    if (bgpConditionsAug != null) {
        final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
        if (!matchExportCondition(entryInfo, routeEntryExportParameters, attributes, bgpConditions)) {
            return false;
        }
        final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpAug = BindingReflections.getAugmentations(bgpConditions);
        for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : bgpAug.entrySet()) {
            final BgpConditionsAugmentationPolicy handler = this.bgpConditionsAugRegistry.get(entry.getKey());
            if (handler == null) {
                continue;
            }
            if (!handler.matchExportCondition(entryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), entry.getValue())) {
                return false;
            }
        }
    }
    return true;
}
Also used : Augmentation(org.opendaylight.yangtools.yang.binding.Augmentation) Conditions1(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.Conditions1) BgpConditions(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions) BgpConditionsAugmentationPolicy(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 BgpConditionsAugmentationPolicy (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy)2 BgpConditionsPolicy (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy)2 Conditions1 (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.Conditions1)2 MatchAsPathSet (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchAsPathSet)2 MatchCommunitySet (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchCommunitySet)2 MatchExtCommunitySet (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchExtCommunitySet)2 BgpConditions (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions)2 Augmentation (org.opendaylight.yangtools.yang.binding.Augmentation)2