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();
}
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);
}
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");
}
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");
}
Aggregations