static DBusMessage *disconnect_device(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; struct network_server *ns = data; struct network_session *session; const char *addr, *devname; bdaddr_t dst_addr; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &addr, DBUS_TYPE_STRING, &devname, DBUS_TYPE_INVALID)) return NULL; str2ba(addr, &dst_addr); session = find_session_by_addr(ns->sessions, dst_addr); if (!session) return btd_error_failed(msg, "No active session"); if (session->io) { bnep_if_down(devname); bnep_kill_connection(&dst_addr); } else return btd_error_not_connected(msg); reply = dbus_message_new_method_return(msg); if (!reply) return NULL; return reply; }
static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond, gpointer data) { struct network_conn *nc = data; if (connection != NULL) { gboolean connected = FALSE; const char *property = ""; emit_property_changed(connection, nc->peer->path, NETWORK_PEER_INTERFACE, "Connected", DBUS_TYPE_BOOLEAN, &connected); emit_property_changed(connection, nc->peer->path, NETWORK_PEER_INTERFACE, "Interface", DBUS_TYPE_STRING, &property); emit_property_changed(connection, nc->peer->path, NETWORK_PEER_INTERFACE, "UUID", DBUS_TYPE_STRING, &property); device_remove_disconnect_watch(nc->peer->device, nc->dc_id); nc->dc_id = 0; if (nc->watch) { g_dbus_remove_watch(connection, nc->watch); nc->watch = 0; } } info("%s disconnected", nc->dev); bnep_if_down(nc->dev); nc->state = DISCONNECTED; memset(nc->dev, 0, sizeof(nc->dev)); strcpy(nc->dev, "bnep%d"); return FALSE; }
static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond, gpointer data) { struct network_conn *nc = data; DBusConnection *conn = btd_get_dbus_connection(); const char *path = device_get_path(nc->peer->device); g_dbus_emit_property_changed(conn, path, NETWORK_PEER_INTERFACE, "Connected"); g_dbus_emit_property_changed(conn, path, NETWORK_PEER_INTERFACE, "Interface"); g_dbus_emit_property_changed(conn, path, NETWORK_PEER_INTERFACE, "UUID"); device_remove_disconnect_watch(nc->peer->device, nc->dc_id); nc->dc_id = 0; btd_service_disconnecting_complete(nc->service, 0); info("%s disconnected", nc->dev); bnep_if_down(nc->dev); nc->state = DISCONNECTED; memset(nc->dev, 0, sizeof(nc->dev)); strcpy(nc->dev, "bnep%d"); return FALSE; }
void bnep_server_delete(char *bridge, char *iface, const bdaddr_t *addr) { if (!bridge || !iface || !addr) return; bnep_del_from_bridge(iface, bridge); bnep_if_down(iface); bnep_conndel(addr); }
static void connection_destroy(DBusConnection *conn, void *user_data) { struct network_conn *nc = user_data; if (nc->state == CONNECTED) { bnep_if_down(nc->dev); bnep_kill_connection(&nc->peer->dst); } else if (nc->io) cancel_connection(nc, NULL); }
static void connection_destroy(DBusConnection *conn, void *user_data) { struct network_conn *nc = user_data; if (nc->state == CONNECTED) { bnep_if_down(nc->dev); bnep_kill_connection(device_get_address(nc->peer->device)); } else if (nc->io) cancel_connection(nc, -EIO); }
void bnep_disconnect(struct bnep *session) { if (!session) return; if (session->watch > 0) { g_source_remove(session->watch); session->watch = 0; } if (session->io) { g_io_channel_unref(session->io); session->io = NULL; } bnep_if_down(session->iface); bnep_conndel(&session->dst_addr); }