Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfba2bf0 authored by Sharvil Nanavati's avatar Sharvil Nanavati Committed by Andre Eisenbach
Browse files

Collapse BNEP #defines that don't need to be configurable.

In some instances, defining these macros to FALSE would result in
broken runtime behavior (e.g. UUID fields containing uninitialized
values). This change collapses the following defines:

BNEP_SUPPORTS_PROT_FILTERS
BNEP_SUPPORTS_MULTI_FILTERS
BNEP_SUPPORTS_DEBUG_DUMP
BNEP_SUPPORTS_ALL_UUID_LENGTHS
parent 6af6ff71
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -1091,30 +1091,11 @@
#define BNEP_INCLUDED               TRUE
#endif

/* Protocol filtering is an optional feature. Bydefault it will be turned on */
#ifndef BNEP_SUPPORTS_PROT_FILTERS
#define BNEP_SUPPORTS_PROT_FILTERS          TRUE
#endif

/* Multicast filtering is an optional feature. Bydefault it will be turned on */
#ifndef BNEP_SUPPORTS_MULTI_FILTERS
#define BNEP_SUPPORTS_MULTI_FILTERS         TRUE
#endif

/* BNEP status API call is used mainly to get the L2CAP handle */
#ifndef BNEP_SUPPORTS_STATUS_API
#define BNEP_SUPPORTS_STATUS_API            TRUE
#endif

/* This is just a debug function */
#ifndef BNEP_SUPPORTS_DEBUG_DUMP
#define BNEP_SUPPORTS_DEBUG_DUMP            TRUE
#endif

#ifndef BNEP_SUPPORTS_ALL_UUID_LENGTHS
#define BNEP_SUPPORTS_ALL_UUID_LENGTHS      TRUE    /* Otherwise it will support only 16bit UUIDs */
#endif

/*
** When BNEP connection changes roles after the connection is established
** we will do an authentication check again on the new role
+0 −13
Original line number Diff line number Diff line
@@ -150,11 +150,6 @@ tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
    if (src_uuid->len != dst_uuid->len)
        return BNEP_CONN_FAILED_UUID_SIZE;

#if (!defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) || BNEP_SUPPORTS_ALL_UUID_LENGTHS == FALSE)
    if (src_uuid->len != 2)
        return BNEP_CONN_FAILED_UUID_SIZE;
#endif

    if (!p_bcb)
    {
        if ((p_bcb = bnepu_allocate_bcb (p_rem_bda)) == NULL)
@@ -585,7 +580,6 @@ tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
                                      UINT16 *p_start_array,
                                      UINT16 *p_end_array)
{
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    UINT16          xx;
    tBNEP_CONN     *p_bcb;

@@ -618,9 +612,6 @@ tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
    bnepu_send_peer_our_filters (p_bcb);

    return (BNEP_SUCCESS);
#else
    return (BNEP_SET_FILTER_FAIL);
#endif
}


@@ -648,7 +639,6 @@ tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
                                       UINT8 *p_start_array,
                                       UINT8 *p_end_array)
{
#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    UINT16          xx;
    tBNEP_CONN     *p_bcb;

@@ -684,9 +674,6 @@ tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
    bnepu_send_peer_our_multi_filters (p_bcb);

    return (BNEP_SUCCESS);
#else
    return (BNEP_SET_FILTER_FAIL);
#endif
}

/*******************************************************************************
+0 −1
Original line number Diff line number Diff line
@@ -239,7 +239,6 @@ extern void bnep_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT trasn
extern tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BD_ADDR p_dest_addr, UINT16 protocol,
                                                    BOOLEAN fw_ext_present, UINT8 *p_data);
extern UINT32      bnep_get_uuid32 (tBT_UUID *src_uuid);
extern void        bnep_dump_status (void);



+0 −4
Original line number Diff line number Diff line
@@ -726,7 +726,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle)

        bnepu_release_bcb (p_bcb);
    }
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    else if (p_bcb->con_flags & BNEP_FLAGS_FILTER_RESP_PEND)
    {
        if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS)
@@ -746,8 +745,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle)
            return;
        }
    }
#endif
#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    else if (p_bcb->con_flags & BNEP_FLAGS_MULTI_RESP_PEND)
    {
        if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS)
@@ -767,7 +764,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle)
            return;
        }
    }
#endif
}


+0 −74
Original line number Diff line number Diff line
@@ -197,7 +197,6 @@ void bnep_send_conn_req (tBNEP_CONN *p_bcb)
        UINT16_TO_BE_STREAM (p, p_bcb->dst_uuid.uu.uuid16);
        UINT16_TO_BE_STREAM (p, p_bcb->src_uuid.uu.uuid16);
    }
#if (defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) && BNEP_SUPPORTS_ALL_UUID_LENGTHS == TRUE)
    else if (p_bcb->dst_uuid.len == 4)
    {
        UINT32_TO_BE_STREAM (p, p_bcb->dst_uuid.uu.uuid32);
@@ -210,7 +209,6 @@ void bnep_send_conn_req (tBNEP_CONN *p_bcb)
        memcpy (p, p_bcb->src_uuid.uu.uuid128, p_bcb->dst_uuid.len);
        p += p_bcb->dst_uuid.len;
    }
#endif

    p_buf->len = (UINT16)(p - p_start);

@@ -268,7 +266,6 @@ void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code)
*******************************************************************************/
void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
{
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    BT_HDR      *p_buf;
    UINT8       *p;
    UINT16      xx;
@@ -305,7 +302,6 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)

    /* Start timer waiting for setup response */
    btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
#endif
}


@@ -320,7 +316,6 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
*******************************************************************************/
void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)
{
#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    BT_HDR      *p_buf;
    UINT8       *p;
    UINT16      xx;
@@ -359,7 +354,6 @@ void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)

    /* Start timer waiting for setup response */
    btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
#endif
}


@@ -637,7 +631,6 @@ void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len)
            return;
        }
    }
#if (defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) && BNEP_SUPPORTS_ALL_UUID_LENGTHS == TRUE)
    else if (p_bcb->dst_uuid.len == 4)
    {
        BE_STREAM_TO_UINT32 (p_bcb->src_uuid.uu.uuid32, p_setup);
@@ -650,7 +643,6 @@ void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len)
        memcpy (p_bcb->dst_uuid.uu.uuid128, p_setup, p_bcb->dst_uuid.len);
        p_setup += p_bcb->dst_uuid.len;
    }
#endif
    else
    {
        BNEP_TRACE_ERROR ("BNEP - Bad UID len %d in ConnReq", p_bcb->dst_uuid.len);
@@ -902,7 +894,6 @@ UINT8 *bnep_process_control_packet (tBNEP_CONN *p_bcb, UINT8 *p, UINT16 *rem_len
*******************************************************************************/
void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len)
{
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    UINT16      num_filters = 0;
    UINT16      xx, resp_code = BNEP_FILTER_CRL_OK;
    UINT16      start, end;
@@ -966,9 +957,6 @@ void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16
    }

    bnepu_send_peer_filter_rsp (p_bcb, resp_code);
#else
    bnepu_send_peer_filter_rsp (p_bcb, BNEP_FILTER_CRL_UNSUPPORTED);
#endif
}


@@ -984,7 +972,6 @@ void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16
*******************************************************************************/
void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
{
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    UINT16          resp_code;
    tBNEP_RESULT    result;

@@ -1017,13 +1004,8 @@ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)

    if (bnep_cb.p_filter_ind_cb)
        (*bnep_cb.p_filter_ind_cb) (p_bcb->handle, FALSE, result, 0, NULL);

    return;
#endif
}



/*******************************************************************************
**
** Function         bnepu_process_multicast_filter_rsp
@@ -1036,7 +1018,6 @@ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
*******************************************************************************/
void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
{
#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    UINT16          resp_code;
    tBNEP_RESULT    result;

@@ -1069,13 +1050,8 @@ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)

    if (bnep_cb.p_mfilter_ind_cb)
        (*bnep_cb.p_mfilter_ind_cb) (p_bcb->handle, FALSE, result, 0, NULL);

    return;
#endif
}



/*******************************************************************************
**
** Function         bnepu_process_peer_multicast_filter_set
@@ -1089,7 +1065,6 @@ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
*******************************************************************************/
void bnepu_process_peer_multicast_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len)
{
#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    UINT16          resp_code = BNEP_FILTER_CRL_OK;
    UINT16          num_filters, xx;
    UINT8           *p_temp_filters, null_bda[BD_ADDR_LEN] = {0,0,0,0,0,0};
@@ -1156,9 +1131,6 @@ void bnepu_process_peer_multicast_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filter

    if (bnep_cb.p_mfilter_ind_cb)
        (*bnep_cb.p_mfilter_ind_cb) (p_bcb->handle, TRUE, 0, len, p_filters);
#else
    bnepu_send_peer_multicast_filter_rsp (p_bcb, BNEP_FILTER_CRL_UNSUPPORTED);
#endif
}


@@ -1321,7 +1293,6 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb,
                                     BOOLEAN fw_ext_present,
                                     UINT8 *p_data)
{
#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE)
    if (p_bcb->rcvd_num_filters)
    {
        UINT16          i, proto;
@@ -1359,9 +1330,7 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb,
            return BNEP_IGNORE_CMD;
        }
    }
#endif

#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE)
    /* Ckeck for multicast address filtering */
    if ((p_dest_addr[0] & 0x01) &&
        p_bcb->rcvd_mcast_filters)
@@ -1392,15 +1361,10 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb,
            return BNEP_IGNORE_CMD;
        }
    }
#endif

    return BNEP_SUCCESS;
}





/*******************************************************************************
**
** Function         bnep_get_uuid32
@@ -1425,41 +1389,3 @@ UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid)
        return result;
    }
}




/*******************************************************************************
**
** Function         bnep_dump_status
**
** Description      This function dumps the bnep control block and connection
**                  blocks information
**
** Returns          none
**
*******************************************************************************/
void bnep_dump_status (void)
{
#if (defined (BNEP_SUPPORTS_DEBUG_DUMP) && BNEP_SUPPORTS_DEBUG_DUMP == TRUE)
    UINT16          i;
    char            buff[200];
    tBNEP_CONN     *p_bcb;

    BNEP_TRACE_DEBUG ("profile registered %d, trace %d", bnep_cb.profile_registered, bnep_cb.trace_level);

    for (i = 0, p_bcb = bnep_cb.bcb; i < BNEP_MAX_CONNECTIONS; i++, p_bcb++)
    {
        sprintf (buff, "%d state %d, flags 0x%x, cid %d, pfilts %d, mfilts %d, src 0x%x, dst 0x%x, BD %x.%x.%x.%x.%x.%x",
            i, p_bcb->con_state, p_bcb->con_flags, p_bcb->l2cap_cid,
            p_bcb->rcvd_num_filters, p_bcb->rcvd_mcast_filters,
            p_bcb->src_uuid.uu.uuid16, p_bcb->dst_uuid.uu.uuid16,
            p_bcb->rem_bda[0], p_bcb->rem_bda[1], p_bcb->rem_bda[2],
            p_bcb->rem_bda[3], p_bcb->rem_bda[4], p_bcb->rem_bda[5]);

        BNEP_TRACE_DEBUG (buff);
    }
#endif
}

Loading