Lines Matching defs:con

104 	ng_l2cap_con_p	con = NULL;
107 con = malloc(sizeof(*con), M_NETGRAPH_L2CAP,
109 if (con == NULL)
112 con->l2cap = l2cap;
113 con->state = NG_L2CAP_CON_CLOSED;
129 con->con_handle = fake_con_handle ++;
133 bcopy(bdaddr, &con->remote, sizeof(con->remote));
134 ng_callout_init(&con->con_timo);
136 con->ident = NG_L2CAP_FIRST_IDENT - 1;
137 TAILQ_INIT(&con->cmd_list);
140 LIST_INSERT_HEAD(&l2cap->con_list, con, next);
142 return (con);
150 ng_l2cap_con_ref(ng_l2cap_con_p con)
152 con->refcnt ++;
154 if (con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO) {
155 if ((con->state != NG_L2CAP_CON_OPEN) ||
156 (con->flags & NG_L2CAP_CON_OUTGOING) == 0)
159 __func__, NG_NODE_NAME(con->l2cap->node),
160 con->state, con->flags);
162 ng_l2cap_discon_untimeout(con);
171 ng_l2cap_con_unref(ng_l2cap_con_p con)
173 con->refcnt --;
175 if (con->refcnt < 0)
177 "%s: %s - con->refcnt < 0\n", __func__, NG_NODE_NAME(con->l2cap->node));
188 if ((con->refcnt == 0) &&
189 (con->state == NG_L2CAP_CON_OPEN) &&
190 (con->flags & NG_L2CAP_CON_OUTGOING) &&
191 (con->l2cap->discon_timo > 0) &&
192 ((con->flags & NG_L2CAP_CON_DYING) == 0))
193 ng_l2cap_discon_timeout(con);
202 ng_l2cap_discon_timeout(ng_l2cap_con_p con)
204 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
207 __func__, NG_NODE_NAME(con->l2cap->node),
208 con->state, con->flags);
210 con->flags |= NG_L2CAP_CON_AUTO_DISCON_TIMO;
211 ng_callout(&con->con_timo, con->l2cap->node, NULL,
212 con->l2cap->discon_timo * hz,
214 con->con_handle);
224 ng_l2cap_discon_untimeout(ng_l2cap_con_p con)
226 if (!(con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO))
229 __func__, NG_NODE_NAME(con->l2cap->node),
230 con->state, con->flags);
232 if (ng_uncallout(&con->con_timo, con->l2cap->node) == 0)
235 con->flags &= ~NG_L2CAP_CON_AUTO_DISCON_TIMO;
245 ng_l2cap_free_con(ng_l2cap_con_p con)
249 con->state = NG_L2CAP_CON_CLOSED;
251 while (con->tx_pkt != NULL) {
252 struct mbuf *m = con->tx_pkt->m_nextpkt;
254 m_freem(con->tx_pkt);
255 con->tx_pkt = m;
258 NG_FREE_M(con->rx_pkt);
260 for (f = LIST_FIRST(&con->l2cap->chan_list); f != NULL; ) {
263 if (f->con == con)
269 while (!TAILQ_EMPTY(&con->cmd_list)) {
270 ng_l2cap_cmd_p cmd = TAILQ_FIRST(&con->cmd_list);
278 if (con->flags & (NG_L2CAP_CON_AUTO_DISCON_TIMO|NG_L2CAP_CON_LP_TIMO))
281 __func__, NG_NODE_NAME(con->l2cap->node),
282 con->state, con->flags);
284 LIST_REMOVE(con, next);
286 bzero(con, sizeof(*con));
287 free(con, M_NETGRAPH_L2CAP);
297 ng_l2cap_con_p con = NULL;
299 LIST_FOREACH(con, &l2cap->con_list, next)
300 if (bcmp(bdaddr, &con->remote, sizeof(con->remote)) == 0)
303 return (con);
313 ng_l2cap_con_p con = NULL;
315 LIST_FOREACH(con, &l2cap->con_list, next)
316 if (con->con_handle == con_handle)
319 return (con);
323 * Allocate new L2CAP channel descriptor on "con" conection with "psm".
328 ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm)
342 ch->con = con;
357 ng_l2cap_con_ref(con);
392 f = TAILQ_FIRST(&ch->con->cmd_list);
408 ng_l2cap_con_unref(ch->con);
419 ng_l2cap_new_cmd(ng_l2cap_con_p con, ng_l2cap_chan_p ch, u_int8_t ident,
424 KASSERT((ch == NULL || ch->con == con),
426 __func__, NG_NODE_NAME(con->l2cap->node)));
433 cmd->con = con;
448 ng_l2cap_cmd_by_ident(ng_l2cap_con_p con, u_int8_t ident)
452 TAILQ_FOREACH(cmd, &con->cmd_list, next) {
454 KASSERT((cmd->con == con),
456 __func__, NG_NODE_NAME(con->l2cap->node)));
471 ng_l2cap_lp_timeout(ng_l2cap_con_p con)
473 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
476 __func__, NG_NODE_NAME(con->l2cap->node),
477 con->state, con->flags);
479 con->flags |= NG_L2CAP_CON_LP_TIMO;
480 ng_callout(&con->con_timo, con->l2cap->node, NULL,
483 con->con_handle);
493 ng_l2cap_lp_untimeout(ng_l2cap_con_p con)
495 if (!(con->flags & NG_L2CAP_CON_LP_TIMO))
498 __func__, NG_NODE_NAME(con->l2cap->node),
499 con->state, con->flags);
501 if (ng_uncallout(&con->con_timo, con->l2cap->node) == 0)
504 con->flags &= ~NG_L2CAP_CON_LP_TIMO;
522 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
525 arg = ((cmd->ident << 16) | cmd->con->con_handle);
527 ng_callout(&cmd->timo, cmd->con->l2cap->node, NULL, timo,
543 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
546 if (ng_uncallout(&cmd->timo, cmd->con->l2cap->node) == 0)
622 ng_l2cap_get_ident(ng_l2cap_con_p con)
624 u_int8_t ident = con->ident + 1;
629 while (ident != con->ident) {
630 if (ng_l2cap_cmd_by_ident(con, ident) == NULL) {
631 con->ident = ident;