#define CHECK_GET_PRIVILEGE "CheckGetPrivilege"
#define CHECK_PROFILE_PRIVILEGE "CheckProfilePrivilege"
#define CHECK_INTERNET_Privilege "CheckInternetPrivilege"
+#define LAUNCH_MDNS "LaunchMdns"
#define DEVICE_POLICY_SET_WIFI "DevicePolicySetWifi"
#define DEVICE_POLICY_GET_WIFI "DevicePolicyGetWifi"
#define DEVICE_POLICY_SET_WIFI_PROFILE "DevicePolicySetWifiProfile"
return ERROR_NONE;
}
+error_e NetworkState::LaunchMdns(const char *name)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(NETCONFIG_SERVICE,
+ NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE,
+ LAUNCH_MDNS,
+ g_variant_new("(s)", name),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
error_e NetworkState::DevicePolicySetWifi(int state)
{
GVariant *message = NULL;
error_e RemoveRoute(const char *ip, const char *mask, const char *interface,
const char *gateway, int family, gboolean *result);
error_e EthernetCableState(int *state);
+ error_e LaunchMdns(const char *name);
error_e DevicePolicySetWifi(int state);
error_e DevicePolicyGetWifi(int *state);
error_e DevicePolicySetWifiProfile(int state);
EXPECT_NE(ERROR_NONE, ret);
}
+TEST(NetworkState, LaunchMdns_p)
+{
+ error_e ret = ERROR_NONE;
+ NetworkState mgr;
+ const char *name = "gtest";
+
+ ret = mgr.LaunchMdns(name);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(NetworkState, LaunchMdns_n)
+{
+ error_e ret = ERROR_NONE;
+ NetworkState mgr;
+ const char *name = "gtest";
+
+ ret = mgr.LaunchMdns(name);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
TEST(NetworkState, DevicePolicySetWifi_p1)
{
error_e ret = ERROR_NONE;
int netconfig_del_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gint address_family);
gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context,
+ gchar *name);
gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * data);
int netconfig_send_message_to_net_popup(const char *title,
<method name="CheckGetPrivilege"></method>
<method name="CheckProfilePrivilege"></method>
<method name="CheckInternetPrivilege"></method>
+ <method name="LaunchMdns">
+ <arg type="s" name="name" direction="in"/>
+ </method>
<method name="DevicePolicySetWifi">
<arg type="i" name="state" direction="in"/>
</method>
Name: net-config
Summary: TIZEN Network Configuration service
-Version: 1.2.9
+Version: 1.2.8
Release: 1
Group: System/Network
License: Apache-2.0
<policy context="default">
<deny own="net.netconfig"/>
<deny send_destination="net.netconfig"/>
+ <allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="LaunchMdns" />
+ <allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="UnrefMdns" />
<allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="DevicePolicyGetWifi" />
<allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="DevicePolicyGetWifiProfile" />
G_CALLBACK(handle_preferred_ipv6_address), NULL);
g_signal_connect(netconfigstate, "handle-remove-route",
G_CALLBACK(handle_remove_route), NULL);
+ g_signal_connect(netconfigstate, "handle-launch-mdns",
+ G_CALLBACK(handle_launch_mdns), NULL);
g_signal_connect(netconfigstate, "handle-device-policy-set-wifi",
G_CALLBACK(handle_device_policy_set_wifi), NULL);
g_signal_connect(netconfigstate, "handle-device-policy-get-wifi",
#define CONNMAN_WIFI_DEF_IFNAME "DefaultWifiInterface"
static gboolean netconfig_device_picker_test = FALSE;
+static int mdnsd_ref_count = 0;
typedef struct {
char *conn_name;
int conn_id;
return TRUE;
}
+int execute_mdnsd_script(char* op)
+{
+ const char *path = "/usr/bin/mdnsresponder-server.sh";
+ char *const args[] = { "mdnsresponder-server.sh", op, NULL };
+ char *const envs[] = { NULL };
+
+ return netconfig_execute_file(path, args, envs);
+}
+
+static void __dnssd_conn_destroyed_cb(GDBusConnection *conn,
+ const gchar *Name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ gchar *name = NULL;
+ gchar *old = NULL;
+ gchar *new = NULL;
+ dnssd_conn_destroy_data *data = user_data;
+ GDBusConnection *connection = NULL;
+ connection = netdbus_get_connection();
+
+ if (param == NULL)
+ return;
+
+ g_variant_get(param, "(sss)", &name, &old, &new);
+
+ if (g_strcmp0(name, data->conn_name) == 0 && *new == '\0') {
+ DBG("Connection %s Destroyed: name %s id %d", data->conn_name, name,
+ data->conn_id);
+ mdnsd_ref_count--;
+ g_dbus_connection_signal_unsubscribe(connection, data->conn_id);
+ if (mdnsd_ref_count == 0) {
+ if (execute_mdnsd_script("stop") < 0)
+ ERR("Failed to stop mdnsresponder daemon");
+ }
+ }
+ g_free(name);
+ g_free(old);
+ g_free(new);
+ g_free(data->conn_name);
+ g_free(data);
+ return;
+}
+
+static void register_dnssd_conn_destroy_signal(gchar *name)
+{
+ dnssd_conn_destroy_data *data;
+ GDBusConnection *connection = NULL;
+ connection = netdbus_get_connection();
+
+ if (connection == NULL) {
+ ERR("Failed to get GDbus Connection");
+ return;
+ }
+
+ data = g_try_malloc0(sizeof(dnssd_conn_destroy_data));
+
+ if (data == NULL) {
+ ERR("Out of Memory!");
+ return;
+ }
+
+ data->conn_name = g_strdup(name);
+
+ data->conn_id = g_dbus_connection_signal_subscribe(connection,
+ DBUS_SERVICE_DBUS, DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged", NULL, name,
+ G_DBUS_SIGNAL_FLAGS_NONE, __dnssd_conn_destroyed_cb,
+ data, NULL);
+ return;
+}
+
+gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context,
+ gchar *name)
+{
+ DBG("Launch mdnsresponder daemon");
+
+ if (execute_mdnsd_script("start") < 0) {
+ ERR("Failed to launch mdnsresponder daemon");
+ netconfig_error_invalid_parameter(context);
+ return TRUE;
+ }
+
+ mdnsd_ref_count++;
+ register_dnssd_conn_destroy_signal(name);
+ DBG("Ref mdnsresponder daemon. ref count: %d", mdnsd_ref_count);
+
+ network_complete_launch_mdns(object, context);
+ return TRUE;
+}
+
gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * ssid)
{
if (!netconfig_plugin_headed_enabled)