/*******************************************************************************
**
** Function         nfa_hciu_remove_all_pipes_from_host
**
** Description      remove all the pipes that are connected to a specific host
**
** Returns          None
**
*******************************************************************************/
void nfa_hciu_remove_all_pipes_from_host (UINT8 host)
{
    tNFA_HCI_DYN_GATE   *pg;
    tNFA_HCI_DYN_PIPE   *pp;
    int                 xx;
    tNFA_HCI_EVT_DATA   evt_data;

    NFA_TRACE_EVENT1 ("nfa_hciu_remove_all_pipes_from_host (0x%02x)", host);

    /* Remove all pipes from the specified host connected to all generic gates */
    for (xx = 0, pp = nfa_hci_cb.cfg.dyn_pipes; xx < NFA_HCI_MAX_PIPE_CB; xx++, pp++)
    {
        if (  (pp->pipe_id == 0)
                    ||
              (  (host != 0)
               &&((pp->dest_host != host) || (pp->pipe_id > NFA_HCI_LAST_DYNAMIC_PIPE)))  )
            continue;

        if ((pg = nfa_hciu_find_gate_by_gid (pp->local_gate)) != NULL)
        {
            evt_data.deleted.status = NFA_STATUS_OK;
            evt_data.deleted.pipe   = pp->pipe_id;

            nfa_hciu_send_to_app (NFA_HCI_DELETE_PIPE_EVT, &evt_data, pg->gate_owner);
        }
        nfa_hciu_release_pipe (pp->pipe_id);
    }
}
Esempio n. 2
0
/*******************************************************************************
**
** Function         nfa_dm_evt_hdlr
**
** Description      Event handling function for DM
**
**
** Returns          void
**
*******************************************************************************/
BOOLEAN nfa_dm_evt_hdlr (BT_HDR *p_msg)
{
    BOOLEAN freebuf = TRUE;
    UINT16  event = p_msg->event & 0x00ff;

#if (BT_TRACE_VERBOSE == TRUE)
    NFA_TRACE_EVENT2 ("nfa_dm_evt_hdlr event: %s (0x%02x)", nfa_dm_evt_2_str (event), event);
#else
    NFA_TRACE_EVENT1 ("nfa_dm_evt_hdlr event: 0x%x", event);
#endif

    /* execute action functions */
    if (event < NFA_DM_NUM_ACTIONS)
    {
        freebuf = (*nfa_dm_action[event]) ((tNFA_DM_MSG*) p_msg);
    }
    return freebuf;
}
/*******************************************************************************
**
** Function         nfa_hciu_release_pipe
**
** Description      remove the specified pipe
**
** Returns          NFA_HCI_ANY_OK, if removed
**                  NFA_HCI_ANY_E_NOK, if otherwise
**
*******************************************************************************/
tNFA_HCI_RESPONSE nfa_hciu_release_pipe (UINT8 pipe_id)
{
    tNFA_HCI_DYN_GATE   *p_gate;
    tNFA_HCI_DYN_PIPE   *p_pipe;
    UINT8               pipe_index;

    NFA_TRACE_EVENT1 ("nfa_hciu_release_pipe: %u", pipe_id);

    if ((p_pipe = nfa_hciu_find_pipe_by_pid (pipe_id)) == NULL)
        return (NFA_HCI_ANY_E_NOK);

    if (pipe_id > NFA_HCI_LAST_DYNAMIC_PIPE)
    {
        NFA_TRACE_DEBUG1 ("ignore pipe: %d", pipe_id);
        return (NFA_HCI_ANY_E_NOK);
    }

    pipe_index = (UINT8) (p_pipe - nfa_hci_cb.cfg.dyn_pipes);

    if (p_pipe->local_gate == NFA_HCI_IDENTITY_MANAGEMENT_GATE)
    {
        /* Remove pipe from ID management gate */
        nfa_hci_cb.cfg.id_mgmt_gate.pipe_inx_mask &= ~ (UINT32) (1 << pipe_index);
    }
    else
    {
        if ((p_gate = nfa_hciu_find_gate_by_gid (p_pipe->local_gate)) == NULL)
        {
            /* Mark the pipe control block as free */
            p_pipe->pipe_id = 0;
            return (NFA_HCI_ANY_E_NOK);
        }

        /* Remove pipe from gate */
        p_gate->pipe_inx_mask &= ~ (UINT32) (1 << pipe_index);
    }

    /* Reset pipe control block */
    memset (p_pipe,0,sizeof (tNFA_HCI_DYN_PIPE));
    nfa_hci_cb.nv_write_needed = TRUE;
    return NFA_HCI_ANY_OK;
}