Esempio n. 1
0
/*******************************************************************************
**
** Function         bta_pan_write_buf
**
** Description      Handle a bta_pan_ci_rx_writebuf() and send data to PAN.
**
**
** Returns          void
**
*******************************************************************************/
void bta_pan_write_buf(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
{
    if ((bta_pan_cb.flow_mask & BTA_PAN_RX_MASK) == BTA_PAN_RX_PUSH_BUF)
    {

        PAN_WriteBuf (p_scb->handle,
                      ((tBTA_PAN_DATA_PARAMS *)p_data)->dst,
                      ((tBTA_PAN_DATA_PARAMS *)p_data)->src,
                      ((tBTA_PAN_DATA_PARAMS *)p_data)->protocol,
                      (BT_HDR *)p_data,
                      ((tBTA_PAN_DATA_PARAMS *)p_data)->ext);

    }
}
static int forward_bnep(tETH_HDR* eth_hdr, BT_HDR *hdr) {
    int broadcast = eth_hdr->h_dest[0] & 1;
    int i;

    // Find the right connection to send this frame over.
    for (i = 0; i < MAX_PAN_CONNS; i++) {
        UINT16 handle = btpan_cb.conns[i].handle;
        if (handle != (UINT16)-1 &&
                (broadcast || memcmp(btpan_cb.conns[i].eth_addr, eth_hdr->h_dest, sizeof(BD_ADDR)) == 0
                 || memcmp(btpan_cb.conns[i].peer, eth_hdr->h_dest, sizeof(BD_ADDR)) == 0)) {
            int result = PAN_WriteBuf(handle, eth_hdr->h_dest, eth_hdr->h_src, ntohs(eth_hdr->h_proto), hdr, 0);
            switch (result) {
                case PAN_Q_SIZE_EXCEEDED:
                    return FORWARD_CONGEST;
                case PAN_SUCCESS:
                    return FORWARD_SUCCESS;
                default:
                    return FORWARD_FAILURE;
            }
        }
    }
    GKI_freebuf(hdr);
    return FORWARD_IGNORE;
}