MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_l2cap_free_con

Function ng_l2cap_free_con

freebsd/netgraph/bluetooth/l2cap/ng_l2cap_misc.c:250–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248 */
249
250void
251ng_l2cap_free_con(ng_l2cap_con_p con)
252{
253 ng_l2cap_chan_p f = NULL, n = NULL;
254
255 con->state = NG_L2CAP_CON_CLOSED;
256
257 while (con->tx_pkt != NULL) {
258 struct mbuf *m = con->tx_pkt->m_nextpkt;
259
260 m_freem(con->tx_pkt);
261 con->tx_pkt = m;
262 }
263
264 NG_FREE_M(con->rx_pkt);
265
266 for (f = LIST_FIRST(&con->l2cap->chan_list); f != NULL; ) {
267 n = LIST_NEXT(f, next);
268
269 if (f->con == con)
270 ng_l2cap_free_chan(f);
271
272 f = n;
273 }
274
275 while (!TAILQ_EMPTY(&con->cmd_list)) {
276 ng_l2cap_cmd_p cmd = TAILQ_FIRST(&con->cmd_list);
277
278 ng_l2cap_unlink_cmd(cmd);
279 if (cmd->flags & NG_L2CAP_CMD_PENDING)
280 ng_l2cap_command_untimeout(cmd);
281 ng_l2cap_free_cmd(cmd);
282 }
283
284 if (con->flags & (NG_L2CAP_CON_AUTO_DISCON_TIMO|NG_L2CAP_CON_LP_TIMO))
285 panic(
286"%s: %s - timeout pending! state=%d, flags=%#x\n",
287 __func__, NG_NODE_NAME(con->l2cap->node),
288 con->state, con->flags);
289
290 LIST_REMOVE(con, next);
291
292 bzero(con, sizeof(*con));
293 free(con, M_NETGRAPH_L2CAP);
294} /* ng_l2cap_free_con */
295
296/*
297 * Get connection by "remote" address

Callers 3

ng_l2cap_lp_con_reqFunction · 0.85
ng_l2cap_lp_con_indFunction · 0.85
ng_l2cap_con_failFunction · 0.85

Calls 6

ng_l2cap_free_chanFunction · 0.85
bzeroFunction · 0.85
m_freemFunction · 0.50
panicFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected