From 6480b42d79adbcf7159fc1e1d7f070b0237ce883 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Sun, 18 Jun 2017 02:16:34 +0200 Subject: [PATCH] add dissectsr name --- src/b2ws-plugin/b2ws_const.lua | 2 ++ src/b2ws-plugin/b2ws_import.lua | 5 +++-- src/b2ws-plugin/b2ws_import_gui.lua | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/b2ws-plugin/b2ws_const.lua b/src/b2ws-plugin/b2ws_const.lua index 6462c7e..aca8e0c 100644 --- a/src/b2ws-plugin/b2ws_const.lua +++ b/src/b2ws-plugin/b2ws_const.lua @@ -13,6 +13,8 @@ B2WS_SHOW_DISSECTOR_BTN_TITLE = "Show Dissector" B2WS_SHOW_DISSECTOR_WIN_TITLE = "Created Dissector" B2WS_CHANGE_SETTINGS_BTN_TITLE = "Change Settings" B2WS_CREATE_DISSECTOR_BTN_TITLE = "Create Dissector" +B2WS_CREATE_DISSECTOR_DLG_TITLE = "Create Dissector" +B2WS_CREATE_DISSECTOR_DLG_NAME_LABEL = "dissector name" B2WS_CHANGE_SETTINGS_DLG_TITLE = "Change Settings" B2WS_IMPORT_BLOB_WIN_TITLE = "Import Blob" B2WS_RELOAD_PLUGIN_WIN_TITLE = "Please reload plugin" diff --git a/src/b2ws-plugin/b2ws_import.lua b/src/b2ws-plugin/b2ws_import.lua index 86988e8..1228f5c 100644 --- a/src/b2ws-plugin/b2ws_import.lua +++ b/src/b2ws-plugin/b2ws_import.lua @@ -53,11 +53,12 @@ function b2ws_change_settings(config_string, blob_src, eth_src, eth_dst, eth_typ return new_config_string end -function b2ws_create_dissector(config_string) +function b2ws_create_dissector(config_string, disector_name) local b2ws_config = create_b2ws_config_object(config_string) local template_string = read_b2ws_folder_file(b2ws_const.B2WS_PLUGIN_PATH, b2ws_const.B2WS_DISSECTOR_TEMPLATE_FILE) template_string = template_string:gsub("0xffff", "0x" .. b2ws_config.eth_fake_header_type) - local dissector_path = b2ws_config.blob_src .. b2ws_const.B2WS_DISSECTOR_EXTENSION + template_string = template_string:gsub("example", disector_name) + local dissector_path = create_b2ws_folder_file_path(b2ws_const.B2WS_PLUGIN_PATH, disector_name .. b2ws_const.B2WS_DISSECTOR_EXTENSION) write_b2ws_file(dissector_path, template_string) return dissector_path end diff --git a/src/b2ws-plugin/b2ws_import_gui.lua b/src/b2ws-plugin/b2ws_import_gui.lua index 16d3047..60cd876 100644 --- a/src/b2ws-plugin/b2ws_import_gui.lua +++ b/src/b2ws-plugin/b2ws_import_gui.lua @@ -40,9 +40,13 @@ local function b2ws_win_import_blob() b2ws_const.B2WS_CONFIG_LABEL_ETH_FAKE_HEADER_TYPE) end - local function b2ws_win_btn_create_dissector() + local function b2ws_dlg_btn_create_dissector(dissector_name) + if dissector_name == "" then + return + end + local win_text = b2ws_trim(win:get_text()) - local dissector_path = b2ws_create_dissector(win_text) + local dissector_path = b2ws_create_dissector(win_text, dissector_name) local info = TextWindow.new(b2ws_const.B2WS_RELOAD_PLUGIN_WIN_TITLE) info:set(b2ws_const.B2WS_RELOAD_PLUGIN_WIN_CONTENT:gsub("{0}", dissector_path)) local function b2ws_win_btn_show_disector() @@ -59,6 +63,12 @@ local function b2ws_win_import_blob() info:add_button(b2ws_const.B2WS_SHOW_DISSECTOR_BTN_TITLE, b2ws_win_btn_show_disector) end + local function b2ws_win_btn_create_dissector() + new_dialog(b2ws_const.B2WS_CREATE_DISSECTOR_DLG_TITLE, + b2ws_dlg_btn_create_dissector, + b2ws_const.B2WS_CREATE_DISSECTOR_DLG_NAME_LABEL) + end + win:add_button(b2ws_const.B2WS_IMPORT_BLOB_BTN_TITLE, b2ws_win_btn_import_blob) win:add_button(b2ws_const.B2WS_SAVE_SETTINGS_BTN_TITLE, b2ws_win_btn_save_settings) win:add_button(b2ws_const.B2WS_CHANGE_SETTINGS_BTN_TITLE, b2ws_win_btn_change_settings)