summaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-20 16:29:21 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-20 16:29:21 +0200
commitf3b51adb6b18a81ee59d064d87cfbccf5e5ec357 (patch)
tree2be223d1a2e7ff72af5ad6a4ffe9df58876cb38d /src/device.c
parent01dc94cf39e46ab095bd18940bdb171df09aff52 (diff)
downloadconnman-f3b51adb6b18a81ee59d064d87cfbccf5e5ec357.tar.gz
connman-f3b51adb6b18a81ee59d064d87cfbccf5e5ec357.tar.bz2
connman-f3b51adb6b18a81ee59d064d87cfbccf5e5ec357.zip
Remove support for CreateNetwork, RemoveNetwork and JoinNetwork
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c205
1 files changed, 0 insertions, 205 deletions
diff --git a/src/device.c b/src/device.c
index 4de39d52..60a04685 100644
--- a/src/device.c
+++ b/src/device.c
@@ -550,208 +550,6 @@ static DBusMessage *set_property(DBusConnection *conn,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-static void convert_name(const char *ssid, char *name,
- unsigned int ssid_len)
-{
- unsigned int i;
-
- for (i = 0; i < ssid_len; i++) {
- if (g_ascii_isprint(ssid[i]))
- name[i] = ssid[i];
- else
- name[i] = ' ';
- }
-}
-
-static struct connman_network *find_network(struct connman_device *device,
- const void *ssid, const char *address,
- const char *security, const char *mode)
-{
- GHashTableIter network_iter;
- gpointer key, value;
-
- if (ssid == NULL)
- return NULL;
-
- g_hash_table_iter_init(&network_iter, device->networks);
- while (g_hash_table_iter_next(&network_iter, &key, &value) == TRUE) {
- const void *tmp_ssid;
- const char *tmp_security, *tmp_mode, *tmp_address;
- unsigned int tmp_ssid_size;
-
- tmp_ssid = connman_network_get_blob(value, "WiFi.SSID",
- &tmp_ssid_size);
- tmp_security = connman_network_get_string(value,
- "WiFi.Security");
- tmp_mode = connman_network_get_string(value, "WiFi.Mode");
- tmp_address = connman_network_get_string(value, "Address");
-
- if (tmp_ssid_size < 1)
- continue;
-
- if (tmp_ssid && memcmp(ssid, tmp_ssid, tmp_ssid_size))
- continue;
-
- if (security && tmp_security &&
- g_strcmp0(security, tmp_security) != 0)
- continue;
-
- if (mode && tmp_mode && g_strcmp0(mode, tmp_mode) != 0)
- continue;
-
- if (address && tmp_address &&
- g_strcmp0(address, tmp_address) != 0)
- continue;
-
- return connman_network_ref(value);
- }
-
- return NULL;
-}
-
-static DBusMessage *join_network(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_device *device = data;
- struct connman_network *network, *found_network;
- enum connman_network_type type;
- unsigned int ssid_size;
- const char *group, *mode, *security, *address;
- const void *ssid;
- DBusMessageIter iter, array;
- int err, index;
-
- DBG("conn %p", conn);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- if (!device->driver || !device->driver->join)
- return __connman_error_not_supported(msg);
-
- dbus_message_iter_init(msg, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- switch (device->type) {
- case CONNMAN_DEVICE_TYPE_WIFI:
- type = CONNMAN_NETWORK_TYPE_WIFI;
- break;
- default:
- return __connman_error_not_supported(msg);
- }
-
- network = connman_network_create("00_00_00_00_00_00", type);
- if (network == NULL)
- return __connman_error_failed(msg, ENOMEM);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, value;
- const char *key, *str;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &value);
-
- switch (dbus_message_iter_get_arg_type(&value)) {
- case DBUS_TYPE_STRING:
- dbus_message_iter_get_basic(&value, &str);
- if (g_str_equal(key, "WiFi.SSID") == TRUE) {
- char *name;
-
- connman_network_set_blob(network, key,
- str, strlen(str));
- name = g_try_malloc0(strlen(str) + 1);
- if (name == NULL)
- return __connman_error_failed(msg,
- -ENOMEM);
-
- convert_name((char *) str, name, strlen(str));
- connman_network_set_name(network, name);
- g_free(name);
-
- } else
- connman_network_set_string(network, key, str);
- break;
- }
-
- dbus_message_iter_next(&array);
- }
-
- ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_size);
- security = connman_network_get_string(network, "WiFi.Security");
- mode = connman_network_get_string(network, "WiFi.Mode");
- address = connman_network_get_string(network, "Address");
-
- found_network = find_network(device, ssid, address, security, mode);
- if (found_network != NULL) {
- const char* passphrase;
-
- passphrase = connman_network_get_string(network,
- "WiFi.Passphrase");
- if (passphrase != NULL)
- connman_network_set_string(found_network,
- "WiFi.Passphrase",
- passphrase);
- connman_network_unref(network);
- network = found_network;
-
- err = __connman_network_connect(found_network);
-
- connman_network_unref(found_network);
-
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- }
-
- group = connman_wifi_build_group_name(ssid, ssid_size, mode, security);
-
- index = connman_device_get_index(device);
- connman_network_set_index(network, index);
-
- connman_network_set_protocol(network, CONNMAN_NETWORK_PROTOCOL_IP);
-
- if (connman_device_get_disconnected(device) == FALSE)
- __connman_device_disconnect(device);
-
- err = device->driver->join(device, network);
-
- connman_network_unref(network);
-
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static DBusMessage *create_network(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBG("conn %p", conn);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- return __connman_error_invalid_arguments(msg);
-}
-
-static DBusMessage *remove_network(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBG("conn %p", conn);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- return __connman_error_invalid_arguments(msg);
-}
-
static DBusMessage *propose_scan(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -780,9 +578,6 @@ static GDBusMethodTable device_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
{ "SetProperty", "sv", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC },
- { "JoinNetwork", "a{sv}", "", join_network },
- { "CreateNetwork", "a{sv}", "o", create_network },
- { "RemoveNetwork", "o", "", remove_network },
{ "ProposeScan", "", "", propose_scan },
{ },
};