]> Kevux Git Server - fll/commitdiff
Progress: Continue refactoring firewall from 0.6.x to 0.7.x/0.8.x.
authorKevin Day <kevin@kevux.org>
Sat, 17 Feb 2024 01:30:30 +0000 (19:30 -0600)
committerKevin Day <kevin@kevux.org>
Sat, 17 Feb 2024 01:30:30 +0000 (19:30 -0600)
This fixes some obvious problems.

The firewall rules are not currently working and I am going to guess that it might be related to the buffering logic.

level_3/firewall/c/main/common.c
level_3/firewall/c/main/common/enumeration.h
level_3/firewall/c/main/operate.c
level_3/firewall/c/main/print/message.c
level_3/firewall/c/main/print/warning.c

index 00e3fe4e04ff38b1663e407ff0b0acd969906c23..68012dd5d7ef3ee204b1fc87c4086df676b05d74 100644 (file)
@@ -82,66 +82,45 @@ extern "C" {
       return;
     }
 
-    f_number_unsigned_t at = 0;
     f_number_unsigned_t index = 0;
 
     if (main->program.parameters.array[firewall_parameter_operation_start_e].result & f_console_result_found_e) {
-      main->setting.flag &= ~firewall_main_flag_operation_lock_e;
-      main->setting.flag &= ~firewall_main_flag_operation_restart_e;
-      main->setting.flag &= ~firewall_main_flag_operation_show_e;
-      main->setting.flag &= ~firewall_main_flag_operation_stop_e;
-
+      main->setting.flag &= ~firewall_main_flag_operation_e;
       main->setting.flag |= firewall_main_flag_operation_start_e;
 
-      at = main->program.parameters.array[firewall_parameter_operation_start_e].values.array[0];
+      index = main->program.parameters.array[firewall_parameter_operation_start_e].location;
     }
 
     if (main->program.parameters.array[firewall_parameter_operation_stop_e].result & f_console_result_found_e) {
-      if (!(main->setting.flag & firewall_main_flag_operation_e) || (main->program.parameters.array[at].values.array[0] > main->program.parameters.array[firewall_parameter_operation_stop_e].values.array[0])) {
-        main->setting.flag &= ~firewall_main_flag_operation_lock_e;
-        main->setting.flag &= ~firewall_main_flag_operation_restart_e;
-        main->setting.flag &= ~firewall_main_flag_operation_show_e;
-        main->setting.flag &= ~firewall_main_flag_operation_start_e;
-
+      if (!(main->setting.flag & firewall_main_flag_operation_e) || main->program.parameters.array[firewall_parameter_operation_stop_e].location > index) {
+        main->setting.flag &= ~firewall_main_flag_operation_e;
         main->setting.flag |= firewall_main_flag_operation_stop_e;
 
-        at = main->program.parameters.array[firewall_parameter_operation_stop_e].values.array[0];
+        index = main->program.parameters.array[firewall_parameter_operation_stop_e].location;
       }
     }
 
     if (main->program.parameters.array[firewall_parameter_operation_restart_e].result & f_console_result_found_e) {
-      if (!(main->setting.flag & firewall_main_flag_operation_e) || (main->program.parameters.array[at].values.array[0] > main->program.parameters.array[firewall_parameter_operation_restart_e].values.array[0])) {
-        main->setting.flag &= ~firewall_main_flag_operation_lock_e;
-        main->setting.flag &= ~firewall_main_flag_operation_show_e;
-        main->setting.flag &= ~firewall_main_flag_operation_start_e;
-        main->setting.flag &= ~firewall_main_flag_operation_stop_e;
-
+      if (!(main->setting.flag & firewall_main_flag_operation_e) || main->program.parameters.array[firewall_parameter_operation_restart_e].location > index) {
+        main->setting.flag &= ~firewall_main_flag_operation_e;
         main->setting.flag |= firewall_main_flag_operation_restart_e;
 
-        at = main->program.parameters.array[firewall_parameter_operation_restart_e].values.array[0];
+        index = main->program.parameters.array[firewall_parameter_operation_restart_e].location;
       }
     }
 
     if (main->program.parameters.array[firewall_parameter_operation_lock_e].result & f_console_result_found_e) {
-      if (!(main->setting.flag & firewall_main_flag_operation_e) || (main->program.parameters.array[at].values.array[0] > main->program.parameters.array[firewall_parameter_operation_lock_e].values.array[0])) {
-        main->setting.flag &= ~firewall_main_flag_operation_restart_e;
-        main->setting.flag &= ~firewall_main_flag_operation_show_e;
-        main->setting.flag &= ~firewall_main_flag_operation_start_e;
-        main->setting.flag &= ~firewall_main_flag_operation_stop_e;
-
+      if (!(main->setting.flag & firewall_main_flag_operation_e) || main->program.parameters.array[firewall_parameter_operation_lock_e].location > index) {
+        main->setting.flag &= ~firewall_main_flag_operation_e;
         main->setting.flag |= firewall_main_flag_operation_lock_e;
 
-        at = main->program.parameters.array[firewall_parameter_operation_lock_e].values.array[0];
+        index = main->program.parameters.array[firewall_parameter_operation_lock_e].location;
       }
     }
 
     if (main->program.parameters.array[firewall_parameter_operation_show_e].result & f_console_result_found_e) {
-      if (!(main->setting.flag & firewall_main_flag_operation_e) || (main->program.parameters.array[at].values.array[0] > main->program.parameters.array[firewall_parameter_operation_show_e].values.array[0])) {
-        main->setting.flag &= ~firewall_main_flag_operation_lock_e;
-        main->setting.flag &= ~firewall_main_flag_operation_restart_e;
-        main->setting.flag &= ~firewall_main_flag_operation_start_e;
-        main->setting.flag &= ~firewall_main_flag_operation_stop_e;
-
+      if (!(main->setting.flag & firewall_main_flag_operation_e) || main->program.parameters.array[firewall_parameter_operation_show_e].location > index) {
+        main->setting.flag &= ~firewall_main_flag_operation_e;
         main->setting.flag |= firewall_main_flag_operation_show_e;
       }
     }
@@ -157,11 +136,11 @@ extern "C" {
       if (main->program.parameters.remaining.used) {
         main->setting.flag &= ~firewall_main_flag_operation_show_filter_nat_mangle_e;
 
-        for (at = 0; at < main->program.parameters.remaining.used; ++at) {
+        for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i) {
 
           if (firewall_signal_check(main)) return;
 
-          index = main->program.parameters.remaining.array[at];
+          index = main->program.parameters.remaining.array[i];
 
           if (f_compare_dynamic(firewall_show_nat_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
             main->setting.flag |= firewall_main_flag_operation_show_nat_e;
@@ -181,24 +160,6 @@ extern "C" {
         main->setting.flag |= firewall_main_flag_operation_show_filter_nat_mangle_e;
       }
     }
-    else {
-      // @todo
-
-      // Example:
-      /*
-      for (f_number_unsigned_t number = 0; index < main->program.parameters.remaining.used; ++index) {
-
-        if (control_signal_check(main)) return;
-
-        number = main->program.parameters.remaining.array[index];
-
-        // Statically allocate the inner strings.
-        main->setting.actions.array[main->setting.actions.used].string = main->program.parameters.arguments.array[number].string;
-        main->setting.actions.array[main->setting.actions.used].used = main->program.parameters.arguments.array[number].used;
-        main->setting.actions.array[main->setting.actions.used++].size = 0;
-      } // for
-      */
-    }
   }
 #endif // _di_firewall_setting_load_
 
index fbcf19344b55d35f56f80a36db73a5e78d4ef9ea..d13cd6b406b889ca4af3b2fd58259936c9fc4c12 100644 (file)
@@ -29,8 +29,8 @@ extern "C" {
  *   - operation_show:                   Perform the show operation.
  *   - operation_show_nat:               For the show operation, show nat.
  *   - operation_show_mangle:            For the show operation, show mangle.
- *   - operation_show_filter:            For the show operation, show ports.
- *   - operation_show_filter_nat_mangle: A helper flag representing the show nat, show mangle, and short port flags set.
+ *   - operation_show_filter:            For the show operation, show filter.
+ *   - operation_show_filter_nat_mangle: A helper flag representing the show nat, show mangle, and short filter flags set.
  *   - operation_start:                  Perform the start operation.
  *   - operation_start_restart:          A helper flag representing both the start and restart operation flag set.
  *   - operation_stop:                   Perform the stop operation.
@@ -47,24 +47,24 @@ extern "C" {
     firewall_main_flag_none_e                             = 0x0,
     firewall_main_flag_copyright_e                        = 0x1,
     firewall_main_flag_help_e                             = 0x2,
-    firewall_main_flag_operation_e                        = 0x4,
-    firewall_main_flag_operation_lock_e                   = 0x8,
-    firewall_main_flag_operation_restart_e                = 0x10,
-    firewall_main_flag_operation_show_e                   = 0x20,
-    firewall_main_flag_operation_show_nat_e               = 0x40,
-    firewall_main_flag_operation_show_mangle_e            = 0x80,
-    firewall_main_flag_operation_show_filter_e            = 0x100,
-    firewall_main_flag_operation_show_filter_nat_mangle_e = 0x1c0,
-    firewall_main_flag_operation_start_e                  = 0x200,
-    firewall_main_flag_operation_start_restart_e          = 0x210,
-    firewall_main_flag_operation_stop_e                   = 0x400,
-    firewall_main_flag_operation_stop_restart_e           = 0x410,
-    firewall_main_flag_operation_stop_restart_lock_e      = 0x418,
-    firewall_main_flag_pipe_e                             = 0x800,
-    firewall_main_flag_print_first_e                      = 0x1000,
-    firewall_main_flag_print_last_e                       = 0x2000,
-    firewall_main_flag_version_e                          = 0x4000,
-    firewall_main_flag_version_copyright_help_e           = 0x4003,
+    firewall_main_flag_operation_e                        = 0x31c,
+    firewall_main_flag_operation_lock_e                   = 0x4,
+    firewall_main_flag_operation_restart_e                = 0x8,
+    firewall_main_flag_operation_show_e                   = 0x10,
+    firewall_main_flag_operation_show_nat_e               = 0x20,
+    firewall_main_flag_operation_show_mangle_e            = 0x40,
+    firewall_main_flag_operation_show_filter_e            = 0x80,
+    firewall_main_flag_operation_show_filter_nat_mangle_e = 0xe0,
+    firewall_main_flag_operation_start_e                  = 0x100,
+    firewall_main_flag_operation_start_restart_e          = 0x108,
+    firewall_main_flag_operation_stop_e                   = 0x200,
+    firewall_main_flag_operation_stop_restart_e           = 0x208,
+    firewall_main_flag_operation_stop_restart_lock_e      = 0x20c,
+    firewall_main_flag_pipe_e                             = 0x400,
+    firewall_main_flag_print_first_e                      = 0x800,
+    firewall_main_flag_print_last_e                       = 0x1000,
+    firewall_main_flag_version_e                          = 0x2000,
+    firewall_main_flag_version_copyright_help_e           = 0x2003,
   }; // enum
 #endif // _di_firewall_main_flag_e_
 
index 62c478af7267065ff1b5259390389a5251618fcb..e9ee255d64207d20ab76b4caf3250e3c46802e5a 100644 (file)
@@ -356,6 +356,7 @@ extern "C" {
 
       parameters.array = show_arrays[i];
       parameters.used = show_lengths[i];
+      return_code = 0;
 
       firewall_print_message_show_header(&main->program.output, show_lefts[i], show_headers[i], show_rights[i]);
 
index 7c6bf35765b49ca7b911dd5ce53c0295b2e03fdb..18879c0db139c0974c06738862774f9a318a768c 100644 (file)
@@ -47,7 +47,7 @@ extern "C" {
       fl_print_format("%[%Q%] ", print->to, print->set->standout, left, print->set->standout);
     }
 
-    fll_print_format("%[%Q%]", print->to, print->set->standout, print->set->standout, print->set->title, print->set->title, print->set->standout, print->set->standout, f_string_eol_s);
+    fll_print_format("%[%Q%]", print->to, print->set->title, header, print->set->title, f_string_eol_s);
 
     if (left.used) {
       fl_print_format(" %[%Q%]", print->to, print->set->standout, right, print->set->standout);
index fae2355a87d868020b869614e149f43998c6fd68..2d44f2b6f162734592a92a90679b952f8edb5e0f 100644 (file)
@@ -67,7 +67,7 @@ extern "C" {
     else {
       fl_print_format(" %[the object '%]", print->to, print->context, print->prefix, print->context);
       fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable);
-      fl_print_format("%[' has no content.%]%r", print->to, print->context, print->context, f_string_eol_s);
+      fl_print_format("%[' is invalid.%]%r", print->to, print->context, print->context, f_string_eol_s);
     }
 
     f_file_stream_unlock(print->to);