| 420 | */ |
| 421 | |
| 422 | void |
| 423 | ng_l2cap_free_chan(ng_l2cap_chan_p ch) |
| 424 | { |
| 425 | ng_l2cap_cmd_p f = NULL, n = NULL; |
| 426 | |
| 427 | f = TAILQ_FIRST(&ch->con->cmd_list); |
| 428 | |
| 429 | while (f != NULL) { |
| 430 | n = TAILQ_NEXT(f, next); |
| 431 | |
| 432 | if (f->ch == ch) { |
| 433 | ng_l2cap_unlink_cmd(f); |
| 434 | if (f->flags & NG_L2CAP_CMD_PENDING) |
| 435 | ng_l2cap_command_untimeout(f); |
| 436 | ng_l2cap_free_cmd(f); |
| 437 | } |
| 438 | |
| 439 | f = n; |
| 440 | } |
| 441 | |
| 442 | LIST_REMOVE(ch, next); |
| 443 | |
| 444 | ng_l2cap_con_unref(ch->con); |
| 445 | |
| 446 | bzero(ch, sizeof(*ch)); |
| 447 | free(ch, M_NETGRAPH_L2CAP); |
| 448 | } /* ng_l2cap_free_chan */ |
| 449 | |
| 450 | /* |
| 451 | * Create new L2CAP command descriptor. WILL NOT add command to the queue. |
no test coverage detected