use of org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy 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;
}
use of org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy 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;
}
use of org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy in project bgpcep by opendaylight.
the class BgpConditionsRegistry method registerBgpConditionsPolicy.
public <T extends ChildOf<BgpMatchConditions>, N> AbstractRegistration registerBgpConditionsPolicy(final Class<T> conditionPolicyClass, final BgpConditionsPolicy<T, N> conditionPolicy) {
synchronized (this.bgpConditionsRegistry) {
final BgpConditionsPolicy prev = this.bgpConditionsRegistry.putIfAbsent(conditionPolicyClass, conditionPolicy);
Preconditions.checkState(prev == null, "Condition Policy %s already registered %s", conditionPolicyClass, prev);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (BgpConditionsRegistry.this.bgpConditionsRegistry) {
BgpConditionsRegistry.this.bgpConditionsRegistry.remove(conditionPolicyClass);
}
}
};
}
}
Aggregations