+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_get_mac_address(connection_h connection, connection_type_e type, char** mac_addr)
+{
+ FILE *fp;
+ char buf[CONNECTION_MAC_INFO_LENGTH + 1];
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if (type == CONNECTION_TYPE_WIFI)
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ else if (type == CONNECTION_TYPE_ETHERNET) //LCOV_EXCL_LINE
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE); //LCOV_EXCL_LINE
+
+ if (mac_addr == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (type) {
+ case CONNECTION_TYPE_WIFI:
+#if defined TIZEN_TV
+ fp = fopen(WIFI_MAC_INFO_FILE, "r");
+ if (fp == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
+
+ *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+ if (*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
+ fclose(fp);
+#else
+ *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+
+ if (*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+#endif
+ break;
+ //LCOV_EXCL_START
+ case CONNECTION_TYPE_ETHERNET:
+ fp = fopen(ETHERNET_MAC_INFO_FILE, "r");
+ if (fp == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", ETHERNET_MAC_INFO_FILE);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", ETHERNET_MAC_INFO_FILE);
+ fclose(fp);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "%s : %s", ETHERNET_MAC_INFO_FILE, buf);
+
+ *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+ if (*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed");
+ fclose(fp);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
+ fclose(fp);
+
+ break;
+ //LCOV_EXCL_STOP
+ default :
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ /* Checking Invalid MAC Address */
+ if ((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
+ (strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr); //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE