/* Searches the main proc list for an "expecting" entry whose connection handle and op code match those specified. If a matching entry is found, it is removed from the list and returned. */
static struct ble_l2cap_sig_proc* ble_l2cap_sig_proc_extract(uint16_t conn_handle, uint8_t op, uint8_t identifier)
/* Searches the main proc list for an "expecting" entry whose connection handle and op code match those specified. If a matching entry is found, it is removed from the list and returned. */
static struct ble_l2cap_sig_proc* ble_l2cap_sig_proc_extract(uint16_t conn_handle, uint8_t op, uint8_t identifier)
{
    struct ble_l2cap_sig_proc *proc;
    struct ble_l2cap_sig_proc *prev;
    ble_hs_lock();
    prev = NULL;
    STAILQ_FOREACH(proc, &ble_l2cap_sig_procs, next) {
        if (ble_l2cap_sig_proc_matches(proc, conn_handle, op, identifier)) {
            if (prev == NULL) {
                STAILQ_REMOVE_HEAD(&ble_l2cap_sig_procs, next);
            } else {
                STAILQ_REMOVE_AFTER(&ble_l2cap_sig_procs, prev, next);
            }
            break;
        }
        prev = proc;
    }
    ble_hs_unlock();
    return proc;
}