diff --git a/.ci_scripts/firewall-test/translate_profiles.sh b/.ci_scripts/firewall-test/translate_profiles.sh index f7e34aa1b413c1863c31399ddcf16caab8e78c9a..1cd12fcca677848c23ab7c6f8849e7823da6707c 100755 --- a/.ci_scripts/firewall-test/translate_profiles.sh +++ b/.ci_scripts/firewall-test/translate_profiles.sh @@ -12,6 +12,6 @@ NFQ_BASE_ID=0 for DEVICE in "$DEVICES_DIR"/*/; do # Call translator over device profile # Arguments $1 & $2 represent the verdict mode - python3 $TRANSLATOR_PATH "$DEVICE"profile.yaml $NFQ_BASE_ID $1 $2 + python3 $TRANSLATOR_PATH "$DEVICE"profile.yaml -q $NFQ_BASE_ID $1 $2 ((NFQ_BASE_ID=NFQ_BASE_ID+100)) done diff --git a/src/translator/translator.py b/src/translator/translator.py index d64b1ffbbc4b53f982dc1c3878ea5fe7d530e09f..4b580c8ceac538544e24bc0e4d326d743db63c60 100644 --- a/src/translator/translator.py +++ b/src/translator/translator.py @@ -160,7 +160,7 @@ if __name__ == "__main__": description = "Translate a device YAML profile to the corresponding pair of NFTables firewall script and NFQueue C source code." parser = argparse.ArgumentParser(description=description) parser.add_argument("profile", type=str, help="Path to the device YAML profile") - parser.add_argument("nfq_id_base", type=uint16, help="NFQueue start index for this profile's policies (must be an integer between 0 and 65535)") + parser.add_argument("-q", "--nfqueue", type=uint16, default=0, help="NFQueue start index for this profile's policies (must be an integer between 0 and 65535)") # Verdict modes parser.add_argument("-r", "--rate", type=int, help="Rate limit, in packets/second, to apply to matched traffic, instead of a binary verdict. Cannot be used with dropping probability.") parser.add_argument("-p", "--drop-proba", type=proba, help="Dropping probability to apply to matched traffic, instead of a binary verdict. Cannot be used with rate limiting.") @@ -201,7 +201,7 @@ if __name__ == "__main__": device = profile["device-info"] # Base nfqueue id, will be incremented at each interaction - nfq_id = args.nfq_id_base + nfq_id = args.nfqueue # Global accumulators global_accs = { diff --git a/test/translator/translate.sh b/test/translator/translate.sh index d72d97ae492b542f019c787a69396e1be1ba25c5..afd413459cfd8d5c6146e3d1c45713b5bcf356b5 100755 --- a/test/translator/translate.sh +++ b/test/translator/translate.sh @@ -11,6 +11,6 @@ shopt -s nullglob # Loop over devices NFQ_BASE_ID=0 for DEVICE in "$DEVICES_DIR"/*/; do - python3 "$TRANSLATOR_PATH" "$DEVICE"profile.yaml $NFQ_BASE_ID + python3 "$TRANSLATOR_PATH" "$DEVICE"profile.yaml -q $NFQ_BASE_ID ((NFQ_BASE_ID=NFQ_BASE_ID+100)) done