diff options
Diffstat (limited to 'network/server.c')
| -rw-r--r-- | network/server.c | 20 | 
1 files changed, 19 insertions, 1 deletions
| diff --git a/network/server.c b/network/server.c index b7806fa8..9dc8eb0b 100644 --- a/network/server.c +++ b/network/server.c @@ -78,6 +78,7 @@ struct network_server {  	uint32_t		record_id;	/* Service record id */  	uint16_t		id;		/* Service class identifier */  	DBusConnection		*conn;		/* D-Bus connection */ +	GSList			*clients;	/* Active connections */  };  static char netdev[16] = "bnep%d"; @@ -329,6 +330,8 @@ static void authorization_callback(DBusPendingCall *pcall, void *data)  	bnep_if_up(devname, TRUE);  	bnep_if_up("pan0", TRUE); +	ns->clients = g_slist_append(ns->clients, g_strdup(pending_auth->addr)); +  	/* FIXME: Enable routing if applied */  	/* FIXME: send the D-Bus message to notify the new bnep iface */ @@ -459,7 +462,6 @@ static gboolean connect_setup_event(GIOChannel *chan,  		goto reply;  	} -  	/*  	 * FIXME: Check if the connection already exists. Check if the  	 * BNEP SPEC allows return "connection not allowed" for this case @@ -828,6 +830,15 @@ static DBusHandlerResult enable(DBusConnection *conn,  	return send_message_and_unref(conn, reply);  } +static void kill_connection(void *data, void *udata) +{ +	const char *address = data; +	bdaddr_t dst; + +	str2ba(address, &dst); +	bnep_kill_connection(&dst); +} +  static DBusHandlerResult disable(DBusConnection *conn,  					DBusMessage *msg, void *data)  { @@ -849,6 +860,8 @@ static DBusHandlerResult disable(DBusConnection *conn,  	ns->enable = FALSE; +	g_slist_foreach(ns->clients, (GFunc) kill_connection, NULL); +  	store_property(&ns->src, ns->id, "enabled", "0");  	dbus_connection_emit_signal(conn, ns->path, NETWORK_SERVER_INTERFACE, @@ -1063,6 +1076,11 @@ static void server_free(struct network_server *ns)  	if (ns->conn)  		dbus_connection_unref(ns->conn); +	if (ns->clients) { +		g_slist_foreach(ns->clients, (GFunc) g_free, NULL); +		g_slist_free(ns->clients); +	} +  	g_free(ns);  } | 
