Correct wrong variable name
authorCheoleun Moon <chleun.moon@samsung.com>
Wed, 8 Apr 2020 04:07:05 +0000 (13:07 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Wed, 8 Apr 2020 04:07:05 +0000 (13:07 +0900)
test/wifi-aware-publish-test.c
test/wifi-aware-subscribe-test.c

index 3a1eb75..1adec7b 100644 (file)
@@ -78,6 +78,7 @@
 #define PRINT_FAILURE_ERROR(format, error) printf(MAKE_RED format " Failure(%d:%s)\n" RESET_COLOR, error, __print_error(error))
 
 #define SERVICE_NAME "Wi-Fi Aware Test"
+#define OTHER_SERVICE_NAME "Other Service Name"
 #define PUB_SSI "Extra bytes in the publisher discovery"
 #define MSG_PUB_TO_SUB "Ready"
 #define PORT 1234
@@ -100,6 +101,10 @@ enum {
        CMD_PSK_SOLICITED,
        CMD_PMK_UNSOLICITED,
        CMD_PMK_SOLICITED,
+
+       CMD_OPEN_UNSOLICITED_OTHER_SERVICE,
+       CMD_OPEN_SOLICITED_OTHER_SERVICE,
+
        CMD_OPEN_UNSOLICITED_RANGING,
        CMD_OPEN_SOLICITED_RANGING,
 
@@ -121,6 +126,10 @@ static char *g_menu_str[] = {
                = "PMK + Unsolicited",
        [CMD_PMK_SOLICITED]
                = "PMK + Solicited",
+       [CMD_OPEN_UNSOLICITED_OTHER_SERVICE]
+               = "Open + Unsolicited + Other Service",
+       [CMD_OPEN_SOLICITED_OTHER_SERVICE]
+               = "Open + Solicited + Other Service",
        [CMD_OPEN_UNSOLICITED_RANGING]
                = "Open + Unsolicited + Ranging",
        [CMD_OPEN_SOLICITED_RANGING]
@@ -142,6 +151,7 @@ static wifi_aware_peer_h g_peer = NULL;
 static wifi_aware_publish_type_e g_pub_type;
 static wifi_aware_security_type_e g_security_type;
 
+static char g_service_name[MAX_SERVICE_NAME_LEN + 1] = {0, };
 static unsigned char g_pmk[PMK_LEN];
 
 void test_init();
@@ -438,7 +448,6 @@ static void __session_terminated_cb(wifi_aware_session_h session,
 static bool __set_publish_config(wifi_aware_publish_h publish)
 {
        int ret = 0;
-       char service_name[MAX_SERVICE_NAME_LEN + 1] = {0, };
        unsigned char specific_info[MAX_SPECIFIC_INFO_LEN + 1] = {0, };
 
        ret = wifi_aware_publish_set_type(publish, g_pub_type);
@@ -451,11 +460,9 @@ static bool __set_publish_config(wifi_aware_publish_h publish)
                return false;
        }
 
-       strncpy(service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
-       ret = wifi_aware_publish_set_service_name(publish,
-                       service_name);
+       ret = wifi_aware_publish_set_service_name(publish, g_service_name);
        if (ret == WIFI_AWARE_ERROR_NONE) {
-               printf("\tService Name: %s\n", SERVICE_NAME);
+               printf("\tService Name: %s\n", g_service_name);
        }
        else {
                PRINT_FAILURE_ERROR("\tService Name:", ret);
@@ -586,6 +593,7 @@ void test_open_unsolicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        run_common();
 }
@@ -595,6 +603,7 @@ void test_open_solicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_SOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        run_common();
 }
@@ -604,6 +613,7 @@ void test_psk_unsolicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        run_common();
 }
@@ -613,6 +623,7 @@ void test_psk_solicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_SOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        run_common();
 }
@@ -622,6 +633,7 @@ void test_pmk_unsolicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        memcpy(g_pmk, PMK, PMK_LEN);
        run_common();
@@ -632,16 +644,38 @@ void test_pmk_solicited()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_SOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = false;
        memcpy(g_pmk, PMK, PMK_LEN);
        run_common();
 }
 
+void test_open_unsolicited_other_service()
+{
+       clear_resources();
+       g_pub_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, OTHER_SERVICE_NAME, MAX_SERVICE_NAME_LEN);
+       g_ranging = false;
+       run_common();
+}
+
+void test_open_solicited_other_service()
+{
+       clear_resources();
+       g_pub_type = WIFI_AWARE_PUBLISH_TYPE_SOLICITED;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, OTHER_SERVICE_NAME, MAX_SERVICE_NAME_LEN);
+       g_ranging = false;
+       run_common();
+}
+
 void test_open_unsolicited_ranging()
 {
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = true;
        run_common();
 }
