Lines Matching defs:con

108 	ng_l2cap_con_p	con = NULL;
111 con = malloc(sizeof(*con), M_NETGRAPH_L2CAP,
113 if (con == NULL)
116 con->l2cap = l2cap;
117 con->state = NG_L2CAP_CON_CLOSED;
118 con->encryption = 0;
133 con->con_handle = fake_con_handle ++;
137 bcopy(bdaddr, &con->remote, sizeof(con->remote));
138 con->linktype = type;
139 ng_callout_init(&con->con_timo);
141 con->ident = NG_L2CAP_FIRST_IDENT - 1;
142 TAILQ_INIT(&con->cmd_list);
145 LIST_INSERT_HEAD(&l2cap->con_list, con, next);
147 return (con);
155 ng_l2cap_con_ref(ng_l2cap_con_p con)
157 con->refcnt ++;
159 if (con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO) {
160 if ((con->state != NG_L2CAP_CON_OPEN) ||
161 (con->flags & NG_L2CAP_CON_OUTGOING) == 0)
164 __func__, NG_NODE_NAME(con->l2cap->node),
165 con->state, con->flags);
167 ng_l2cap_discon_untimeout(con);
176 ng_l2cap_con_unref(ng_l2cap_con_p con)
178 con->refcnt --;
180 if (con->refcnt < 0)
182 "%s: %s - con->refcnt < 0\n", __func__, NG_NODE_NAME(con->l2cap->node));
193 if ((con->refcnt == 0) &&
194 (con->state == NG_L2CAP_CON_OPEN) &&
195 (con->flags & NG_L2CAP_CON_OUTGOING) &&
196 (con->l2cap->discon_timo > 0) &&
197 ((con->flags & NG_L2CAP_CON_DYING) == 0))
198 ng_l2cap_discon_timeout(con);
207 ng_l2cap_discon_timeout(ng_l2cap_con_p con)
209 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
212 __func__, NG_NODE_NAME(con->l2cap->node),
213 con->state, con->flags);
215 con->flags |= NG_L2CAP_CON_AUTO_DISCON_TIMO;
216 ng_callout(&con->con_timo, con->l2cap->node, NULL,
217 con->l2cap->discon_timo * hz,
219 con->con_handle);
229 ng_l2cap_discon_untimeout(ng_l2cap_con_p con)
231 if (!(con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO))
234 __func__, NG_NODE_NAME(con->l2cap->node),
235 con->state, con->flags);
237 if (ng_uncallout(&con->con_timo, con->l2cap->node) < 1)
240 con->flags &= ~NG_L2CAP_CON_AUTO_DISCON_TIMO;
250 ng_l2cap_free_con(ng_l2cap_con_p con)
254 con->state = NG_L2CAP_CON_CLOSED;
256 while (con->tx_pkt != NULL) {
257 struct mbuf *m = con->tx_pkt->m_nextpkt;
259 m_freem(con->tx_pkt);
260 con->tx_pkt = m;
263 NG_FREE_M(con->rx_pkt);
265 for (f = LIST_FIRST(&con->l2cap->chan_list); f != NULL; ) {
268 if (f->con == con)
274 while (!TAILQ_EMPTY(&con->cmd_list)) {
275 ng_l2cap_cmd_p cmd = TAILQ_FIRST(&con->cmd_list);
283 if (con->flags & (NG_L2CAP_CON_AUTO_DISCON_TIMO|NG_L2CAP_CON_LP_TIMO))
286 __func__, NG_NODE_NAME(con->l2cap->node),
287 con->state, con->flags);
289 LIST_REMOVE(con, next);
291 bzero(con, sizeof(*con));
292 free(con, M_NETGRAPH_L2CAP);
302 ng_l2cap_con_p con = NULL;
304 LIST_FOREACH(con, &l2cap->con_list, next)
305 if ((bcmp(bdaddr, &con->remote, sizeof(con->remote)) == 0)&&
306 (con->linktype == type))
309 return (con);
319 ng_l2cap_con_p con = NULL;
321 LIST_FOREACH(con, &l2cap->con_list, next)
322 if (con->con_handle == con_handle)
325 return (con);
329 * Allocate new L2CAP channel descriptor on "con" connection with "psm".
334 ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm, int idtype)
348 (con->linktype!= NG_HCI_LINK_ACL));
355 ch->con = con;
370 ng_l2cap_con_ref(con);
392 (ch->con->linktype == NG_HCI_LINK_ACL ))
395 (ch->con->linktype != NG_HCI_LINK_ACL ))
411 (ch->con->con_handle == con_handle))
426 f = TAILQ_FIRST(&ch->con->cmd_list);
443 ng_l2cap_con_unref(ch->con);
454 ng_l2cap_new_cmd(ng_l2cap_con_p con, ng_l2cap_chan_p ch, u_int8_t ident,
459 KASSERT((ch == NULL || ch->con == con),
461 __func__, NG_NODE_NAME(con->l2cap->node)));
468 cmd->con = con;
483 ng_l2cap_cmd_by_ident(ng_l2cap_con_p con, u_int8_t ident)
487 TAILQ_FOREACH(cmd, &con->cmd_list, next) {
489 KASSERT((cmd->con == con),
491 __func__, NG_NODE_NAME(con->l2cap->node)));
506 ng_l2cap_lp_timeout(ng_l2cap_con_p con)
508 if (con->flags & (NG_L2CAP_CON_LP_TIMO|NG_L2CAP_CON_AUTO_DISCON_TIMO))
511 __func__, NG_NODE_NAME(con->l2cap->node),
512 con->state, con->flags);
514 con->flags |= NG_L2CAP_CON_LP_TIMO;
515 ng_callout(&con->con_timo, con->l2cap->node, NULL,
518 con->con_handle);
528 ng_l2cap_lp_untimeout(ng_l2cap_con_p con)
530 if (!(con->flags & NG_L2CAP_CON_LP_TIMO))
533 __func__, NG_NODE_NAME(con->l2cap->node),
534 con->state, con->flags);
536 if (ng_uncallout(&con->con_timo, con->l2cap->node) < 1)
539 con->flags &= ~NG_L2CAP_CON_LP_TIMO;
557 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
560 arg = ((cmd->ident << 16) | cmd->con->con_handle);
562 ng_callout(&cmd->timo, cmd->con->l2cap->node, NULL, timo,
578 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
581 if (ng_uncallout(&cmd->timo, cmd->con->l2cap->node) < 1)
676 ng_l2cap_get_ident(ng_l2cap_con_p con)
678 u_int8_t ident = con->ident + 1;
683 while (ident != con->ident) {
684 if (ng_l2cap_cmd_by_ident(con, ident) == NULL) {
685 con->ident = ident;