Search in sources :

Example 1 with LiteralInt

use of org.batfish.datamodel.routing_policy.expr.LiteralInt in project batfish by batfish.

the class RouteMapMatchTagLine method toBooleanExpr.

@Override
public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) {
    Disjunction d = new Disjunction();
    List<BooleanExpr> disjuncts = d.getDisjuncts();
    for (int tag : _tags) {
        disjuncts.add(new MatchTag(IntComparator.EQ, new LiteralInt(tag)));
    }
    return d.simplify();
}
Also used : Disjunction(org.batfish.datamodel.routing_policy.expr.Disjunction) MatchTag(org.batfish.datamodel.routing_policy.expr.MatchTag) BooleanExpr(org.batfish.datamodel.routing_policy.expr.BooleanExpr) LiteralInt(org.batfish.datamodel.routing_policy.expr.LiteralInt)

Example 2 with LiteralInt

use of org.batfish.datamodel.routing_policy.expr.LiteralInt in project batfish by batfish.

the class TransferBDD method applyIntExprModification.

/*
   * Apply the effect of modifying an integer value (e.g., to set the local pref)
   */
private BDDInteger applyIntExprModification(TransferParam<BDDRoute> p, BDDInteger x, IntExpr e) {
    if (e instanceof LiteralInt) {
        LiteralInt z = (LiteralInt) e;
        p.debug("LiteralInt: " + z.getValue());
        return BDDInteger.makeFromValue(x.getFactory(), 32, z.getValue());
    }
    if (e instanceof IncrementLocalPreference) {
        IncrementLocalPreference z = (IncrementLocalPreference) e;
        p.debug("IncrementLocalPreference: " + z.getAddend());
        return x.add(BDDInteger.makeFromValue(x.getFactory(), 32, z.getAddend()));
    }
    if (e instanceof DecrementLocalPreference) {
        DecrementLocalPreference z = (DecrementLocalPreference) e;
        p.debug("DecrementLocalPreference: " + z.getSubtrahend());
        return x.sub(BDDInteger.makeFromValue(x.getFactory(), 32, z.getSubtrahend()));
    }
    throw new BatfishException("TODO: int expr transfer function: " + e);
}
Also used : BatfishException(org.batfish.common.BatfishException) IncrementLocalPreference(org.batfish.datamodel.routing_policy.expr.IncrementLocalPreference) LiteralInt(org.batfish.datamodel.routing_policy.expr.LiteralInt) DecrementLocalPreference(org.batfish.datamodel.routing_policy.expr.DecrementLocalPreference)

Example 3 with LiteralInt

use of org.batfish.datamodel.routing_policy.expr.LiteralInt in project batfish by batfish.

the class TransferBDD method prependLength.

/*
   * Compute how many times to prepend to a path from the AST
   */
private int prependLength(AsPathListExpr expr) {
    if (expr instanceof MultipliedAs) {
        MultipliedAs x = (MultipliedAs) expr;
        IntExpr e = x.getNumber();
        LiteralInt i = (LiteralInt) e;
        return i.getValue();
    }
    if (expr instanceof LiteralAsList) {
        LiteralAsList x = (LiteralAsList) expr;
        return x.getList().size();
    }
    throw new BatfishException("Error[prependLength]: unreachable");
}
Also used : BatfishException(org.batfish.common.BatfishException) LiteralAsList(org.batfish.datamodel.routing_policy.expr.LiteralAsList) IntExpr(org.batfish.datamodel.routing_policy.expr.IntExpr) LiteralInt(org.batfish.datamodel.routing_policy.expr.LiteralInt) MultipliedAs(org.batfish.datamodel.routing_policy.expr.MultipliedAs)

Example 4 with LiteralInt

use of org.batfish.datamodel.routing_policy.expr.LiteralInt in project batfish by batfish.

the class TransferSSA method prependLength.

/*
   * Compute how many times to prepend to a path from the AST
   */
private int prependLength(AsPathListExpr expr) {
    if (expr instanceof MultipliedAs) {
        MultipliedAs x = (MultipliedAs) expr;
        IntExpr e = x.getNumber();
        LiteralInt i = (LiteralInt) e;
        return i.getValue();
    }
    if (expr instanceof LiteralAsList) {
        LiteralAsList x = (LiteralAsList) expr;
        return x.getList().size();
    }
    throw new BatfishException("Error[prependLength]: unreachable");
}
Also used : BatfishException(org.batfish.common.BatfishException) LiteralAsList(org.batfish.datamodel.routing_policy.expr.LiteralAsList) IntExpr(org.batfish.datamodel.routing_policy.expr.IntExpr) LiteralInt(org.batfish.datamodel.routing_policy.expr.LiteralInt) MultipliedAs(org.batfish.datamodel.routing_policy.expr.MultipliedAs)

Aggregations

LiteralInt (org.batfish.datamodel.routing_policy.expr.LiteralInt)4 BatfishException (org.batfish.common.BatfishException)3 IntExpr (org.batfish.datamodel.routing_policy.expr.IntExpr)2 LiteralAsList (org.batfish.datamodel.routing_policy.expr.LiteralAsList)2 MultipliedAs (org.batfish.datamodel.routing_policy.expr.MultipliedAs)2 BooleanExpr (org.batfish.datamodel.routing_policy.expr.BooleanExpr)1 DecrementLocalPreference (org.batfish.datamodel.routing_policy.expr.DecrementLocalPreference)1 Disjunction (org.batfish.datamodel.routing_policy.expr.Disjunction)1 IncrementLocalPreference (org.batfish.datamodel.routing_policy.expr.IncrementLocalPreference)1 MatchTag (org.batfish.datamodel.routing_policy.expr.MatchTag)1