@@ -651,6 +685,7 @@ void test_open_solicited_ranging()
        clear_resources();
        g_pub_type = WIFI_AWARE_PUBLISH_TYPE_SOLICITED;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_ranging = true;
        run_common();
 }
@@ -684,8 +719,10 @@ test_func g_menu_func[] = {
        [CMD_PSK_SOLICITED]             = test_psk_solicited,
        [CMD_PMK_UNSOLICITED]   = test_pmk_unsolicited,
        [CMD_PMK_SOLICITED]             = test_pmk_solicited,
-       [CMD_OPEN_UNSOLICITED_RANGING]  = test_open_unsolicited_ranging,
-       [CMD_OPEN_SOLICITED_RANGING]            = test_open_solicited_ranging,
+       [CMD_OPEN_UNSOLICITED_OTHER_SERVICE]    = test_open_unsolicited_other_service,
+       [CMD_OPEN_SOLICITED_OTHER_SERVICE]              = test_open_solicited_other_service,
+       [CMD_OPEN_UNSOLICITED_RANGING]                  = test_open_unsolicited_ranging,
+       [CMD_OPEN_SOLICITED_RANGING]                    = test_open_solicited_ranging,
 
        [CMD_INVALID]                   = NULL,
 };
index c5f6b7d..b546051 100644 (file)
@@ -78,6 +78,7 @@
 #define PRINT_FAILURE_ERROR(format, error) printf(MAKE_RED format " Failure(%d:%s)" RESET_COLOR "\n", error, __print_error(error))
 
 #define SERVICE_NAME "Wi-Fi Aware Test"
+#define OTHER_SERVICE_NAME "Other Service Name"
 #define PUB_SSI "Extra bytes in the subscriber discovery"
 #define MSG_SUB_TO_PUB "Let's talk"
 
