From 40f988d0d8715040b0cb0e04673ff6d53b3fd2fd Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 16 Sep 2024 21:19:41 -0500 Subject: [PATCH] Update: Relocate firewall rules to under the /etc/network/firewall/. This should help isolate all of the firewall rules from other network related tasks. --- level_3/firewall/c/main/common/string.c | 2 +- level_3/firewall/c/main/common/string.h | 10 +++++----- level_3/firewall/c/main/operate.c | 18 +++++++++--------- level_3/firewall/c/main/operate/process.c | 2 +- .../settings/network/{ => firewall}/default-blacklist | 0 .../settings/network/{ => firewall}/default-whitelist | 0 .../network/{ => firewall}/example-device-firewall | 0 .../settings/network/{ => firewall}/firewall-first | 0 .../data/settings/network/{ => firewall}/firewall-last | 0 .../settings/network/{ => firewall}/firewall-other | 0 10 files changed, 16 insertions(+), 16 deletions(-) rename level_3/firewall/data/settings/network/{ => firewall}/default-blacklist (100%) rename level_3/firewall/data/settings/network/{ => firewall}/default-whitelist (100%) rename level_3/firewall/data/settings/network/{ => firewall}/example-device-firewall (100%) rename level_3/firewall/data/settings/network/{ => firewall}/firewall-first (100%) rename level_3/firewall/data/settings/network/{ => firewall}/firewall-last (100%) rename level_3/firewall/data/settings/network/{ => firewall}/firewall-other (100%) diff --git a/level_3/firewall/c/main/common/string.c b/level_3/firewall/c/main/common/string.c index afb3440..42a6675 100644 --- a/level_3/firewall/c/main/common/string.c +++ b/level_3/firewall/c/main/common/string.c @@ -99,7 +99,7 @@ extern "C" { const f_string_static_t firewall_file_other_s = macro_f_string_static_t_initialize_1(FIREWALL_file_other_s, 0, FIREWALL_file_other_s_length); const f_string_static_t firewall_file_suffix_s = macro_f_string_static_t_initialize_1(FIREWALL_file_suffix_s, 0, FIREWALL_file_suffix_s_length); - const f_string_static_t firewall_network_path_s = macro_f_string_static_t_initialize_1(FIREWALL_network_path_s, 0, FIREWALL_network_path_s_length); + const f_string_static_t firewall_network_firewall_path_s = macro_f_string_static_t_initialize_1(FIREWALL_network_firewall_path_s, 0, FIREWALL_network_firewall_path_s_length); const f_string_static_t firewall_network_devices_s = macro_f_string_static_t_initialize_1(FIREWALL_network_devices_s, 0, FIREWALL_network_devices_s_length); #endif // _di_firewall_path_s_ diff --git a/level_3/firewall/c/main/common/string.h b/level_3/firewall/c/main/common/string.h index 32760bb..47d695d 100644 --- a/level_3/firewall/c/main/common/string.h +++ b/level_3/firewall/c/main/common/string.h @@ -328,23 +328,23 @@ extern "C" { #define FIREWALL_file_other_s "firewall-other" #define FIREWALL_file_suffix_s "-firewall" - #define FIREWALL_network_path_s "/etc/network/" - #define FIREWALL_network_devices_s "/sys/class/net/" + #define FIREWALL_network_firewall_path_s "/etc/network/firewall/" + #define FIREWALL_network_devices_s "/sys/class/net/" #define FIREWALL_file_first_s_length 14 #define FIREWALL_file_last_s_length 13 #define FIREWALL_file_other_s_length 14 #define FIREWALL_file_suffix_s_length 9 - #define FIREWALL_network_path_s_length 13 - #define FIREWALL_network_devices_s_length 15 + #define FIREWALL_network_firewall_path_s_length 22 + #define FIREWALL_network_devices_s_length 15 extern const f_string_static_t firewall_file_first_s; extern const f_string_static_t firewall_file_last_s; extern const f_string_static_t firewall_file_other_s; extern const f_string_static_t firewall_file_suffix_s; - extern const f_string_static_t firewall_network_path_s; + extern const f_string_static_t firewall_network_firewall_path_s; extern const f_string_static_t firewall_network_devices_s; #endif // _di_firewall_path_s_ diff --git a/level_3/firewall/c/main/operate.c b/level_3/firewall/c/main/operate.c index 7497fd7..1779159 100644 --- a/level_3/firewall/c/main/operate.c +++ b/level_3/firewall/c/main/operate.c @@ -55,14 +55,14 @@ extern "C" { main->data.file.used = 0; if (main->setting.flag & firewall_main_flag_operation_stop_restart_lock_d) { - main->data.file.used = firewall_network_path_s.used + firewall_file_other_s.used; + main->data.file.used = firewall_network_firewall_path_s.used + firewall_file_other_s.used; f_char_t path_file_other[main->data.file.used + 1]; main->data.file.string = path_file_other; path_file_other[main->data.file.used] = 0; - memcpy(path_file_other, firewall_network_path_s.string, sizeof(f_char_t) * firewall_network_path_s.used); - memcpy(path_file_other + firewall_network_path_s.used, firewall_file_other_s.string, sizeof(f_char_t) * firewall_file_other_s.used); + memcpy(path_file_other, firewall_network_firewall_path_s.string, sizeof(f_char_t) * firewall_network_firewall_path_s.used); + memcpy(path_file_other + firewall_network_firewall_path_s.used, firewall_file_other_s.string, sizeof(f_char_t) * firewall_file_other_s.used); firewall_operate_buffer_chain(main, main->data.file, F_false); if (F_status_is_error(main->setting.state.status) || main->setting.state.status == F_child) return; @@ -140,14 +140,14 @@ extern "C" { } if (main->setting.flag & firewall_main_flag_operation_start_restart_d) { - main->data.file.used = firewall_network_path_s.used + firewall_file_first_s.used; + main->data.file.used = firewall_network_firewall_path_s.used + firewall_file_first_s.used; f_char_t path_file_first[main->data.file.used + 1]; main->data.file.string = path_file_first; path_file_first[main->data.file.used] = 0; - memcpy(path_file_first, firewall_network_path_s.string, sizeof(f_char_t) * firewall_network_path_s.used); - memcpy(path_file_first + firewall_network_path_s.used, firewall_file_first_s.string, sizeof(f_char_t) * firewall_file_first_s.used); + memcpy(path_file_first, firewall_network_firewall_path_s.string, sizeof(f_char_t) * firewall_network_firewall_path_s.used); + memcpy(path_file_first + firewall_network_firewall_path_s.used, firewall_file_first_s.string, sizeof(f_char_t) * firewall_file_first_s.used); firewall_operate_buffer_chain(main, main->data.file, F_false); @@ -172,7 +172,7 @@ extern "C" { main->cache.path_file.used = 0; main->data.device = j; - main->setting.state.status = f_memory_array_increase_by(firewall_network_path_s.used + main->setting.devices.array[j].used + firewall_file_suffix_s.used + 1, sizeof(f_char_t), (void **) &main->cache.path_file.string, &main->cache.path_file.used, &main->cache.path_file.size); + main->setting.state.status = f_memory_array_increase_by(firewall_network_firewall_path_s.used + main->setting.devices.array[j].used + firewall_file_suffix_s.used + 1, sizeof(f_char_t), (void **) &main->cache.path_file.string, &main->cache.path_file.used, &main->cache.path_file.size); if (F_status_is_error(main->setting.state.status)) { firewall_print_error(&main->program.error, macro_firewall_f(f_memory_array_increase_by)); @@ -182,7 +182,7 @@ extern "C" { main->data.file = main->cache.path_file; - main->setting.state.status = f_string_dynamic_append(firewall_network_path_s, &main->cache.path_file); + main->setting.state.status = f_string_dynamic_append(firewall_network_firewall_path_s, &main->cache.path_file); if (F_status_is_error_not(main->setting.state.status)) { main->setting.state.status = f_string_dynamic_append(main->setting.devices.array[j], &main->cache.path_file); @@ -210,7 +210,7 @@ extern "C" { main->cache.path_file.used = 0; - main->setting.state.status = f_string_dynamic_append(firewall_network_path_s, &main->cache.path_file); + main->setting.state.status = f_string_dynamic_append(firewall_network_firewall_path_s, &main->cache.path_file); if (F_status_is_error_not(main->setting.state.status)) { main->setting.state.status = f_string_dynamic_append(firewall_file_last_s, &main->cache.path_file); diff --git a/level_3/firewall/c/main/operate/process.c b/level_3/firewall/c/main/operate/process.c index b7a028c..f03f55c 100644 --- a/level_3/firewall/c/main/operate/process.c +++ b/level_3/firewall/c/main/operate/process.c @@ -438,7 +438,7 @@ extern "C" { main->cache.delimits.used = 0; main->cache.path_file_specific.used = 0; - main->setting.state.status = f_string_dynamic_append(firewall_network_path_s, &main->cache.path_file_specific); + main->setting.state.status = f_string_dynamic_append(firewall_network_firewall_path_s, &main->cache.path_file_specific); if (F_status_is_error_not(main->setting.state.status)) { main->setting.state.status = f_string_dynamic_append(main->cache.ip_list, &main->cache.path_file_specific); diff --git a/level_3/firewall/data/settings/network/default-blacklist b/level_3/firewall/data/settings/network/firewall/default-blacklist similarity index 100% rename from level_3/firewall/data/settings/network/default-blacklist rename to level_3/firewall/data/settings/network/firewall/default-blacklist diff --git a/level_3/firewall/data/settings/network/default-whitelist b/level_3/firewall/data/settings/network/firewall/default-whitelist similarity index 100% rename from level_3/firewall/data/settings/network/default-whitelist rename to level_3/firewall/data/settings/network/firewall/default-whitelist diff --git a/level_3/firewall/data/settings/network/example-device-firewall b/level_3/firewall/data/settings/network/firewall/example-device-firewall similarity index 100% rename from level_3/firewall/data/settings/network/example-device-firewall rename to level_3/firewall/data/settings/network/firewall/example-device-firewall diff --git a/level_3/firewall/data/settings/network/firewall-first b/level_3/firewall/data/settings/network/firewall/firewall-first similarity index 100% rename from level_3/firewall/data/settings/network/firewall-first rename to level_3/firewall/data/settings/network/firewall/firewall-first diff --git a/level_3/firewall/data/settings/network/firewall-last b/level_3/firewall/data/settings/network/firewall/firewall-last similarity index 100% rename from level_3/firewall/data/settings/network/firewall-last rename to level_3/firewall/data/settings/network/firewall/firewall-last diff --git a/level_3/firewall/data/settings/network/firewall-other b/level_3/firewall/data/settings/network/firewall/firewall-other similarity index 100% rename from level_3/firewall/data/settings/network/firewall-other rename to level_3/firewall/data/settings/network/firewall/firewall-other -- 1.8.3.1