Bluetooth: ISO: Add bitmask for retrieving iso header lenght
Add a macro to retrieve the iso data load length (the length stored in the iso header) with a bit mask that ensures that we only take the first 14 bits. This is to remove any RFU bits that may have been set. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
08b1dfb4a2
commit
12decc70d0
8 changed files with 11 additions and 9 deletions
|
@ -135,7 +135,7 @@ static inline void get_iso_hdr(void)
|
||||||
if (!rx.remaining) {
|
if (!rx.remaining) {
|
||||||
struct bt_hci_iso_hdr *hdr = &rx.iso;
|
struct bt_hci_iso_hdr *hdr = &rx.iso;
|
||||||
|
|
||||||
rx.remaining = sys_le16_to_cpu(hdr->len);
|
rx.remaining = bt_iso_hdr_len(sys_le16_to_cpu(hdr->len));
|
||||||
BT_DBG("Got ISO header. Payload %u bytes", rx.remaining);
|
BT_DBG("Got ISO header. Payload %u bytes", rx.remaining);
|
||||||
rx.have_hdr = true;
|
rx.have_hdr = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ static struct net_buf *bt_esp_iso_recv(uint8_t *data, size_t remaining)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining != sys_le16_to_cpu(hdr.len)) {
|
if (remaining != bt_iso_hdr_len(sys_le16_to_cpu(hdr.len))) {
|
||||||
BT_ERR("ISO payload length is not correct");
|
BT_ERR("ISO payload length is not correct");
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -147,7 +147,7 @@ static struct net_buf *bt_rpmsg_iso_recv(uint8_t *data, size_t remaining)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining != sys_le16_to_cpu(hdr.len)) {
|
if (remaining != bt_iso_hdr_len(sys_le16_to_cpu(hdr.len))) {
|
||||||
BT_ERR("ISO payload length is not correct");
|
BT_ERR("ISO payload length is not correct");
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -74,6 +74,7 @@ struct bt_hci_acl_hdr {
|
||||||
(((pb) & 0x0003) | (((ts) & 0x0001) << 2))
|
(((pb) & 0x0003) | (((ts) & 0x0001) << 2))
|
||||||
#define bt_iso_handle_pack(h, pb, ts) \
|
#define bt_iso_handle_pack(h, pb, ts) \
|
||||||
((h) | (bt_iso_pack_flags(pb, ts) << 12))
|
((h) | (bt_iso_pack_flags(pb, ts) << 12))
|
||||||
|
#define bt_iso_hdr_len(h) ((h) & BIT_MASK(14))
|
||||||
|
|
||||||
#define BT_ISO_DATA_VALID 0x00
|
#define BT_ISO_DATA_VALID 0x00
|
||||||
#define BT_ISO_DATA_INVALID 0x01
|
#define BT_ISO_DATA_INVALID 0x01
|
||||||
|
@ -96,8 +97,8 @@ struct bt_hci_iso_ts_data_hdr {
|
||||||
#define BT_HCI_ISO_TS_DATA_HDR_SIZE 8
|
#define BT_HCI_ISO_TS_DATA_HDR_SIZE 8
|
||||||
|
|
||||||
struct bt_hci_iso_hdr {
|
struct bt_hci_iso_hdr {
|
||||||
uint16_t handle;
|
uint16_t handle; /* 12 bit handle, 2 bit PB flags, 1 bit TS_Flag, 1 bit RFU */
|
||||||
uint16_t len;
|
uint16_t len; /* 14 bits, 2 bits RFU */
|
||||||
} __packed;
|
} __packed;
|
||||||
#define BT_HCI_ISO_HDR_SIZE 4
|
#define BT_HCI_ISO_HDR_SIZE 4
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ static struct net_buf *hci_rpmsg_iso_recv(uint8_t *data, size_t remaining)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining != sys_le16_to_cpu(hdr->len)) {
|
if (remaining != bt_iso_hdr_len(sys_le16_to_cpu(hdr->len))) {
|
||||||
LOG_ERR("ISO payload length is not correct");
|
LOG_ERR("ISO payload length is not correct");
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -81,7 +81,8 @@ static uint32_t get_len(const uint8_t *hdr_buf, uint8_t type)
|
||||||
case H4_CMD:
|
case H4_CMD:
|
||||||
return ((const struct bt_hci_cmd_hdr *)hdr_buf)->param_len;
|
return ((const struct bt_hci_cmd_hdr *)hdr_buf)->param_len;
|
||||||
case H4_ISO:
|
case H4_ISO:
|
||||||
return sys_le16_to_cpu(((const struct bt_hci_iso_hdr *)hdr_buf)->len);
|
return bt_iso_hdr_len(
|
||||||
|
sys_le16_to_cpu(((const struct bt_hci_iso_hdr *)hdr_buf)->len));
|
||||||
case H4_ACL:
|
case H4_ACL:
|
||||||
return sys_le16_to_cpu(((const struct bt_hci_acl_hdr *)hdr_buf)->len);
|
return sys_le16_to_cpu(((const struct bt_hci_acl_hdr *)hdr_buf)->len);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -85,7 +85,7 @@ void hci_iso(struct net_buf *buf)
|
||||||
BT_ASSERT(buf->len >= sizeof(*hdr));
|
BT_ASSERT(buf->len >= sizeof(*hdr));
|
||||||
|
|
||||||
hdr = net_buf_pull_mem(buf, sizeof(*hdr));
|
hdr = net_buf_pull_mem(buf, sizeof(*hdr));
|
||||||
len = sys_le16_to_cpu(hdr->len);
|
len = bt_iso_hdr_len(sys_le16_to_cpu(hdr->len));
|
||||||
handle = sys_le16_to_cpu(hdr->handle);
|
handle = sys_le16_to_cpu(hdr->handle);
|
||||||
flags = bt_iso_flags(handle);
|
flags = bt_iso_flags(handle);
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ static uint16_t hci_pkt_get_len(struct net_buf *buf,
|
||||||
|
|
||||||
hdr_len = sizeof(*iso_hdr);
|
hdr_len = sizeof(*iso_hdr);
|
||||||
iso_hdr = (struct bt_hci_iso_hdr *)data;
|
iso_hdr = (struct bt_hci_iso_hdr *)data;
|
||||||
len = sys_le16_to_cpu(iso_hdr->len) + hdr_len;
|
len = bt_iso_hdr_len(sys_le16_to_cpu(iso_hdr->len)) + hdr_len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue