Lines Matching refs:con

107 	ng_l2cap_con_p	con = NULL;
110 con = malloc(sizeof(*con), M_NETGRAPH_L2CAP,
112 if (con == NULL)
115 con->l2cap = l2cap;
116 con->state = NG_L2CAP_CON_CLOSED;
117 con->encryption = 0;
132 con->con_handle = fake_con_handle ++;
136 bcopy(bdaddr, &con->remote, sizeof(con->remote));
137 con->linktype = type;
138 ng_callout_init(&con->con_timo);
140 con->ident = NG_L2CAP_FIRST_IDENT - 1;
141 TAILQ_INIT(&con->cmd_list);
144 LIST_INSERT_HEAD(&l2cap->con_list, con, next);
146 return (con);
154 ng_l2cap_con_ref(ng_l2cap_con_p con)
156 con->refcnt ++;
158 if (con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO) {
159 if ((con->state != NG_L2CAP_CON_OPEN) ||
160 (con->flags & NG_L2CAP_CON_OUTGOING) == 0)
163 __func__, NG_NODE_NAME(con->l2cap->node),
164 con->state, con->flags);
166 ng_l2cap_discon_untimeout(con);
175 ng_l2cap_con_unref(ng_l2cap_con_p con)
177 con->refcnt --;
179 if (con->refcnt < 0)
181 "%s: %s - con->refcnt < 0\n", __func__, NG_NODE_NAME(con->l2cap->node));
192 if ((con->refcnt == 0) &&
193 (con->state == NG_L2CAP_CON_OPEN) &&
194 (con->flags & NG_L2CAP_CON_OUTGOING) &&
195 (con->l2cap->discon_timo > 0) &&
196 ((con->flags & NG_L2CAP_CON_DYING) == 0))
197 ng_l2cap_discon_timeout(con);
206 ng_l2cap_discon_timeout(ng_l2cap_con_p con)
208 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
211 __func__, NG_NODE_NAME(con->l2cap->node),
212 con->state, con->flags);
214 con->flags |= NG_L2CAP_CON_AUTO_DISCON_TIMO;
215 ng_callout(&con->con_timo, con->l2cap->node, NULL,
216 con->l2cap->discon_timo * hz,
218 con->con_handle);
228 ng_l2cap_discon_untimeout(ng_l2cap_con_p con)
230 if (!(con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO))
233 __func__, NG_NODE_NAME(con->l2cap->node),
234 con->state, con->flags);
236 if (ng_uncallout(&con->con_timo, con->l2cap->node) == 0)
239 con->flags &= ~NG_L2CAP_CON_AUTO_DISCON_TIMO;
249 ng_l2cap_free_con(ng_l2cap_con_p con)
253 con->state = NG_L2CAP_CON_CLOSED;
255 while (con->tx_pkt != NULL) {
256 struct mbuf *m = con->tx_pkt->m_nextpkt;
258 m_freem(con->tx_pkt);
259 con->tx_pkt = m;
262 NG_FREE_M(con->rx_pkt);
264 for (f = LIST_FIRST(&con->l2cap->chan_list); f != NULL; ) {
267 if (f->con == con)
273 while (!TAILQ_EMPTY(&con->cmd_list)) {
274 ng_l2cap_cmd_p cmd = TAILQ_FIRST(&con->cmd_list);
282 if (con->flags & (NG_L2CAP_CON_AUTO_DISCON_TIMO|NG_L2CAP_CON_LP_TIMO))
285 __func__, NG_NODE_NAME(con->l2cap->node),
286 con->state, con->flags);
288 LIST_REMOVE(con, next);
290 bzero(con, sizeof(*con));
291 free(con, M_NETGRAPH_L2CAP);
301 ng_l2cap_con_p con = NULL;
303 LIST_FOREACH(con, &l2cap->con_list, next)
304 if ((bcmp(bdaddr, &con->remote, sizeof(con->remote)) == 0)&&
305 (con->linktype == type))
308 return (con);
318 ng_l2cap_con_p con = NULL;
320 LIST_FOREACH(con, &l2cap->con_list, next)
321 if (con->con_handle == con_handle)
324 return (con);
328 * Allocate new L2CAP channel descriptor on "con" connection with "psm".
333 ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm, int idtype)
347 (con->linktype!= NG_HCI_LINK_ACL));
354 ch->con = con;
369 ng_l2cap_con_ref(con);
392 (ch->con->linktype == NG_HCI_LINK_ACL ))
395 (ch->con->linktype != NG_HCI_LINK_ACL ))
412 (ch->con->con_handle == con_handle))
427 f = TAILQ_FIRST(&ch->con->cmd_list);
444 ng_l2cap_con_unref(ch->con);
455 ng_l2cap_new_cmd(ng_l2cap_con_p con, ng_l2cap_chan_p ch, u_int8_t ident,
460 KASSERT((ch == NULL || ch->con == con),
462 __func__, NG_NODE_NAME(con->l2cap->node)));
469 cmd->con = con;
484 ng_l2cap_cmd_by_ident(ng_l2cap_con_p con, u_int8_t ident)
488 TAILQ_FOREACH(cmd, &con->cmd_list, next) {
490 KASSERT((cmd->con == con),
492 __func__, NG_NODE_NAME(con->l2cap->node)));
507 ng_l2cap_lp_timeout(ng_l2cap_con_p con)
509 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
512 __func__, NG_NODE_NAME(con->l2cap->node),
513 con->state, con->flags);
515 con->flags |= NG_L2CAP_CON_LP_TIMO;
516 ng_callout(&con->con_timo, con->l2cap->node, NULL,
519 con->con_handle);
529 ng_l2cap_lp_untimeout(ng_l2cap_con_p con)
531 if (!(con->flags & NG_L2CAP_CON_LP_TIMO))
534 __func__, NG_NODE_NAME(con->l2cap->node),
535 con->state, con->flags);
537 if (ng_uncallout(&con->con_timo, con->l2cap->node) == 0)
540 con->flags &= ~NG_L2CAP_CON_LP_TIMO;
558 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
561 arg = ((cmd->ident << 16) | cmd->con->con_handle);
563 ng_callout(&cmd->timo, cmd->con->l2cap->node, NULL, timo,
579 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
582 if (ng_uncallout(&cmd->timo, cmd->con->l2cap->node) == 0)
677 ng_l2cap_get_ident(ng_l2cap_con_p con)
679 u_int8_t ident = con->ident + 1;
684 while (ident != con->ident) {
685 if (ng_l2cap_cmd_by_ident(con, ident) == NULL) {
686 con->ident = ident;