Use getJump{Pass,Drop}Label for counter range checks
This commit refactors the code to use the getJump{Pass,Drop}Label
methods for counter range checks. This change reduces code duplication
by centralizing the logic for handling these checks.
Test: TH
Change-Id: If254711ab9691d6dd299dc73b6877624323b2db5
diff --git a/src/android/net/apf/BaseApfGenerator.java b/src/android/net/apf/BaseApfGenerator.java
index 6f52835..c505f5d 100644
--- a/src/android/net/apf/BaseApfGenerator.java
+++ b/src/android/net/apf/BaseApfGenerator.java
@@ -769,24 +769,12 @@
void checkPassCounterRange(ApfCounterTracker.Counter cnt) {
if (mDisableCounterRangeCheck) return;
- if (cnt.value() < ApfCounterTracker.MIN_PASS_COUNTER.value()
- || cnt.value() > ApfCounterTracker.MAX_PASS_COUNTER.value()) {
- throw new IllegalArgumentException(
- String.format("Counter %s, is not in range [%s, %s]", cnt,
- ApfCounterTracker.MIN_PASS_COUNTER,
- ApfCounterTracker.MAX_PASS_COUNTER));
- }
+ cnt.getJumpPassLabel();
}
void checkDropCounterRange(ApfCounterTracker.Counter cnt) {
if (mDisableCounterRangeCheck) return;
- if (cnt.value() < ApfCounterTracker.MIN_DROP_COUNTER.value()
- || cnt.value() > ApfCounterTracker.MAX_DROP_COUNTER.value()) {
- throw new IllegalArgumentException(
- String.format("Counter %s, is not in range [%s, %s]", cnt,
- ApfCounterTracker.MIN_DROP_COUNTER,
- ApfCounterTracker.MAX_DROP_COUNTER));
- }
+ cnt.getJumpDropLabel();
}
/**