Skip to content

Commit

Permalink
Bluetooth: L2CAP: Build fixed channels mask on runtime
Browse files Browse the repository at this point in the history
Build Information Response with fixed channels mask  based on
registered channels.

Change-Id: I47bd3255bd000d3721c77a34c6ea84bbb888630d
Signed-off-by: Szymon Janc <[email protected]>
  • Loading branch information
Szymon Janc authored and Johan Hedberg committed Oct 16, 2016
1 parent d84397a commit 7d4c746
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions net/bluetooth/l2cap_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,17 @@ static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident,
return err;
}

static bool br_sc_supported(void)
static uint8_t get_fixed_channels_mask(void)
{
#if defined(CONFIG_BLUETOOTH_SMP_FORCE_BREDR)
return true;
#else
return BT_FEAT_SC(bt_dev.features);
#endif /* CONFIG_BLUETOOTH_SMP_FORCE_BREDR */
struct bt_l2cap_fixed_chan *fchan;
uint8_t mask = 0;

/* this needs to be enhanced if AMP Test Manager support is added */
for (fchan = br_fixed_channels; fchan; fchan = fchan->_next) {
mask |= BIT(fchan->cid);
}

return mask;
}

static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident,
Expand Down Expand Up @@ -531,13 +535,7 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident,
rsp->result = sys_cpu_to_le16(BT_L2CAP_INFO_SUCCESS);
/* fixed channel mask protocol data is 8 octets wide */
memset(net_buf_add(rsp_buf, 8), 0, 8);
/* signaling channel is mandatory on BR/EDR transport */
rsp->data[0] = BIT(BT_L2CAP_CID_BR_SIG);

/* Add SMP channel if SC are supported */
if (br_sc_supported()) {
rsp->data[0] |= BIT(BT_L2CAP_CID_BR_SMP);
}
rsp->data[0] = get_fixed_channels_mask();

hdr_info->len = sys_cpu_to_le16(sizeof(*rsp) + 8);
break;
Expand Down

0 comments on commit 7d4c746

Please sign in to comment.