Add multi interfaces function
[platform/core/connectivity/net-config.git] / src / utils / util.c
index 363f6ef..e139ab8 100755 (executable)
@@ -50,7 +50,6 @@
 #define DBUS_INTERFACE_DBUS            "org.freedesktop.DBus"
 #define MAC_INFO_FILEPATH              tzplatform_mkpath(TZ_SYS_ETC, "/.mac.info")
 #define MAC_ADDRESS_FILEPATH   "/sys/class/net/wlan0/address"
-#define MAC_ADDRESS_MAX_LEN            18
 #define HEADED_PLUGIN_FILEPATH         "/usr/lib/net-config-plugin-headed.so"
 #define TELEPHONY_PLUGIN_FILEPATH      "/usr/lib/net-config-plugin-telephony.so"
 #define STC_PLUGIN_FILEPATH            "/usr/lib/net-config-plugin-stc.so"
@@ -79,6 +78,32 @@ static struct netconfig_battery_plugin_t *battery_plugin;
 static bool is_feature_checked[NETCONFIG_SUPPORTED_FEATURE_MAX] = {0, };
 static bool feature_supported[NETCONFIG_SUPPORTED_FEATURE_MAX] = {0, };
 
+gboolean netconfig_check_mac_address(const char *service, const char *mac_address)
+{
+       int service_index = 0;
+       int mac_index = 0;
+       const char *org = NULL;
+       const char *dst = NULL;
+       int i = 0;
+
+       if (g_str_has_prefix(service, "wifi_") == FALSE)
+               return FALSE;
+
+       service_index = strlen("wifi_");
+       for (i = 0; i < 6; i++) {
+               org = &service[service_index];
+               dst = &mac_address[mac_index];
+
+               if (g_ascii_strncasecmp(org, dst, 2) != 0)
+                       return FALSE;
+
+               service_index += 2;
+               mac_index += 3;
+       }
+
+       return TRUE;
+}
+
 gboolean netconfig_check_passphrase(const gchar *service, const char *passphrase)
 {
        gsize length;
@@ -1277,7 +1302,8 @@ void netconfig_set_vconf_int(const char * key, int value)
 {
        int ret = 0;
 
-       DBG("[%s: %d]", key, value);
+       if (g_strcmp0(key, VCONFKEY_WIFI_TRANSFER_STATE) != 0)
+               DBG("[%s: %d]", key, value);
 
        ret = vconf_set_int(key, value);
        if (ret != VCONF_OK)