Search in sources :

Example 1 with IncrementLocalPreference

use of org.batfish.datamodel.routing_policy.expr.IncrementLocalPreference 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)

Aggregations

BatfishException (org.batfish.common.BatfishException)1 DecrementLocalPreference (org.batfish.datamodel.routing_policy.expr.DecrementLocalPreference)1 IncrementLocalPreference (org.batfish.datamodel.routing_policy.expr.IncrementLocalPreference)1 LiteralInt (org.batfish.datamodel.routing_policy.expr.LiteralInt)1