From ef8229a2d6535930cabbd7e7b866cc9db7c37ea5 Mon Sep 17 00:00:00 2001 From: WFA-KennyTseng Date: Thu, 1 Dec 2022 15:58:41 +0800 Subject: [PATCH] QuickTrack R2.1 changes --- Makefile | 1 - indigo_api.c | 7 ++ indigo_api.h | 10 +- indigo_api_callback.h | 1 - indigo_api_callback_dut.c | 36 ++++-- indigo_api_callback_tp.c | 246 +++++++++++++++++++++++++++++++------- utils.c | 8 +- utils.h | 2 + 8 files changed, 257 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index 1f012d1..6a6e573 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ TYPE = laptop # Role is dut or platform ROLE = dut # Package Version -APP_VERSION = "2.0.0" VERSION = "" OBJS = main.o eloop.o indigo_api.o indigo_packet.o utils.o wpa_ctrl.o diff --git a/indigo_api.c b/indigo_api.c index 7560c63..e69a830 100644 --- a/indigo_api.c +++ b/indigo_api.c @@ -266,6 +266,13 @@ struct indigo_tlv indigo_tlv_list[] = { { TLV_WPS_INDEPENDENT, "WPS_INDEPENDENT" }, { TLV_LOCAL_PWR_CONST, "LOCAL_PWR_CONST" }, { TLV_SPECTRUM_MGMT_REQ, "SPECTRUM_MGMT_REQ" }, + { TLV_CAPTURE_FILE, "CAPTURE_FILE" }, + { TLV_CAPTURE_FILTER, "CAPTURE_FILTER" }, + { TLV_CAPTURE_INFILE, "CAPTURE_INFILE" }, + { TLV_CAPTURE_OUTFILE, "CAPTURE_OUTFILE" }, + { TLV_TP_IP_ADDRESS, "TP_IP_ADDRESS" }, + { TLV_WPS_ER_SUPPORT, "WPS_ER_SUPPORT" }, + { TLV_ADDITIONAL_TEST_PLATFORM_ID, "ADDITIONAL_TEST_PLATFORM_ID" }, }; /* Find the type of the API stucture by the ID from the list */ diff --git a/indigo_api.h b/indigo_api.h index cf3b3d7..59fe540 100644 --- a/indigo_api.h +++ b/indigo_api.h @@ -275,6 +275,13 @@ struct indigo_api { #define TLV_WPS_INDEPENDENT 0x00d8 #define TLV_LOCAL_PWR_CONST 0x00d9 #define TLV_SPECTRUM_MGMT_REQ 0x00da +#define TLV_CAPTURE_FILE 0x00db +#define TLV_CAPTURE_FILTER 0x00dc +#define TLV_CAPTURE_INFILE 0x00dd +#define TLV_CAPTURE_OUTFILE 0x00de +#define TLV_TP_IP_ADDRESS 0x00df +#define TLV_WPS_ER_SUPPORT 0x00e0 +#define TLV_ADDITIONAL_TEST_PLATFORM_ID 0x00e1 // class ResponseTLV // List of TLV used in the QuickTrack API response and ACK messages from the DUT @@ -304,8 +311,7 @@ struct indigo_api { #define TLV_BAND_5GHZ "5GHz" #define TLV_BAND_6GHZ "6GHz" -#define TLV_VALUE_APP_VERSION "v2.0" -#define TLV_VALUE_TEST_PLATFORM_APP_VERSION "v2.0" +#define TLV_VALUE_APP_VERSION "v2.1" #define TLV_VALUE_OK "OK" #define TLV_VALUE_NOT_OK "Failed" #define TLV_VALUE_INSUFFICIENT_TLV "TLV is insufficient to run the command" diff --git a/indigo_api_callback.h b/indigo_api_callback.h index 5e1f765..758513e 100644 --- a/indigo_api_callback.h +++ b/indigo_api_callback.h @@ -20,7 +20,6 @@ #define LOOPBACK_TIMEOUT 180 - struct tlv_to_config_name { unsigned short tlv_id; char config_name[NAME_SIZE]; diff --git a/indigo_api_callback_dut.c b/indigo_api_callback_dut.c index 7c2c322..b3eda4e 100644 --- a/indigo_api_callback_dut.c +++ b/indigo_api_callback_dut.c @@ -92,6 +92,12 @@ void register_apis() { static int get_control_app_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { char ipAddress[INET_ADDRSTRLEN]; + char buffer[S_BUFFER_LEN]; +#ifdef _VERSION_ + snprintf(buffer, sizeof(buffer), "%s", _VERSION_); +#else + snprintf(buffer, sizeof(buffer), "%s", TLV_VALUE_APP_VERSION); +#endif if (tool_addr) { inet_ntop(AF_INET, &(tool_addr->sin_addr), ipAddress, INET_ADDRSTRLEN); indigo_logger(LOG_LEVEL_DEBUG, "Tool Control IP address on DUT network path: %s", ipAddress); @@ -100,7 +106,7 @@ static int get_control_app_handler(struct packet_wrapper *req, struct packet_wra fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq); fill_wrapper_tlv_byte(resp, TLV_STATUS, TLV_VALUE_STATUS_OK); fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(TLV_VALUE_OK), TLV_VALUE_OK); - fill_wrapper_tlv_bytes(resp, TLV_CONTROL_APP_VERSION, strlen(TLV_VALUE_APP_VERSION), TLV_VALUE_APP_VERSION); + fill_wrapper_tlv_bytes(resp, TLV_CONTROL_APP_VERSION, strlen(buffer), buffer); return 0; } @@ -449,6 +455,20 @@ static int generate_hostapd_config(char *output, int output_size, struct packet_ continue; } + /* wps er support. upnp */ + if (tlv->id == TLV_WPS_ER_SUPPORT) { + memset(cfg_item, 0, sizeof(cfg_item)); + sprintf(cfg_item, "upnp_iface=%s\n", wlanp->ifname); + strcat(output, cfg_item); + memset(cfg_item, 0, sizeof(cfg_item)); + sprintf(cfg_item, "friendly_name=WPS Access Point\n"); + strcat(output, cfg_item); + memset(cfg_item, 0, sizeof(cfg_item)); + sprintf(cfg_item, "model_description=Wireless Access Point\n"); + strcat(output, cfg_item); + continue; + } + cfg = find_tlv_config(tlv->id); if (!cfg) { indigo_logger(LOG_LEVEL_ERROR, "Unknown AP configuration name: TLV ID 0x%04x", tlv->id); @@ -639,6 +659,12 @@ static int generate_hostapd_config(char *output, int output_size, struct packet_ if (enable_ac == 0 && enable_ax == 0) chwidth = 0; + /* Add country IE if there is no country config */ + if (strlen(country) == 0) { + strcat(output, "ieee80211d=1\n"); + strcat(output, "country_code=US\n"); + } + if (is_6g_only) { if (chwidthset == 0) { sprintf(buffer, "he_oper_chwidth=%d\n", chwidth); @@ -656,10 +682,8 @@ static int generate_hostapd_config(char *output, int output_size, struct packet_ } else { strcat(output, "fils_discovery_max_interval=20\n"); } - /* Enable bss_color and country IE */ + /* Enable bss_color IE */ strcat(output, "he_bss_color=19\n"); - strcat(output, "ieee80211d=1\n"); - strcat(output, "country_code=US\n"); } else if (strstr(band, "a")) { if (is_ht40plus_chan(channel)) strcat(output, "ht_capab=[HT40+]\n"); @@ -671,9 +695,7 @@ static int generate_hostapd_config(char *output, int output_size, struct packet_ int center_freq = get_center_freq_index(channel, chwidth); #ifndef _WTS_OPENWRT_ if (chwidth == 2) { - /* 160M: Need to enable 11h for DFS and enable 11d for 11h */ - strcat(output, "ieee80211d=1\n"); - strcat(output, "country_code=US\n"); + /* 160M: Need to enable 11h for DFS */ strcat(output, "ieee80211h=1\n"); } #endif diff --git a/indigo_api_callback_tp.c b/indigo_api_callback_tp.c index ab7587f..2e14d9b 100644 --- a/indigo_api_callback_tp.c +++ b/indigo_api_callback_tp.c @@ -39,6 +39,7 @@ int rrm = 0, he_mu_edca = 0; extern struct sockaddr_in *tool_addr; extern wps_setting* get_vendor_wps_settings_for_ie_frag_test(enum wps_device_role role); +int additional_tp_id = 0; void register_apis() { /* Basic */ @@ -46,6 +47,8 @@ void register_apis() { register_api(API_GET_CONTROL_APP_VERSION, NULL, get_control_app_handler); register_api(API_SEND_LOOP_BACK_DATA, NULL, send_loopback_data_handler); register_api(API_STOP_LOOP_BACK_DATA, NULL, stop_loopback_data_handler); + register_api(API_START_LOOP_BACK_SERVER, NULL, start_loopback_server); + register_api(API_STOP_LOOP_BACK_SERVER, NULL, stop_loop_back_server_handler); /* TODO: API_CREATE_NEW_INTERFACE_BRIDGE_NETWORK */ register_api(API_ASSIGN_STATIC_IP, NULL, assign_static_ip_handler); register_api(API_START_DHCP, NULL, start_dhcp_handler); @@ -69,11 +72,17 @@ void register_apis() { } static int get_control_app_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { + char buffer[S_BUFFER_LEN]; +#ifdef _VERSION_ + snprintf(buffer, sizeof(buffer), "%s", _VERSION_); +#else + snprintf(buffer, sizeof(buffer), "%s", TLV_VALUE_APP_VERSION); +#endif fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq); fill_wrapper_tlv_byte(resp, TLV_STATUS, TLV_VALUE_STATUS_OK); fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(TLV_VALUE_OK), TLV_VALUE_OK); fill_wrapper_tlv_bytes(resp, TLV_TEST_PLATFORM_APP_VERSION, - strlen(TLV_VALUE_TEST_PLATFORM_APP_VERSION), TLV_VALUE_TEST_PLATFORM_APP_VERSION); + strlen(buffer), buffer); return 0; } @@ -82,17 +91,35 @@ static int get_control_app_handler(struct packet_wrapper *req, struct packet_wra */ void upload_wlan_hapd_conf(void *if_info) { struct interface_info *wlan = (struct interface_info *) if_info; + char buffer[S_BUFFER_LEN], conf_name[128]; + int id = 0; if (tool_addr != NULL) { - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, wlan->hapd_conf_file); - sleep(1); + if (additional_tp_id != 0) { + id = additional_tp_id & 0x0F; + memset(conf_name, 0, sizeof(conf_name)); + snprintf(conf_name, sizeof(conf_name),"/tmp/hostapd_%s_add_tp_%d.conf", wlan->ifname, id); + + memset(buffer, 0, sizeof(buffer)); + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", wlan->hapd_conf_file, conf_name); + system(buffer); + + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, conf_name); + sleep(1); + + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", conf_name); + system(buffer); + } else { + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, wlan->hapd_conf_file); + sleep(1); + } } } // RESP: {: '0', : 'AP stop completed : Hostapd service is inactive.'} static int stop_ap_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { - int len = 0, reset = 0; - char buffer[S_BUFFER_LEN], reset_type[16]; + int len = 0, reset = 0, id = 0; + char buffer[S_BUFFER_LEN], reset_type[16], log_name[128]; char *parameter[] = {"pidof", get_hapd_exec_file(), NULL}; char *message = NULL; int status = TLV_VALUE_STATUS_NOT_OK; @@ -154,11 +181,40 @@ static int stop_ap_handler(struct packet_wrapper *req, struct packet_wrapper *re /* Test case teardown case */ if (reset == RESET_TYPE_TEARDOWN) { + /* TLV: ADDITIONAL_TEST_PLATFORM_ID */ + tlv = find_wrapper_tlv_by_id(req, TLV_ADDITIONAL_TEST_PLATFORM_ID); + memset(buffer, 0, sizeof(buffer)); + if (tlv) { + memcpy(buffer, tlv->value, tlv->len); + additional_tp_id = atoi(buffer); + id = additional_tp_id & 0x0F; + indigo_logger(LOG_LEVEL_DEBUG, "Additional AP test platform id: %d", id); + } + /* Send hostapd conf and log to Tool */ if (tool_addr != NULL) { - iterate_all_wlan_interfaces(upload_wlan_hapd_conf); - sleep(1); - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, HAPD_LOG_FILE); + if (additional_tp_id != 0) { + memset(log_name, 0, sizeof(log_name)); + snprintf(log_name, sizeof(log_name),"/tmp/hostapd_add_tp_%d.log", id); + + memset(buffer, 0, sizeof(buffer)); + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", WPAS_LOG_FILE, log_name); + system(buffer); + + iterate_all_wlan_interfaces(upload_wlan_hapd_conf); + sleep(1); + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, log_name); + + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", log_name); + system(buffer); + + /* reset additional_tp_id */ + additional_tp_id = 0; + } else { + iterate_all_wlan_interfaces(upload_wlan_hapd_conf); + sleep(1); + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, HAPD_UPLOAD_API, HAPD_LOG_FILE); + } } else { indigo_logger(LOG_LEVEL_ERROR, "Can't get tool IP address"); } @@ -977,19 +1033,25 @@ static int stop_loopback_data_handler(struct packet_wrapper *req, struct packet_ static int send_loopback_data_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { struct tlv_hdr *tlv; - char dut_ip[64]; + char dst_ip[64]; char dut_port[32]; char rate[16], pkt_count[16], pkt_size[16], recv_count[16], pkt_type[16]; int status = TLV_VALUE_STATUS_NOT_OK, recvd = 0; char *message = TLV_VALUE_SEND_LOOPBACK_DATA_NOT_OK; /* TLV: TLV_DUT_IP_ADDRESS */ - memset(dut_ip, 0, sizeof(dut_ip)); + memset(dst_ip, 0, sizeof(dst_ip)); tlv = find_wrapper_tlv_by_id(req, TLV_DUT_IP_ADDRESS); if (tlv) { - memcpy(dut_ip, tlv->value, tlv->len); + memcpy(dst_ip, tlv->value, tlv->len); } else { - goto done; + /* TLV: TLV_TP_IP_ADDRESS */ + tlv = find_wrapper_tlv_by_id(req, TLV_TP_IP_ADDRESS); + if (tlv) { + memcpy(dst_ip, tlv->value, tlv->len); + } else { + goto done; + } } memset(dut_port, 0, sizeof(dut_port)); tlv = find_wrapper_tlv_by_id(req, TLV_DUT_UDP_PORT); @@ -1032,15 +1094,15 @@ static int send_loopback_data_handler(struct packet_wrapper *req, struct packet_ } /* Detect and delete existing ARP entry for STAUT randomized MAC */ - detect_del_arp_entry(dut_ip); + detect_del_arp_entry(dst_ip); /* Start loopback */ snprintf(recv_count, sizeof(recv_count), "0"); if (strcmp(pkt_type, "icmp") == 0) { - recvd = send_icmp_data(dut_ip, atoi(pkt_count), atoi(pkt_size), atof(rate)); + recvd = send_icmp_data(dst_ip, atoi(pkt_count), atoi(pkt_size), atof(rate)); } else if (strcmp(pkt_type, "udp") == 0) { - recvd = send_udp_data(dut_ip, atoi(dut_port), atoi(pkt_count), atoi(pkt_size), atof(rate)); + recvd = send_udp_data(dst_ip, atoi(dut_port), atoi(pkt_count), atoi(pkt_size), atof(rate)); } /* -1 : Continuous data case uses timer and directly reply OK */ @@ -1058,6 +1120,57 @@ static int send_loopback_data_handler(struct packet_wrapper *req, struct packet_ return 0; } +static int start_loopback_server(struct packet_wrapper *req, struct packet_wrapper *resp) { + struct tlv_hdr *tlv; + char local_ip[256]; + int status = TLV_VALUE_STATUS_NOT_OK; + char *message = TLV_VALUE_LOOPBACK_SVR_START_NOT_OK; + char tool_udp_port[16]; + char if_name[32]; + + /* Find network interface. If P2P Group or bridge exists, then use it. Otherwise, it uses the initiation value. */ + memset(local_ip, 0, sizeof(local_ip)); + if (get_p2p_group_if(if_name, sizeof(if_name)) == 0 && find_interface_ip(local_ip, sizeof(local_ip), if_name)) { + indigo_logger(LOG_LEVEL_DEBUG, "use %s", if_name); + } else if (find_interface_ip(local_ip, sizeof(local_ip), get_wlans_bridge())) { + indigo_logger(LOG_LEVEL_DEBUG, "use %s", get_wlans_bridge()); + } else if (find_interface_ip(local_ip, sizeof(local_ip), get_wireless_interface())) { + indigo_logger(LOG_LEVEL_DEBUG, "use %s", get_wireless_interface()); +// #ifdef __TEST__ + } else if (find_interface_ip(local_ip, sizeof(local_ip), "eth0")) { + indigo_logger(LOG_LEVEL_DEBUG, "use %s", "eth0"); +// #endif /* __TEST__ */ + } else { + indigo_logger(LOG_LEVEL_ERROR, "No available interface"); + goto done; + } + /* Start loopback */ + if (!loopback_server_start(local_ip, tool_udp_port, LOOPBACK_TIMEOUT)) { + status = TLV_VALUE_STATUS_OK; + message = TLV_VALUE_LOOPBACK_SVR_START_OK; + } +done: + fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq); + fill_wrapper_tlv_byte(resp, TLV_STATUS, status); + fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(message), message); + fill_wrapper_tlv_bytes(resp, TLV_LOOP_BACK_SERVER_PORT, strlen(tool_udp_port), tool_udp_port); + + return 0; +} + +// RESP: {: '0', : 'Loopback server in idle state'} +static int stop_loop_back_server_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { + /* Stop loopback */ + if (loopback_server_status()) { + loopback_server_stop(); + } + fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq); + fill_wrapper_tlv_byte(resp, TLV_STATUS, TLV_VALUE_STATUS_OK); + fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(TLV_VALUE_LOOP_BACK_STOP_OK), TLV_VALUE_LOOP_BACK_STOP_OK); + + return 0; +} + static int send_ap_arp_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { struct tlv_hdr *tlv; char target_ip[64]; @@ -1113,8 +1226,9 @@ static int send_ap_arp_handler(struct packet_wrapper *req, struct packet_wrapper int delete_sta_if = 0; static int stop_sta_handler(struct packet_wrapper *req, struct packet_wrapper *resp) { - int len = 0, reset = 0; - char buffer[S_BUFFER_LEN*2], reset_type[16], buffer1[S_BUFFER_LEN], buffer2[S_BUFFER_LEN]; + int len = 0, reset = 0, id = 0; + char buffer[S_BUFFER_LEN*2], reset_type[16]; + char log_name[128], conf_name[128]; char *parameter[] = {"pidof", get_wpas_exec_file(), NULL}; char *message = NULL; struct tlv_hdr *tlv = NULL; @@ -1147,11 +1261,46 @@ static int stop_sta_handler(struct packet_wrapper *req, struct packet_wrapper *r /* Test case teardown case */ if (reset == RESET_TYPE_TEARDOWN) { + /* TLV: ADDITIONAL_TEST_PLATFORM_ID */ + tlv = find_wrapper_tlv_by_id(req, TLV_ADDITIONAL_TEST_PLATFORM_ID); + memset(buffer, 0, sizeof(buffer)); + if (tlv) { + memcpy(buffer, tlv->value, tlv->len); + additional_tp_id = atoi(buffer); + id = additional_tp_id & 0x0F; + indigo_logger(LOG_LEVEL_DEBUG, "Additional STA test platform id: %d", id); + } + /* Send supplicant conf and log to Tool */ if (tool_addr != NULL) { - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, get_wpas_conf_file()); - sleep(1); - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, WPAS_LOG_FILE); + if (additional_tp_id != 0) { + memset(conf_name, 0, sizeof(conf_name)); + memset(log_name, 0, sizeof(log_name)); + snprintf(conf_name, sizeof(conf_name),"/tmp/wpa_supplicant_add_tp_%d.conf", id); + snprintf(log_name, sizeof(log_name),"/tmp/supplicant_add_tp_%d.log", id); + + memset(buffer, 0, sizeof(buffer)); + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", get_wpas_conf_file(), conf_name); + system(buffer); + + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", WPAS_LOG_FILE, log_name); + system(buffer); + + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, conf_name); + sleep(1); + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, log_name); + + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", conf_name); + system(buffer); + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", log_name); + system(buffer); + /* reset additional_tp_id */ + additional_tp_id = 0; + } else { + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, get_wpas_conf_file()); + sleep(1); + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, WPAS_LOG_FILE); + } } else { indigo_logger(LOG_LEVEL_ERROR, "Can't get tool IP address"); } @@ -1173,37 +1322,50 @@ static int stop_sta_handler(struct packet_wrapper *req, struct packet_wrapper *r if (reset == RESET_TYPE_RECONFIGURE) { + /* TLV: ADDITIONAL_TEST_PLATFORM_ID */ + tlv = find_wrapper_tlv_by_id(req, TLV_ADDITIONAL_TEST_PLATFORM_ID); + memset(buffer, 0, sizeof(buffer)); + if (tlv) { + memcpy(buffer, tlv->value, tlv->len); + additional_tp_id = atoi(buffer); + id = additional_tp_id & 0x0F; + indigo_logger(LOG_LEVEL_DEBUG, "Additional STA test platform id: %d", id); + } reconf_count++; - /* Send intermediate supplicant conf and log to Tool */ + + /* Upload intermediate supplicant conf and log to Tool */ if (tool_addr != NULL) { - /* wpas conf file rename and send */ + memset(conf_name, 0, sizeof(conf_name)); + memset(log_name, 0, sizeof(log_name)); + + if (additional_tp_id != 0) { + snprintf(conf_name, sizeof(conf_name),"/tmp/wpa_supplicant_add_tp_%d_reconf_%d.conf", id, reconf_count); + snprintf(log_name, sizeof(log_name),"/tmp/supplicant_add_tp_%d_reconf_%d.log", id, reconf_count); + /* reset additional_tp_id */ + additional_tp_id = 0; + } else { + snprintf(conf_name, sizeof(conf_name),"/tmp/wpa_supplicant_reconf_%d.conf", reconf_count); + snprintf(log_name, sizeof(log_name),"/tmp/supplicant_reconf_%d.log", reconf_count); + } + memset(buffer, 0, sizeof(buffer)); - memset(buffer1, 0, sizeof(buffer1)); - snprintf(buffer1, sizeof(buffer1), "%s.reconfig_%d", get_wpas_conf_file(), reconf_count); - snprintf(buffer, sizeof(buffer), "mv %s %s", get_wpas_conf_file(), buffer1); + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", get_wpas_conf_file(), conf_name); system(buffer); - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, buffer1); - sleep(1); - /* wpas log file rename and send */ - memset(buffer, 0, sizeof(buffer)); - memset(buffer2, 0, sizeof(buffer2)); - snprintf(buffer2, sizeof(buffer2), "%s.reconfig_%d", WPAS_LOG_FILE, reconf_count); - snprintf(buffer, sizeof(buffer), "mv %s %s", WPAS_LOG_FILE, buffer2); + + snprintf(buffer, sizeof(buffer),"cp %s %s 1>/dev/null 2>/dev/null", WPAS_LOG_FILE, log_name); system(buffer); - http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, buffer2); + + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, conf_name); sleep(1); + http_file_post(inet_ntoa(tool_addr->sin_addr), TOOL_POST_PORT, WPAS_UPLOAD_API, log_name); + + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", conf_name); + system(buffer); + snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", log_name); + system(buffer); } else { indigo_logger(LOG_LEVEL_ERROR, "Can't get tool IP address"); } - len = unlink(buffer1); - if (len) { - indigo_logger(LOG_LEVEL_DEBUG, "Failed to remove %s", buffer1); - } - - /* clean the log */ - memset(buffer, 0, sizeof(buffer)); - snprintf(buffer, sizeof(buffer), "rm -rf %s >/dev/null 2>/dev/null", buffer2); - system(buffer); } len = reset_interface_ip(get_wireless_interface()); diff --git a/utils.c b/utils.c index 9efcaf1..d152fb4 100644 --- a/utils.c +++ b/utils.c @@ -695,7 +695,7 @@ int send_icmp_data(char *target_ip, int packet_count, int packet_size, double ra indigo_logger(LOG_LEVEL_INFO, "icmp echo reply from %s, Receive echo %d bytes data", target_ip, n - 20); pkt_rcv++; } else { - indigo_logger(LOG_LEVEL_INFO, "Received packet is not the ICMP reply from the DUT"); + indigo_logger(LOG_LEVEL_INFO, "Received packet is not the ICMP reply from the Destination"); } } usleep(rate * 1000000); @@ -1750,3 +1750,9 @@ int http_file_post(char *host, int port, char *path, char *file_name) { close(socketfd); } } + +int file_exists(const char *fname) +{ + struct stat s; + return stat(fname, &s) == 0; +} diff --git a/utils.h b/utils.h index 609cd53..9807670 100644 --- a/utils.h +++ b/utils.h @@ -26,6 +26,7 @@ #define TOOL_POST_PORT 8080 #define HAPD_UPLOAD_API "/upload-platform-hapd-log" #define WPAS_UPLOAD_API "/upload-platform-wpas-log" +#define ARTIFACTS_UPLOAD_API "/upload-test-artifacts" #ifdef _DUT_ #define APP_LOG_FILE "controlappc_DUT.log" #else @@ -225,4 +226,5 @@ int get_6g_center_freq_index(int channel, int width); int is_ht40plus_chan(int chan); int is_ht40minus_chan(int chan); int http_file_post(char *host, int port, char *path, char *file_name); +int file_exists(const char *fname); #endif