#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
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,
= "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]
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();
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);
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);
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();
}
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();
}
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();
}
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();
}
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();
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();
}
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();
}
[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,
};
#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"
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,
= "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]
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];
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);
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);
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();
}
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();
}
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();
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();
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();
}
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();
}
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();
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();
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();
}
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();
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();
[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,