use of org.batfish.datamodel.BgpRoute in project batfish by batfish.
the class DecrementLocalPreference method evaluate.
@Override
public int evaluate(Environment environment) {
BgpRoute oldRoute = (BgpRoute) environment.getOriginalRoute();
int oldLp = oldRoute.getLocalPreference();
int newVal = oldLp - _subtrahend;
return newVal;
}
use of org.batfish.datamodel.BgpRoute in project batfish by batfish.
the class SetOrigin method execute.
@Override
public Result execute(Environment environment) {
BgpRoute.Builder bgpRoute = (BgpRoute.Builder) environment.getOutputRoute();
OriginType originType = _origin.evaluate(environment);
bgpRoute.setOriginType(originType);
if (environment.getWriteToIntermediateBgpAttributes()) {
environment.getIntermediateBgpAttributes().setOriginType(originType);
}
Result result = new Result();
return result;
}
use of org.batfish.datamodel.BgpRoute in project batfish by batfish.
the class AddCommunity method execute.
@Override
public Result execute(Environment environment) {
BgpRoute.Builder bgpRoute = (BgpRoute.Builder) environment.getOutputRoute();
SortedSet<Long> communities = _expr.allCommunities(environment);
bgpRoute.getCommunities().addAll(communities);
if (environment.getWriteToIntermediateBgpAttributes()) {
environment.getIntermediateBgpAttributes().getCommunities().addAll(communities);
}
Result result = new Result();
return result;
}
use of org.batfish.datamodel.BgpRoute in project batfish by batfish.
the class NamedAsPathSet method matches.
@Override
public boolean matches(Environment environment) {
AsPathAccessList list = environment.getConfiguration().getAsPathAccessLists().get(_name);
if (list != null) {
boolean match = false;
AsPath inputAsPath = null;
if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder) {
BgpRoute.Builder bgpRouteBuilder = (BgpRoute.Builder) environment.getOutputRoute();
inputAsPath = new AsPath(bgpRouteBuilder.getAsPath());
} else if (environment.getReadFromIntermediateBgpAttributes()) {
inputAsPath = new AsPath(environment.getIntermediateBgpAttributes().getAsPath());
} else if (environment.getOriginalRoute() instanceof BgpRoute) {
BgpRoute bgpRoute = (BgpRoute) environment.getOriginalRoute();
inputAsPath = bgpRoute.getAsPath();
}
if (inputAsPath != null) {
match = list.permits(inputAsPath);
}
return match;
} else {
environment.setError(true);
return false;
}
}
use of org.batfish.datamodel.BgpRoute in project batfish by batfish.
the class VirtualRouter method initBgpAggregateRoutes.
/**
* This function creates BGP routes from generated routes that go into the BGP RIB, but cannot be
* imported into the main RIB. The purpose of these routes is to prevent the local router from
* accepting advertisements less desirable than the local generated ones for the given network.
* They are not themselves advertised.
*/
void initBgpAggregateRoutes() {
// first import aggregates
switch(_c.getConfigurationFormat()) {
case JUNIPER:
case JUNIPER_SWITCH:
return;
// $CASES-OMITTED$
default:
break;
}
for (AbstractRoute grAbstract : _generatedRib.getRoutes()) {
GeneratedRoute gr = (GeneratedRoute) grAbstract;
BgpRoute.Builder b = new BgpRoute.Builder();
b.setAdmin(gr.getAdministrativeCost());
b.setAsPath(gr.getAsPath().getAsSets());
b.setMetric(gr.getMetric());
b.setSrcProtocol(RoutingProtocol.AGGREGATE);
b.setProtocol(RoutingProtocol.AGGREGATE);
b.setNetwork(gr.getNetwork());
b.setLocalPreference(BgpRoute.DEFAULT_LOCAL_PREFERENCE);
/* Note: Origin type and originator IP should get overwritten, but are needed initially */
b.setOriginatorIp(_vrf.getBgpProcess().getRouterId());
b.setOriginType(OriginType.INCOMPLETE);
b.setReceivedFromIp(Ip.ZERO);
BgpRoute br = b.build();
br.setNonRouting(true);
_bgpMultipathRib.mergeRoute(br);
_bgpBestPathRib.mergeRoute(br);
}
}
Aggregations