Beispiel #1
0
/*******************************************************************************
**
** Function         llcp_sdp_proc_deactivation
**
** Description      Report SDP failure for any pending request because of deactivation
**
**
** Returns          void
**
*******************************************************************************/
void llcp_sdp_proc_deactivation (void)
{
    UINT8 i;

    LLCP_TRACE_DEBUG0 ("llcp_sdp_proc_deactivation ()");

    for (i = 0; i < LLCP_MAX_SDP_TRANSAC; i++)
    {
        if (llcp_cb.sdp_cb.transac[i].p_cback)
        {
            (*llcp_cb.sdp_cb.transac[i].p_cback) (llcp_cb.sdp_cb.transac[i].tid, 0x00);

            llcp_cb.sdp_cb.transac[i].p_cback = NULL;
        }
    }

    /* free any pending SNL PDU */
    if (llcp_cb.sdp_cb.p_snl)
    {
        GKI_freebuf (llcp_cb.sdp_cb.p_snl);
        llcp_cb.sdp_cb.p_snl = NULL;
    }

    llcp_cb.sdp_cb.next_tid = 0;
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
    llcp_cb.dta_snl_resp = FALSE;
#endif
}
Beispiel #2
0
/*******************************************************************************
**
** Function         llcp_sdp_check_send_snl
**
** Description      Enqueue Service Name Lookup PDU into sig_xmit_q for transmitting
**
**
** Returns          void
**
*******************************************************************************/
void llcp_sdp_check_send_snl (void)
{
    UINT8 *p;

    if (llcp_cb.sdp_cb.p_snl)
    {
        LLCP_TRACE_DEBUG0 ("SDP: llcp_sdp_check_send_snl ()");

        llcp_cb.sdp_cb.p_snl->len     += LLCP_PDU_HEADER_SIZE;
        llcp_cb.sdp_cb.p_snl->offset  -= LLCP_PDU_HEADER_SIZE;

        p = (UINT8 *) (llcp_cb.sdp_cb.p_snl + 1) + llcp_cb.sdp_cb.p_snl->offset;
        UINT16_TO_BE_STREAM (p, LLCP_GET_PDU_HEADER (LLCP_SAP_SDP, LLCP_PDU_SNL_TYPE, LLCP_SAP_SDP ));

        GKI_enqueue (&llcp_cb.lcb.sig_xmit_q, llcp_cb.sdp_cb.p_snl);
        llcp_cb.sdp_cb.p_snl = NULL;
    }
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
    else
    {
        /* Notify DTA after sending out SNL with SDRES not to send SNLs in AGF PDU */
        if ((llcp_cb.p_dta_cback) && (llcp_cb.dta_snl_resp))
        {
            llcp_cb.dta_snl_resp = FALSE;
            (*llcp_cb.p_dta_cback) ();
        }
    }
#endif
}
/*******************************************************************************
**
** Function         llcp_sdp_proc_deactivation
**
** Description      Report SDP failure for any pending request because of deactivation
**
**
** Returns          void
**
*******************************************************************************/
void llcp_sdp_proc_deactivation (void)
{
    UINT8 i;

    LLCP_TRACE_DEBUG0 ("llcp_sdp_proc_deactivation ()");

    for (i = 0; i < LLCP_MAX_SDP_TRANSAC; i++)
    {
        if (llcp_cb.sdp_cb.transac[i].p_cback)
        {
            (*llcp_cb.sdp_cb.transac[i].p_cback) (llcp_cb.sdp_cb.transac[i].tid, 0x00);

            llcp_cb.sdp_cb.transac[i].p_cback = NULL;
        }
    }

    /* free any pending SNL PDU */
    if (llcp_cb.sdp_cb.p_snl)
    {
        GKI_freebuf (llcp_cb.sdp_cb.p_snl);
        llcp_cb.sdp_cb.p_snl = NULL;
    }

    llcp_cb.sdp_cb.next_tid = 0;
}
/*******************************************************************************
**
** Function         llcp_init
**
** Description      This function is called once at startup to initialize
**                  all the LLCP structures
**
** Returns          void
**
*******************************************************************************/
void llcp_init (void)
{
    UINT32 pool_count;

    memset (&llcp_cb, 0, sizeof (tLLCP_CB));

    llcp_cb.trace_level = LLCP_INITIAL_TRACE_LEVEL;

    LLCP_TRACE_DEBUG0 ("LLCP - llcp_init ()");

    llcp_cb.lcb.local_link_miu = (LLCP_MIU <= LLCP_MAX_MIU ? LLCP_MIU : LLCP_MAX_MIU);
    llcp_cb.lcb.local_opt      = LLCP_OPT_VALUE;
    llcp_cb.lcb.local_wt       = LLCP_WAITING_TIME;
    llcp_cb.lcb.local_lto      = LLCP_LTO_VALUE;

    llcp_cb.lcb.inact_timeout_init   = LLCP_INIT_INACTIVITY_TIMEOUT;
    llcp_cb.lcb.inact_timeout_target = LLCP_TARGET_INACTIVITY_TIMEOUT;
    llcp_cb.lcb.symm_delay           = LLCP_DELAY_RESP_TIME;
    llcp_cb.lcb.data_link_timeout    = LLCP_DATA_LINK_CONNECTION_TOUT;
    llcp_cb.lcb.delay_first_pdu_timeout = LLCP_DELAY_TIME_TO_SEND_FIRST_PDU;

    llcp_cb.lcb.wks  = LLCP_WKS_MASK_LM;

    /* total number of buffers for LLCP */
    pool_count = GKI_poolcount (LLCP_POOL_ID);

    /* number of buffers for receiving data */
    llcp_cb.num_rx_buff = (pool_count * LLCP_RX_BUFF_RATIO) / 100;

    /* rx congestion start/end threshold */
    llcp_cb.overall_rx_congest_start = (UINT8) ((llcp_cb.num_rx_buff * LLCP_RX_CONGEST_START) / 100);
    llcp_cb.overall_rx_congest_end   = (UINT8) ((llcp_cb.num_rx_buff * LLCP_RX_CONGEST_END) / 100);

    /* max number of buffers for receiving data on logical data link */
    llcp_cb.max_num_ll_rx_buff = (UINT8) ((llcp_cb.num_rx_buff * LLCP_LL_RX_BUFF_LIMIT) / 100);

    LLCP_TRACE_DEBUG4 ("num_rx_buff = %d, rx_congest_start = %d, rx_congest_end = %d, max_num_ll_rx_buff = %d",
                        llcp_cb.num_rx_buff, llcp_cb.overall_rx_congest_start,
                        llcp_cb.overall_rx_congest_end, llcp_cb.max_num_ll_rx_buff);

    /* max number of buffers for transmitting data */
    llcp_cb.max_num_tx_buff    = (UINT8) (pool_count - llcp_cb.num_rx_buff);

    /* max number of buffers for transmitting data on logical data link */
    llcp_cb.max_num_ll_tx_buff = (UINT8) ((llcp_cb.max_num_tx_buff * LLCP_LL_TX_BUFF_LIMIT) / 100);

    LLCP_TRACE_DEBUG2 ("max_num_tx_buff = %d, max_num_ll_tx_buff = %d",
                        llcp_cb.max_num_tx_buff, llcp_cb.max_num_ll_tx_buff);

    llcp_cb.ll_tx_uncongest_ntf_start_sap = LLCP_SAP_SDP + 1;

    LLCP_RegisterServer (LLCP_SAP_SDP, LLCP_LINK_TYPE_DATA_LINK_CONNECTION, "urn:nfc:sn:sdp", llcp_sdp_proc_data);
}
/*******************************************************************************
**
** Function         llcp_sdp_check_send_snl
**
** Description      Enqueue Service Name Lookup PDU into sig_xmit_q for transmitting
**
**
** Returns          void
**
*******************************************************************************/
void llcp_sdp_check_send_snl (void)
{
    UINT8 *p;

    if (llcp_cb.sdp_cb.p_snl)
    {
        LLCP_TRACE_DEBUG0 ("SDP: llcp_sdp_check_send_snl ()");

        llcp_cb.sdp_cb.p_snl->len     += LLCP_PDU_HEADER_SIZE;
        llcp_cb.sdp_cb.p_snl->offset  -= LLCP_PDU_HEADER_SIZE;

        p = (UINT8 *) (llcp_cb.sdp_cb.p_snl + 1) + llcp_cb.sdp_cb.p_snl->offset;
        UINT16_TO_BE_STREAM (p, LLCP_GET_PDU_HEADER (LLCP_SAP_SDP, LLCP_PDU_SNL_TYPE, LLCP_SAP_SDP ));

        GKI_enqueue (&llcp_cb.lcb.sig_xmit_q, llcp_cb.sdp_cb.p_snl);
        llcp_cb.sdp_cb.p_snl = NULL;
    }
}
/*******************************************************************************
**
** Function         llcp_cleanup
**
** Description      This function is called once at closing to clean up
**
** Returns          void
**
*******************************************************************************/
void llcp_cleanup (void)
{
    UINT8 sap;
    tLLCP_APP_CB *p_app_cb;

    LLCP_TRACE_DEBUG0 ("LLCP - llcp_cleanup ()");

    for (sap = LLCP_SAP_SDP; sap < LLCP_NUM_SAPS; sap++)
    {
        p_app_cb = llcp_util_get_app_cb (sap);

        if (  (p_app_cb)
            &&(p_app_cb->p_app_cback)  )
        {
            LLCP_Deregister (sap);
        }
    }

    nfc_stop_quick_timer (&llcp_cb.lcb.inact_timer);
    nfc_stop_quick_timer (&llcp_cb.lcb.timer);
}
Beispiel #7
0
/*******************************************************************************
**
** Function         llcp_sdp_proc_snl
**
** Description      Process SDREQ and SDRES in SNL
**
**
** Returns          LLCP_STATUS
**
*******************************************************************************/
tLLCP_STATUS llcp_sdp_proc_snl (UINT16 sdu_length, UINT8 *p)
{
    UINT8  type, length, tid, sap, *p_value;

    LLCP_TRACE_DEBUG0 ("llcp_sdp_proc_snl ()");

    if ((llcp_cb.lcb.agreed_major_version < LLCP_MIN_SNL_MAJOR_VERSION)||
       ((llcp_cb.lcb.agreed_major_version == LLCP_MIN_SNL_MAJOR_VERSION)&&(llcp_cb.lcb.agreed_minor_version < LLCP_MIN_SNL_MINOR_VERSION)))
    {
        LLCP_TRACE_DEBUG0 ("llcp_sdp_proc_snl(): version number less than 1.1, SNL not supported.");
        return LLCP_STATUS_FAIL;
    }
    while (sdu_length >= 2) /* at least type and length */
    {
        BE_STREAM_TO_UINT8 (type, p);
        BE_STREAM_TO_UINT8 (length, p);

        switch (type)
        {
        case LLCP_SDREQ_TYPE:
            if (  (length > 1)                /* TID and sevice name */
                &&(sdu_length >= 2 + length)  ) /* type, length, TID and service name */
            {
                p_value = p;
                BE_STREAM_TO_UINT8 (tid, p_value);
                sap = llcp_sdp_get_sap_by_name ((char*) p_value, (UINT8) (length - 1));
                llcp_sdp_send_sdres (tid, sap);
            }
            else
            {
                LLCP_TRACE_ERROR1 ("llcp_sdp_proc_snl (): bad length (%d) in LLCP_SDREQ_TYPE", length);
            }
            break;

        case LLCP_SDRES_TYPE:
            if (  (length == LLCP_SDRES_LEN)  /* TID and SAP */
                &&(sdu_length >= 2 + length)  ) /* type, length, TID and SAP */
            {
                p_value = p;
                BE_STREAM_TO_UINT8 (tid, p_value);
                BE_STREAM_TO_UINT8 (sap, p_value);
                llcp_sdp_return_sap (tid, sap);
            }
            else
            {
                LLCP_TRACE_ERROR1 ("llcp_sdp_proc_snl (): bad length (%d) in LLCP_SDRES_TYPE", length);
            }
            break;

        default:
            LLCP_TRACE_WARNING1 ("llcp_sdp_proc_snl (): Unknown type (0x%x) is ignored", type);
            break;
        }

        if (sdu_length >= 2 + length)   /* type, length, value */
        {
            sdu_length -= 2 + length;
            p += length;
        }
        else
        {
            break;
        }
    }

    if (sdu_length)
    {
        LLCP_TRACE_ERROR0 ("llcp_sdp_proc_snl (): Bad format of SNL");
        return LLCP_STATUS_FAIL;
    }
    else
    {
        return LLCP_STATUS_SUCCESS;
    }
}