From 2df520414ee871d38f4a24b5288f520062e042bc Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Sat, 3 Feb 2024 09:29:15 +0000 Subject: [PATCH] Netcontrol: allow supplying explicit name to Debug plugin This change extends the arguments of NetControl::create_debug, and allows the specification of an optional name argument, which can be used instead of the default-generated name. This is helpful when one wants to attach several plugins to verify behavior in those cases. --- scripts/base/frameworks/netcontrol/plugins/debug.zeek | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/base/frameworks/netcontrol/plugins/debug.zeek b/scripts/base/frameworks/netcontrol/plugins/debug.zeek index f159cda73f..8d9e7c700a 100644 --- a/scripts/base/frameworks/netcontrol/plugins/debug.zeek +++ b/scripts/base/frameworks/netcontrol/plugins/debug.zeek @@ -12,7 +12,7 @@ export { ## ## do_something: If true, the plugin will claim it supports all operations; if ## false, it will indicate it doesn't support any. - global create_debug: function(do_something: bool) : PluginState; + global create_debug: function(do_something: bool, name: string &default="") : PluginState; } function do_something(p: PluginState) : bool @@ -22,7 +22,7 @@ function do_something(p: PluginState) : bool function debug_name(p: PluginState) : string { - return fmt("Debug-%s", (do_something(p) ? "All" : "None")); + return p$config["name"]; } function debug_log(p: PluginState, msg: string) @@ -73,13 +73,17 @@ global debug_plugin = Plugin( $remove_rule = debug_remove_rule ); -function create_debug(do_something: bool) : PluginState +function create_debug(do_something: bool, name: string) : PluginState { local p: PluginState = [$plugin=debug_plugin]; # FIXME: Why's the default not working? p$config = table(); p$config["all"] = (do_something ? "1" : "0"); + if ( name == "" ) + p$config["name"] = fmt("Debug-%s", (do_something ? "All" : "None")); + else + p$config["name"] = name; return p; }