From: Kevin Day Date: Sat, 26 Mar 2022 03:43:46 +0000 (-0500) Subject: Progress: Controller and Control sockets. X-Git-Tag: 0.5.9~65 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=6e49ad04f9e308bb659b830a09644b3214959c51;p=fll Progress: Controller and Control sockets. --- diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 1148426..7408506 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -26,6 +26,65 @@ extern "C" { const f_string_static_t control_long_socket_s = macro_f_string_static_t_initialize(CONTROL_long_socket_s, 0, CONTROL_long_socket_s_length); #endif // _di_control_parameters_ +#ifndef _di_control_action_type_identify_ + uint8_t control_action_type_identify(const f_string_static_t action) { + + if (fl_string_dynamic_compare(action, control_freeze_s) == F_equal_to) { + return control_action_type_freeze_e; + } + + if (fl_string_dynamic_compare(action, control_kexec_s) == F_equal_to) { + return control_action_type_kexec_e; + } + + if (fl_string_dynamic_compare(action, control_kill_s) == F_equal_to) { + return control_action_type_kill_e; + } + + if (fl_string_dynamic_compare(action, control_pause_s) == F_equal_to) { + return control_action_type_pause_e; + } + + if (fl_string_dynamic_compare(action, control_reboot_s) == F_equal_to) { + return control_action_type_reboot_e; + } + + if (fl_string_dynamic_compare(action, control_reload_s) == F_equal_to) { + return control_action_type_reload_e; + } + + if (fl_string_dynamic_compare(action, control_rerun_s) == F_equal_to) { + return control_action_type_rerun_e; + } + + if (fl_string_dynamic_compare(action, control_restart_s) == F_equal_to) { + return control_action_type_restart_e; + } + + if (fl_string_dynamic_compare(action, control_resume_s) == F_equal_to) { + return control_action_type_resume_e; + } + + if (fl_string_dynamic_compare(action, control_shutdown_s) == F_equal_to) { + return control_action_type_shutdown_e; + } + + if (fl_string_dynamic_compare(action, control_start_s) == F_equal_to) { + return control_action_type_start_e; + } + + if (fl_string_dynamic_compare(action, control_stop_s) == F_equal_to) { + return control_action_type_stop_e; + } + + if (fl_string_dynamic_compare(action, control_thaw_s) == F_equal_to) { + return control_action_type_thaw_e; + } + + return 0; + } +#endif // _di_control_action_type_identify_ + #ifndef _di_control_action_type_name_ f_string_static_t control_action_type_name(const uint8_t type) { @@ -33,6 +92,9 @@ extern "C" { case control_action_type_freeze_e: return control_freeze_s; + case control_action_type_kexec_e: + return control_kexec_s; + case control_action_type_kill_e: return control_kill_s; @@ -71,6 +133,25 @@ extern "C" { } #endif // _di_control_action_type_name_ +#ifndef _di_control_payload_type_identify_ + uint8_t control_payload_type_identify(const f_string_static_t payload) { + + if (fl_string_dynamic_compare(payload, control_controller_s) == F_equal_to) { + return control_payload_type_controller_e; + } + + if (fl_string_dynamic_compare(payload, control_error_s) == F_equal_to) { + return control_payload_type_error_e; + } + + if (fl_string_dynamic_compare(payload, control_init_s) == F_equal_to) { + return control_payload_type_init_e; + } + + return 0; + } +#endif // _di_control_payload_type_identify_ + #ifndef _di_control_payload_type_name_ f_string_static_t control_payload_type_name(const uint8_t type) { @@ -80,6 +161,9 @@ extern "C" { case control_payload_type_error_e: return control_error_s; + + case control_payload_type_init_e: + return control_init_s; } return f_string_empty_s; diff --git a/level_3/control/c/common.h b/level_3/control/c/common.h index 61225e2..bb61eda 100644 --- a/level_3/control/c/common.h +++ b/level_3/control/c/common.h @@ -134,6 +134,7 @@ extern "C" { * Codes representing supported actions. * * freeze: Perform the freeze controller operation. + * kexec: Perform the kexec controller operation (only for init mode). * kill: Perform the kill controller operation. * pause: Perform the pause controller operation. * reboot: Perform the reboot controller operation (only for init mode). @@ -149,6 +150,7 @@ extern "C" { #ifndef _di_control_action_types_ enum { control_action_type_freeze_e = 1, + control_action_type_kexec_e, control_action_type_kill_e, control_action_type_pause_e, control_action_type_reboot_e, @@ -166,17 +168,33 @@ extern "C" { /** * Supported payload types. * - * error: The payload is an error payload. * controller: The payload is a controller payload. + * error: The payload is an error payload. + * init: The payload is an init payload (only available when operating in "init" mode). */ #ifndef _di_control_payload_types_ enum { - control_payload_type_error_e = 1, - control_payload_type_controller_e, + control_payload_type_controller_e = 1, + control_payload_type_error_e, + control_payload_type_init_e, }; #endif // _di_control_payload_types_ /** + * Identify the action code the given name represents. + * + * @param action + * The string representing a action. + * + * @return + * The action type code on success. + * 0 if name is unknown. + */ +#ifndef _di_control_action_type_identify_ + extern uint8_t control_action_type_identify(const f_string_static_t action); +#endif // _di_control_action_type_identify_ + +/** * Get a string representing the action type. * * @param type @@ -191,6 +209,20 @@ extern "C" { #endif // _di_control_action_type_name_ /** + * Identify the payload code the given name represents. + * + * @param payload + * The string representing a payload. + * + * @return + * The payload type code on success. + * 0 if name is unknown. + */ +#ifndef _di_control_payload_type_identify_ + extern uint8_t control_payload_type_identify(const f_string_static_t payload); +#endif // _di_control_payload_type_identify_ + +/** * Get a string representing the payload type. * * @param type diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 20fc047..fd39fb7 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -196,7 +196,7 @@ extern "C" { control_data_t data = control_data_t_initialize; data.argv = main->parameters.arguments.array; - data.action = control_action_identify(main, &data, data.argv[main->parameters.remaining.array[0]]); + data.action = control_action_type_identify(data.argv[main->parameters.remaining.array[0]]); if (data.action) { status = control_action_verify(main, &data); diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index 71807da..e0df4da 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/control/c/private-common.c b/level_3/control/c/private-common.c index 1dffbfb..c93d0bc 100644 --- a/level_3/control/c/private-common.c +++ b/level_3/control/c/private-common.c @@ -20,6 +20,8 @@ extern "C" { const f_string_static_t control_controller_s = macro_f_string_static_t_initialize(CONTROL_controller_s, 0, CONTROL_controller_s_length); const f_string_static_t control_default_s = macro_f_string_static_t_initialize(CONTROL_default_s, 0, CONTROL_default_s_length); const f_string_static_t control_error_s = macro_f_string_static_t_initialize(CONTROL_error_s, 0, CONTROL_error_s_length); + const f_string_static_t control_init_s = macro_f_string_static_t_initialize(CONTROL_init_s, 0, CONTROL_init_s_length); + const f_string_static_t control_kexec_s = macro_f_string_static_t_initialize(CONTROL_kexec_s, 0, CONTROL_kexec_s_length); const f_string_static_t control_length_s = macro_f_string_static_t_initialize(CONTROL_length_s, 0, CONTROL_length_s_length); const f_string_static_t control_name_socket_s = macro_f_string_static_t_initialize(CONTROL_name_socket_s, 0, CONTROL_name_socket_s_length); const f_string_static_t control_path_socket_s = macro_f_string_static_t_initialize(CONTROL_path_socket_s, 0, CONTROL_path_socket_s_length); @@ -47,7 +49,7 @@ extern "C" { f_string_dynamic_resize(0, &data->cache.large); f_string_dynamic_resize(0, &data->cache.small); - f_string_dynamic_resize(0, &data->cache.payload); + f_string_dynamic_resize(0, &data->cache.packet); f_string_ranges_resize(0, &data->cache.packet_objects); f_string_rangess_resize(0, &data->cache.packet_contents); diff --git a/level_3/control/c/private-common.h b/level_3/control/c/private-common.h index 4f6a64d..1256fb2 100644 --- a/level_3/control/c/private-common.h +++ b/level_3/control/c/private-common.h @@ -131,6 +131,8 @@ extern "C" { #define CONTROL_controller_s "controller" #define CONTROL_default_s "default" #define CONTROL_error_s "error" + #define CONTROL_kexec_s "kexec" + #define CONTROL_init_s "init" #define CONTROL_length_s "length" #define CONTROL_name_socket_s "name_socket" #define CONTROL_path_socket_s "path_socket" @@ -156,6 +158,8 @@ extern "C" { #define CONTROL_controller_s_length 10 #define CONTROL_default_s_length 7 #define CONTROL_error_s_length 5 + #define CONTROL_init_s_length 4 + #define CONTROL_kexec_s_length 5 #define CONTROL_length_s_length 6 #define CONTROL_name_socket_s_length 11 #define CONTROL_path_socket_s_length 11 @@ -183,6 +187,8 @@ extern "C" { extern const f_string_static_t control_controller_s; extern const f_string_static_t control_default_s; extern const f_string_static_t control_error_s; + extern const f_string_static_t control_init_s; + extern const f_string_static_t control_kexec_s; extern const f_string_static_t control_length_s; extern const f_string_static_t control_name_socket_s; extern const f_string_static_t control_path_socket_s; @@ -208,9 +214,9 @@ extern "C" { /** * The control cache. * - * large: A buffer for storing large sets of data. - * small: A buffer for storing small sets of data. - * payload: A buffer dedicated for the payload. + * large: A buffer for storing large sets of data. + * small: A buffer for storing small sets of data. + * packet: A buffer for storing the send packet or the response payload. * * packet_objects: The FSS Objects for a packet. * packet_contents: The FSS Contents for a packet. @@ -224,7 +230,7 @@ extern "C" { typedef struct { f_string_dynamic_t large; f_string_dynamic_t small; - f_string_dynamic_t payload; + f_string_dynamic_t packet; f_fss_objects_t packet_objects; f_fss_contents_t packet_contents; @@ -251,8 +257,8 @@ extern "C" { /** * The control data. * - * argv: The argument structure in the progam data parameters for simplifying syntax. * action: The action type code. + * argv: The argument structure in the progam data parameters for simplifying syntax. * cache: A cache. * socket: A socket used to connect to the controller. */ @@ -272,7 +278,6 @@ extern "C" { 0, \ f_string_dynamic_t_initialize, \ f_socket_t_initialize, \ - /*f_string_dynamic_t_initialize,*/ \ 0, \ } #endif // _di_control_data_t_ diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index fb27c05..7d50e40 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -7,61 +7,6 @@ extern "C" { #endif -#ifndef _di_control_action_identify_ - uint8_t control_action_identify(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t action) { - - if (fl_string_dynamic_compare(action, control_freeze_s) == F_equal_to) { - return control_action_type_freeze_e; - } - - if (fl_string_dynamic_compare(action, control_kill_s) == F_equal_to) { - return control_action_type_kill_e; - } - - if (fl_string_dynamic_compare(action, control_pause_s) == F_equal_to) { - return control_action_type_pause_e; - } - - if (fl_string_dynamic_compare(action, control_reboot_s) == F_equal_to) { - return control_action_type_reboot_e; - } - - if (fl_string_dynamic_compare(action, control_reload_s) == F_equal_to) { - return control_action_type_reload_e; - } - - if (fl_string_dynamic_compare(action, control_rerun_s) == F_equal_to) { - return control_action_type_rerun_e; - } - - if (fl_string_dynamic_compare(action, control_restart_s) == F_equal_to) { - return control_action_type_restart_e; - } - - if (fl_string_dynamic_compare(action, control_resume_s) == F_equal_to) { - return control_action_type_resume_e; - } - - if (fl_string_dynamic_compare(action, control_shutdown_s) == F_equal_to) { - return control_action_type_shutdown_e; - } - - if (fl_string_dynamic_compare(action, control_start_s) == F_equal_to) { - return control_action_type_start_e; - } - - if (fl_string_dynamic_compare(action, control_stop_s) == F_equal_to) { - return control_action_type_stop_e; - } - - if (fl_string_dynamic_compare(action, control_thaw_s) == F_equal_to) { - return control_action_type_thaw_e; - } - - return 0; - } -#endif // _di_control_action_identify_ - #ifndef _di_control_action_verify_ f_status_t control_action_verify(fll_program_data_t * const main, control_data_t * const data) { @@ -236,6 +181,7 @@ extern "C" { data->cache.large.used = 0; data->cache.small.used = 0; + data->cache.packet.used = 0; data->cache.packet_objects.used = 0; data->cache.packet_contents.used = 0; data->cache.header_objects.used = 0; @@ -435,7 +381,7 @@ extern "C" { control_print_debug_packet_header_object_and_content(main, control_action_s, data->cache.large, data->cache.header_contents.array[i].array[0]); - header->action = control_action_identify(main, data, action); + header->action = control_action_type_identify(action); if (!header->action) { control_print_debug_packet_message(main, "Failed to identify %[" CONTROL_action_s "%] from: ", &data->cache.large, &data->cache.header_contents.array[i].array[0], 0); @@ -594,15 +540,79 @@ extern "C" { #ifndef _di_control_packet_send_ f_status_t control_packet_send(fll_program_data_t * const main, control_data_t * const data) { - // @todo f_array_length_t length = 0; - //F_status_t status = f_socket_write(&data->socket, 0, data->cache.large, &length); + f_status_t status = control_packet_send_build_header(main, data, control_action_type_name(data->action), f_string_empty_s, length); + if (F_status_is_error(status)) return status; + + const f_state_t state = f_state_t_initialize; - return F_none; + status = fll_fss_payload_write_string(f_fss_string_payload_s, f_string_empty_s, F_false, 0, state, &data->cache.packet); + if (F_status_is_error(status)) return status; + + data->socket.size_write = data->cache.packet.used; + + return f_socket_write(&data->socket, 0, (void *) &data->cache.packet, 0); } #endif // _di_control_packet_send_ +#ifndef _di_control_packet_send_build_header_ + f_status_t control_packet_send_build_header(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t status, const f_array_length_t length) { + + f_status_t status2 = F_none; + + const f_state_t state = f_state_t_initialize; + const f_conversion_data_t data_conversion = macro_f_conversion_data_t_initialize(10, 0, 1); + + f_string_statics_t content = f_string_statics_t_initialize; + f_string_static_t contents[1]; + content.array = contents; + content.used = 1; + content.size = 1; + + data->cache.large.used = 0; + data->cache.small.used = 0; + data->cache.packet.used = 0; + + // Header: type. + if (type.used) { + contents[0] = type; + + status2 = fll_fss_extended_write_string(control_type_s, content, 0, state, &data->cache.large); + if (F_status_is_error(status2)) return status2; + } + + // Header: status. + if (status.used) { + contents[0] = status; + + status2 = fll_fss_extended_write_string(control_status_s, content, 0, state, &data->cache.large); + if (F_status_is_error(status2)) return status2; + + data->cache.small.used = 0; + } + + // Header: length. + status2 = f_conversion_number_unsigned_to_string(length, data_conversion, &data->cache.small); + if (F_status_is_error(status2)) return status2; + + contents[0] = data->cache.small; + + status2 = fll_fss_extended_write_string(control_length_s, content, 0, state, &data->cache.large); + if (F_status_is_error(status2)) return status2; + + // Prepend the identifier comment to the output. + status2 = f_string_dynamic_append(control_type_s, &data->cache.packet); + if (F_status_is_error(status2)) return status2; + + // Append entire header block to the output. + status2 = fll_fss_payload_write_string(f_fss_string_header_s, data->cache.large, F_false, 0, state, &data->cache.packet); + if (F_status_is_error(status2)) return status2; + + return F_none; + } +#endif // _di_control_packet_send_build_header_ + #ifndef _di_control_settings_load_ f_status_t control_settings_load(fll_program_data_t * const main, control_data_t * const data) { diff --git a/level_3/control/c/private-control.h b/level_3/control/c/private-control.h index 109f405..7dc6a7e 100644 --- a/level_3/control/c/private-control.h +++ b/level_3/control/c/private-control.h @@ -12,25 +12,6 @@ extern "C" { #endif - -/** - * Identify the action code the given name represents. - * - * @param main - * The main program data. - * @param data - * The control data. - * @param action - * The parameter representing a action. - * - * @return - * action type code on success. - * 0 if name is unknown. - */ -#ifndef _di_control_action_identify_ - extern uint8_t control_action_identify(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t action) F_attribute_visibility_internal_d; -#endif // _di_control_action_identify_ - /** * Verify that the additional parameters are reasonably correct for the identified action. * @@ -141,6 +122,47 @@ extern "C" { #ifndef _di_control_packet_send_ extern f_status_t control_packet_send(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_control_packet_send_ + +/** + * Construct the header portion of the payload. + * + * This also prepends the FSS identifier comment. + * + * This resets and uses data->cache.small, data->cache.large, and data->cache.packet. + * Do not use any of these for passing strings to this function. + * + * The results of this function replaces data->cache.packet. + * + * @param global + * The global data. + * @param data + * The control data. + * @param type + * The packet type. + * Set type.used to 0 to not add to the header. + * @param status + * The status code. + * Set status.used to 0 to not add to the header. + * @param length + * The length of the payload Content. + * This is always added to the header. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_conversion_number_unsigned_to_string(). + * Errors (with error bit) from: f_string_append(). + * Errors (with error bit) from: fll_fss_extended_write_string(). + * Errors (with error bit) from: fll_fss_payload_write_string(). + * + * @see f_conversion_number_unsigned_to_string() + * @see f_string_append() + * @see fll_fss_extended_write_string() + * @see fll_fss_payload_write_string() + */ +#ifndef _di_control_packet_send_build_header_ + extern f_status_t control_packet_send_build_header(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t status, const f_array_length_t length) F_attribute_visibility_internal_d; +#endif // _di_control_packet_send_build_header_ /** * Load and process the control settings file. * diff --git a/level_3/control/documents/packet_response.txt b/level_3/control/documents/packet_response.txt index d30d7ff..59de322 100644 --- a/level_3/control/documents/packet_response.txt +++ b/level_3/control/documents/packet_response.txt @@ -16,7 +16,7 @@ Packet Response: The Control program only supports the following Payload Packet header Objects\: - status: Allowing only a single status header Object. - - type: Allowing only a single type header Object and may only be one of: "error" and "controller". + - type: Allowing only a single type header Object and may only be one of: "controller", "error", or "kexec". - action: Allowing only a single action header Object and may only be one of: "freeze", "kill", "pause", "reboot", "reload", "rerun", "restart", "resume", "shutdown", "start", "stop", and "thaw". - length: Allowing only a single length header Object and must properly describe the length of the entire Payload Packet as per the referenced Specifications. diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index 588251c..8e928d6 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -55,6 +55,122 @@ extern "C" { const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length); #endif // _di_controller_parameters_ +#ifndef _di_controller_control_payload_type_identify_ + uint8_t controller_control_payload_type_identify(const f_string_static_t payload) { + + if (fl_string_dynamic_compare(payload, controller_controller_s) == F_equal_to) { + return controller_control_payload_type_controller_e; + } + + if (fl_string_dynamic_compare(payload, controller_error_s) == F_equal_to) { + return controller_control_payload_type_error_e; + } + + if (fl_string_dynamic_compare(payload, controller_init_s) == F_equal_to) { + return controller_control_payload_type_init_e; + } + + return 0; + } +#endif // _di_controller_control_payload_type_identify_ + +#ifndef _di_controller_control_payload_type_name_ + f_string_static_t controller_control_payload_type_name(const uint8_t type) { + + switch (type) { + case controller_control_payload_type_controller_e: + return controller_controller_s; + + case controller_control_payload_type_error_e: + return controller_error_s; + + case controller_control_payload_type_init_e: + return controller_init_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_control_payload_type_name_ + +#ifndef _di_controller_entry_action_type_identify_ + uint8_t controller_entry_action_type_identify(const f_string_static_t action) { + + if (fl_string_dynamic_compare(action, controller_consider_s) == F_equal_to) { + return controller_entry_action_type_consider_e; + } + + if (fl_string_dynamic_compare(action, controller_execute_s) == F_equal_to) { + return controller_entry_action_type_execute_e; + } + + if (fl_string_dynamic_compare(action, controller_failsafe_s) == F_equal_to) { + return controller_entry_action_type_failsafe_e; + } + + if (fl_string_dynamic_compare(action, controller_freeze_s) == F_equal_to) { + return controller_entry_action_type_freeze_e; + } + + if (fl_string_dynamic_compare(action, controller_item_s) == F_equal_to) { + return controller_entry_action_type_item_e; + } + + if (fl_string_dynamic_compare(action, controller_kexec_s) == F_equal_to) { + return controller_entry_action_type_kexec_e; + } + + if (fl_string_dynamic_compare(action, controller_kill_s) == F_equal_to) { + return controller_entry_action_type_kill_e; + } + + if (fl_string_dynamic_compare(action, controller_pause_s) == F_equal_to) { + return controller_entry_action_type_pause_e; + } + + if (fl_string_dynamic_compare(action, controller_ready_s) == F_equal_to) { + return controller_entry_action_type_ready_e; + } + + if (fl_string_dynamic_compare(action, controller_reboot_s) == F_equal_to) { + return controller_entry_action_type_reboot_e; + } + + if (fl_string_dynamic_compare(action, controller_reload_s) == F_equal_to) { + return controller_entry_action_type_reload_e; + } + + if (fl_string_dynamic_compare(action, controller_restart_s) == F_equal_to) { + return controller_entry_action_type_restart_e; + } + + if (fl_string_dynamic_compare(action, controller_resume_s) == F_equal_to) { + return controller_entry_action_type_resume_e; + } + + if (fl_string_dynamic_compare(action, controller_shutdown_s) == F_equal_to) { + return controller_entry_action_type_shutdown_e; + } + + if (fl_string_dynamic_compare(action, controller_start_s) == F_equal_to) { + return controller_entry_action_type_start_e; + } + + if (fl_string_dynamic_compare(action, controller_stop_s) == F_equal_to) { + return controller_entry_action_type_stop_e; + } + + if (fl_string_dynamic_compare(action, controller_thaw_s) == F_equal_to) { + return controller_entry_action_type_thaw_e; + } + + if (fl_string_dynamic_compare(action, controller_timeout_s) == F_equal_to) { + return controller_entry_action_type_timeout_e; + } + + return 0; + } +#endif // _di_controller_entry_action_type_identify_ + #ifndef _di_controller_entry_action_type_name_ f_string_static_t controller_entry_action_type_name(const uint8_t type) { @@ -74,6 +190,9 @@ extern "C" { case controller_entry_action_type_item_e: return controller_item_s; + case controller_entry_action_type_kexec_e: + return controller_kexec_s; + case controller_entry_action_type_kill_e: return controller_kill_s; @@ -83,6 +202,9 @@ extern "C" { case controller_entry_action_type_ready_e: return controller_ready_s; + case controller_entry_action_type_reboot_e: + return controller_reboot_s; + case controller_entry_action_type_reload_e: return controller_reload_s; @@ -92,6 +214,9 @@ extern "C" { case controller_entry_action_type_resume_e: return controller_resume_s; + case controller_entry_action_type_shutdown_e: + return controller_shutdown_s; + case controller_entry_action_type_start_e: return controller_start_s; @@ -120,6 +245,73 @@ extern "C" { } #endif // _di_controller_main_delete_ +#ifndef _di_controller_rule_action_type_identify_ + uint8_t controller_rule_action_type_identify(const f_string_static_t action) { + + if (fl_string_dynamic_compare(action, controller_freeze_s) == F_equal_to) { + return controller_rule_action_type_freeze_e; + } + + if (fl_string_dynamic_compare(action, controller_group_s) == F_equal_to) { + return controller_rule_action_type_group_e; + } + + if (fl_string_dynamic_compare(action, controller_kill_s) == F_equal_to) { + return controller_rule_action_type_kill_e; + } + + if (fl_string_dynamic_compare(action, controller_pause_s) == F_equal_to) { + return controller_rule_action_type_pause_e; + } + + if (fl_string_dynamic_compare(action, controller_pid_file_s) == F_equal_to) { + return controller_rule_action_type_pid_file_e; + } + + if (fl_string_dynamic_compare(action, controller_reload_s) == F_equal_to) { + return controller_rule_action_type_reload_e; + } + + if (fl_string_dynamic_compare(action, controller_rerun_s) == F_equal_to) { + return controller_rule_action_type_rerun_e; + } + + if (fl_string_dynamic_compare(action, controller_restart_s) == F_equal_to) { + return controller_rule_action_type_restart_e; + } + + if (fl_string_dynamic_compare(action, controller_resume_s) == F_equal_to) { + return controller_rule_action_type_resume_e; + } + + if (fl_string_dynamic_compare(action, controller_start_s) == F_equal_to) { + return controller_rule_action_type_start_e; + } + + if (fl_string_dynamic_compare(action, controller_stop_s) == F_equal_to) { + return controller_rule_action_type_stop_e; + } + + if (fl_string_dynamic_compare(action, controller_start_s) == F_equal_to) { + return controller_rule_action_type_start_e; + } + + if (fl_string_dynamic_compare(action, controller_thaw_s) == F_equal_to) { + return controller_rule_action_type_thaw_e; + } + + if (fl_string_dynamic_compare(action, controller_user_s) == F_equal_to) { + return controller_rule_action_type_user_e; + } + + if (fl_string_dynamic_compare(action, controller_with_s) == F_equal_to) { + return controller_rule_action_type_with_e; + } + + return 0; + } +#endif // _di_controller_rule_action_type_identify_ + #ifndef _di_controller_rule_action_type_name_ f_string_static_t controller_rule_action_type_name(const uint8_t type) { @@ -139,12 +331,12 @@ extern "C" { case controller_rule_action_type_pid_file_e: return controller_pid_file_s; - case controller_rule_action_type_rerun_e: - return controller_rerun_s; - case controller_rule_action_type_reload_e: return controller_reload_s; + case controller_rule_action_type_rerun_e: + return controller_rerun_s; + case controller_rule_action_type_restart_e: return controller_restart_s; @@ -171,41 +363,111 @@ extern "C" { } #endif // _di_controller_rule_action_type_name_ -#ifndef _di_controller_rule_action_type_execute_name_ - f_string_static_t controller_rule_action_type_execute_name(const uint8_t type) { +#ifndef _di_controller_rule_action_execute_type_identify_ + uint8_t controller_rule_action_execute_type_identify(const f_string_static_t action) { + + if (fl_string_dynamic_compare(action, controller_freeze_s) == F_equal_to) { + return controller_rule_action_execute_type_freeze_e; + } + + if (fl_string_dynamic_compare(action, controller_kill_s) == F_equal_to) { + return controller_rule_action_execute_type_kill_e; + } + + if (fl_string_dynamic_compare(action, controller_pause_s) == F_equal_to) { + return controller_rule_action_execute_type_pause_e; + } + + if (fl_string_dynamic_compare(action, controller_reload_s) == F_equal_to) { + return controller_rule_action_execute_type_reload_e; + } + + if (fl_string_dynamic_compare(action, controller_restart_s) == F_equal_to) { + return controller_rule_action_execute_type_restart_e; + } + + if (fl_string_dynamic_compare(action, controller_resume_s) == F_equal_to) { + return controller_rule_action_execute_type_resume_e; + } + + if (fl_string_dynamic_compare(action, controller_start_s) == F_equal_to) { + return controller_rule_action_execute_type_start_e; + } + + if (fl_string_dynamic_compare(action, controller_stop_s) == F_equal_to) { + return controller_rule_action_execute_type_stop_e; + } + + if (fl_string_dynamic_compare(action, controller_thaw_s) == F_equal_to) { + return controller_rule_action_execute_type_thaw_e; + } + + return controller_rule_action_execute_type__enum_size_e; + } +#endif // _di_controller_rule_action_execute_type_identify_ + +#ifndef _di_controller_rule_action_execute_type_name_ + f_string_static_t controller_rule_action_execute_type_name(const uint8_t type) { switch (type) { - case controller_rule_action_type_execute_freeze_e: + case controller_rule_action_execute_type_freeze_e: return controller_freeze_s; - case controller_rule_action_type_execute_kill_e: + case controller_rule_action_execute_type_kill_e: return controller_kill_s; - case controller_rule_action_type_execute_pause_e: + case controller_rule_action_execute_type_pause_e: return controller_pause_s; - case controller_rule_action_type_execute_reload_e: + case controller_rule_action_execute_type_reload_e: return controller_reload_s; - case controller_rule_action_type_execute_restart_e: + case controller_rule_action_execute_type_restart_e: return controller_restart_s; - case controller_rule_action_type_execute_resume_e: + case controller_rule_action_execute_type_resume_e: return controller_resume_s; - case controller_rule_action_type_execute_start_e: + case controller_rule_action_execute_type_start_e: return controller_start_s; - case controller_rule_action_type_execute_stop_e: + case controller_rule_action_execute_type_stop_e: return controller_stop_s; - case controller_rule_action_type_execute_thaw_e: + case controller_rule_action_execute_type_thaw_e: return controller_thaw_s; } return f_string_empty_s; } -#endif // _di_controller_rule_action_type_execute_name_ +#endif // _di_controller_rule_action_execute_type_name_ + +#ifndef _di_controller_rule_item_type_identify_ + uint8_t controller_rule_item_type_identify(const f_string_static_t item) { + + if (fl_string_dynamic_compare(item, controller_command_s) == F_equal_to) { + return controller_rule_item_type_command_e; + } + + if (fl_string_dynamic_compare(item, controller_script_s) == F_equal_to) { + return controller_rule_item_type_script_e; + } + + if (fl_string_dynamic_compare(item, controller_service_s) == F_equal_to) { + return controller_rule_item_type_service_e; + } + + if (fl_string_dynamic_compare(item, controller_setting_s) == F_equal_to) { + return controller_rule_item_type_setting_e; + } + + if (fl_string_dynamic_compare(item, controller_utility_s) == F_equal_to) { + return controller_rule_item_type_utility_e; + } + + return 0; + } +#endif // _di_controller_rule_item_type_identify_ #ifndef _di_controller_rule_item_type_name_ f_string_static_t controller_rule_item_type_name(const uint8_t type) { @@ -231,6 +493,77 @@ extern "C" { } #endif // _di_controller_rule_item_type_name_ +#ifndef _di_controller_rule_setting_limit_type_identify_ + uint8_t controller_rule_setting_limit_type_identify(const f_string_static_t limit) { + + if (fl_string_dynamic_compare(limit, controller_as_s) == F_equal_to) { + return controller_resource_limit_type_as_e; + } + + if (fl_string_dynamic_compare(limit, controller_core_s) == F_equal_to) { + return controller_resource_limit_type_core_e; + } + + if (fl_string_dynamic_compare(limit, controller_cpu_s) == F_equal_to) { + return controller_resource_limit_type_cpu_e; + } + + if (fl_string_dynamic_compare(limit, controller_data_s) == F_equal_to) { + return controller_resource_limit_type_data_e; + } + + if (fl_string_dynamic_compare(limit, controller_fsize_s) == F_equal_to) { + return controller_resource_limit_type_fsize_e; + } + + if (fl_string_dynamic_compare(limit, controller_locks_s) == F_equal_to) { + return controller_resource_limit_type_locks_e; + } + + if (fl_string_dynamic_compare(limit, controller_memlock_s) == F_equal_to) { + return controller_resource_limit_type_memlock_e; + } + + if (fl_string_dynamic_compare(limit, controller_msgqueue_s) == F_equal_to) { + return controller_resource_limit_type_msgqueue_e; + } + + if (fl_string_dynamic_compare(limit, controller_nice_s) == F_equal_to) { + return controller_resource_limit_type_nice_e; + } + + if (fl_string_dynamic_compare(limit, controller_nofile_s) == F_equal_to) { + return controller_resource_limit_type_nofile_e; + } + + if (fl_string_dynamic_compare(limit, controller_nproc_s) == F_equal_to) { + return controller_resource_limit_type_nproc_e; + } + + if (fl_string_dynamic_compare(limit, controller_rss_s) == F_equal_to) { + return controller_resource_limit_type_rss_e; + } + + if (fl_string_dynamic_compare(limit, controller_rtprio_s) == F_equal_to) { + return controller_resource_limit_type_rtprio_e; + } + + if (fl_string_dynamic_compare(limit, controller_rttime_s) == F_equal_to) { + return controller_resource_limit_type_rttime_e; + } + + if (fl_string_dynamic_compare(limit, controller_sigpending_s) == F_equal_to) { + return controller_resource_limit_type_sigpending_e; + } + + if (fl_string_dynamic_compare(limit, controller_stack_s) == F_equal_to) { + return controller_resource_limit_type_stack_e; + } + + return 0; + } +#endif // _di_controller_rule_setting_limit_type_identify_ + #ifndef _di_controller_rule_setting_limit_type_name_ f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type) { diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index fdcdc38..247b87f 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -381,20 +381,42 @@ extern "C" { #endif // _di_controller_main_t_ /** + * Codes representing control payload types. + * + * controller_control_payload_type_*: + * - controller: The item type represents a command operation. + * - error: The item type represents a script operation. + * - init: The item type represents an init operation (Only fo init mode). + */ +#ifndef _di_controller_control_payload_types_t_ + enum { + controller_control_payload_type_controller_e = 1, + controller_control_payload_type_error_e, + controller_control_payload_type_init_e, + }; +#endif // _di_controller_control_payload_types_t_ + +/** * Codes representing supported actions. * - * freeze: Perform the freeze controller operation. - * kill: Perform the kill controller operation. - * pause: Perform the pause controller operation. - * reboot: Perform the reboot controller operation (only for init mode). - * reload: Perform the reload controller operation. - * rerun: Perform the rerun controller operation. - * restart: Perform the restart controller operation. - * resume: Perform the resume controller operation. - * shutdown: Perform the shutdown controller operation (only for init mode). - * start: Perform the start controller operation. - * stop: Perform the stop controller operation. - * thaw: Perform the thaw controller operation. + * controller_entry_action_type_*: + * - consider: Perform the consider controller operation. + * - execute: Perform the execute controller operation. + * - freeze: Perform the freeze controller operation.. + * - item: Perform the item controller operation. + * - kexec: Perform the kexec controller operation (only for init mode). + * - kill: Perform the kill controller operation. + * - pause: Perform the pause controller operation. + * - ready: Perform the ready controller operation. + * - reboot: Perform the reboot controller operation (only for init mode). + * - reload: Perform the reload controller operation. + * - restart: Perform the restart controller operation. + * - resume: Perform the resume controller operation. + * - shutdown: Perform the shutdown controller operation (only for init mode). + * - start: Perform the start controller operation. + * - stop: Perform the stop controller operation. + * - timeout: Perform the timeout controller operation. + * - thaw: Perform the thaw controller operation. */ #ifndef _di_controller_entry_action_types_t_ enum { @@ -403,12 +425,15 @@ extern "C" { controller_entry_action_type_failsafe_e, controller_entry_action_type_freeze_e, controller_entry_action_type_item_e, + controller_entry_action_type_kexec_e, controller_entry_action_type_kill_e, controller_entry_action_type_pause_e, controller_entry_action_type_ready_e, + controller_entry_action_type_reboot_e, controller_entry_action_type_reload_e, controller_entry_action_type_restart_e, controller_entry_action_type_resume_e, + controller_entry_action_type_shutdown_e, controller_entry_action_type_start_e, controller_entry_action_type_stop_e, controller_entry_action_type_timeout_e, @@ -417,13 +442,88 @@ extern "C" { #endif // _di_controller_entry_action_types_t_ /** - * Codes representing items. + * Codes representing rule actions. + * + * controller_rule_action_type_*: + * - freeze: The Freeze execution instructions. + * - group: The Group setting. + * - kill: The Kill execution instructions. + * - pause: The Pause execution instructions. + * - pid_file: The PID file setting. + * - rerun: The Re-run execution after success or failure. + * - reload: The Reload execution instructions. + * - restart: The Restart execution instructions. + * - resume: The Resume execution instructions. + * - start: The Start execution instructions. + * - stop: The Stop execution instructions. + * - thaw: The Thaw execution instructions. + * - user: The User setting. + * - with: The With flags. + */ +#ifndef _di_controller_rule_action_types_t_ + enum { + controller_rule_action_type_freeze_e = 1, + controller_rule_action_type_group_e, + controller_rule_action_type_kill_e, + controller_rule_action_type_pause_e, + controller_rule_action_type_pid_file_e, + controller_rule_action_type_reload_e, + controller_rule_action_type_rerun_e, + controller_rule_action_type_restart_e, + controller_rule_action_type_resume_e, + controller_rule_action_type_start_e, + controller_rule_action_type_stop_e, + controller_rule_action_type_thaw_e, + controller_rule_action_type_user_e, + controller_rule_action_type_with_e, + + // Designate the largest value in the enum, the '__' is intended. + controller_rule_action_type__enum_size_e, + }; +#endif // _di_controller_rule_action_types_t_ + +/** + * Codes representing rule action executes. + * + * Execute type starts at 0 because it is intended to be used as an index within a static array. + * + * controller_rule_action_execute_type_*: + * - freeze: The Freeze execution instructions. + * - kill: The Kill execution instructions. + * - pause: The Pause execution instructions. + * - reload: The Reload execution instructions. + * - restart: The Restart execution instructions. + * - resume: The Resume execution instructions. + * - start: The Start execution instructions. + * - stop: The Stop execution instructions. + * - thaw: The Thaw execution instructions. + */ +#ifndef _di_controller_rule_action_execute_types_t_ + enum { + controller_rule_action_execute_type_freeze_e = 0, + controller_rule_action_execute_type_kill_e, + controller_rule_action_execute_type_pause_e, + controller_rule_action_execute_type_reload_e, + controller_rule_action_execute_type_restart_e, + controller_rule_action_execute_type_resume_e, + controller_rule_action_execute_type_start_e, + controller_rule_action_execute_type_stop_e, + controller_rule_action_execute_type_thaw_e, + + // Designate the largest value in the enum, the '__' is intended. + controller_rule_action_execute_type__enum_size_e, + }; +#endif // _di_controller_rule_action_execute_types_t_ + +/** + * Codes representing rule items. * - * command: The item type represents a command operation. - * script: The item type represents a script operation. - * service: The item type represents a service operation. - * setting: The item type represents a setting operation. - * utility: The item type represents a utility operation. + * controller_rule_item_type_*: + * - command: The item type represents a command operation. + * - script: The item type represents a script operation. + * - service: The item type represents a service operation. + * - setting: The item type represents a setting operation. + * - utility: The item type represents a utility operation. */ #ifndef _di_controller_rule_item_types_t_ enum { @@ -462,6 +562,48 @@ extern "C" { #endif // _di_controller_resource_limit_t_ /** + * Identify the payload code the given name represents. + * + * @param payload + * The string representing a payload. + * + * @return + * The payload type code on success. + * 0 if name is unknown. + */ +#ifndef _di_controller_control_payload_type_identify_ + extern uint8_t controller_control_payload_type_identify(const f_string_static_t payload); +#endif // _di_controller_control_payload_type_identify_ + +/** + * Get a string representing the payload type. + * + * @param type + * The payload type id. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_control_payload_type_name_ + extern f_string_static_t controller_control_payload_type_name(const uint8_t type); +#endif // _di_controller_control_payload_type_name_ + +/** + * Identify the entry action code the given name represents. + * + * @param action + * The string representing an entry action. + * + * @return + * The entry action type code on success. + * 0 if name is unknown. + */ +#ifndef _di_controller_entry_action_type_identify_ + extern uint8_t controller_entry_action_type_identify(const f_string_static_t action); +#endif // _di_controller_entry_action_type_identify_ + +/** * Get a string representing the entry action type. * * @param type @@ -503,6 +645,20 @@ extern "C" { #endif // _di_controller_main_delete_ /** + * Identify the rule action code the given name represents. + * + * @param action + * The string representing an rule action. + * + * @return + * The rule action type code on success. + * 0 if name is unknown. + */ +#ifndef _di_controller_rule_action_type_identify_ + extern uint8_t controller_rule_action_type_identify(const f_string_static_t action); +#endif // _di_controller_rule_action_type_identify_ + +/** * Get a string representing the rule action type. * * @param type @@ -517,6 +673,20 @@ extern "C" { #endif // _di_controller_rule_action_type_name_ /** + * Identify the rule action execute code the given name represents. + * + * @param action + * The string representing an rule action execute. + * + * @return + * The rule action execute type code on success. + * controller_rule_action_execute_type__enum_size_e if name is unknown. + */ +#ifndef _di_controller_rule_action_execute_type_identify_ + extern uint8_t controller_rule_action_execute_type_identify(const f_string_static_t action); +#endif // _di_controller_rule_action_execute_type_identify_ + +/** * Get a string representing the rule action execute type. * * @param type @@ -526,9 +696,23 @@ extern "C" { * The string with used > 0 on success. * The string with used == 0 if no match was found. */ -#ifndef _di_controller_rule_action_type_execute_name_ - extern f_string_static_t controller_rule_action_type_execute_name(const uint8_t type); -#endif // _di_controller_rule_action_type_execute_name_ +#ifndef _di_controller_rule_action_execute_type_name_ + extern f_string_static_t controller_rule_action_execute_type_name(const uint8_t type); +#endif // _di_controller_rule_action_execute_type_name_ + +/** + * Identify the rule item code the given name represents. + * + * @param item + * The string representing an rule action. + * + * @return + * The rule item type code on success. + * 0 if name is unknown. + */ +#ifndef _di_controller_rule_item_type_identify_ + extern uint8_t controller_rule_item_type_identify(const f_string_static_t item); +#endif // _di_controller_rule_item_type_identify_ /** * Get a string representing the rule item type. @@ -545,6 +729,20 @@ extern "C" { #endif // _di_controller_rule_item_type_name_ /** + * Identify the rule item code the given name represents. + * + * @param item + * The string representing an rule action. + * + * @return + * The rule item type code on success. + * 0 if name is unknown. + */ +#ifndef _di_controller_rule_setting_limit_type_identify_ + extern uint8_t controller_rule_setting_limit_type_identify(const f_string_static_t item); +#endif // _di_controller_rule_setting_limit_type_identify_ + +/** * Get a string representing the rule setting limit type. * * @param type diff --git a/level_3/controller/c/common/private-common.c b/level_3/controller/c/common/private-common.c index 6187948..bced2e7 100644 --- a/level_3/controller/c/common/private-common.c +++ b/level_3/controller/c/common/private-common.c @@ -22,6 +22,7 @@ extern "C" { const f_string_static_t controller_control_group_s = macro_f_string_static_t_initialize(CONTROLLER_control_group_s, 0, CONTROLLER_control_group_s_length); const f_string_static_t controller_control_mode_s = macro_f_string_static_t_initialize(CONTROLLER_control_mode_s, 0, CONTROLLER_control_mode_s_length); const f_string_static_t controller_control_user_s = macro_f_string_static_t_initialize(CONTROLLER_control_user_s, 0, CONTROLLER_control_user_s_length); + const f_string_static_t controller_controller_s = macro_f_string_static_t_initialize(CONTROLLER_controller_s, 0, CONTROLLER_controller_s_length); const f_string_static_t controller_cpu_s = macro_f_string_static_t_initialize(CONTROLLER_cpu_s, 0, CONTROLLER_cpu_s_length); const f_string_static_t controller_core_s = macro_f_string_static_t_initialize(CONTROLLER_core_s, 0, CONTROLLER_core_s_length); const f_string_static_t controller_data_s = macro_f_string_static_t_initialize(CONTROLLER_data_s, 0, CONTROLLER_data_s_length); @@ -52,6 +53,7 @@ extern "C" { const f_string_static_t controller_iki_s = macro_f_string_static_t_initialize(CONTROLLER_iki_s, 0, CONTROLLER_iki_s_length); const f_string_static_t controller_item_s = macro_f_string_static_t_initialize(CONTROLLER_item_s, 0, CONTROLLER_item_s_length); const f_string_static_t controller_init_s = macro_f_string_static_t_initialize(CONTROLLER_init_s, 0, CONTROLLER_init_s_length); + const f_string_static_t controller_kexec_s = macro_f_string_static_t_initialize(CONTROLLER_kexec_s, 0, CONTROLLER_kexec_s_length); const f_string_static_t controller_kill_s = macro_f_string_static_t_initialize(CONTROLLER_kill_s, 0, CONTROLLER_kill_s_length); const f_string_static_t controller_length_s = macro_f_string_static_t_initialize(CONTROLLER_length_s, 0, CONTROLLER_length_s_length); const f_string_static_t controller_limit_s = macro_f_string_static_t_initialize(CONTROLLER_limit_s, 0, CONTROLLER_limit_s_length); @@ -83,6 +85,7 @@ extern "C" { const f_string_static_t controller_processor_s = macro_f_string_static_t_initialize(CONTROLLER_processor_s, 0, CONTROLLER_processor_s_length); const f_string_static_t controller_program_s = macro_f_string_static_t_initialize(CONTROLLER_program_s, 0, CONTROLLER_program_s_length); const f_string_static_t controller_ready_s = macro_f_string_static_t_initialize(CONTROLLER_ready_s, 0, CONTROLLER_ready_s_length); + const f_string_static_t controller_reboot_s = macro_f_string_static_t_initialize(CONTROLLER_reboot_s, 0, CONTROLLER_reboot_s_length); const f_string_static_t controller_reload_s = macro_f_string_static_t_initialize(CONTROLLER_reload_s, 0, CONTROLLER_reload_s_length); const f_string_static_t controller_require_s = macro_f_string_static_t_initialize(CONTROLLER_require_s, 0, CONTROLLER_require_s_length); const f_string_static_t controller_required_s = macro_f_string_static_t_initialize(CONTROLLER_required_s, 0, CONTROLLER_required_s_length); @@ -105,6 +108,7 @@ extern "C" { const f_string_static_t controller_session_new_s = macro_f_string_static_t_initialize(CONTROLLER_session_new_s, 0, CONTROLLER_session_new_s_length); const f_string_static_t controller_session_same_s = macro_f_string_static_t_initialize(CONTROLLER_session_same_s, 0, CONTROLLER_session_same_s_length); const f_string_static_t controller_show_s = macro_f_string_static_t_initialize(CONTROLLER_show_s, 0, CONTROLLER_show_s_length); + const f_string_static_t controller_shutdown_s = macro_f_string_static_t_initialize(CONTROLLER_shutdown_s, 0, CONTROLLER_shutdown_s_length); const f_string_static_t controller_sigpending_s = macro_f_string_static_t_initialize(CONTROLLER_sigpending_s, 0, CONTROLLER_sigpending_s_length); const f_string_static_t controller_stack_s = macro_f_string_static_t_initialize(CONTROLLER_stack_s, 0, CONTROLLER_stack_s_length); const f_string_static_t controller_start_s = macro_f_string_static_t_initialize(CONTROLLER_start_s, 0, CONTROLLER_start_s_length); diff --git a/level_3/controller/c/common/private-common.h b/level_3/controller/c/common/private-common.h index 941f26e..e98889f 100644 --- a/level_3/controller/c/common/private-common.h +++ b/level_3/controller/c/common/private-common.h @@ -47,6 +47,7 @@ extern "C" { #define CONTROLLER_control_group_s "control_group" #define CONTROLLER_control_mode_s "control_mode" #define CONTROLLER_control_user_s "control_user" + #define CONTROLLER_controller_s "controller" #define CONTROLLER_cpu_s "cpu" #define CONTROLLER_core_s "core" #define CONTROLLER_data_s "data" @@ -77,6 +78,7 @@ extern "C" { #define CONTROLLER_iki_s "iki" #define CONTROLLER_item_s "item" #define CONTROLLER_init_s "init" + #define CONTROLLER_kexec_s "kexec" #define CONTROLLER_kill_s "kill" #define CONTROLLER_length_s "length" #define CONTROLLER_limit_s "limit" @@ -108,6 +110,7 @@ extern "C" { #define CONTROLLER_processor_s "processor" #define CONTROLLER_program_s "program" #define CONTROLLER_ready_s "ready" + #define CONTROLLER_reboot_s "reboot" #define CONTROLLER_reload_s "reload" #define CONTROLLER_require_s "require" #define CONTROLLER_required_s "required" @@ -131,6 +134,7 @@ extern "C" { #define CONTROLLER_setting_s "setting" #define CONTROLLER_sigpending_s "sigpending" #define CONTROLLER_show_s "show" + #define CONTROLLER_shutdown_s "shutdown" #define CONTROLLER_stack_s "stack" #define CONTROLLER_start_s "start" #define CONTROLLER_status_s "status" @@ -173,6 +177,7 @@ extern "C" { #define CONTROLLER_control_group_s_length 13 #define CONTROLLER_control_mode_s_length 12 #define CONTROLLER_control_user_s_length 12 + #define CONTROLLER_controller_s_length 10 #define CONTROLLER_core_s_length 4 #define CONTROLLER_cpu_s_length 3 #define CONTROLLER_data_s_length 4 @@ -203,6 +208,7 @@ extern "C" { #define CONTROLLER_iki_s_length 3 #define CONTROLLER_init_s_length 4 #define CONTROLLER_item_s_length 4 + #define CONTROLLER_kexec_s_length 5 #define CONTROLLER_kill_s_length 4 #define CONTROLLER_length_s_length 6 #define CONTROLLER_limit_s_length 5 @@ -234,6 +240,7 @@ extern "C" { #define CONTROLLER_processor_s_length 9 #define CONTROLLER_program_s_length 7 #define CONTROLLER_ready_s_length 5 + #define CONTROLLER_reboot_s_length 6 #define CONTROLLER_reload_s_length 6 #define CONTROLLER_require_s_length 7 #define CONTROLLER_required_s_length 8 @@ -256,6 +263,7 @@ extern "C" { #define CONTROLLER_session_same_s_length 12 #define CONTROLLER_setting_s_length 7 #define CONTROLLER_show_s_length 4 + #define CONTROLLER_shutdown_s_length 8 #define CONTROLLER_sigpending_s_length 10 #define CONTROLLER_stack_s_length 5 #define CONTROLLER_start_s_length 5 @@ -299,6 +307,7 @@ extern "C" { extern const f_string_static_t controller_control_group_s; extern const f_string_static_t controller_control_mode_s; extern const f_string_static_t controller_control_user_s; + extern const f_string_static_t controller_controller_s; extern const f_string_static_t controller_core_s; extern const f_string_static_t controller_cpu_s; extern const f_string_static_t controller_data_s; @@ -329,6 +338,7 @@ extern "C" { extern const f_string_static_t controller_iki_s; extern const f_string_static_t controller_init_s; extern const f_string_static_t controller_item_s; + extern const f_string_static_t controller_kexec_s; extern const f_string_static_t controller_kill_s; extern const f_string_static_t controller_length_s; extern const f_string_static_t controller_limit_s; @@ -360,6 +370,7 @@ extern "C" { extern const f_string_static_t controller_processor_s; extern const f_string_static_t controller_program_s; extern const f_string_static_t controller_ready_s; + extern const f_string_static_t controller_reboot_s; extern const f_string_static_t controller_reload_s; extern const f_string_static_t controller_require_s; extern const f_string_static_t controller_required_s; @@ -382,6 +393,7 @@ extern "C" { extern const f_string_static_t controller_session_same_s; extern const f_string_static_t controller_setting_s; extern const f_string_static_t controller_show_s; + extern const f_string_static_t controller_shutdown_s; extern const f_string_static_t controller_sigpending_s; extern const f_string_static_t controller_stack_s; extern const f_string_static_t controller_start_s; diff --git a/level_3/controller/c/common/private-rule.h b/level_3/controller/c/common/private-rule.h index 8dbbf9e..220c2a7 100644 --- a/level_3/controller/c/common/private-rule.h +++ b/level_3/controller/c/common/private-rule.h @@ -80,22 +80,6 @@ extern "C" { * - extended: Designate that this Action is represented using FSS Extended. * - extended_list: Designate that this Action is represented using FSS Extended List. * - * controller_rule_action_type_*: - * - freeze: The Freeze execution instructions. - * - group: The Group setting. - * - kill: The Kill execution instructions. - * - pause: The Pause execution instructions. - * - pid_file: The PID file setting. - * - rerun: The Re-run execution after success or failure. - * - reload: The Reload execution instructions. - * - restart: The Restart execution instructions. - * - resume: The Resume execution instructions. - * - start: The Start execution instructions. - * - stop: The Stop execution instructions. - * - thaw: The Thaw execution instructions. - * - user: The User setting. - * - with: The With flags. - * * type: The Rule Action type. * line: The line number where the Rule Action begins. * status: The last execution status of the Rule Action. @@ -116,42 +100,6 @@ extern "C" { controller_rule_action_method_extended_list_e, }; - enum { - controller_rule_action_type_freeze_e = 1, - controller_rule_action_type_group_e, - controller_rule_action_type_kill_e, - controller_rule_action_type_pause_e, - controller_rule_action_type_pid_file_e, - controller_rule_action_type_reload_e, - controller_rule_action_type_rerun_e, - controller_rule_action_type_restart_e, - controller_rule_action_type_resume_e, - controller_rule_action_type_start_e, - controller_rule_action_type_stop_e, - controller_rule_action_type_thaw_e, - controller_rule_action_type_user_e, - controller_rule_action_type_with_e, - - // designate the largest value in the enum, the '__' is intended. - controller_rule_action_type__enum_size_e, - }; - - // Execute type starts at 0 because it is intended to be used as an index within a static array. - enum { - controller_rule_action_type_execute_freeze_e = 0, - controller_rule_action_type_execute_kill_e, - controller_rule_action_type_execute_pause_e, - controller_rule_action_type_execute_reload_e, - controller_rule_action_type_execute_restart_e, - controller_rule_action_type_execute_resume_e, - controller_rule_action_type_execute_start_e, - controller_rule_action_type_execute_stop_e, - controller_rule_action_type_execute_thaw_e, - - // designate the largest value in the enum, the '__' is intended. - controller_rule_action_type_execute__enum_size_e, - }; - typedef struct { uint8_t type; f_array_length_t line; @@ -215,7 +163,7 @@ extern "C" { f_array_length_t line; f_string_dynamic_t pid_file; - controller_rule_rerun_t reruns[controller_rule_action_type_execute__enum_size_e]; + controller_rule_rerun_t reruns[controller_rule_action_execute_type__enum_size_e]; controller_rule_actions_t actions; } controller_rule_item_t; diff --git a/level_3/controller/c/control/private-control.c b/level_3/controller/c/control/private-control.c index 80f5bee..e8eff60 100644 --- a/level_3/controller/c/control/private-control.c +++ b/level_3/controller/c/control/private-control.c @@ -299,7 +299,7 @@ extern "C" { status2 = f_conversion_number_unsigned_to_string(F_status_set_fine(status), data_conversion, &control->cache_3); if (F_status_is_error(status2)) return status2; - } + }; status2 = controller_control_respond_build_header(global, control, controller_error_s, control->cache_3, message.used); if (F_status_is_error(status2)) return status2; @@ -311,6 +311,8 @@ extern "C" { if (F_status_is_error(status2)) return status2; } + control->client.size_write = control->output.used; + return f_socket_write(&control->client, 0, control->output.string, 0); } #endif // _di_controller_control_respond_error_ diff --git a/level_3/controller/c/control/private-control.h b/level_3/controller/c/control/private-control.h index 509afd1..f485471 100644 --- a/level_3/controller/c/control/private-control.h +++ b/level_3/controller/c/control/private-control.h @@ -104,40 +104,6 @@ extern "C" { #endif // _di_controller_control_packet_header_length_ /** - * Accept connections from a control socket server. - * - * Connectons are processed and actions are performed. - * - * The response packet (string based) packet format is FSS-000E (Payload). - * This format is stored within packet and has it's own header and payload parts. - * Example pseudo-structure: - * [0][0][4294967296][# fss-000e - * header: - * type message - * length 4294965248 - * payload: - * ... - * ] - * - * @param global - * The global data. - * @param control - * The control data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_socket_accept(). - * Errors (with error bit) from: f_socket_read(). - * - * @see f_socket_accept() - * @see f_socket_read() - */ -#ifndef _di_controller_control_respond_ - extern f_status_t controller_control_respond(const controller_global_t * const global, controller_control_t * const control) F_attribute_visibility_internal_d; -#endif // _di_controller_control_respond_ - -/** * Construct the header portion of the payload. * * This also prepends the FSS identifier comment. diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 77c60d7..7e7dc01 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -24,7 +24,7 @@ extern "C" { } break; - } // while + } // for return result; } @@ -142,7 +142,7 @@ extern "C" { f_status_t status = F_none; - // the file exists, do not attempt to overwrite. + // The file exists, do not attempt to overwrite. if (f_file_exists(path) == F_true) { return F_status_set_error(F_file_found); } @@ -160,7 +160,7 @@ extern "C" { if (F_status_is_error(status)) return status; - // the directory does not exist so do not bother attempting to create a pid file. + // The directory does not exist so do not bother attempting to create a pid file. if (status == F_false) { return F_status_set_error(F_directory_not); } @@ -186,7 +186,7 @@ extern "C" { #ifndef _di_controller_file_pid_delete_ f_status_t controller_file_pid_delete(const pid_t pid, const f_string_static_t path) { - // only delete if the file exists and there is no error while checking. + // Only delete if the file exists and there is no error while checking. if (f_file_exists(path) != F_true) { return F_none; } diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 8cc278f..738bd37 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -177,42 +177,42 @@ extern "C" { uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type) { if (type == controller_rule_action_type_freeze_e) { - return controller_rule_action_type_execute_freeze_e; + return controller_rule_action_execute_type_freeze_e; } if (type == controller_rule_action_type_kill_e) { - return controller_rule_action_type_execute_kill_e; + return controller_rule_action_execute_type_kill_e; } if (type == controller_rule_action_type_pause_e) { - return controller_rule_action_type_execute_pause_e; + return controller_rule_action_execute_type_pause_e; } if (type == controller_rule_action_type_reload_e) { - return controller_rule_action_type_execute_reload_e; + return controller_rule_action_execute_type_reload_e; } if (type == controller_rule_action_type_restart_e) { - return controller_rule_action_type_execute_restart_e; + return controller_rule_action_execute_type_restart_e; } if (type == controller_rule_action_type_resume_e) { - return controller_rule_action_type_execute_resume_e; + return controller_rule_action_execute_type_resume_e; } if (type == controller_rule_action_type_start_e) { - return controller_rule_action_type_execute_start_e; + return controller_rule_action_execute_type_start_e; } if (type == controller_rule_action_type_stop_e) { - return controller_rule_action_type_execute_stop_e; + return controller_rule_action_execute_type_stop_e; } if (type == controller_rule_action_type_thaw_e) { - return controller_rule_action_type_execute_thaw_e; + return controller_rule_action_execute_type_thaw_e; } - return controller_rule_action_type_execute__enum_size_e; + return controller_rule_action_execute_type__enum_size_e; } #endif // _di_controller_rule_action_type_to_action_execute_type_ @@ -409,31 +409,31 @@ extern "C" { if (cache->content_action.used) { if (fl_string_dynamic_partial_compare_string(controller_freeze_s.string, cache->buffer_item, controller_freeze_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_freeze_e; + type_rerun = controller_rule_action_execute_type_freeze_e; } if (fl_string_dynamic_partial_compare_string(controller_kill_s.string, cache->buffer_item, controller_kill_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_kill_e; + type_rerun = controller_rule_action_execute_type_kill_e; } else if (fl_string_dynamic_partial_compare_string(controller_pause_s.string, cache->buffer_item, controller_pause_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_pause_e; + type_rerun = controller_rule_action_execute_type_pause_e; } else if (fl_string_dynamic_partial_compare_string(controller_reload_s.string, cache->buffer_item, controller_reload_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_reload_e; + type_rerun = controller_rule_action_execute_type_reload_e; } else if (fl_string_dynamic_partial_compare_string(controller_restart_s.string, cache->buffer_item, controller_restart_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_restart_e; + type_rerun = controller_rule_action_execute_type_restart_e; } else if (fl_string_dynamic_partial_compare_string(controller_resume_s.string, cache->buffer_item, controller_resume_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_resume_e; + type_rerun = controller_rule_action_execute_type_resume_e; } else if (fl_string_dynamic_partial_compare_string(controller_start_s.string, cache->buffer_item, controller_start_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_start_e; + type_rerun = controller_rule_action_execute_type_start_e; } else if (fl_string_dynamic_partial_compare_string(controller_stop_s.string, cache->buffer_item, controller_stop_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_stop_e; + type_rerun = controller_rule_action_execute_type_stop_e; } else if (fl_string_dynamic_partial_compare_string(controller_thaw_s.string, cache->buffer_item, controller_thaw_s.used, cache->content_action.array[0]) == F_equal_to) { - type_rerun = controller_rule_action_type_execute_thaw_e; + type_rerun = controller_rule_action_execute_type_thaw_e; } } @@ -898,7 +898,7 @@ extern "C" { status = f_string_dynamic_append(item_source->pid_file, &item_destination->pid_file); if (F_status_is_error(status)) return status; - for (j = 0; j < controller_rule_action_type_execute__enum_size_e; ++j) { + for (j = 0; j < controller_rule_action_execute_type__enum_size_e; ++j) { item_destination->reruns[j].is = item_source->reruns[j].is; item_destination->reruns[j].failure.count = item_source->reruns[j].failure.count; @@ -1779,7 +1779,7 @@ extern "C" { fl_print_format("%rRe-running '", main->output.to.stream, f_string_eol_s); fl_print_format("%[%r%]' '", main->output.to.stream, main->context.set.title, process->rule.alias, main->context.set.title); - fl_print_format("%[%r%]' with a ", main->output.to.stream, main->context.set.notable, controller_rule_action_type_execute_name(action), main->context.set.notable); + fl_print_format("%[%r%]' with a ", main->output.to.stream, main->context.set.notable, controller_rule_action_execute_type_name(action), main->context.set.notable); fl_print_format("%[%r%] of ", main->output.to.stream, main->context.set.notable, controller_delay_s, main->context.set.notable); fl_print_format("%[%ul%] MegaTime", main->output.to.stream, main->context.set.notable, rerun_item->delay, main->context.set.notable); @@ -5640,10 +5640,10 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - // script. + // Script. fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_script_s, main->context.set.important, rule.script, f_string_eol_s); - // user. + // User. fl_print_format(" %[%r%]", main->output.to.stream, main->context.set.important, controller_user_s, main->context.set.important); if (rule.has & controller_rule_has_user_d) { @@ -5652,17 +5652,17 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - // wait. + // Wait. fl_print_format(" %[%r%] %r%r", main->output.to.stream, main->context.set.important, controller_wait_s, main->context.set.important, options & controller_process_option_wait_d ? controller_yes_s : controller_no_s, f_string_eol_s); - // affinity. + // Affinity. fl_print_format(" %[%r%] {%r", main->output.to.stream, main->context.set.important, controller_affinity_s, main->context.set.important, f_string_eol_s); for (i = 0; i < rule.affinity.used; ++i) { fl_print_format(" %i%r", main->output.to.stream, rule.affinity.array[i], f_string_eol_s); } // for - // define. + // Define. fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_define_s, main->context.set.important, f_string_eol_s); for (i = 0; i < rule.define.used; ++i) { @@ -5672,7 +5672,7 @@ extern "C" { } } // for - // environment. + // Environment. fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_environment_s, main->context.set.important, f_string_eol_s); for (i = 0; i < rule.environment.used; ++i) { @@ -5684,7 +5684,7 @@ extern "C" { fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_parameter_s, main->context.set.important, f_string_eol_s); - // parameter. + // Parameter. for (i = 0; i < rule.parameter.used; ++i) { if (rule.parameter.array[i].name.used && rule.parameter.array[i].value.used) { @@ -5692,7 +5692,7 @@ extern "C" { } } // for - // group. + // Group. fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_group_s, main->context.set.important, f_string_eol_s); if (rule.has & controller_rule_has_group_d) { @@ -5703,14 +5703,14 @@ extern "C" { } // for } - // limit. + // Limit. fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_limit_s, main->context.set.important, f_string_eol_s); for (i = 0; i < rule.limits.used; ++i) { fl_print_format(" %Q %[=%] %un %un%r", main->output.to.stream, controller_rule_setting_limit_type_name(rule.limits.array[i].type), main->context.set.important, main->context.set.important, rule.limits.array[i].value.rlim_cur, rule.limits.array[i].value.rlim_max, f_string_eol_s); } // for - // on. + // On. fl_print_format(" }%r %[%r%] {%r", main->output.to.stream, f_string_eol_s, main->context.set.important, controller_on_s, main->context.set.important, f_string_eol_s); for (i = 0; i < rule.ons.used; ++i) { @@ -5783,7 +5783,7 @@ extern "C" { fl_print_format(" }%r", main->output.to.stream, f_string_eol_s); - // items. + // Items. if (rule.items.used) { controller_rule_action_t *action = 0; controller_rule_item_t *item = 0; @@ -5799,17 +5799,17 @@ extern "C" { fl_print_format(" %[%r%] {%r", main->output.to.stream, main->context.set.important, controller_item_s, main->context.set.important, f_string_eol_s); - // type. + // Type. fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_type_s, main->context.set.important, controller_rule_item_type_name(item->type), f_string_eol_s); - // pid_file. + // Pid file. fl_print_format(" %[%r%]", main->output.to.stream, main->context.set.important, controller_pid_file_s, main->context.set.important); if (item->pid_file.used) { fl_print_format(" %Q", main->output.to.stream, item->pid_file); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - // with. + // With. fl_print_format(" %[%r%]", main->output.to.stream, main->context.set.important, controller_with_s, main->context.set.important); if (item->with & controller_with_full_path_d) { fl_print_format(" %r", main->output.to.stream, controller_full_path_s); @@ -5822,7 +5822,7 @@ extern "C" { } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - // actions. + // Actions. for (j = 0; j < item->actions.used; ++j) { action = &item->actions.array[j]; @@ -5881,7 +5881,7 @@ extern "C" { // Rerun. fl_print_format(" %[%r%] {%r", main->output.to.stream, main->context.set.important, controller_rerun_s, main->context.set.important, f_string_eol_s); - for (j = 0; j < controller_rule_action_type_execute__enum_size_e; ++j) { + for (j = 0; j < controller_rule_action_execute_type__enum_size_e; ++j) { for (k = 0; k < 2; ++k) { if (!k && (item->reruns[j].is & controller_rule_rerun_is_failure_d)) { @@ -5897,39 +5897,39 @@ extern "C" { fl_print_format(" %[", main->output.to.stream, main->context.set.important); switch (j) { - case controller_rule_action_type_execute_freeze_e: + case controller_rule_action_execute_type_freeze_e: f_print_dynamic_raw(controller_freeze_s, main->output.to.stream); break; - case controller_rule_action_type_execute_kill_e: + case controller_rule_action_execute_type_kill_e: f_print_dynamic_raw(controller_kill_s, main->output.to.stream); break; - case controller_rule_action_type_execute_pause_e: + case controller_rule_action_execute_type_pause_e: f_print_dynamic_raw(controller_pause_s, main->output.to.stream); break; - case controller_rule_action_type_execute_reload_e: + case controller_rule_action_execute_type_reload_e: f_print_dynamic_raw(controller_reload_s, main->output.to.stream); break; - case controller_rule_action_type_execute_restart_e: + case controller_rule_action_execute_type_restart_e: f_print_dynamic_raw(controller_restart_s, main->output.to.stream); break; - case controller_rule_action_type_execute_resume_e: + case controller_rule_action_execute_type_resume_e: f_print_dynamic_raw(controller_resume_s, main->output.to.stream); break; - case controller_rule_action_type_execute_start_e: + case controller_rule_action_execute_type_start_e: f_print_dynamic_raw(controller_start_s, main->output.to.stream); break; - case controller_rule_action_type_execute_stop_e: + case controller_rule_action_execute_type_stop_e: f_print_dynamic_raw(controller_stop_s, main->output.to.stream); break; - case controller_rule_action_type_execute_thaw_e: + case controller_rule_action_execute_type_thaw_e: f_print_dynamic_raw(controller_thaw_s, main->output.to.stream); break; diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index 3579478..9a54bc9 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -113,7 +113,7 @@ extern "C" { * @return * The converted action type, converted into an action execute type. * - * The code controller_rule_action_type_execute__enum_size_e is returned for unknown types. + * The code controller_rule_action_execute_type__enum_size_e is returned for unknown types. */ #ifndef _di_controller_rule_action_type_to_action_execute_type_ extern uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type) F_attribute_visibility_internal_d; diff --git a/level_3/controller/documents/packet.txt b/level_3/controller/documents/packet.txt index 7016fe2..968b7ed 100644 --- a/level_3/controller/documents/packet.txt +++ b/level_3/controller/documents/packet.txt @@ -30,6 +30,7 @@ Packet Documentation: The following types of payload are received or sent\: 1) controller payload. 2) error payload. + 3) init payload. The controller payload\: Commands being sent to the controller and their respective responses utilize a "controller" payload. @@ -37,12 +38,6 @@ Packet Documentation: Commands such as starting or stopping some rule, for example. A controller payload is also sent in response to a controller payload request to represent a success. - When operating in "init" mode, additional commands are available: "reboot" and "shutdown". - The "kexec" is for booting into another kernel, which may effectively be the same as a "reboot" (currently not supported nor implemented). - The "reboot" is for rebooting the machine (currently not implemented). - The "shutdown" is for shutting down the machine (currently not implemented). - These three commands are configurable to fire off based on conditions\: - The "now" condition designates that the kexec, reboot, or shutdown is to begin immediately. The "at" condition designates that the kexec, reboot, or shutdown is to begin once a specific date and time is reached by the system clock. The "in" condition designates that the kexec, reboot, or shutdown is to begin once a specific amount of time is passed by the system clock since the execution of this command started. @@ -67,3 +62,12 @@ Packet Documentation: The control (the client) is not expected to send error payloads and the controller (the service) should send an error in response to an error payload or ignore it entirely. The "status" from the "header" designates the status code as either a status code name string or a status code number (where a number may have error and warning bits). The "payload" will contain a NULL terminated string representing the message used to describe the error. + + The init payload\: + The init payload is intended exclusively for the "init" operation mode and is expected to only be available when running as "init". + This is used to provide special actions, namely "kexec", "reboot", and "shutdown". + + The "kexec" is for booting into another kernel, which may effectively be the same as a "reboot" ("kexec" is currently neither supported nor implemented). + The "reboot" is for rebooting the machine (currently not implemented). + The "shutdown" is for shutting down the machine (currently not implemented). + These three commands are configurable to fire off based on conditions\: diff --git a/level_3/controller/documents/task.txt b/level_3/controller/documents/task.txt index 17561b6..2c7cac6 100644 --- a/level_3/controller/documents/task.txt +++ b/level_3/controller/documents/task.txt @@ -2,6 +2,8 @@ # # license: open-standard-license-1.0 # +# A "Task" is not fully implemented but is provided as a proposal for consideration and is subject to completion or removal. +# Ideally, a task will be used to replace hardcoded "init" mode operations like "kexec", "reboot", and "shutdown". Task Documentation: This describes the intent and purpose of a Task file. diff --git a/level_3/controller/specifications/packet.txt b/level_3/controller/specifications/packet.txt index 2953a34..1ce92c5 100644 --- a/level_3/controller/specifications/packet.txt +++ b/level_3/controller/specifications/packet.txt @@ -12,14 +12,14 @@ Packet Specification: Packet Structure\: Packet is grouped into the following blocks\: - - control: A single 1-byte block representing contol codes. - - size: A single 4-byte block representing the size of the entire packet, including the contol block. + - control: A single 1-byte block representing control codes. + - size: A single 4-byte block representing the size of the entire packet, including the control block. The "header" Object contains the following FSS-0001 Extended Objects (depending on "type")\: - action: A valid action type: "freeze", "kill", "pause", "reboot", "reload", "rerun", "restart", "resume", "shutdown", "start", "stop", or "thaw". - length: A positive whole number inclusively between 0 and 4294965248 representing the length of the "payload" (may be in binary, octal, decimal, duodecimal, or hexidecimal). - status: The status code name or number representing an FSS status code, such as F_none, F_failure, or 200 (where a number may have error and warning bits and may be in binary, octal, decimal, duodecimal, or hexidecimal). - - type: The packet type that is one of "error" and "controller". + - type: The packet type that is one of "controller", "error", or "init". When there are multiple Objects of the same name inside the "header"\: - action: The order represents the order in which the actions are performed. @@ -29,19 +29,27 @@ Packet Specification: There are different headers and payload properties based on the "type". + The "controller" type\: + Supports the following headers: "action", "length", "status", and "type". + + Only a single "action" may be provided and must exist for request and response packets. + Only a single "status" may be provided and must exist for response packets. + + The "payload" is dependent on the "action". + The "error" type\: Supports the following headers: "length", "status", and "type". - Currently only a single "status" is supported. + Only a single "status" may be provided and must exist for request and response packets. The "payload" is a NULL terminated string whose length is defined by the "length" "header" Content. There are different headers and payload properties based on the "type". - The "controller" type\: + The "init" type\: Supports the following headers: "action", "length", "status", and "type". - Multiple "action" may be provided, but at least one must exist. - Multiple "status" may be provided, but at least one must exist. + Only a single "action" may be provided and must exist for request and response packets. + Only a single "status" may be provided and must exist for response packets. The "payload" is dependent on the "action". diff --git a/level_3/controller/specifications/task.txt b/level_3/controller/specifications/task.txt index 74c2483..5c974ae 100644 --- a/level_3/controller/specifications/task.txt +++ b/level_3/controller/specifications/task.txt @@ -2,5 +2,6 @@ # # license: open-standard-license-1.0 # +# A "Task" is not fully implemented but is provided as a proposal for consideration and is subject to completion or removal. Task Specification: