@JsonCreator private static PrependAsPath jsonCreator(@Nullable @JsonProperty(PROP_EXPR) AsPathListExpr expr) { checkArgument(expr != null, "%s must be provided", PROP_EXPR); return new PrependAsPath(expr); }
@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(ofSingletonAsSets(3L, 4L)); Environment env = newTestEnvironment(builder); operation.execute(env); assertThat(builder.getAsPath(), equalTo(ofSingletonAsSets(1L, 2L, 3L, 4L))); }
curP.debug("PrependAsPath"); PrependAsPath pap = (PrependAsPath) stmt; Integer prependCost = prependLength(pap.getExpr()); ArithExpr newValue = _enc.mkSum(curP.getData().getMetric(), _enc.mkInt(prependCost)); newValue =
@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(ofSingletonAsSets(3L, 4L)); BgpRoute.Builder intermediateAttributes = new BgpRoute.Builder(); intermediateAttributes.setAsPath(ofSingletonAsSets(5L, 6L)); Environment env = newTestEnvironment(outputRoute); env.setIntermediateBgpAttributes(intermediateAttributes); env.setWriteToIntermediateBgpAttributes(true); operation.execute(env); assertThat(outputRoute.getAsPath(), equalTo(ofSingletonAsSets(1L, 2L, 3L, 4L))); assertThat(intermediateAttributes.getAsPath(), equalTo(ofSingletonAsSets(1L, 2L, 5L, 6L))); } }
curP.debug("PrependAsPath"); PrependAsPath pap = (PrependAsPath) stmt; Integer prependCost = prependLength(pap.getExpr()); curP.indent().debug("Cost: " + prependCost); BDDInteger met = curP.getData().getMetric();
@Override public void applyTo( List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) { statements.add(new PrependAsPath(new LiteralAsList(_asList))); }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings w) { List<AsExpr> asList = _asPath.stream().map(ExplicitAs::new).collect(ImmutableList.toImmutableList()); statements.add(new PrependAsPath(new LiteralAsList(asList))); } }
@Override public void applyTo( List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) { statements.add(new PrependAsPath(new MultipliedAs(_expr, _number))); } }