Home | History | Annotate | Download | only in network

Lines Matching refs:nc

101 		struct network_conn *nc = list->data;
103 if (nc->id == id)
104 return nc;
113 struct network_conn *nc = data;
118 emit_property_changed(connection, nc->peer->path,
121 emit_property_changed(connection, nc->peer->path,
124 emit_property_changed(connection, nc->peer->path,
127 device_remove_disconnect_watch(nc->peer->device, nc->dc_id);
128 nc->dc_id = 0;
129 if (nc->watch) {
130 g_dbus_remove_watch(connection, nc->watch);
131 nc->watch = 0;
135 info("%s disconnected", nc->dev);
137 bnep_if_down(nc->dev);
138 nc->state = DISCONNECTED;
139 memset(nc->dev, 0, sizeof(nc->dev));
140 strcpy(nc->dev, "bnep%d");
145 static void cancel_connection(struct network_conn *nc, const char *err_msg)
149 if (nc->watch) {
150 g_dbus_remove_watch(connection, nc->watch);
151 nc->watch = 0;
154 if (nc->msg && err_msg) {
155 reply = btd_error_failed(nc->msg, err_msg);
159 g_io_channel_shutdown(nc->io, TRUE, NULL);
160 g_io_channel_unref(nc->io);
161 nc->io = NULL;
163 nc->state = DISCONNECTED;
168 struct network_conn *nc = user_data;
170 if (nc->state == CONNECTED) {
171 bnep_if_down(nc->dev);
172 bnep_kill_connection(&nc->peer->dst);
173 } else if (nc->io)
174 cancel_connection(nc, NULL);
180 struct network_conn *nc = user_data;
182 info("Network: disconnect %s", nc->peer->path);
190 struct network_conn *nc = data;
249 if (bnep_connadd(sk, BNEP_SVC_PANU, nc->dev)) {
250 error("%s could not be added", nc->dev);
254 bnep_if_up(nc->dev);
255 pdev = nc->dev;
256 uuid = bnep_uuid(nc->id);
258 g_dbus_send_reply(connection, nc->msg,
263 emit_property_changed(connection, nc->peer->path,
266 emit_property_changed(connection, nc->peer->path,
269 emit_property_changed(connection, nc->peer->path,
273 nc->state = CONNECTED;
274 nc->dc_id = device_add_disconnect_watch(nc->peer->device, disconnect_cb,
275 nc, NULL);
277 info("%s connected", nc->dev);
280 (GIOFunc) bnep_watchdog_cb, nc);
281 g_io_channel_unref(nc->io);
282 nc->io = NULL;
287 cancel_connection(nc, "bnep setup failed");
292 static int bnep_connect(struct network_conn *nc)
306 s->dst = htons(nc->id);
312 fd = g_io_channel_unix_get_fd(nc->io);
318 g_io_add_watch(nc->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
319 (GIOFunc) bnep_setup_cb, nc);
326 struct network_conn *nc = data;
336 perr = bnep_connect(nc);
346 cancel_connection(nc, err_msg);
354 struct network_conn *nc;
364 nc = find_connection(peer->connections, id);
365 if (!nc)
368 if (nc->state != DISCONNECTED)
371 nc->io = bt_io_connect(BT_IO_L2CAP, connect_cb, nc,
379 if (!nc->io) {
387 nc->state = CONNECTING;
388 nc->msg = dbus_message_ref(msg);
389 nc->watch = g_dbus_add_disconnect_watch(conn,
392 nc, NULL);
400 struct network_conn *nc = data;
401 const char *owner = dbus_message_get_sender(nc->msg);
407 connection_destroy(conn, nc);
419 struct network_conn *nc = l->data;
421 if (nc->state == DISCONNECTED)
424 return connection_cancel(conn, msg, nc);
434 struct network_conn *nc = NULL;
460 nc = tmp;
464 connected = nc ? TRUE : FALSE;
468 property = nc ? nc->dev : "";
472 property = nc ? bnep_uuid(nc->id) : "";
480 static void connection_free(struct network_conn *nc)
482 if (nc->dc_id)
483 device_remove_disconnect_watch(nc->peer->device, nc->dc_id);
485 connection_destroy(connection, nc);
487 g_free(nc);
488 nc = NULL;
527 struct network_conn *nc;
533 nc = find_connection(peer->connections, id);
534 if (!nc)
537 peer->connections = g_slist_remove(peer->connections, nc);
538 connection_free(nc);
578 struct network_conn *nc;
591 nc = find_connection(peer->connections, id);
592 if (nc)
595 nc = g_new0(struct network_conn, 1);
596 nc->id = id;
597 memset(nc->dev, 0, sizeof(nc->dev));
598 strcpy(nc->dev, "bnep%d");
599 nc->state = DISCONNECTED;
600 nc->peer = peer;
602 peer->connections = g_slist_append(peer->connections, nc);