@@ -107,6 +108,10 @@ enum {
        CMD_WRONG_PSK_ACTIVE,
        CMD_WRONG_PMK_PASSIVE,
        CMD_WRONG_PMK_ACTIVE,
+
+       CMD_OPEN_PASSIVE_OTHER_SERVICE,
+       CMD_OPEN_ACTIVE_OTHER_SERVICE,
+
        CMD_OPEN_PASSIVE_RANGING,
        CMD_OPEN_ACTIVE_RANGING,
 
@@ -136,6 +141,10 @@ static char *g_menu_str[] = {
                = "PMK + Passive (Wrong password)",
        [CMD_WRONG_PMK_ACTIVE]
                = "PMK + Active (Wrong password)",
+       [CMD_OPEN_PASSIVE_OTHER_SERVICE]
+               = "Open + Passive + Other Service",
+       [CMD_OPEN_ACTIVE_OTHER_SERVICE]
+               = "Open + Active + Other Service",
        [CMD_OPEN_PASSIVE_RANGING]
                = "Open + Passive + Ranging",
        [CMD_OPEN_ACTIVE_RANGING]
@@ -157,6 +166,8 @@ static wifi_aware_peer_h g_peer = NULL;
 
 static wifi_aware_subscribe_type_e g_sub_type;
 static wifi_aware_security_type_e g_security_type;
+
+static char g_service_name[MAX_SERVICE_NAME_LEN + 1] = {0, };
 static char g_psk[MAX_PSK_LEN + 1];
 static unsigned char g_pmk[PMK_LEN];
 
@@ -493,7 +504,6 @@ static void __session_terminated_cb(wifi_aware_session_h session,
 static bool __set_subscribe_config(wifi_aware_subscribe_h subscribe)
 {
        int ret = 0;
-       char service_name[MAX_SERVICE_NAME_LEN + 1] = {0, };
        unsigned char specific_info[MAX_SPECIFIC_INFO_LEN + 1] = {0, };
 
        ret = wifi_aware_subscribe_set_type(subscribe, g_sub_type);
@@ -506,11 +516,10 @@ static bool __set_subscribe_config(wifi_aware_subscribe_h subscribe)
                return false;
        }
 
-       strncpy(service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        ret = wifi_aware_subscribe_set_service_name(subscribe,
-                       service_name);
+                       g_service_name);
        if (ret == WIFI_AWARE_ERROR_NONE) {
-               printf("\tService Name: %s\n", SERVICE_NAME);
+               printf("\tService Name: %s\n", g_service_name);
        }
        else {
                PRINT_FAILURE_ERROR("\tService Name:", ret);
@@ -663,6 +672,7 @@ void test_open_passive()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        run_common();
 }
 
@@ -671,6 +681,7 @@ void test_open_active()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        run_common();
 }
 
@@ -679,6 +690,7 @@ void test_psk_passive()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        strncpy(g_psk, PSK, MAX_PSK_LEN);
        g_psk[MAX_PSK_LEN] = '\0';
        run_common();
@@ -689,6 +701,7 @@ void test_psk_active()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        strncpy(g_psk, PSK, MAX_PSK_LEN);
        g_psk[MAX_PSK_LEN] = '\0';
        run_common();
@@ -699,6 +712,7 @@ void test_pmk_passive()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        memcpy(g_pmk, PMK, PMK_LEN);
        run_common();
 }
@@ -708,6 +722,7 @@ void test_pmk_active()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        memcpy(g_pmk, PMK, PMK_LEN);
        run_common();
 }
@@ -717,6 +732,7 @@ void test_wrong_psk_passive()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        strncpy(g_psk, WRONG_PSK, MAX_PSK_LEN);
        g_psk[MAX_PSK_LEN] = '\0';
        run_common();
@@ -727,6 +743,7 @@ void test_wrong_psk_active()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PSK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        strncpy(g_psk, WRONG_PSK, MAX_PSK_LEN);
        g_psk[MAX_PSK_LEN] = '\0';
        run_common();
@@ -737,6 +754,7 @@ void test_wrong_pmk_passive()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        memcpy(g_pmk, WRONG_PMK, PMK_LEN);
        run_common();
 }
@@ -746,15 +764,35 @@ void test_wrong_pmk_active()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_PMK;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        memcpy(g_pmk, WRONG_PMK, PMK_LEN);
        run_common();
 }
 
+void test_open_passive_other_service()
+{
+       clear_resources();
+       g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, OTHER_SERVICE_NAME, MAX_SERVICE_NAME_LEN);
+       run_common();
+}
+
+void test_open_active_other_service()
+{
+       clear_resources();
+       g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, OTHER_SERVICE_NAME, MAX_SERVICE_NAME_LEN);
+       run_common();
+}
+
 void test_open_passive_ranging()
 {
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_min_distance = 0;
        g_max_distance = 100000;
        run_common();
@@ -765,6 +803,7 @@ void test_open_active_ranging()
        clear_resources();
        g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
        g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       strncpy(g_service_name, SERVICE_NAME, MAX_SERVICE_NAME_LEN);
        g_min_distance = 0;
        g_max_distance = 100000;
        run_common();
@@ -803,6 +842,8 @@ test_func g_menu_func[] = {
        [CMD_WRONG_PSK_ACTIVE]          = test_wrong_psk_active,
        [CMD_WRONG_PMK_PASSIVE]         = test_wrong_pmk_passive,
        [CMD_WRONG_PMK_ACTIVE]          = test_wrong_pmk_active,
+       [CMD_OPEN_PASSIVE_OTHER_SERVICE]                        = test_open_passive_other_service,
+       [CMD_OPEN_ACTIVE_OTHER_SERVICE]                 = test_open_active_other_service,
        [CMD_OPEN_PASSIVE_RANGING]      = test_open_passive_ranging,
        [CMD_OPEN_ACTIVE_RANGING]       = test_open_active_ranging,