diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc36c3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Build directories +build/ +build_*/ +_codeql_build_dir/ + +# Compilation database +compile_commands.json + +# Object files +*.o +*.obj +*.so +*.a + +# Executables +*.out +cci +cci_cli + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS files +.DS_Store +Thumbs.db diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/src/bus/common/wlan_emu_bus_common.cpp b/src/bus/common/wlan_emu_bus_common.cpp index 6a5a9e1..e1590ad 100644 --- a/src/bus/common/wlan_emu_bus_common.cpp +++ b/src/bus/common/wlan_emu_bus_common.cpp @@ -23,15 +23,18 @@ #include #include -#define COMPARE_INT_RANGE(min_value, max_value, set_value) do { \ - if ((set_value) < (min_value)) { \ - wlan_emu_print(wlan_emu_log_level_err, "Value %d is less than the minimum value (%d)\n", (set_value), (min_value)); \ - return RETURN_ERR; \ - } else if ((set_value) > (max_value)) { \ - wlan_emu_print(wlan_emu_log_level_err, "Value %d is greater than the maximum value (%d)\n", (set_value), (max_value)); \ - return RETURN_ERR; \ - } \ -} while (0) +#define COMPARE_INT_RANGE(min_value, max_value, set_value) \ + do { \ + if ((set_value) < (min_value)) { \ + wlan_emu_print(wlan_emu_log_level_err, \ + "Value %d is less than the minimum value (%d)\n", (set_value), (min_value)); \ + return RETURN_ERR; \ + } else if ((set_value) > (max_value)) { \ + wlan_emu_print(wlan_emu_log_level_err, \ + "Value %d is greater than the maximum value (%d)\n", (set_value), (max_value)); \ + return RETURN_ERR; \ + } \ + } while (0) pthread_mutex_t *get_bus_mux_mutex(void) { @@ -65,7 +68,7 @@ static bool is_string_digit(const char *str) return true; } -static void node_elems_free(elem_node_map_t* node, node_traversal_cb_param_t param) +static void node_elems_free(elem_node_map_t *node, node_traversal_cb_param_t param) { (void)param; VERIFY_NULL(node); @@ -86,24 +89,26 @@ static void node_elems_free(elem_node_map_t* node, node_traversal_cb_param_t par free(node->node_elem_data); node->node_elem_data = NULL; } - wlan_emu_print(wlan_emu_log_level_info, "node delete [%p]:%s:%s\n", node, node->name, node->full_name); + wlan_emu_print(wlan_emu_log_level_info, "node delete [%p]:%s:%s\n", node, node->name, + node->full_name); free(node); } -static void node_elem_recurse_traversal(elem_node_map_t* node, node_elem_traversal_arg_t *input_action) +static void node_elem_recurse_traversal(elem_node_map_t *node, + node_elem_traversal_arg_t *input_action) { VERIFY_NULL(node); - elem_node_map_t* child = node->child; + elem_node_map_t *child = node->child; if (node->reference_childs != reference_child_node) { - while(child != NULL) - { - elem_node_map_t* tmp = child; + while (child != NULL) { + elem_node_map_t *tmp = child; child = child->nextSibling; node_elem_recurse_traversal(tmp, input_action); } } else { - wlan_emu_print(wlan_emu_log_level_info, "mirror link node found [%p]->child:%p\n", node, node->child); + wlan_emu_print(wlan_emu_log_level_info, "mirror link node found [%p]->child:%p\n", node, + node->child); } if (input_action->traversal_cb != NULL) { @@ -111,37 +116,30 @@ static void node_elem_recurse_traversal(elem_node_map_t* node, node_elem_travers } } -static void node_elem_traversal(elem_node_map_t* node, node_elem_traversal_arg_t *input_action) +static void node_elem_traversal(elem_node_map_t *node, node_elem_traversal_arg_t *input_action) { VERIFY_NULL(node); - elem_node_map_t* parent = node->parent; - elem_node_map_t* child = node->child; + elem_node_map_t *parent = node->parent; + elem_node_map_t *child = node->child; if (node->reference_childs != reference_child_node) { - while(child) - { - elem_node_map_t* tmp = child; + while (child) { + elem_node_map_t *tmp = child; child = child->nextSibling; node_elem_recurse_traversal(tmp, input_action); } } else { - wlan_emu_print(wlan_emu_log_level_info, "%s:%d mirror link node found [%p]->child:%p\n", __func__, - __LINE__, node, node->child); + wlan_emu_print(wlan_emu_log_level_info, "%s:%d mirror link node found [%p]->child:%p\n", + __func__, __LINE__, node, node->child); } - if (parent != NULL) - { - if(parent->child == node) - { + if (parent != NULL) { + if (parent->child == node) { parent->child = node->nextSibling; - } - else - { + } else { child = parent->child; - while(child != NULL) - { - if(child->nextSibling == node) - { + while (child != NULL) { + if (child->nextSibling == node) { child->nextSibling = node->nextSibling; break; } @@ -157,7 +155,7 @@ static void node_elem_traversal(elem_node_map_t* node, node_elem_traversal_arg_t static bus_error_t free_node_elems(elem_node_map_t *node) { - node_elem_traversal_arg_t input_arg; + node_elem_traversal_arg_t input_arg; input_arg.traversal_cb = node_elems_free; BUS_MUX_LOCK(get_bus_mux_mutex()); @@ -168,20 +166,19 @@ static bus_error_t free_node_elems(elem_node_map_t *node) return bus_error_success; } -static char const* get_type_string(bus_element_type_t type) +static char const *get_type_string(bus_element_type_t type) { - switch(type) - { - case bus_element_type_property: - return "property"; - case bus_element_type_table: - return "table"; - case bus_element_type_event: - return "event"; - case bus_element_type_method: - return "method"; - default: - return "object"; + switch (type) { + case bus_element_type_property: + return "property"; + case bus_element_type_table: + return "table"; + case bus_element_type_event: + return "event"; + case bus_element_type_method: + return "method"; + default: + return "object"; } } @@ -209,37 +206,36 @@ static void print_elem(elem_node_map_t *node, int level) void print_registered_elems(elem_node_map_t *root, int level) { - elem_node_map_t *child = root; + elem_node_map_t *child = root; elem_node_map_t *sibling = NULL; - if(child != NULL) { + if (child != NULL) { print_elem(child, level); - if(child->child) { - print_registered_elems(child->child, level+1); + if (child->child) { + print_registered_elems(child->child, level + 1); } sibling = child->nextSibling; - while(sibling) { + while (sibling) { print_elem(sibling, level); - if(sibling->child) { - print_registered_elems(sibling->child, level+1); + if (sibling->child) { + print_registered_elems(sibling->child, level + 1); } sibling = sibling->nextSibling; } } } -elem_node_map_t* retrieve_instance_elem_node(elem_node_map_t* root, const char* elmentName) +elem_node_map_t *retrieve_instance_elem_node(elem_node_map_t *root, const char *elmentName) { - char* token = NULL; - char* saveptr = NULL; + char *token = NULL; + char *saveptr = NULL; bus_name_string_t name; - elem_node_map_t* current_node = root; - elem_node_map_t* next_node = NULL; - int token_found = 0; - bool is_wild_card = false; + elem_node_map_t *current_node = root; + elem_node_map_t *next_node = NULL; + int token_found = 0; + bool is_wild_card = false; - if(current_node == NULL || elmentName == NULL) - { + if (current_node == NULL || elmentName == NULL) { return NULL; } @@ -249,32 +245,25 @@ elem_node_map_t* retrieve_instance_elem_node(elem_node_map_t* root, const char* next_node = current_node->child; token = strtok_r(name, ".", &saveptr); - while( token != NULL) - { + while (token != NULL) { token_found = 0; - if(next_node == NULL) - { + if (next_node == NULL) { break; } - if(strcmp(next_node->name, token) == 0) - { + if (strcmp(next_node->name, token) == 0) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d token_found!\n", __func__, __LINE__); token_found = 1; current_node = next_node; next_node = current_node->child; - } - else - { + } else { current_node = next_node; next_node = current_node->nextSibling; - while(next_node != NULL) - { - if(strcmp(next_node->name, token) == 0) - { - wlan_emu_print(wlan_emu_log_level_info,"token_found!\n"); + while (next_node != NULL) { + if (strcmp(next_node->name, token) == 0) { + wlan_emu_print(wlan_emu_log_level_info, "token_found!\n"); token_found = 1; current_node = next_node; next_node = current_node->child; @@ -288,15 +277,13 @@ elem_node_map_t* retrieve_instance_elem_node(elem_node_map_t* root, const char* token = strtok_r(NULL, ".", &saveptr); - if(token && next_node && next_node->parent && next_node->parent->type == bus_element_type_table) - { - if(!is_wild_card && !strcmp(token,"*")) - { + if (token && next_node && next_node->parent && + next_node->parent->type == bus_element_type_table) { + if (!is_wild_card && !strcmp(token, "*")) { is_wild_card = true; } - if(is_wild_card) - { + if (is_wild_card) { token = "{i}"; } } @@ -304,48 +291,45 @@ elem_node_map_t* retrieve_instance_elem_node(elem_node_map_t* root, const char* BUS_MUX_UNLOCK(get_bus_mux_mutex()); - if(token_found) - { + if (token_found) { return current_node; - } - else - { + } else { return NULL; } } -static elem_node_map_t* link_tables_with_node(elem_node_map_t* parent_node) +static elem_node_map_t *link_tables_with_node(elem_node_map_t *parent_node) { VERIFY_NULL_WITH_RETURN_ADDR(parent_node); - elem_node_map_t* child_node_reference = parent_node->child; - elem_node_map_t* next_node = parent_node->nextSibling; - while(next_node) { + elem_node_map_t *child_node_reference = parent_node->child; + elem_node_map_t *next_node = parent_node->nextSibling; + while (next_node) { if (next_node->child == NULL && is_string_digit(next_node->name)) { next_node->child = child_node_reference; next_node->reference_childs = reference_child_node; - wlan_emu_print(wlan_emu_log_level_info, "%s:%d Added duplicate node ref for=%s\n", __func__, - __LINE__, next_node->full_name); + wlan_emu_print(wlan_emu_log_level_info, "%s:%d Added duplicate node ref for=%s\n", + __func__, __LINE__, next_node->full_name); } next_node = next_node->nextSibling; } return child_node_reference; } -static bool is_grandparent_node_elem_is_table(elem_node_map_t* cur_parent) +static bool is_grandparent_node_elem_is_table(elem_node_map_t *cur_parent) { - elem_node_map_t* grandparent_node = ((cur_parent != NULL) ? cur_parent->parent : NULL); + elem_node_map_t *grandparent_node = ((cur_parent != NULL) ? cur_parent->parent : NULL); if (grandparent_node && grandparent_node->type == bus_element_type_table) { return true; } return false; } -static elem_node_map_t* get_empty_elem_node(void) +static elem_node_map_t *get_empty_elem_node(void) { - elem_node_map_t* node; + elem_node_map_t *node; - node = (elem_node_map_t *) calloc(1, sizeof(elem_node_map_t)); + node = (elem_node_map_t *)calloc(1, sizeof(elem_node_map_t)); BUS_CHECK_NULL_WITH_RC(node, NULL); node->reference_childs = original_child_node; @@ -354,11 +338,12 @@ static elem_node_map_t* get_empty_elem_node(void) elem_node_map_t *get_bus_node_info(elem_node_map_t *cb_root, char *name) { - bus_name_string_t recv_name = { 0 }; - elem_node_map_t *node_elem; + bus_name_string_t recv_name = { 0 }; + elem_node_map_t *node_elem; if (cb_root == NULL || name == NULL) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: user cb root map not found\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: user cb root map not found\n", __func__, + __LINE__); return NULL; } @@ -376,14 +361,13 @@ elem_node_map_t *get_bus_node_info(elem_node_map_t *cb_root, char *name) bus_error_t bus_remove_all_elems(elem_node_map_t *root) { - node_elem_traversal_arg_t input_arg; + node_elem_traversal_arg_t input_arg; input_arg.traversal_cb = node_elems_free; BUS_MUX_LOCK(get_bus_mux_mutex()); - while(root) - { - elem_node_map_t* tmp = root; + while (root) { + elem_node_map_t *tmp = root; root = root->nextSibling; node_elem_traversal(tmp, &input_arg); } @@ -412,41 +396,39 @@ void deinit_bus_all_mux_param(void) static elem_node_map_t *insert_table_row(elem_node_map_t *table_root, char *node_name) { - elem_node_map_t* current_node = table_root; - elem_node_map_t* temp_node = NULL; - elem_node_map_t* next_node = NULL; - char buff[256]; - bus_error_t status = bus_error_destination_not_found; + elem_node_map_t *current_node = table_root; + elem_node_map_t *temp_node = NULL; + elem_node_map_t *next_node = NULL; + char buff[256]; + bus_error_t status = bus_error_destination_not_found; VERIFY_NULL_WITH_RETURN_ADDR(table_root); VERIFY_NULL_WITH_RETURN_ADDR(node_name); next_node = current_node->child; - while(next_node != NULL) - { + while (next_node != NULL) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d child name=[%s], Token = [%s]\n", __func__, __LINE__, next_node->name, node_name); - if(strcmp(next_node->name, node_name) == 0) - { + if (strcmp(next_node->name, node_name) == 0) { current_node = next_node; - wlan_emu_print(wlan_emu_log_level_dbg,"%s:%d child name=[%s], Token = [%s] already present\n",__func__, __LINE__, next_node->name, node_name); + wlan_emu_print(wlan_emu_log_level_dbg, + "%s:%d child name=[%s], Token = [%s] already present\n", __func__, __LINE__, + next_node->name, node_name); status = bus_error_success; break; - } - else - { + } else { current_node = next_node; next_node = current_node->nextSibling; - if(next_node == NULL) - { + if (next_node == NULL) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d Create Sibling [%s]\n", __func__, __LINE__, node_name); temp_node = get_empty_elem_node(); VERIFY_NULL_WITH_RETURN_ADDR(temp_node); temp_node->parent = current_node->parent; - if(strlen(current_node->parent->full_name) != 0) { - snprintf(buff, sizeof(buff), "%s.%s", current_node->parent->full_name, node_name); + if (strlen(current_node->parent->full_name) != 0) { + snprintf(buff, sizeof(buff), "%s.%s", current_node->parent->full_name, + node_name); } else { snprintf(buff, sizeof(buff), "%s", node_name); } @@ -470,8 +452,8 @@ static elem_node_map_t *insert_table_row(elem_node_map_t *table_root, char *node static bus_error_t bus_add_table_row(elem_node_map_t *table_root, unsigned int num_of_table_row) { - char str_node_index_name[8]; - uint32_t index = 0; + char str_node_index_name[8]; + uint32_t index = 0; for (unsigned int i = 1; i <= num_of_table_row; i++) { index = i; @@ -481,15 +463,15 @@ static bus_error_t bus_add_table_row(elem_node_map_t *table_root, unsigned int n return bus_error_success; } -elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t* elem) +elem_node_map_t *bus_insert_elem_node(elem_node_map_t *root, bus_mux_data_elem_t *elem) { - char* token = NULL; - char* saveptr = NULL; + char *token = NULL; + char *saveptr = NULL; bus_name_string_t name; - elem_node_map_t* current_node = root; - elem_node_map_t* temp_node = NULL; - elem_node_map_t* next_node = NULL; - int ret = 0, create_child = 0; + elem_node_map_t *current_node = root; + elem_node_map_t *temp_node = NULL; + elem_node_map_t *next_node = NULL; + int ret = 0, create_child = 0; char buff[256]; if (current_node == NULL || elem == NULL) { @@ -503,39 +485,28 @@ elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t strncpy(name, elem->full_name, sizeof(name) - 1); - if(elem->type == bus_element_type_table) - { + if (elem->type == bus_element_type_table) { size_t len = strlen(name); - if(len > 4) - { - if(strcmp(name + len - 5, ".{i}.") == 0) - { - name[len-5] = 0; - } - else if(strcmp(name + len - 4, ".{i}") == 0) - { - name[len-4] = 0; + if (len > 4) { + if (strcmp(name + len - 5, ".{i}.") == 0) { + name[len - 5] = 0; + } else if (strcmp(name + len - 4, ".{i}") == 0) { + name[len - 4] = 0; } } } token = strtok_r(name, ".", &saveptr); - while( token != NULL ) - { - if(next_node == NULL) - { - if(create_child) - { + while (token != NULL) { + if (next_node == NULL) { + if (create_child) { temp_node = get_empty_elem_node(); BUS_CHECK_NULL_WITH_RC(temp_node, NULL); temp_node->parent = current_node; - if(current_node == root) - { + if (current_node == root) { strncpy(temp_node->full_name, token, sizeof(temp_node->full_name) - 1); - } - else - { + } else { snprintf(buff, sizeof(buff), "%s.%s", current_node->full_name, token); strncpy(temp_node->full_name, buff, sizeof(temp_node->full_name) - 1); } @@ -550,8 +521,7 @@ elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t } } } - while(next_node != NULL) - { + while (next_node != NULL) { if (strcmp(next_node->name, token) == 0) { current_node = next_node; next_node = current_node->child; @@ -561,13 +531,13 @@ elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t current_node = next_node; next_node = current_node->nextSibling; create_child = 0; - if(next_node == NULL) - { + if (next_node == NULL) { temp_node = get_empty_elem_node(); BUS_CHECK_NULL_WITH_RC(temp_node, NULL); temp_node->parent = current_node->parent; - if(strlen(current_node->parent->full_name) != 0) { - snprintf(buff, sizeof(buff), "%s.%s", current_node->parent->full_name, token); + if (strlen(current_node->parent->full_name) != 0) { + snprintf(buff, sizeof(buff), "%s.%s", current_node->parent->full_name, + token); } else { snprintf(buff, sizeof(buff), "%s", token); } @@ -583,18 +553,16 @@ elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t } token = strtok_r(NULL, ".", &saveptr); } - if(ret == 0) - { - current_node->type = elem->type; + if (ret == 0) { + current_node->type = elem->type; current_node->node_data_type = elem->node_data_type; current_node->node_elem_data = malloc(elem->cfg_data_len); BUS_CHECK_NULL_WITH_RC(current_node->node_elem_data, NULL); memcpy(current_node->node_elem_data, elem->cfg_data, elem->cfg_data_len); current_node->node_elem_data_len = elem->cfg_data_len; - if(elem->type == bus_element_type_table) - { - elem_node_map_t* rowTemplate = get_empty_elem_node(); + if (elem->type == bus_element_type_table) { + elem_node_map_t *rowTemplate = get_empty_elem_node(); BUS_CHECK_NULL_WITH_RC(rowTemplate, NULL); rowTemplate->parent = current_node; strncpy(rowTemplate->name, "{i}", sizeof(rowTemplate->name) - 1); @@ -602,29 +570,29 @@ elem_node_map_t* bus_insert_elem_node(elem_node_map_t* root, bus_mux_data_elem_t strncpy(rowTemplate->full_name, buff, sizeof(rowTemplate->full_name) - 1); current_node->child = rowTemplate; - //bus_add_table_row(current_node, elem->num_of_table_row); + // bus_add_table_row(current_node, elem->num_of_table_row); } } BUS_MUX_UNLOCK(get_bus_mux_mutex()); - if(ret == 0) - { + if (ret == 0) { return current_node; - } - else - { + } else { return NULL; } } -static int check_dm_min_max_data_range(long int min_data, long int max_data, raw_data_t *bus_set_data) +static int check_dm_min_max_data_range(long int min_data, long int max_data, + raw_data_t *bus_set_data) { if (min_data == 0 && max_data == 0) { - wlan_emu_print(wlan_emu_log_level_err,"%s:%d: int range validation is not needed\n",__func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: int range validation is not needed\n", + __func__, __LINE__); return RETURN_OK; } - wlan_emu_print(wlan_emu_log_level_dbg,"%s:%d: set data type:%d\n",__func__, __LINE__, bus_set_data->data_type); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: set data type:%d\n", __func__, __LINE__, + bus_set_data->data_type); if (bus_set_data->data_type == bus_data_type_boolean) { COMPARE_INT_RANGE((bool)min_data, (bool)max_data, bus_set_data->raw_data.b); } else if (bus_set_data->data_type == bus_data_type_int8) { @@ -644,13 +612,13 @@ static int check_dm_min_max_data_range(long int min_data, long int max_data, raw return RETURN_OK; } -static void duplicate_node_ref(elem_node_map_t* child_table_node, elem_node_map_t* parent_node) +static void duplicate_node_ref(elem_node_map_t *child_table_node, elem_node_map_t *parent_node) { VERIFY_NULL(child_table_node); VERIFY_NULL(parent_node); elem_node_map_t *child_node = parent_node->child; - while(child_node) { - if(strcmp(child_node->name, "{i}") == 0) { + while (child_node) { + if (strcmp(child_node->name, "{i}") == 0) { break; } child_node = child_node->nextSibling; @@ -661,16 +629,18 @@ static void duplicate_node_ref(elem_node_map_t* child_table_node, elem_node_map_ child_table_node->node_data_type = parent_node->node_data_type; child_table_node->node_elem_data = malloc(parent_node->node_elem_data_len); VERIFY_NULL(child_table_node->node_elem_data); - memcpy(child_table_node->node_elem_data, parent_node->node_elem_data, parent_node->node_elem_data_len); + memcpy(child_table_node->node_elem_data, parent_node->node_elem_data, + parent_node->node_elem_data_len); child_table_node->node_elem_data_len = parent_node->node_elem_data_len; - wlan_emu_print(wlan_emu_log_level_dbg,"%s:%d Added node new data info for %s--data len:%d\n", __func__, - __LINE__, child_table_node->full_name, parent_node->node_elem_data_len); + wlan_emu_print(wlan_emu_log_level_dbg, + "%s:%d Added node new data info for %s--data len:%d\n", __func__, __LINE__, + child_table_node->full_name, parent_node->node_elem_data_len); } if (child_table_node->child == NULL) { child_table_node->child = child_node->child; child_table_node->reference_childs = reference_child_node; - wlan_emu_print(wlan_emu_log_level_dbg,"%s:%d Added duplicate node ref for %s\n", __func__, + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d Added duplicate node ref for %s\n", __func__, __LINE__, child_table_node->full_name); } } @@ -684,10 +654,11 @@ bus_error_t bus_table_remove_row(elem_node_map_t *p_root_node, char *p_name_spac return bus_error_destination_not_found; } -bus_error_t bus_table_add_row(elem_node_map_t *p_root_node, char *p_name_space, uint32_t table_index) +bus_error_t bus_table_add_row(elem_node_map_t *p_root_node, char *p_name_space, + uint32_t table_index) { elem_node_map_t *retrieve_table_elem; - char str_table_name[8]; + char str_table_name[8]; retrieve_table_elem = get_bus_node_info(p_root_node, p_name_space); if (retrieve_table_elem != NULL) { @@ -696,15 +667,15 @@ bus_error_t bus_table_add_row(elem_node_map_t *p_root_node, char *p_name_space, snprintf(str_table_name, sizeof(str_table_name), "%d", table_index); table_node_elem = insert_table_row(retrieve_table_elem, str_table_name); if (table_node_elem == NULL) { - wlan_emu_print(wlan_emu_log_level_err,"%s:%d table node is not found:%s.%d\n", __func__, - __LINE__, p_name_space, table_index); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d table node is not found:%s.%d\n", + __func__, __LINE__, p_name_space, table_index); return bus_error_general; } - wlan_emu_print(wlan_emu_log_level_dbg,"%s:%d Added table node:%s.%d\n", __func__, - __LINE__, p_name_space, table_index); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d Added table node:%s.%d\n", __func__, __LINE__, + p_name_space, table_index); duplicate_node_ref(table_node_elem, retrieve_table_elem); } else { - wlan_emu_print(wlan_emu_log_level_err,"%s:%d table node is not found:%s.%d\n", __func__, + wlan_emu_print(wlan_emu_log_level_err, "%s:%d table node is not found:%s.%d\n", __func__, __LINE__, p_name_space, table_index); return bus_error_general; } @@ -715,9 +686,11 @@ bus_error_t bus_table_add_row(elem_node_map_t *p_root_node, char *p_name_space, static int validate_dm_string_param(uint32_t num_of_str, char **str, char *set_str) { if (num_of_str == 0) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: string validation is not set\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: string validation is not set\n", __func__, + __LINE__); } else if (str == NULL || set_str == NULL) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: input string is NULL:%p:%p\n", __func__, __LINE__, str, set_str); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: input string is NULL:%p:%p\n", __func__, + __LINE__, str, set_str); } else { uint32_t index; bool str_found = false; @@ -729,8 +702,8 @@ static int validate_dm_string_param(uint32_t num_of_str, char **str, char *set_s } } if (str_found == false) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: string:%s validation is failed:%d\n", __func__, - __LINE__, set_str, num_of_str); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: string:%s validation is failed:%d\n", + __func__, __LINE__, set_str, num_of_str); return RETURN_ERR; } } @@ -745,17 +718,20 @@ int validate_dm_set_parameters(data_model_properties_t *data_model_prop, raw_dat BUS_CHECK_NULL_WITH_RC(data_model_prop, ret); if (data_model_prop->data_permission == false) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: data is not permitted to set\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: data is not permitted to set\n", __func__, + __LINE__); return ret; } - ret = check_dm_min_max_data_range(data_model_prop->min_data_range, data_model_prop->max_data_range, bus_set_data); + ret = check_dm_min_max_data_range(data_model_prop->min_data_range, + data_model_prop->max_data_range, bus_set_data); if (ret != RETURN_OK) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: set data min/max data range is not proper\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: set data min/max data range is not proper\n", + __func__, __LINE__); return ret; } else if (bus_set_data->data_type == bus_data_type_string) { - ret = validate_dm_string_param(data_model_prop->num_of_str_validation, data_model_prop->str_validation, - (char *)bus_set_data->raw_data.bytes); + ret = validate_dm_string_param(data_model_prop->num_of_str_validation, + data_model_prop->str_validation, (char *)bus_set_data->raw_data.bytes); } return ret; diff --git a/src/bus/linux/wlan_emu_bus.cpp b/src/bus/linux/wlan_emu_bus.cpp index 15a8f88..c163e10 100644 --- a/src/bus/linux/wlan_emu_bus.cpp +++ b/src/bus/linux/wlan_emu_bus.cpp @@ -104,13 +104,12 @@ static bus_error_t bus_get_trace_context(bus_handle_t *handle, char *traceParent return bus_error_success; } -static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, - uint32_t row_index, char const *alias) +static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, uint32_t row_index, + char const *alias) { return bus_error_success; } - static bus_error_t bus_unreg_table_row(bus_handle_t *handle, char const *name) { return bus_error_success; diff --git a/src/bus/openwrt/wlan_emu_bus.cpp b/src/bus/openwrt/wlan_emu_bus.cpp index 15a8f88..c163e10 100644 --- a/src/bus/openwrt/wlan_emu_bus.cpp +++ b/src/bus/openwrt/wlan_emu_bus.cpp @@ -104,13 +104,12 @@ static bus_error_t bus_get_trace_context(bus_handle_t *handle, char *traceParent return bus_error_success; } -static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, - uint32_t row_index, char const *alias) +static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, uint32_t row_index, + char const *alias) { return bus_error_success; } - static bus_error_t bus_unreg_table_row(bus_handle_t *handle, char const *name) { return bus_error_success; diff --git a/src/bus/rdkb/wlan_emu_bus.cpp b/src/bus/rdkb/wlan_emu_bus.cpp index 18452c9..21810bb 100644 --- a/src/bus/rdkb/wlan_emu_bus.cpp +++ b/src/bus/rdkb/wlan_emu_bus.cpp @@ -24,7 +24,7 @@ #include #include -static wlan_emu_bus_t *g_bus_obj = NULL; //rework needed on this +static wlan_emu_bus_t *g_bus_obj = NULL; // rework needed on this static void add_bus_mgr(wlan_emu_bus_t *bus_mgr) { @@ -235,7 +235,8 @@ static rbusElementType_t convert_bus_to_rbus_elem_type(bus_element_type_t bus_el return rbus_elem_type; } -static bus_error_t get_rbus_property_data(char *event_name, rbusProperty_t property, raw_data_t *bus_data) +static bus_error_t get_rbus_property_data(char *event_name, rbusProperty_t property, + raw_data_t *bus_data) { bus_error_t ret = bus_error_success; rbusValue_t value = rbusProperty_GetValue(property); @@ -432,7 +433,8 @@ static bool remove_substring(char *str, const char *sub) return false; } -static bus_error_t set_rbus_property_data(char *event_name, rbusProperty_t property, raw_data_t *bus_data) +static bus_error_t set_rbus_property_data(char *event_name, rbusProperty_t property, + raw_data_t *bus_data) { bus_error_t ret = bus_error_success; rbusValue_t value; @@ -954,7 +956,8 @@ static bus_error_t bus_set(bus_handle_t *handle, char const *name, raw_data_t *d return convert_rbus_to_bus_error_code(rc); } -static bus_event_sub_action_t convert_rbus_to_bus_sub_action_type(rbusEventSubAction_t rbus_sub_action) +static bus_event_sub_action_t convert_rbus_to_bus_sub_action_type( + rbusEventSubAction_t rbus_sub_action) { bus_event_sub_action_t bus_sub_action; @@ -1046,8 +1049,8 @@ static rbusError_t rbus_table_remove_row_handler(rbusHandle_t handle, char const return convert_bus_to_rbus_error_code(ret); } -static rbusError_t rbus_method_handler(rbusHandle_t handle, char const *methodName, rbusObject_t inParams, - rbusObject_t outParams, rbusMethodAsyncHandle_t asyncHandle) +static rbusError_t rbus_method_handler(rbusHandle_t handle, char const *methodName, + rbusObject_t inParams, rbusObject_t outParams, rbusMethodAsyncHandle_t asyncHandle) { raw_data_t bus_input_data, bus_output_data; bus_error_t ret = bus_error_success; @@ -1210,7 +1213,7 @@ static bus_error_t bus_reg_data_elements(bus_handle_t *handle, bus_data_element_ strncpy(name, data_element[index].full_name, sizeof(name) - 1); if ((data_element[index].num_of_table_row) && (remove_substring(name, sub) == 1)) { for (table_index = 1; table_index <= data_element[index].num_of_table_row; - table_index++) { + table_index++) { rc = rbusTable_addRow(p_rbus_handle, name, NULL, NULL); if (rc != RBUS_ERROR_SUCCESS) { wlan_emu_print(wlan_emu_log_level_err, @@ -1351,8 +1354,8 @@ static bus_error_t bus_event_publish(bus_handle_t *handle, char const *name, raw return convert_rbus_to_bus_error_code(rc); } -static bus_error_t bus_event_subscribe_ex_async(bus_handle_t *handle, bus_event_sub_t *l_sub_info_map, - int num_sub, void *l_sub_handler, int timeout) +static bus_error_t bus_event_subscribe_ex_async(bus_handle_t *handle, + bus_event_sub_t *l_sub_info_map, int num_sub, void *l_sub_handler, int timeout) { rbusError_t ret = RBUS_ERROR_SUCCESS; rbusHandle_t p_rbus_handle = handle->u.rbus_handle; diff --git a/src/common/wlan_common_utils.cpp b/src/common/wlan_common_utils.cpp index 1b55967..55b7a7f 100644 --- a/src/common/wlan_common_utils.cpp +++ b/src/common/wlan_common_utils.cpp @@ -207,7 +207,6 @@ int wlan_common_utils::encode_pcap_frame_type(cJSON *fc_arr, } cJSON_AddItemToArray(fc_arr, frame_obj); cJSON_AddStringToObject(frame_obj, "FrameType", "Disassociation"); - } if (frame_capture_req.frm80211_ops & (1 << wlan_emu_frm80211_ops_type_eapol)) { frame_obj = cJSON_CreateObject(); @@ -225,8 +224,7 @@ int wlan_common_utils::encode_pcap_frame_type(cJSON *fc_arr, cJSON_AddItemToArray(fc_arr, frame_obj); cJSON_AddStringToObject(frame_obj, "FrameType", "ReassociationRequest"); } - if (frame_capture_req.frm80211_ops & - (1 << wlan_emu_frm80211_ops_type_reassoc_resp)) { + if (frame_capture_req.frm80211_ops & (1 << wlan_emu_frm80211_ops_type_reassoc_resp)) { frame_obj = cJSON_CreateObject(); if (frame_obj == NULL) { return RETURN_ERR; diff --git a/src/common/wlan_emu_ext_agent_interface.cpp b/src/common/wlan_emu_ext_agent_interface.cpp index c7ac7de..a757728 100644 --- a/src/common/wlan_emu_ext_agent_interface.cpp +++ b/src/common/wlan_emu_ext_agent_interface.cpp @@ -297,9 +297,9 @@ int wlan_emu_ext_agent_interface_t::decode_external_agent_capability(const std:: // Debug print for decoded Ethernet interface data char eth_mac_str[32] = { 0 }; uint8_mac_to_string_mac(eth_dev->interface_mac, eth_mac_str); - wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: Decoded ETH: MAC=%s, Name=%s, IP=%s\n", __func__, __LINE__, eth_mac_str, - eth_dev->interface_name.c_str(), eth_dev->ip_address.c_str()); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Decoded ETH: MAC=%s, Name=%s, IP=%s\n", + __func__, __LINE__, eth_mac_str, eth_dev->interface_name.c_str(), + eth_dev->ip_address.c_str()); queue_push(agent_details->eth_client_interfaces, eth_dev); @@ -482,6 +482,7 @@ static int get_external_agent_details(uint instance_number, bus_handle_t *handle static bool check_hostname(const std::string &ip) { struct sockaddr_in sa {}; + char agent_host_name[] = "ots_ext_agent"; sa.sin_family = AF_INET; inet_pton(AF_INET, ip.c_str(), &sa.sin_addr); @@ -608,7 +609,8 @@ int wlan_emu_ext_agent_interface_t::get_external_agent_capabilities(hash_map_t * snprintf(capability_url, sizeof(capability_url), "%s:%d/%s", agent_details->agent_ip_address, 1234, "Capability"); - if (http_get(capability_url, response, status_code, m_ui_mgr->cci_error_code) != RETURN_OK) { + if (http_get(capability_url, response, status_code, m_ui_mgr->cci_error_code) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: http_get failed for %s\n", __func__, __LINE__, capability_url); agent_details = (wlan_emu_ext_agent_interface_t *)hash_map_get_next(ext_agent_map, diff --git a/src/external_agent_cci/wlan_ext_emu_sta_mgr.cpp b/src/external_agent_cci/wlan_ext_emu_sta_mgr.cpp index 18b24f9..c16e1f8 100644 --- a/src/external_agent_cci/wlan_ext_emu_sta_mgr.cpp +++ b/src/external_agent_cci/wlan_ext_emu_sta_mgr.cpp @@ -354,8 +354,8 @@ int wlan_ext_emu_sta_mgr_t::init(wifi_hal_capability_t *sta_hal_cap) } wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: num_vaps : %d, vap_name : %s interface_name : %s\n", __func__, - __LINE__, vap_info_map->num_vaps, sta_info->vap_name, sta_info->interface_name); + "%s:%d: num_vaps : %d, vap_name : %s interface_name : %s\n", __func__, __LINE__, + vap_info_map->num_vaps, sta_info->vap_name, sta_info->interface_name); for (unsigned int itr = 0; itr < vap_info_map->num_vaps; itr++) { if (vap_info_map->vap_array[itr].vap_index == sta_info->index) { diff --git a/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_client.cpp b/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_client.cpp index bc973e1..afcd237 100644 --- a/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_client.cpp +++ b/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_client.cpp @@ -56,10 +56,11 @@ int wlan_ext_test_step_param_iperf_client::wlan_ext_step_execute() __func__, __LINE__, step->step_number, iperf_client_cmd.c_str()); if (step->u.iperf_client->interface_type == interface_type_ethernet) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: In ethernet namespace\n", __func__, __LINE__); - //list_interfaces_in_namespace(); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: In ethernet namespace\n", __func__, + __LINE__); + // list_interfaces_in_namespace(); ext_emu->enter_namespace("/var/run/netns/ots"); - //list_interfaces_in_namespace(); + // list_interfaces_in_namespace(); } int result = execute_process_once(iperf_client_cmd, @@ -72,7 +73,7 @@ int wlan_ext_test_step_param_iperf_client::wlan_ext_step_execute() } if (step->u.iperf_client->interface_type == interface_type_ethernet) { ext_emu->leave_namespace(); - //list_interfaces_in_namespace(); + // list_interfaces_in_namespace(); } cJSON_AddItemToArray(step->artifact_json_list, cJSON_CreateString(step->u.iperf_client->u.start_conf.result_file)); diff --git a/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_server.cpp b/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_server.cpp index 6bb1e0f..dd4d99c 100644 --- a/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_server.cpp +++ b/src/external_agent_cci/wlan_ext_emu_test_step_param_iperf_server.cpp @@ -56,10 +56,11 @@ int wlan_ext_test_step_param_iperf_server::wlan_ext_step_execute() __func__, __LINE__, step->step_number, iperf_server_cmd.c_str()); if (step->u.iperf_server->interface_type == interface_type_ethernet) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: In ethernet namespace\n", __func__, __LINE__); - //list_interfaces_in_namespace(); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: In ethernet namespace\n", __func__, + __LINE__); + // list_interfaces_in_namespace(); ext_emu->enter_namespace("/var/run/netns/ots"); - //list_interfaces_in_namespace(); + // list_interfaces_in_namespace(); } int result = execute_process_once(iperf_server_cmd, @@ -73,7 +74,7 @@ int wlan_ext_test_step_param_iperf_server::wlan_ext_step_execute() if (step->u.iperf_server->interface_type == interface_type_ethernet) { ext_emu->leave_namespace(); - //list_interfaces_in_namespace(); + // list_interfaces_in_namespace(); } cJSON_AddItemToArray(step->artifact_json_list, diff --git a/src/external_agent_cci/wlan_ext_emu_test_step_params.cpp b/src/external_agent_cci/wlan_ext_emu_test_step_params.cpp index 8c86fc9..985e49c 100644 --- a/src/external_agent_cci/wlan_ext_emu_test_step_params.cpp +++ b/src/external_agent_cci/wlan_ext_emu_test_step_params.cpp @@ -125,10 +125,8 @@ int wlan_ext_test_step_params_t::create_pcap(wlan_emu_msg_t *msg) if (msg_type == wlan_emu_msg_type_frm80211) { cap_len = sizeof(radio_tap_header) + f_data->u.frm80211.u.frame.frame_len; } else { - cap_len = sizeof(radio_tap_header) + - f_data->u.cfg80211.u.start_ap.head_len + - sizeof(traffic_indication_map) + - f_data->u.cfg80211.u.start_ap.tail_len; + cap_len = sizeof(radio_tap_header) + f_data->u.cfg80211.u.start_ap.head_len + + sizeof(traffic_indication_map) + f_data->u.cfg80211.u.start_ap.tail_len; } buff = malloc(cap_len); @@ -175,7 +173,7 @@ int wlan_ext_test_step_params_t::create_pcap(wlan_emu_msg_t *msg) head = (struct ieee80211_mgmt *)f_data->u.cfg80211.u.start_ap.beacon_head; - // Filling timestamp. + // Filling timestamp. memcpy(head->u.beacon.timestamp, &tv.tv_sec, sizeof(head->u.beacon.timestamp)); // Filling Head @@ -188,17 +186,16 @@ int wlan_ext_test_step_params_t::create_pcap(wlan_emu_msg_t *msg) // Filling Tail. memcpy(buff, f_data->u.cfg80211.u.start_ap.beacon_tail, - f_data->u.cfg80211.u.start_ap.tail_len); + f_data->u.cfg80211.u.start_ap.tail_len); buff += f_data->u.cfg80211.u.start_ap.tail_len; - if (f_data->u.cfg80211.u.start_ap.beacon_head != NULL) { + if (f_data->u.cfg80211.u.start_ap.beacon_head != NULL) { free(f_data->u.cfg80211.u.start_ap.beacon_head); } if (f_data->u.cfg80211.u.start_ap.beacon_tail != NULL) { free(f_data->u.cfg80211.u.start_ap.beacon_tail); } - } memcpy(to_queue, fname, 248); diff --git a/src/gateway_cci/wlan_emu.cpp b/src/gateway_cci/wlan_emu.cpp index 904829d..4bb1966 100644 --- a/src/gateway_cci/wlan_emu.cpp +++ b/src/gateway_cci/wlan_emu.cpp @@ -164,7 +164,7 @@ int wlan_emu_t::run() if (m_ui_mgr.upload_results() != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: upload_results failed for abort\n", - __func__, __LINE__); + __func__, __LINE__); } abort_test(); @@ -384,7 +384,8 @@ void wlan_emu_t::abort_test() #define STR_LEN 128 -bus_error_t wlan_emu_t::set_cci_handler(char *event_name, raw_data_t *data, bus_user_data_t *user_data) +bus_error_t wlan_emu_t::set_cci_handler(char *event_name, raw_data_t *data, + bus_user_data_t *user_data) { (void)user_data; char parameter[STR_LEN] = { 0 }; @@ -452,7 +453,8 @@ bus_error_t wlan_emu_t::set_cci_handler(char *event_name, raw_data_t *data, bus_ return bus_error_success; } -bus_error_t wlan_emu_t::get_cci_handler(char *event_name, raw_data_t *data, bus_user_data_t *user_data) +bus_error_t wlan_emu_t::get_cci_handler(char *event_name, raw_data_t *data, + bus_user_data_t *user_data) { wlan_emu_print(wlan_emu_log_level_dbg, "%s: bus property=%s\n", __FUNCTION__, event_name); (void)user_data; diff --git a/src/messages/wlan_emu_msg.cpp b/src/messages/wlan_emu_msg.cpp index c489750..6539e97 100644 --- a/src/messages/wlan_emu_msg.cpp +++ b/src/messages/wlan_emu_msg.cpp @@ -243,10 +243,8 @@ int wlan_emu_msg_t::dump(test_step_params_t *step) if (msg_type == wlan_emu_msg_type_frm80211) { cap_len = sizeof(radio_tap_header) + f_data->u.frm80211.u.frame.frame_len; } else { - cap_len = sizeof(radio_tap_header) + - f_data->u.cfg80211.u.start_ap.head_len + - sizeof(traffic_indication_map) + - f_data->u.cfg80211.u.start_ap.tail_len; + cap_len = sizeof(radio_tap_header) + f_data->u.cfg80211.u.start_ap.head_len + + sizeof(traffic_indication_map) + f_data->u.cfg80211.u.start_ap.tail_len; } buff = malloc(cap_len); diff --git a/src/sta/wlan_emu_sta.cpp b/src/sta/wlan_emu_sta.cpp index 6564043..1db1844 100644 --- a/src/sta/wlan_emu_sta.cpp +++ b/src/sta/wlan_emu_sta.cpp @@ -86,11 +86,10 @@ void wlan_emu_sta_t::send_radio_tap_header(heart_beat_data_t *heart_beat_data) memcpy(&char_buf[byte_count], &heart_beat_data->bitrate, sizeof(heart_beat_data->bitrate)); byte_count += sizeof(heart_beat_data->bitrate); - wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: mac_str : %s rssi : %d noise : %d bitrate : %d\n", - __func__, __LINE__, to_mac_str(heart_beat_data->mac, mac_str), heart_beat_data->rssi, - heart_beat_data->noise, heart_beat_data->bitrate); + "%s:%d: mac_str : %s rssi : %d noise : %d bitrate : %d\n", __func__, __LINE__, + to_mac_str(heart_beat_data->mac, mac_str), heart_beat_data->rssi, heart_beat_data->noise, + heart_beat_data->bitrate); /* for (count = 0; count < byte_count; count++) { wlan_emu_print(wlan_emu_log_level_dbg, " %02X", char_buf[count]); diff --git a/src/tests/wlan_emu_test_param_dml_subdoc.cpp b/src/tests/wlan_emu_test_param_dml_subdoc.cpp index 826cb3a..809b691 100644 --- a/src/tests/wlan_emu_test_param_dml_subdoc.cpp +++ b/src/tests/wlan_emu_test_param_dml_subdoc.cpp @@ -42,8 +42,8 @@ int test_step_param_dmlsubdoc::step_execute() step->frame_request.msg_type |= 1 << wlan_emu_msg_type_webconfig; step->frame_request.subdoc_type = webconfig_subdoc_type_dml; - rc = step->m_bus_mgr->desc.bus_data_get_fn(&webconfig_data->handle, WIFI_WEBCONFIG_INIT_DML_DATA, - &bus_data); + rc = step->m_bus_mgr->desc.bus_data_get_fn(&webconfig_data->handle, + WIFI_WEBCONFIG_INIT_DML_DATA, &bus_data); if (rc != bus_error_success) { wlan_emu_print(wlan_emu_log_level_err, "bus_get failed for [%s] with error [%d]\n", WIFI_WEBCONFIG_INIT_DML_DATA, rc); diff --git a/src/tests/wlan_emu_test_param_get_file.cpp b/src/tests/wlan_emu_test_param_get_file.cpp index b4c56fd..151206c 100644 --- a/src/tests/wlan_emu_test_param_get_file.cpp +++ b/src/tests/wlan_emu_test_param_get_file.cpp @@ -43,8 +43,7 @@ int test_step_param_get_file::step_execute() return RETURN_ERR; } - if (copy_file(step->u.get_file->source_file, 0, step->u.get_file->dest_filename) != - RETURN_OK) { + if (copy_file(step->u.get_file->source_file, 0, step->u.get_file->dest_filename) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: File copy failed from src %s to dest %s step : %d\n", __func__, __LINE__, step->u.get_file->source_file, step->u.get_file->dest_filename, step->step_number); diff --git a/src/tests/wlan_emu_test_param_iperf_client.cpp b/src/tests/wlan_emu_test_param_iperf_client.cpp index da89986..0abe14a 100644 --- a/src/tests/wlan_emu_test_param_iperf_client.cpp +++ b/src/tests/wlan_emu_test_param_iperf_client.cpp @@ -33,8 +33,8 @@ int test_step_param_iperf_client::step_execute() std::string agent_subdoc; if (step->u.iperf_client->input_operation == iperf_operation_type_stop) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: stop_step_number : %d\n", __func__, - __LINE__, step->u.iperf_client->u.stop_conf.stop_step_number); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: stop_step_number : %d\n", __func__, __LINE__, + step->u.iperf_client->u.stop_conf.stop_step_number); if (encode_external_iperf_client_stop_subdoc(agent_subdoc) == RETURN_ERR) { wlan_emu_print(wlan_emu_log_level_err, @@ -46,8 +46,7 @@ int test_step_param_iperf_client::step_execute() } else if (step->u.iperf_client->input_operation == iperf_operation_type_start) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: interface_step_number : %d ServerLogResultName : %s cmd_options : %s\n", - __func__, __LINE__, - step->u.iperf_client->u.start_conf.interface_step_number, + __func__, __LINE__, step->u.iperf_client->u.start_conf.interface_step_number, step->u.iperf_client->u.start_conf.input_filename, step->u.iperf_client->u.start_conf.cmd_options); @@ -90,8 +89,8 @@ int test_step_param_iperf_client::push_ext_iperf_client_result_files( wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: result file is : %s\n", __func__, __LINE__, step->u.iperf_client->u.start_conf.result_file); if (step->u.iperf_client->input_operation != iperf_operation_type_stop) { - if (step->m_ui_mgr->step_upload_files( - step->u.iperf_client->u.start_conf.result_file) != RETURN_OK) { + if (step->m_ui_mgr->step_upload_files(step->u.iperf_client->u.start_conf.result_file) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step_upload_files failed\n", __func__, __LINE__); step->m_ui_mgr->cci_error_code = EPUSHTSTRESFILE; @@ -198,7 +197,6 @@ int test_step_param_iperf_client::step_timeout() return RETURN_OK; } - if (step->test_state == wlan_emu_tests_state_cmd_results) { if (step->u.iperf_client->input_operation == iperf_operation_type_stop) { @@ -234,7 +232,6 @@ int test_step_param_iperf_client::step_timeout() step->test_state = wlan_emu_tests_state_cmd_continue; } - return RETURN_OK; } @@ -382,8 +379,8 @@ int test_step_param_iperf_client::encode_external_iperf_client_start_subdoc( client_interface_step->u.sta_test->key); if (client_interface_step->u.sta_test->ip_address.empty() || - client_interface_step->u.sta_test->ip_address.find_first_not_of(' ') == std -::string::npos) { + client_interface_step->u.sta_test->ip_address.find_first_not_of(' ') == + std ::string::npos) { step->m_ui_mgr->cci_error_code = EEXTAGENT; return RETURN_ERR; } @@ -419,14 +416,15 @@ ::string::npos) { step->test_state = wlan_emu_tests_state_cmd_abort; return RETURN_ERR; } -/* - wlan_emu_print(wlan_emu_log_level_info, - "%s:%d: client interface step : %d sta_name : %s ip_address : %s sta key : %s\n", - __func__, __LINE__, step->u.iperf_client->u.start_conf.interface_step_number, - client_interface_step->u.eth_lan_client->eth_dev_info.interface_name.c_str(), - client_interface_step->u.eth_lan_client->eth_dev_info.ip_address.c_str(), - client_interface_step->u.eth_lan_client->key); -*/ + /* + wlan_emu_print(wlan_emu_log_level_info, + "%s:%d: client interface step : %d sta_name : %s ip_address : %s sta key : + %s\n", + __func__, __LINE__, step->u.iperf_client->u.start_conf.interface_step_number, + client_interface_step->u.eth_lan_client->eth_dev_info.interface_name.c_str(), + client_interface_step->u.eth_lan_client->eth_dev_info.ip_address.c_str(), + client_interface_step->u.eth_lan_client->key); + */ client_cmd = std::string(step->u.iperf_client->u.start_conf.cmd_options) + std::string(" -B ") + client_interface_step->u.eth_lan_client->eth_dev_info.ip_address + diff --git a/src/tests/wlan_emu_test_param_iperf_server.cpp b/src/tests/wlan_emu_test_param_iperf_server.cpp index a687a18..d3a6fb5 100644 --- a/src/tests/wlan_emu_test_param_iperf_server.cpp +++ b/src/tests/wlan_emu_test_param_iperf_server.cpp @@ -34,8 +34,8 @@ int test_step_param_iperf_server::step_execute() std::string agent_subdoc; if (step->u.iperf_server->input_operation == iperf_operation_type_stop) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: stop_step_number : %d\n", __func__, - __LINE__, step->u.iperf_server->u.stop_conf.stop_step_number); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: stop_step_number : %d\n", __func__, __LINE__, + step->u.iperf_server->u.stop_conf.stop_step_number); if (encode_external_iperf_server_stop_subdoc(agent_subdoc) == RETURN_ERR) { wlan_emu_print(wlan_emu_log_level_err, @@ -47,8 +47,7 @@ int test_step_param_iperf_server::step_execute() } else if (step->u.iperf_server->input_operation == iperf_operation_type_start) { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: interface_step_number : %d ServerLogResultName : %s cmd_options : %s\n", - __func__, __LINE__, - step->u.iperf_server->u.start_conf.interface_step_number, + __func__, __LINE__, step->u.iperf_server->u.start_conf.interface_step_number, step->u.iperf_server->u.start_conf.input_filename, step->u.iperf_server->u.start_conf.cmd_options); @@ -91,8 +90,8 @@ int test_step_param_iperf_server::push_ext_iperf_server_result_files( wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: result file is : %s\n", __func__, __LINE__, step->u.iperf_server->u.start_conf.result_file); if (step->u.iperf_server->input_operation != iperf_operation_type_stop) { - if (step->m_ui_mgr->step_upload_files( - step->u.iperf_server->u.start_conf.result_file) != RETURN_OK) { + if (step->m_ui_mgr->step_upload_files(step->u.iperf_server->u.start_conf.result_file) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step_upload_files failed\n", __func__, __LINE__); step->m_ui_mgr->cci_error_code = EPUSHTSTRESFILE; @@ -201,7 +200,6 @@ int test_step_param_iperf_server::step_timeout() return RETURN_OK; } - if (step->test_state == wlan_emu_tests_state_cmd_results) { if (step->u.iperf_server->input_operation == iperf_operation_type_stop) { diff --git a/src/tests/wlan_emu_test_param_log_redirect.cpp b/src/tests/wlan_emu_test_param_log_redirect.cpp index a26b891..41dda2e 100644 --- a/src/tests/wlan_emu_test_param_log_redirect.cpp +++ b/src/tests/wlan_emu_test_param_log_redirect.cpp @@ -164,7 +164,8 @@ int test_step_param_logredirect::step_execute() log_step->u.log_capture->log_operation = log_operation_type_stop; pthread_cancel(log_step->u.log_capture->thread_id); close(log_step->u.log_capture->redirect_fd); - if (step->m_ui_mgr->step_upload_files(log_step->u.log_capture->log_result_file) != RETURN_OK) { + if (step->m_ui_mgr->step_upload_files(log_step->u.log_capture->log_result_file) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step_upload_files failed for %s\n", __func__, __LINE__, log_step->u.log_capture->log_result_file); step->test_state = wlan_emu_tests_state_cmd_abort; diff --git a/src/tests/wlan_emu_test_param_packet_generator.cpp b/src/tests/wlan_emu_test_param_packet_generator.cpp index fbe4e1d..15d4571 100644 --- a/src/tests/wlan_emu_test_param_packet_generator.cpp +++ b/src/tests/wlan_emu_test_param_packet_generator.cpp @@ -331,7 +331,7 @@ int test_step_param_packet_generator::update_brlan0_config() } vap_info = step->m_ui_mgr->get_cci_vap_info( - const_cast(step->u.packet_generator->vapname.c_str())); + const_cast(step->u.packet_generator->vapname.c_str())); if (vap_info == NULL) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: vap_info is NULL\n", __func__, __LINE__); return RETURN_ERR; @@ -477,6 +477,7 @@ unsigned int test_step_param_packet_generator::update_pcap_bssids(char *pcap_fil } struct ifreq if_idx {}; + strncpy(if_idx.ifr_name, step->u.packet_generator->bridge_name.c_str(), IFNAMSIZ - 1); if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: SIOCGIFINDEX failed: %s\n", __func__, @@ -537,11 +538,12 @@ unsigned int test_step_param_packet_generator::update_pcap_bssids(char *pcap_fil memcpy(full_packet + sizeof(ethernet_header_t) + sizeof(u8aRadiotapHeader), mgmt, mgmt_len); struct sockaddr_ll socket_address {}; + socket_address.sll_ifindex = if_idx.ifr_ifindex; socket_address.sll_halen = ETH_ALEN; memcpy(socket_address.sll_addr, step->u.packet_generator->brlan0_mac, ETH_ALEN); - //print_hex_dump(total_len, full_packet); //enable for debug + // print_hex_dump(total_len, full_packet); //enable for debug ssize_t sent = sendto(sockfd, full_packet, total_len, 0, (struct sockaddr *)&socket_address, sizeof(socket_address)); diff --git a/src/tests/wlan_emu_test_param_radio.cpp b/src/tests/wlan_emu_test_param_radio.cpp index 4cd8217..0d13012 100644 --- a/src/tests/wlan_emu_test_param_radio.cpp +++ b/src/tests/wlan_emu_test_param_radio.cpp @@ -62,8 +62,7 @@ int test_step_param_radio::step_execute() cci_webconfig = step->m_ui_mgr->get_webconfig_data(); root_json = cJSON_Parse(json_data); step->frame_request.msg_type |= 1 << wlan_emu_msg_type_webconfig; - step->frame_request.subdoc_type = find_subdoc_type(&cci_webconfig->webconfig, - root_json); + step->frame_request.subdoc_type = find_subdoc_type(&cci_webconfig->webconfig, root_json); // wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: subdoc_type : %d\n", __func__, __LINE__, // step->subdoc_type); @@ -80,7 +79,7 @@ int test_step_param_radio::step_execute() free(json_data); cJSON_Delete(root_json); - //moved to wlan_emu_tests_state_cmd_results when subdoc received by step_frame_filter + // moved to wlan_emu_tests_state_cmd_results when subdoc received by step_frame_filter step->test_state = wlan_emu_tests_state_cmd_continue; wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: step->test_state : %d\n", __func__, __LINE__, diff --git a/src/tests/wlan_emu_test_param_stats_get.cpp b/src/tests/wlan_emu_test_param_stats_get.cpp index c2235ae..7b1d053 100644 --- a/src/tests/wlan_emu_test_param_stats_get.cpp +++ b/src/tests/wlan_emu_test_param_stats_get.cpp @@ -217,7 +217,8 @@ int test_step_param_get_stats_t::update_output_file_name() return RETURN_ERR; } -void test_step_param_get_stats_t::stats_get_event_handler(char *event_name, raw_data_t *p_data, void *userData) +void test_step_param_get_stats_t::stats_get_event_handler(char *event_name, raw_data_t *p_data, + void *userData) { bus_error_t rc = bus_error_success; const char *json_str = NULL; @@ -267,7 +268,8 @@ void test_step_param_get_stats_t::stats_get_event_handler(char *event_name, raw_ snprintf(file_name, sizeof(file_name), "%s/%s_%d_%s_%s_%d.json", step->m_ui_mgr->get_test_results_dir_path(), step->test_case_id, step->step_number, - timestamp, step->u.wifi_stats_get->output_file_name, step->u.wifi_stats_get->get_stats_count); + timestamp, step->u.wifi_stats_get->output_file_name, + step->u.wifi_stats_get->get_stats_count); wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d file_name : %s\n", __FUNCTION__, __LINE__, file_name); @@ -286,8 +288,8 @@ void test_step_param_get_stats_t::stats_get_event_handler(char *event_name, raw_ fclose(fp); temp_file_name = strdup(file_name); if (step->m_ui_mgr->step_upload_files(temp_file_name) != RETURN_OK) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step_upload_files failed for %s\n", - __func__, __LINE__, temp_file_name); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step_upload_files failed for %s\n", __func__, + __LINE__, temp_file_name); step->test_state = wlan_emu_tests_state_cmd_abort; step->m_ui_mgr->cci_error_code = EPUSHTSTRESFILE; free((void *)json_str); diff --git a/src/tests/wlan_emu_test_param_stats_set.cpp b/src/tests/wlan_emu_test_param_stats_set.cpp index 3e0ec09..56a59b1 100644 --- a/src/tests/wlan_emu_test_param_stats_set.cpp +++ b/src/tests/wlan_emu_test_param_stats_set.cpp @@ -46,6 +46,7 @@ int wifi_hal_emu_set_radio_temp(unsigned int radio_index, bool emu_state, int te unsigned int phy_index, unsigned int interface_index); void copy_chanstats_to_chandata(radio_chan_data_t *chan_data, wifi_channelStats_t *chan_stats); } + int test_step_param_set_stats_t::step_frame_filter(wlan_emu_msg_t *msg) { test_step_params_t *step = this; @@ -704,7 +705,7 @@ int test_step_param_set_assoc_clients_stats::webconfig_stats_set_execute_start() step->test_state = wlan_emu_tests_state_cmd_abort; return RETURN_ERR; } - memset(assoc_stats, 0 , sizeof(wifi_associated_dev3_t)); + memset(assoc_stats, 0, sizeof(wifi_associated_dev3_t)); for (assoc_count = 0; assoc_count < (unsigned int)response->stat_array_size; assoc_count++) { uint8_mac_to_string_mac((uint8_t *)assoc_data[assoc_count].cli_MACAddress, str); string_mac_to_uint8_mac((uint8_t *)assoc_stats[assoc_count].cli_MACAddress, str); @@ -839,7 +840,8 @@ int test_step_param_set_assoc_clients_stats::webconfig_stats_set_execute_start() assoc_stats[i].cli_AuthenticationFailures); wlan_emu_print(wlan_emu_log_level_dbg, "Associations %llu\n", assoc_stats[i].cli_Associations); - wlan_emu_print(wlan_emu_log_level_dbg, "Packets Sent %lu\n", assoc_stats[i].cli_PacketsSent); + wlan_emu_print(wlan_emu_log_level_dbg, "Packets Sent %lu\n", + assoc_stats[i].cli_PacketsSent); wlan_emu_print(wlan_emu_log_level_dbg, "Packets Received %lu\n", assoc_stats[i].cli_PacketsReceived); wlan_emu_print(wlan_emu_log_level_dbg, "Errors Sent %lu\n", assoc_stats[i].cli_ErrorsSent); @@ -1336,8 +1338,8 @@ int test_step_param_set_stats_t::step_timeout() step->timeout_count++; if (step->u.wifi_stats_set->set_exec_duration < reference->stats_duration) { wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: Duration for current instance: %d\n", __func__, __LINE__, - step->u.wifi_stats_set->set_exec_duration); + "%s:%d: Duration for current instance: %d\n", __func__, __LINE__, + step->u.wifi_stats_set->set_exec_duration); step->u.wifi_stats_set->set_exec_duration++; if (step->fork == true) { step->test_state = wlan_emu_tests_state_cmd_wait; @@ -1369,18 +1371,18 @@ int test_step_param_set_stats_t::step_timeout() step->u.wifi_stats_set->current_stats_set_count = count - 1; step->u.wifi_stats_set->set_exec_duration = 0; wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: Next instance for step number : %d\n", __func__, __LINE__, - step->step_number); + "%s:%d: Next instance for step number : %d\n", __func__, __LINE__, + step->step_number); ret = webconfig_stats_set_instance(); if (ret != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, - "%s:%d: webconfig_stats_set_instance failed\n", __func__, __LINE__); + "%s:%d: webconfig_stats_set_instance failed\n", __func__, __LINE__); step->m_ui_mgr->cci_error_code = EWEBSET; step->test_state = wlan_emu_tests_state_cmd_abort; return RETURN_ERR; } else { wlan_emu_print(wlan_emu_log_level_dbg, - "%s:%d: webconfig_stats_set_instance success\n", __func__, __LINE__); + "%s:%d: webconfig_stats_set_instance success\n", __func__, __LINE__); } step->u.wifi_stats_set->set_exec_duration++; if (step->fork == true) { @@ -1608,4 +1610,4 @@ test_step_param_set_radio_temperature_stats::~test_step_param_set_radio_temperat { wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d\n", __func__, __LINE__); } -#endif //CONFIG_EXT_AGENT_CCI +#endif // CONFIG_EXT_AGENT_CCI diff --git a/src/tests/wlan_emu_test_param_upgrade_or_reboot.cpp b/src/tests/wlan_emu_test_param_upgrade_or_reboot.cpp index b5514d0..092cebc 100644 --- a/src/tests/wlan_emu_test_param_upgrade_or_reboot.cpp +++ b/src/tests/wlan_emu_test_param_upgrade_or_reboot.cpp @@ -34,12 +34,11 @@ int test_step_param_upgrade_or_reboot::create_reboot_case_json(test_step_params_t *step) { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Entered create_reboot_case_json\n", - __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Entered create_reboot_case_json\n", __func__, + __LINE__); if (step == NULL) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step is NULL\n", - __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step is NULL\n", __func__, __LINE__); return RETURN_ERR; } @@ -49,19 +48,19 @@ int test_step_param_upgrade_or_reboot::create_reboot_case_json(test_step_params_ // config file (with localhost handling) if (step->m_ui_mgr->get_local_host_enabled() == true) { cJSON_AddStringToObject(root, "config file", - ("http://localhost" + std::string(step->m_ui_mgr->get_tda_url())).c_str()); + ("http://localhost" + std::string(step->m_ui_mgr->get_tda_url())).c_str()); } else { - cJSON_AddStringToObject(root, "config file", - step->m_ui_mgr->get_tda_url()); + cJSON_AddStringToObject(root, "config file", step->m_ui_mgr->get_tda_url()); } - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Config file: %s\n", - __func__, __LINE__, step->m_ui_mgr->get_tda_url()); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Config file: %s\n", __func__, __LINE__, + step->m_ui_mgr->get_tda_url()); // Other fields cJSON_AddStringToObject(root, "server_address", step->m_ui_mgr->get_server_address()); cJSON_AddStringToObject(root, "interface", step->m_ui_mgr->get_tda_interface()); - cJSON_AddNumberToObject(root, "simulated_client_count", step->m_ui_mgr->get_simulated_client_count()); + cJSON_AddNumberToObject(root, "simulated_client_count", + step->m_ui_mgr->get_simulated_client_count()); cJSON_AddStringToObject(root, "ResultsFileName", step->m_ui_mgr->get_tda_output_file()); // logging_step_numbers @@ -92,8 +91,8 @@ int test_step_param_upgrade_or_reboot::create_reboot_case_json(test_step_params_ char *json_str = cJSON_Print(root); // pretty formatted, use cJSON_PrintUnformatted for compact FILE *fp = fopen(CCI_TEST_REBOOT_STEP_CONFIG_JSON, "w"); if (fp == NULL) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d: Failed to open file for writing\n", - __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: Failed to open file for writing\n", __func__, + __LINE__); cJSON_Delete(root); free(json_str); return RETURN_ERR; @@ -101,8 +100,8 @@ int test_step_param_upgrade_or_reboot::create_reboot_case_json(test_step_params_ fputs(json_str, fp); fclose(fp); - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Created JSON file successfully\n", - __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: Created JSON file successfully\n", __func__, + __LINE__); // Cleanup cJSON_Delete(root); @@ -212,8 +211,8 @@ int test_step_param_upgrade_or_reboot::step_execute() void test_step_param_upgrade_or_reboot::step_remove() { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: STEP : %d - Called for Step Remove\n", - __func__, __LINE__, this->step_number); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: STEP : %d - Called for Step Remove\n", __func__, + __LINE__, this->step_number); if (this->u.upgrade_or_reboot != NULL) { if (this->u.upgrade_or_reboot->logging_step_numbers != NULL) { @@ -227,8 +226,9 @@ void test_step_param_upgrade_or_reboot::step_remove() int test_step_param_upgrade_or_reboot::step_timeout() { - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: STEP : %d - Timeout not applicable for upgrade/reboot\n", - __func__, __LINE__, this->step_number); + wlan_emu_print(wlan_emu_log_level_dbg, + "%s:%d: STEP : %d - Timeout not applicable for upgrade/reboot\n", __func__, __LINE__, + this->step_number); return RETURN_OK; // No timeout handling for upgrade/reboot steps } @@ -239,7 +239,7 @@ test_step_param_upgrade_or_reboot::test_step_param_upgrade_or_reboot() wlan_emu_print(wlan_emu_log_level_err, "%s:%d: Memory allocation failed for device_upgrade_t\n", __func__, __LINE__); } - //this->u.upgrade_or_reboot->is_upgrade = false; // Default to reboot + // this->u.upgrade_or_reboot->is_upgrade = false; // Default to reboot this->u.upgrade_or_reboot->is_logging_enabled = false; this->u.upgrade_or_reboot->logging_step_numbers = NULL; this->is_step_initialized = true; diff --git a/src/tests/wlan_emu_test_param_vap.cpp b/src/tests/wlan_emu_test_param_vap.cpp index 7295b4e..1a519f8 100644 --- a/src/tests/wlan_emu_test_param_vap.cpp +++ b/src/tests/wlan_emu_test_param_vap.cpp @@ -67,15 +67,14 @@ int test_step_param_vap::step_execute() root_json = cJSON_Parse(json_data); step->frame_request.msg_type |= 1 << wlan_emu_msg_type_webconfig; - step->frame_request.subdoc_type = find_subdoc_type(&cci_webconfig->webconfig, - root_json); + step->frame_request.subdoc_type = find_subdoc_type(&cci_webconfig->webconfig, root_json); wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: subdoc_type : %d\n", __func__, __LINE__, step->frame_request.subdoc_type); if (step->frame_request.subdoc_type == webconfig_subdoc_type_xfinity) { step->execution_time = 40; - wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: new execution time : %d for xfinity\n", __func__, __LINE__, - step->execution_time); + wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: new execution time : %d for xfinity\n", + __func__, __LINE__, step->execution_time); } ret = step->m_ui_mgr->bus_send(json_data, step->m_bus_mgr); @@ -90,7 +89,7 @@ int test_step_param_vap::step_execute() free(json_data); cJSON_Delete(root_json); - //moved to wlan_emu_tests_state_cmd_results when subdoc received by step_frame_filter + // moved to wlan_emu_tests_state_cmd_results when subdoc received by step_frame_filter step->test_state = wlan_emu_tests_state_cmd_continue; wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: step->test_state : %d\n", __func__, __LINE__, diff --git a/src/ui/wlan_emu_ui_get_ssl_config.cpp b/src/ui/wlan_emu_ui_get_ssl_config.cpp index 9c3cd7f..4c66e42 100644 --- a/src/ui/wlan_emu_ui_get_ssl_config.cpp +++ b/src/ui/wlan_emu_ui_get_ssl_config.cpp @@ -46,6 +46,6 @@ wlan_emu_ui_ssl_config::wlan_emu_ui_ssl_config() set_ssl_key(ssl_key); } -wlan_emu_ui_ssl_config::~wlan_emu_ui_ssl_config() { - +wlan_emu_ui_ssl_config::~wlan_emu_ui_ssl_config() +{ } diff --git a/src/ui/wlan_emu_ui_mgr.cpp b/src/ui/wlan_emu_ui_mgr.cpp index b1adfd6..48c42d7 100644 --- a/src/ui/wlan_emu_ui_mgr.cpp +++ b/src/ui/wlan_emu_ui_mgr.cpp @@ -68,13 +68,14 @@ http_info_t *wlan_emu_ui_mgr_t::fill_http_info() return NULL; } http_info->is_local_host_enabled = is_local_host_enabled; - if (this->m_ssl_config.get_ssl_cert() == NULL || - this->m_ssl_config.get_ssl_key() == NULL) { - wlan_emu_print(wlan_emu_log_level_err, "%s:%d SSL cert or key is NULL\n", __func__, __LINE__); + if (this->m_ssl_config.get_ssl_cert() == NULL || this->m_ssl_config.get_ssl_key() == NULL) { + wlan_emu_print(wlan_emu_log_level_err, "%s:%d SSL cert or key is NULL\n", __func__, + __LINE__); free(http_info); return NULL; } - strncpy(http_info->ssl_cert, this->m_ssl_config.get_ssl_cert(), sizeof(http_info->ssl_cert) - 1); + strncpy(http_info->ssl_cert, this->m_ssl_config.get_ssl_cert(), + sizeof(http_info->ssl_cert) - 1); strncpy(http_info->ssl_key, this->m_ssl_config.get_ssl_key(), sizeof(http_info->ssl_key) - 1); strncpy(http_info->interface, interface, sizeof(http_info->interface) - 1); strncpy(http_info->tda_url, tda_url, sizeof(http_info->tda_url) - 1); @@ -173,8 +174,8 @@ int wlan_emu_ui_mgr_t::get_file_name_from_url(char *str, char *file_name, int le return RETURN_ERR; } - if (get_last_substring_after_slash(str, file_name_substr, sizeof(file_name_substr), cci_error_code) != - RETURN_OK) { + if (get_last_substring_after_slash(str, file_name_substr, sizeof(file_name_substr), + cci_error_code) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: get_last_substring_after_slash failed for str : %s\n", __func__, __LINE__, str); free(http_info); @@ -1061,15 +1062,15 @@ int wlan_emu_ui_mgr_t::decode_step_configure_upgrade_or_reboot(cJSON *step, test_step_params_t *step_config) { if (step == NULL || step_config == NULL || step_config->u.upgrade_or_reboot == NULL) { - wlan_emu_print(wlan_emu_log_level_err, - "%s:%d: step or upgrade_or_reboot is NULL\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: step or upgrade_or_reboot is NULL\n", + __func__, __LINE__); return RETURN_ERR; } cJSON *config = cJSON_GetObjectItem(step, "UpgradeOrReboot"); if (config == NULL) { - wlan_emu_print(wlan_emu_log_level_err, - "%s:%d: UpgradeOrReboot object not found\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: UpgradeOrReboot object not found\n", + __func__, __LINE__); return RETURN_ERR; } @@ -1097,8 +1098,8 @@ int wlan_emu_ui_mgr_t::decode_step_configure_upgrade_or_reboot(cJSON *step, } } } else { - wlan_emu_print(wlan_emu_log_level_err, - "%s:%d: is_logging_enabled is missing or invalid\n", __func__, __LINE__); + wlan_emu_print(wlan_emu_log_level_err, "%s:%d: is_logging_enabled is missing or invalid\n", + __func__, __LINE__); return RETURN_ERR; } @@ -1155,8 +1156,8 @@ int wlan_emu_ui_mgr_t::decode_step_iperf_client(cJSON *step, test_step_params_t iperf_client->input_operation = iperf_operation_type_stop; iperf_client->u.stop_conf.stop_step_number = param->valuedouble; - wlan_emu_print(wlan_emu_log_level_info, "%s:%d: stop_step_number : %d\n", __func__, __LINE__, - iperf_client->u.stop_conf.stop_step_number); + wlan_emu_print(wlan_emu_log_level_info, "%s:%d: stop_step_number : %d\n", __func__, + __LINE__, iperf_client->u.stop_conf.stop_step_number); } else if (update_json_param_integer(config, "ClientInterfaceStepNumber", ¶m) == RETURN_OK) { @@ -3144,7 +3145,8 @@ int wlan_emu_ui_mgr_t::download_file(char *input_file_name, unsigned int input_f return RETURN_ERR; } - if (https_get_file(http_info, file_download_url, download_test_file, cci_error_code) != RETURN_OK) { + if (https_get_file(http_info, file_download_url, download_test_file, cci_error_code) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: https_get_file failed for %s\n", __func__, __LINE__, file_download_url); free(http_info); @@ -3376,7 +3378,7 @@ int wlan_emu_ui_mgr_t::decode_reboot_case_json() } } - // "result_file" + // "result_file" cJSON *server_addr = cJSON_GetObjectItem(root, "server_address"); if (cJSON_IsString(server_addr) && cfg_file->valuestring) { strncpy(server_address, server_addr->valuestring, STR_LEN); @@ -3531,8 +3533,7 @@ int wlan_emu_ui_mgr_t::step_upload_files(char *output_file) wlan_emu_print(wlan_emu_log_level_dbg, "%s:%d: File: %s\n", __func__, __LINE__, output_file); - if (upload_file_to_server(output_file, - remote_test_results_loc) != RETURN_OK) { + if (upload_file_to_server(output_file, remote_test_results_loc) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: failed to upload %s\n", __func__, __LINE__, output_file); return RETURN_ERR; @@ -3540,8 +3541,8 @@ int wlan_emu_ui_mgr_t::step_upload_files(char *output_file) wlan_emu_print(wlan_emu_log_level_info, "%s:%d: uploaded %s\n", __func__, __LINE__, output_file); temp_res_file = strdup(output_file); - if (get_last_substring_after_slash(temp_res_file, res_file_name, - sizeof(res_file_name), cci_error_code) != RETURN_OK) { + if (get_last_substring_after_slash(temp_res_file, res_file_name, sizeof(res_file_name), + cci_error_code) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: get_last_substring_after_slash failed for str : %s\n", __func__, __LINE__, temp_res_file); @@ -3728,8 +3729,8 @@ int wlan_emu_ui_mgr_t::upload_cci_log(char *test_case_id, char *test_case_name, } else { wlan_emu_print(wlan_emu_log_level_info, "%s:%d: uploaded %s\n", __func__, __LINE__, cci_log_copy); - if (get_last_substring_after_slash(cci_log_copy, res_file_name, sizeof(res_file_name), cci_error_code) != - RETURN_OK) { + if (get_last_substring_after_slash(cci_log_copy, res_file_name, sizeof(res_file_name), + cci_error_code) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: get_last_substring_after_slash failed for str : %s\n", __func__, __LINE__, cci_log_copy); @@ -3776,7 +3777,8 @@ unsigned int wlan_emu_ui_mgr_t::upload_results() } while (test != NULL) { // Call function to upload cci file - if (upload_cci_log(test->test_case_id, test->test_case_name, res_output_file_fp) == RETURN_ERR) { + if (upload_cci_log(test->test_case_id, test->test_case_name, res_output_file_fp) == + RETURN_ERR) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: Failed to upload cci log for %s_%s\n", __func__, __LINE__, test->test_case_id, test->test_case_name); } diff --git a/src/utils/cci_wifi_utils.cpp b/src/utils/cci_wifi_utils.cpp index 1687b20..2ea1ea3 100644 --- a/src/utils/cci_wifi_utils.cpp +++ b/src/utils/cci_wifi_utils.cpp @@ -335,7 +335,8 @@ int copy_file(const char *source_path, long source_offset, const char *destinati return RETURN_OK; } -int https_get_file(http_info_t *http_info, const char *url, const char *output_file, int &error_code) +int https_get_file(http_info_t *http_info, const char *url, const char *output_file, + int &error_code) { CURL *curl; CURLcode res; @@ -426,7 +427,8 @@ int https_get_file(http_info_t *http_info, const char *url, const char *output_f return ret; } -int https_post_file(http_info_t *http_info, const char *post_url, const char *input_file, int &error_code) +int https_post_file(http_info_t *http_info, const char *post_url, const char *input_file, + int &error_code) { int ret = RETURN_ERR; CURL *curl; @@ -455,7 +457,8 @@ int https_post_file(http_info_t *http_info, const char *post_url, const char *in } } else { - if (get_last_substring_after_slash(input_file, file_name, sizeof(file_name), error_code) != RETURN_OK) { + if (get_last_substring_after_slash(input_file, file_name, sizeof(file_name), error_code) != + RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: get_last_substring_after_slash failed for input_file : %s\n", __func__, __LINE__, input_file); @@ -515,7 +518,6 @@ int https_post_file(http_info_t *http_info, const char *post_url, const char *in // Clean up curl_easy_cleanup(curl); curl_mime_free(mime); - } free(test_config_URL); @@ -662,7 +664,8 @@ static size_t write_file_callback(void *contents, size_t size, size_t nmemb, return total_size; } -int http_get_file(const std::string &url, const std::string &file_path, long &status_code, int &error_code) +int http_get_file(const std::string &url, const std::string &file_path, long &status_code, + int &error_code) { CURLcode ret; CURL *curl = NULL; @@ -843,7 +846,8 @@ int http_post(const std::string &url, const std::string &data, long &status_code return RETURN_OK; } -int http_post_file(const std::string &url, const std::string &file_path, long &status_code, int &error_code) +int http_post_file(const std::string &url, const std::string &file_path, long &status_code, + int &error_code) { CURLcode ret; CURL *curl = NULL; @@ -852,8 +856,8 @@ int http_post_file(const std::string &url, const std::string &file_path, long &s char file_name[128] = { 0 }; std::string url_with_filename; - if (get_last_substring_after_slash(file_path.c_str(), file_name, sizeof(file_name), error_code) != - RETURN_OK) { + if (get_last_substring_after_slash(file_path.c_str(), file_name, sizeof(file_name), + error_code) != RETURN_OK) { wlan_emu_print(wlan_emu_log_level_err, "%s:%d: get_last_substring_after_slash failed for input_file: %s\n", __func__, __LINE__, file_path.c_str()); @@ -938,7 +942,8 @@ int http_post_file(const std::string &url, const std::string &file_path, long &s return RETURN_OK; } -int get_last_substring_after_slash(const char *str, char *sub_string, int sub_str_len, int &error_code) +int get_last_substring_after_slash(const char *str, char *sub_string, int sub_str_len, + int &error_code) { char *last_slash = NULL; int ret = 0; diff --git a/src/utils/timespec_macro.h b/src/utils/timespec_macro.h index 6df3075..c051b2d 100644 --- a/src/utils/timespec_macro.h +++ b/src/utils/timespec_macro.h @@ -29,33 +29,32 @@ #endif #ifndef timespeccmp -#define timespeccmp(a, b, CMP) \ - (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP (b)->tv_nsec) \ - : ((a)->tv_sec CMP (b)->tv_sec)) +#define timespeccmp(a, b, CMP) \ + (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP(b)->tv_nsec) : ((a)->tv_sec CMP(b)->tv_sec)) #endif #ifndef timespecadd -#define timespecadd(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ - (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \ - if ((result)->tv_nsec >= (1000 * 1000 * 1000)) { \ - (result)->tv_sec++; \ - (result)->tv_nsec -= (1000 * 1000 * 1000); \ - } \ - } while (0) +#define timespecadd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \ + if ((result)->tv_nsec >= (1000 * 1000 * 1000)) { \ + (result)->tv_sec++; \ + (result)->tv_nsec -= (1000 * 1000 * 1000); \ + } \ + } while (0) #endif #ifndef timespecsub -#define timespecsub(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ - if ((result)->tv_nsec < 0) { \ - (result)->tv_sec--; \ - (result)->tv_nsec += (1000 * 1000 * 1000); \ - } \ - } while (0) +#define timespecsub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ + if ((result)->tv_nsec < 0) { \ + (result)->tv_sec--; \ + (result)->tv_nsec += (1000 * 1000 * 1000); \ + } \ + } while (0) #endif #endif /* _UTILS_TIMESPEC_MACRO_H_ */