use of org.batfish.datamodel.routing_policy.expr.AsExpr in project batfish by batfish.
the class PrependAsPathTest method testPrepend.
@Test
public void testPrepend() {
List<AsExpr> prepend = Lists.newArrayList(new ExplicitAs(1), new ExplicitAs(2));
PrependAsPath operation = new PrependAsPath(new LiteralAsList(prepend));
BgpRoute.Builder builder = new BgpRoute.Builder();
builder.setAsPath(mkAsPath(3, 4));
Environment env = newTestEnvironment(builder);
operation.execute(env);
assertThat(builder.getAsPath(), equalTo(mkAsPath(1, 2, 3, 4)));
}
use of org.batfish.datamodel.routing_policy.expr.AsExpr in project batfish by batfish.
the class CiscoControlPlaneExtractor method toRoutePolicyStatement.
private RoutePolicyStatement toRoutePolicyStatement(Prepend_as_path_rp_stanzaContext ctx) {
AsExpr expr = toAsExpr(ctx.as);
IntExpr number = null;
if (ctx.number != null) {
number = toIntExpr(ctx.number);
}
return new RoutePolicyPrependAsPath(expr, number);
}
use of org.batfish.datamodel.routing_policy.expr.AsExpr in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitSet_as_path_prepend_rm_stanza.
@Override
public void exitSet_as_path_prepend_rm_stanza(Set_as_path_prepend_rm_stanzaContext ctx) {
List<AsExpr> asList = new ArrayList<>();
for (As_exprContext asx : ctx.as_list) {
AsExpr as = toAsExpr(asx);
asList.add(as);
}
RouteMapSetAsPathPrependLine line = new RouteMapSetAsPathPrependLine(asList);
_currentRouteMapClause.addSetLine(line);
}
use of org.batfish.datamodel.routing_policy.expr.AsExpr in project batfish by batfish.
the class PrependAsPathTest method testPrependWithIntermediateAttributes.
@Test
public void testPrependWithIntermediateAttributes() {
List<AsExpr> prepend = Lists.newArrayList(new ExplicitAs(1), new ExplicitAs(2));
PrependAsPath operation = new PrependAsPath(new LiteralAsList(prepend));
BgpRoute.Builder outputRoute = new BgpRoute.Builder();
outputRoute.setAsPath(mkAsPath(3, 4));
BgpRoute.Builder intermediateAttributes = new BgpRoute.Builder();
intermediateAttributes.setAsPath(mkAsPath(5, 6));
Environment env = newTestEnvironment(outputRoute);
env.setIntermediateBgpAttributes(intermediateAttributes);
env.setWriteToIntermediateBgpAttributes(true);
operation.execute(env);
assertThat(outputRoute.getAsPath(), equalTo(mkAsPath(1, 2, 3, 4)));
assertThat(intermediateAttributes.getAsPath(), equalTo(mkAsPath(1, 2, 5, 6)));
}
Aggregations