Home | History | Annotate | Download | only in health

Lines Matching refs:mdl

68 	struct mcap_mdl		*mdl;		/* MDL for this operation */
87 static void default_mdl_connected_cb(struct mcap_mdl *mdl, gpointer data)
89 DBG("MCAP Unmanaged mdl connection");
92 static void default_mdl_closed_cb(struct mcap_mdl *mdl, gpointer data)
94 DBG("MCAP Unmanaged mdl closed");
97 static void default_mdl_deleted_cb(struct mcap_mdl *mdl, gpointer data)
99 DBG("MCAP Unmanaged mdl deleted");
102 static void default_mdl_aborted_cb(struct mcap_mdl *mdl, gpointer data)
104 DBG("MCAP Unmanaged mdl aborted");
111 DBG("MCAP mdl remote connection aborted");
116 static uint8_t default_mdl_reconn_req_cb(struct mcap_mdl *mdl,
119 DBG("MCAP mdl remote reconnection aborted");
151 return "Invalid MDL";
153 return "MDL Busy";
211 struct mcap_mdl *mdl;
217 mdl = l->data;
219 if (mdl->state == MDL_CONNECTED) {
228 static void shutdown_mdl(struct mcap_mdl *mdl)
230 mdl->state = MDL_CLOSED;
232 if (mdl->wid) {
233 g_source_remove(mdl->wid);
234 mdl->wid = 0;
237 if (mdl->dc) {
238 g_io_channel_shutdown(mdl->dc, TRUE, NULL);
239 g_io_channel_unref(mdl->dc);
240 mdl->dc = NULL;
244 static void free_mdl(struct mcap_mdl *mdl)
246 if (!mdl)
249 mcap_mcl_unref(mdl->mcl);
250 g_free(mdl);
255 const struct mcap_mdl *mdl = a;
258 if (mdl->state == *st)
260 else if (mdl->state < *st)
271 if (op->mdl)
272 mcap_mdl_unref(op->mdl);
286 struct mcap_mdl *mdl;
297 mdl = l->data;
298 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
299 mcap_mdl_unref(mdl);
312 mdl = l->data;
313 if (mdl->state == MDL_DELETING)
314 mdl->state = (mdl->dc) ? MDL_CONNECTED :
350 uint16_t mdl, uint8_t *data, size_t len)
363 cmd->mdl = htons(mdl);
377 struct mcap_mdl *mdl;
380 mdl = l->data;
381 if (mdlid == mdl->mdlid)
382 return mdl;
391 struct mcap_mdl *mdl;
394 mdl = get_mdl(mcl, mdlid);
395 if (!mdl) {
413 req_cmd->mdl = htons(mdl_id);
426 req_mdl->mdl = htons(mdl_id);
474 struct mcap_mdl *mdl;
486 mdl = g_new0(struct mcap_mdl, 1);
487 mdl->mcl = mcap_mcl_ref(mcl);
488 mdl->mdlid = id;
489 mdl->mdep_id = mdepid;
490 mdl->state = MDL_WAITING;
493 con->mdl = mcap_mdl_ref(mdl);
501 mcap_mdl_unref(con->mdl);
510 mcl->mdls = g_slist_insert_sorted(mcl->mdls, mcap_mdl_ref(mdl),
517 gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl,
524 struct mcap_mcl *mcl = mdl->mcl;
527 if (mdl->state != MDL_CLOSED) {
529 "MDL is not closed");
533 cmd = create_req(MCAP_MD_RECONNECT_MDL_REQ, mdl->mdlid);
539 mdl->state = MDL_WAITING;
542 con->mdl = mcap_mdl_ref(mdl);
582 struct mcap_mdl *mdl;
593 mdl = l->data;
594 if (mdl->state != MDL_WAITING)
595 mdl->state = MDL_DELETING;
599 con->mdl = NULL;
613 gboolean mcap_delete_mdl(struct mcap_mdl *mdl, mcap_mdl_notify_cb delete_cb,
618 struct mcap_mcl *mcl= mdl->mcl;
622 l = g_slist_find(mcl->mdls, mdl);
630 if (mdl->state == MDL_WAITING) {
632 "Mdl is not created");
636 mdl->state = MDL_DELETING;
639 con->mdl = mcap_mdl_ref(mdl);
644 if (!send_delete_req(mcl, con, mdl->mdlid, err)) {
645 mcap_mdl_unref(con->mdl);
653 gboolean mcap_mdl_abort(struct mcap_mdl *mdl, mcap_mdl_notify_cb abort_cb,
659 struct mcap_mcl *mcl = mdl->mcl;
662 if (mdl->state != MDL_WAITING) {
664 "Mdl in invalid state");
668 cmd = create_req(MCAP_MD_ABORT_MDL_REQ, mdl->mdlid);
675 con->mdl = mcap_mdl_ref(mdl);
700 int mcap_mdl_get_fd(struct mcap_mdl *mdl)
702 if (!mdl || mdl->state != MDL_CONNECTED)
705 return g_io_channel_unix_get_fd(mdl->dc);
708 uint16_t mcap_mdl_get_mdlid(struct mcap_mdl *mdl)
710 if (!mdl)
713 return mdl->mdlid;
953 struct mcap_mdl *mdl = elem;
956 shutdown_mdl(mdl);
958 mdl->mcl->cb->mdl_deleted(mdl, mdl->mcl->cb->user_data);
960 mcap_mdl_unref(mdl);
972 mdl_id = ntohs(req->mdl);
988 struct mcap_mdl *mdl;
999 mdl_id = ntohs(req->mdl);
1013 mdl = get_mdl(mcl, mdl_id);
1014 if (mdl && (mdl->state == MDL_WAITING || mdl->state == MDL_DELETING )) {
1015 /* Creation request arrives for a MDL that is being managed
1045 if (!mdl) {
1046 mdl = g_new0(struct mcap_mdl, 1);
1047 mdl->mcl = mcap_mcl_ref(mcl);
1048 mdl->mdlid = mdl_id;
1049 mcl->mdls = g_slist_insert_sorted(mcl->mdls, mcap_mdl_ref(mdl),
1051 } else if (mdl->state == MDL_CONNECTED) {
1054 shutdown_mdl(mdl);
1057 mdl->mdep_id = mdep_id;
1058 mdl->state = MDL_WAITING;
1069 struct mcap_mdl *mdl;
1078 mdl_id = ntohs(req->mdl);
1080 mdl = get_mdl(mcl, mdl_id);
1081 if (!mdl) {
1085 } else if (mdl->state == MDL_WAITING || mdl->state == MDL_DELETING ) {
1086 /* Creation request arrives for a MDL that is being managed
1094 rsp = mcl->cb->mdl_reconn_req(mdl, mcl->cb->user_data);
1104 if (mdl->state == MDL_CONNECTED)
1105 shutdown_mdl(mdl);
1107 mdl->state = MDL_WAITING;
1118 struct mcap_mdl *mdl, *abrt;
1126 mdl_id = ntohs(req->mdl);
1130 mdl = l->data;
1131 if (mdl_id == mdl->mdlid && mdl->state == MDL_WAITING) {
1132 abrt = mdl;
1137 if (mdl->state == MDL_CONNECTED && mcl->state != MCL_ACTIVE)
1160 struct mcap_mdl *mdl, *aux;
1170 mdlid = ntohs(req->mdl);
1177 /* NULL mdl means ALL_MDLS */
1188 for (l = mcl->mdls, mdl = NULL; l; l = l->next) {
1191 mdl = aux;
1196 if (!mdl || mdl->state == MDL_WAITING) {
1202 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
1205 mcap_del_mdl(mdl, &notify);
1221 ntohs(((mcap_md_req *) cmd)->mdl);
1296 if (rsp->mdl != cmdlast->mdl) {
1334 struct mcap_mdl *mdl = conn->mdl;
1355 connect_cb(mdl, rsp->data[0], gerr, user_data);
1360 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
1361 mcap_mdl_unref(mdl);
1373 struct mcap_mdl *mdl = reconn->mdl;
1383 reconn_cb(mdl, gerr, user_data);
1388 shutdown_mdl(mdl);
1395 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
1396 mcl->cb->mdl_deleted(mdl, mcl->cb->user_data);
1397 mcap_mdl_unref(mdl);
1408 struct mcap_mdl *mdl = abrt->mdl;
1419 shutdown_mdl(mdl);
1422 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
1423 mcl->cb->mdl_deleted(mdl, mcl->cb->user_data);
1424 mcap_mdl_unref(mdl);
1437 struct mcap_mdl *mdl = elem;
1439 if (mdl->state == MDL_DELETING) {
1440 if (mdl->dc)
1441 mdl
1443 mdl->state = MDL_CLOSED;
1444 } else if (mdl->state == MDL_CLOSED)
1445 mdl->mcl->cb->mdl_closed(mdl, mdl->mcl->cb->user_data);
1448 static void check_mdl_del_err(struct mcap_mdl *mdl, mcap_rsp *rsp)
1451 restore_mdl(mdl, NULL);
1455 /* MDL does not exist in remote side, we can delete it */
1456 mdl->mcl->mdls = g_slist_remove(mdl->mcl->mdls, mdl);
1457 mcap_mdl_unref(mdl);
1464 struct mcap_mdl *mdl = del->mdl;
1468 uint16_t mdlid = ntohs(cmdlast->mdl);
1480 if (mdl)
1481 check_mdl_del_err(mdl, rsp);
1495 mcl->mdls = g_slist_remove(mcl->mdls, mdl);
1497 mcap_del_mdl(mdl, &notify);
1603 struct mcap_mdl *mdl = data;
1606 DBG("Close MDL %d", mdl->mdlid);
1608 notify = (mdl->state == MDL_CONNECTED);
1609 shutdown_mdl(mdl);
1611 update_mcl_state(mdl->mcl);
1615 mdl->mcl->cb->mdl_closed(mdl, mdl->mcl->cb->user_data);
1625 struct mcap_mdl *mdl = con->mdl;
1629 DBG("mdl connect callback");
1632 DBG("ERROR: mdl connect callback");
1633 mdl->state = MDL_CLOSED;
1634 g_io_channel_unref(mdl->dc);
1635 mdl->dc = NULL;
1636 cb(mdl, conn_err, user_data);
1640 mdl->state = MDL_CONNECTED;
1641 mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
1644 mcap_mdl_ref(mdl),
1647 cb(mdl, conn_err, user_data);
1650 gboolean mcap_connect_mdl(struct mcap_mdl *mdl, uint8_t mode,
1659 if (mdl->state != MDL_WAITING) {
1667 "Invalid MDL configuration");
1672 con->mdl = mcap_mdl_ref(mdl);
1677 mdl->dc = bt_io_connect(BT_IO_L2CAP, mcap_connect_mdl_cb, con,
1679 BT_IO_OPT_SOURCE_BDADDR, &mdl->mcl->mi->src,
1680 BT_IO_OPT_DEST_BDADDR, &mdl->mcl->addr,
1683 BT_IO_OPT_SEC_LEVEL, mdl->mcl->mi->sec,
1686 if (!mdl->dc) {
1687 DBG("MDL Connection error");
1688 mdl->state = MDL_CLOSED;
1689 mcap_mdl_unref(con->mdl);
1788 static void set_mdl_properties(GIOChannel *chan, struct mcap_mdl *mdl)
1790 struct mcap_mcl *mcl = mdl->mcl;
1792 mdl->state = MDL_CONNECTED;
1793 mdl->dc = g_io_channel_ref(chan);
1794 mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
1797 mcap_mdl_ref(mdl),
1801 mcl->cb->mdl_connected(mdl, mcl->cb->user_data);
1878 struct mcap_mdl *mdl;
1900 mdl = l->data;
1901 if (mdl->state == MDL_WAITING) {
1902 set_mdl_properties(chan, mdl);
2175 struct mcap_mdl *mcap_mdl_ref(struct mcap_mdl *mdl)
2177 mdl->ref++;
2179 DBG("mcap_mdl_ref(%p): ref=%d", mdl, mdl->ref);
2181 return mdl;
2184 void mcap_mdl_unref(struct mcap_mdl *mdl)
2186 mdl->ref--;
2188 DBG("mcap_mdl_unref(%p): ref=%d", mdl, mdl->ref);
2190 if (mdl->ref > 0)
2193 free_mdl(mdl);