static void peer_free(gpointer data) { struct connman_peer *peer = data; reply_pending(peer, ENOENT); connman_peer_unregister(peer); if (peer->path) { g_free(peer->path); peer->path = NULL; } if (peer->ipconfig) { __connman_ipconfig_set_ops(peer->ipconfig, NULL); __connman_ipconfig_set_data(peer->ipconfig, NULL); __connman_ipconfig_unref(peer->ipconfig); peer->ipconfig = NULL; } stop_dhcp_server(peer); if (peer->device) { connman_device_unref(peer->device); peer->device = NULL; } if (peer->services) connman_peer_reset_services(peer); g_free(peer->identifier); g_free(peer->name); g_free(peer); }
static int jolla_gps_init() { DBG(""); connection = connman_dbus_get_connection(); if (connection == NULL) { connman_warn("Failed to get dbus connection"); return -EIO; } watch = g_dbus_add_service_watch(connection, JOLLA_SERVICE, jolla_gps_connect, jolla_gps_disconnect, NULL, NULL); if (watch == 0) { connman_warn("Failed to add jolla service watcher"); dbus_connection_unref(connection); return -EIO; } device_watch = g_dbus_add_signal_watch(connection, JOLLA_SERVICE, JOLLA_DEVICE_PATH, JOLLA_DEVICE_INTERFACE, PROPERTY_CHANGED, device_changed, NULL, NULL); if (device_watch == 0) { connman_warn("Failed to add jolla device property changed signal watcher"); g_dbus_remove_watch(connection, watch); dbus_connection_unref(connection); return -EIO; } if (connman_technology_driver_register(&tech_driver) < 0) { connman_warn("Failed to initialize technology for Jolla GPS"); g_dbus_remove_watch(connection, device_watch); g_dbus_remove_watch(connection, watch); dbus_connection_unref(connection); return -EIO; } if (connman_device_driver_register(&device_driver) < 0) { connman_warn("Failed to initialize device driver for " JOLLA_SERVICE); connman_technology_driver_unregister(&tech_driver); g_dbus_remove_watch(connection, device_watch); g_dbus_remove_watch(connection, watch); dbus_connection_unref(connection); return -EIO; } jolla_gps_device = connman_device_create("gps", CONNMAN_DEVICE_TYPE_GPS); if (jolla_gps_device == NULL) { connman_warn("Failed to creat GPS device"); return -ENODEV; } if (connman_device_register(jolla_gps_device) < 0) { connman_warn("Failed to register GPS device"); connman_device_unref(jolla_gps_device); jolla_gps_device = NULL; return -EIO; } return 0; }
static void hh2serial_exit(void) { if (hh2serial_device != NULL) { connman_device_unregister(hh2serial_device); connman_device_unref(hh2serial_device); } }
static void mk3_remove(struct connman_device *device) { struct mk3_data *mk3 = NULL; DBG("device %p", device); g_return_if_fail(device); mk3 = connman_device_get_data(device); if(!mk3) { connman_error("Could not get device data"); return; } DBG("device %p data %p", device, mk3); delete_network(mk3); connman_device_set_data(device, NULL); connman_device_unref(mk3->device); g_free(mk3->devname); g_free(mk3->group); g_free(mk3->name); g_free(mk3->ident); g_free(mk3); }
static void hh2serial_exit(void) { if (hh2serial_device) { connman_device_unregister(hh2serial_device); connman_device_unref(hh2serial_device); } connman_device_driver_unregister(&hh2serial_device_driver); }
static void unregister_device(gpointer data) { struct connman_device *device = data; DBG(""); remove_device_networks(device); connman_device_unregister(device); connman_device_unref(device); }
static void device_free(gpointer data) { struct connman_device *device = data; GDBusProxy *proxy = connman_device_get_data(device); connman_device_set_data(device, NULL); if (proxy) g_dbus_proxy_unref(proxy); connman_device_unregister(device); connman_device_unref(device); }
static void jolla_gps_exit() { DBG(""); if (jolla_gps_device != NULL) { connman_device_unregister(jolla_gps_device); connman_device_unref(jolla_gps_device); jolla_gps_device = NULL; } connman_device_driver_unregister(&device_driver); connman_technology_driver_unregister(&tech_driver); }
static void add_interface_reply(DBusPendingCall *call, void *user_data) { struct supplicant_task *task = user_data; DBusMessage *reply; DBusError error; const char *path; _DBG_SUPPLICANT("task %p", task); reply = dbus_pending_call_steal_reply(call); if (reply == NULL) return; if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) goto failed; dbus_error_init(&error); if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) { if (dbus_error_is_set(&error) == TRUE) { connman_error("%s", error.message); dbus_error_free(&error); } else connman_error("Wrong arguments for add interface"); goto failed; } _DBG_SUPPLICANT("path %s", path); task->path = g_strdup(path); task->created = TRUE; connman_device_set_powered(task->device, TRUE); dbus_message_unref(reply); return; failed: dbus_message_unref(reply); task_list = g_slist_remove(task_list, task); connman_device_unref(task->device); free_task(task); }
static void detect_dellink(unsigned short type, int index, unsigned flags, unsigned change) { struct connman_device *device; DBG("type %d index %d", type, index); device = find_device(index); if (device == NULL) return; device_list = g_slist_remove(device_list, device); connman_device_unregister(device); connman_device_unref(device); }
void __connman_detect_cleanup(void) { GSList *list; DBG(""); connman_rtnl_unregister(&detect_rtnl); for (list = device_list; list; list = list->next) { struct connman_device *device = list->data; connman_device_unregister(device); connman_device_unref(device); } g_slist_free(device_list); device_list = NULL; }
static void remove_interface_reply(DBusPendingCall *call, void *user_data) { struct supplicant_task *task = user_data; DBusMessage *reply; _DBG_SUPPLICANT("task %p", task); reply = dbus_pending_call_steal_reply(call); connman_device_set_powered(task->device, FALSE); connman_device_unref(task->device); connman_inet_ifdown(task->ifindex); free_task(task); dbus_message_unref(reply); }
static void detect_newlink(unsigned short type, int index, unsigned flags, unsigned change) { struct connman_device *device; enum connman_device_type devtype; DBG("type %d index %d", type, index); devtype = __connman_rtnl_get_device_type(index); switch (devtype) { case CONNMAN_DEVICE_TYPE_UNKNOWN: case CONNMAN_DEVICE_TYPE_VENDOR: case CONNMAN_DEVICE_TYPE_WIMAX: case CONNMAN_DEVICE_TYPE_BLUETOOTH: case CONNMAN_DEVICE_TYPE_CELLULAR: case CONNMAN_DEVICE_TYPE_GPS: return; case CONNMAN_DEVICE_TYPE_ETHERNET: case CONNMAN_DEVICE_TYPE_WIFI: case CONNMAN_DEVICE_TYPE_GADGET: break; } device = find_device(index); if (device != NULL) return; device = connman_inet_create_device(index); if (device == NULL) return; if (connman_device_register(device) < 0) { connman_device_unref(device); return; } device_list = g_slist_prepend(device_list, device); }
static void reset_autoscan(struct connman_device *device) { struct wifi_data *wifi = connman_device_get_data(device); struct autoscan_params *autoscan; DBG(""); if (wifi == NULL || wifi->autoscan == NULL) return; autoscan = wifi->autoscan; if (autoscan->timeout == 0 && autoscan->interval == 0) return; g_source_remove(autoscan->timeout); autoscan->timeout = 0; autoscan->interval = 0; connman_device_unref(device); }
static int hh2serial_init(void) { int err; err = connman_device_driver_register(&hh2serial_device_driver); if (err < 0) return err; hh2serial_device = connman_device_create("hh2serial_gps", CONNMAN_DEVICE_TYPE_GPS); if (!hh2serial_device) { connman_device_driver_unregister(&hh2serial_device_driver); return -ENODEV; } err = connman_device_register(hh2serial_device); if (err < 0) { connman_device_unref(hh2serial_device); return err; } return 0; }
static void wifi_remove(struct connman_device *device) { struct wifi_data *wifi = connman_device_get_data(device); DBG("device %p wifi %p", device, wifi); if (wifi == NULL) return; iface_list = g_list_remove(iface_list, wifi); remove_networks(device, wifi); connman_device_set_powered(device, FALSE); connman_device_set_data(device, NULL); connman_device_unref(wifi->device); connman_rtnl_remove_watch(wifi->watch); g_supplicant_interface_set_data(wifi->interface, NULL); g_free(wifi->autoscan); g_free(wifi->identifier); g_free(wifi); }
static void adapter_properties_reply(DBusPendingCall *call, void *user_data) { char *path = user_data; struct connman_device *device; DBusMessage *reply; DBusMessageIter networks; const char *address = NULL, *name = NULL; dbus_bool_t powered = FALSE, scanning = FALSE; struct ether_addr addr; char ident[13]; DBG("path %s", path); reply = dbus_pending_call_steal_reply(call); if (path == NULL) goto done; extract_properties(reply, NULL, &address, &name, NULL, &powered, &scanning, NULL, &networks); if (address == NULL) goto done; if (g_strcmp0(address, "00:00:00:00:00:00") == 0) goto done; device = g_hash_table_lookup(bluetooth_devices, path); if (device != NULL) goto update; ether_aton_r(address, &addr); snprintf(ident, 13, "%02x%02x%02x%02x%02x%02x", addr.ether_addr_octet[0], addr.ether_addr_octet[1], addr.ether_addr_octet[2], addr.ether_addr_octet[3], addr.ether_addr_octet[4], addr.ether_addr_octet[5]); device = connman_device_create("bluetooth_legacy", CONNMAN_DEVICE_TYPE_BLUETOOTH); if (device == NULL) goto done; g_hash_table_insert(bluetooth_devices, g_strdup(path), device); connman_device_set_ident(device, ident); connman_device_set_string(device, "Path", path); if (connman_device_register(device) < 0) { connman_device_unref(device); g_hash_table_remove(bluetooth_devices, path); goto done; } update: connman_device_set_string(device, "Address", address); connman_device_set_string(device, "Name", name); connman_device_set_string(device, "Path", path); connman_device_set_powered(device, powered); connman_device_set_scanning(device, scanning); if (powered == FALSE) { remove_device_networks(device); add_pending_networks(path, &networks); } else check_networks(&networks); done: dbus_message_unref(reply); dbus_pending_call_unref(call); }