Return errors to caller
[platform/core/connectivity/stc-manager.git] / src / stc-manager-plugin-tether.c
old mode 100644 (file)
new mode 100755 (executable)
index 1813e40..4c5e528
@@ -65,3 +65,66 @@ int stc_plugin_tether_deinit(void)
        __STC_LOG_FUNC_EXIT__;
        return STC_ERROR_NONE;
 }
+
+API int stc_plugin_tether_get_station_ip(const char *mac, char **ipaddr)
+{
+       char ip[INET_ADDRSTRLEN+1];
+
+       if (!stc_tether_plugin_enabled ||
+               mac == NULL || ipaddr == NULL) {
+               if (STC_DEBUG_LOG)
+                       STC_LOGE("invalid args");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(ip, 0, sizeof(ip));
+
+       if (plugin->get_station_ip(mac, ip) != STC_ERROR_NONE)
+               return STC_ERROR_FAIL;
+
+       *ipaddr = g_strdup(ip);
+       STC_LOGI("station ip(%s)", *ipaddr);
+
+       return STC_ERROR_NONE;
+}
+
+API int stc_plugin_tether_get_station_by_classid(const int classid, char **mac)
+{
+       __STC_LOG_FUNC_ENTER__;
+       char mac_addr[STATION_MAC_STR_LEN+1];
+
+       if (!stc_tether_plugin_enabled || mac == NULL) {
+               if (STC_DEBUG_LOG)
+                       STC_LOGE("invalid args");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(mac_addr, 0, sizeof(mac_addr));
+
+       if (plugin->get_station_by_classid(classid, mac_addr) != STC_ERROR_NONE)
+               return STC_ERROR_FAIL;
+
+       *mac = g_strdup(mac_addr);
+       STC_LOGI("station mac(%s)", *mac);
+
+       return STC_ERROR_NONE;
+}
+
+API int stc_plugin_tether_set_station_classid(const char *mac, int classid)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_tether_plugin_enabled || mac == NULL) {
+               if (STC_DEBUG_LOG)
+                       STC_LOGE("invalid args");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (plugin->set_station_classid(mac, classid) != STC_ERROR_NONE)
+               return STC_ERROR_FAIL;
+
+       STC_LOGI("classid(%d) for station mac(%s) is set successfully",
+                       classid, mac);
+
+       return STC_ERROR_NONE;
+}