You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/01/11 14:48:35 UTC

[GitHub] rymanluk closed pull request #284: nimble/ll: Couple of fixes for extended scanner

rymanluk closed pull request #284: nimble/ll: Couple of fixes for extended scanner
URL: https://github.com/apache/mynewt-nimble/pull/284
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/controller/include/controller/ble_ll_scan.h b/nimble/controller/include/controller/ble_ll_scan.h
index 388a5999..641acd6d 100644
--- a/nimble/controller/include/controller/ble_ll_scan.h
+++ b/nimble/controller/include/controller/ble_ll_scan.h
@@ -97,8 +97,9 @@ struct ble_ll_scan_params
 #define BLE_LL_AUX_TRUNCATED_SENT       0x40
 #define BLE_LL_AUX_HAS_ADI              0x80
 
-#define BLE_LL_SET_AUX_FLAG(aux_data, flag) ((aux_data)->flags |= flag)
-#define BLE_LL_CHECK_AUX_FLAG(aux_data, flag) (!!((aux_data)->flags & flag))
+#define BLE_LL_AUX_SET_FLAG(aux_data, flag) ((aux_data)->flags |= (flag))
+#define BLE_LL_AUX_CLEAR_FLAG(aux_data, flag) ((aux_data)->flags &= ~(flag))
+#define BLE_LL_AUX_CHECK_FLAG(aux_data, flag) ((aux_data)->flags & (flag))
 
 struct ble_ll_aux_data {
     uint8_t ref_cnt;
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 3748a4df..dca7031c 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -460,7 +460,7 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
 
     BLE_LL_ASSERT(aux_data);
 
-    if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
+    if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
         /* if not chained, there is nothing to do here */
         goto done;
     }
@@ -478,14 +478,14 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
     evt->event_len = sizeof(*evt) - BLE_HCI_EVENT_HDR_LEN;
     evt->evt_type = aux_data->evt_type;
     evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
-    BLE_LL_SET_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+    BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
 
-    if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
+    if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
         memcpy(evt->addr, aux_data->addr, 6);
         evt->addr_type = aux_data->addr_type;
     }
 
-    if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
+    if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
         memcpy(evt->dir_addr, aux_data->dir_addr, 6);
         evt->dir_addr_type = aux_data->dir_addr_type;
     }
@@ -504,7 +504,7 @@ ble_ll_scan_get_adi(struct ble_ll_aux_data *aux_data, uint16_t *adi)
         return -1;
     }
 
-    if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_ADI)) {
+    if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADI)) {
         return -1;
     }
 
@@ -527,7 +527,7 @@ ble_ll_scan_end_adv_evt(struct ble_ll_aux_data *aux_data)
      * (truncated was sent to the host) and we just need to drop last reference.
      * Otherwise we should try to send truncated event to the host.
      */
-    if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT)) {
+    if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT)) {
         ble_ll_scan_send_truncated_if_chained(aux_data);
     }
 
@@ -929,14 +929,15 @@ ble_ll_scan_send_adv_report(uint8_t pdu_type, uint8_t *adva, uint8_t adva_type,
     }
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
+    /* If RPA has been used, make sure we use correct address types
+     * in the advertising report.
+     */
     if (BLE_MBUF_HDR_RESOLVED(hdr)) {
-        /*
-         * NOTE: this looks a bit odd, but the resolved address types
-         * are 2 greater than the unresolved ones in the spec, so
-         * we just add 2 here.
-         */
         adva_type += 2;
     }
+    if (BLE_MBUF_HDR_INITA_RESOLVED(hdr)) {
+        inita_type += 2;
+    }
 #endif
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
@@ -1851,7 +1852,19 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
     tmp_aux_data.mode = rxbuf[2] >> 6;
 
     ext_hdr_len = rxbuf[2] & 0x3F;
-    if (ext_hdr_len < BLE_LL_EXT_ADV_AUX_PTR_SIZE && !ble_hdr->rxinfo.user_data) {
+    if (ext_hdr_len < BLE_LL_EXT_ADV_AUX_PTR_SIZE && !current_aux) {
+        return -1;
+    }
+
+    if (ext_hdr_len == 0) {
+        if (current_aux) {
+            /* This is last element in the chain.
+             * Clear incomplete flag
+             */
+            BLE_LL_AUX_CLEAR_FLAG(current_aux, BLE_LL_AUX_INCOMPLETE_BIT);
+            return 1;
+        }
+
         return -1;
     }
 
@@ -1859,7 +1872,6 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
     ext_hdr = &rxbuf[4];
 
     i = 0;
-    /* Just all until AUX PTR it for now*/
     if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
         memcpy(tmp_aux_data.addr, ext_hdr + i, 6);
         tmp_aux_data.addr_type =
@@ -1902,11 +1914,11 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
             if (!(new_aux->evt_type & (BLE_HCI_ADV_SCAN_MASK))
                             && (tmp_aux_data.adi != new_aux->adi)) {
                 STATS_INC(ble_ll_stats, aux_chain_err);
-                new_aux->flags |= BLE_LL_AUX_INCOMPLETE_ERR_BIT;
+                BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_ERR_BIT);
             }
 
-            new_aux->flags |= BLE_LL_AUX_CHAIN_BIT;
-            new_aux->flags |= BLE_LL_AUX_INCOMPLETE_BIT;
+            BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_CHAIN_BIT);
+            BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_BIT);
         } else {
             if (ble_ll_scan_ext_adv_init(&new_aux) < 0) {
             /* Out of memory */
@@ -1942,7 +1954,7 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
         new_aux = ble_hdr->rxinfo.user_data;
 
         /* Clear incomplete flag */
-        new_aux->flags &= ~BLE_LL_AUX_INCOMPLETE_BIT;
+        BLE_LL_AUX_CLEAR_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_BIT);
 
         /* Current processing aux_ptr */
         rc = 1;
@@ -1950,19 +1962,19 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
 
     if (has_adi) {
         new_aux->adi = tmp_aux_data.adi;
-        BLE_LL_SET_AUX_FLAG(new_aux, BLE_LL_AUX_HAS_ADI);
+        BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_ADI);
     }
 
     if (has_addr) {
         memcpy(new_aux->addr, tmp_aux_data.addr, 6);
         new_aux->addr_type = tmp_aux_data.addr_type;
-        new_aux->flags |= BLE_LL_AUX_HAS_ADDRA;
+        BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_ADDRA);
     }
 
     if (has_dir_addr) {
         memcpy(new_aux->dir_addr, tmp_aux_data.dir_addr, 6);
         new_aux->dir_addr_type = tmp_aux_data.dir_addr_type;
-        new_aux->flags |= BLE_LL_AUX_HAS_DIR_ADDRA;
+        BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_DIR_ADDRA);
     }
 
     ble_hdr->rxinfo.user_data = new_aux;
@@ -2026,55 +2038,56 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
     ext_hdr_flags = rxbuf[3];
     ext_hdr = &rxbuf[4];
 
-    i = 0;
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
-        i += BLE_LL_EXT_ADV_ADVA_SIZE;
-    }
+    if (ext_hdr_len) {
+        i = 0;
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
+            i += BLE_LL_EXT_ADV_ADVA_SIZE;
+        }
 
-    if (adva) {
-        memcpy(out_evt->addr, adva, 6);
-        out_evt->addr_type = adva_type;
-    }
+        if (adva) {
+            memcpy(out_evt->addr, adva, 6);
+            out_evt->addr_type = adva_type;
+        }
 
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TARGETA_BIT)) {
-        i += BLE_LL_EXT_ADV_TARGETA_SIZE;
-    }
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TARGETA_BIT)) {
+            i += BLE_LL_EXT_ADV_TARGETA_SIZE;
+        }
 
-    if (inita) {
-       memcpy(out_evt->dir_addr, inita, 6);
-       out_evt->dir_addr_type = inita_type;
-       out_evt->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
-    }
+        if (inita) {
+           memcpy(out_evt->dir_addr, inita, 6);
+           out_evt->dir_addr_type = inita_type;
+           out_evt->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
+        }
 
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_RFU_BIT)) {
-        /* Just skip it for now*/
-        i += 1;
-    }
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_RFU_BIT)) {
+            /* Just skip it for now*/
+            i += 1;
+        }
 
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT)) {
-        ble_ll_ext_scan_parse_adv_info(scansm, out_evt, (ext_hdr + i));
-        i += BLE_LL_EXT_ADV_DATA_INFO_SIZE;
-    } else if (out_evt->evt_type & BLE_HCI_ADV_SCAN_RSP_MASK) {
-        out_evt->sid = (aux_data->adi >> 12);
-    }
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT)) {
+            ble_ll_ext_scan_parse_adv_info(scansm, out_evt, (ext_hdr + i));
+            i += BLE_LL_EXT_ADV_DATA_INFO_SIZE;
+        } else if (out_evt->evt_type & BLE_HCI_ADV_SCAN_RSP_MASK) {
+            out_evt->sid = (aux_data->adi >> 12);
+        }
 
-    /* In this point of time we don't want to care about aux ptr */
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_AUX_PTR_BIT)) {
-        i += BLE_LL_EXT_ADV_AUX_PTR_SIZE;
-    }
+        /* In this point of time we don't want to care about aux ptr */
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_AUX_PTR_BIT)) {
+            i += BLE_LL_EXT_ADV_AUX_PTR_SIZE;
+        }
 
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_SYNC_INFO_BIT)) {
-        /* TODO Handle periodic adv */
-        i += BLE_LL_EXT_ADV_SYNC_INFO_SIZE;
-    }
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_SYNC_INFO_BIT)) {
+            /* TODO Handle periodic adv */
+            i += BLE_LL_EXT_ADV_SYNC_INFO_SIZE;
+        }
 
-    if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TX_POWER_BIT)) {
-        out_evt->tx_power = *(ext_hdr + i);
-        i += BLE_LL_EXT_ADV_TX_POWER_SIZE;
-    }
+        if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TX_POWER_BIT)) {
+            out_evt->tx_power = *(ext_hdr + i);
+            i += BLE_LL_EXT_ADV_TX_POWER_SIZE;
+        }
 
-    /* Skip ADAC if it is there */
-    i = ext_hdr_len;
+        /* TODO Handle ACAD if needed */
+    }
 
     /* In the event we need information on primary and secondary PHY used during
      * advertising.
@@ -2087,8 +2100,10 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
     out_evt->sec_phy = aux_data->aux_phy;
     out_evt->prim_phy = aux_data->aux_primary_phy;
 
-    /* Adjust mbuf to contain advertising data only */
-    os_mbuf_adj(om, i);
+    if (ext_hdr_len) {
+        /* Adjust mbuf to contain advertising data only */
+        os_mbuf_adj(om, ext_hdr_len);
+    }
 
     /* Let us first keep update event type in aux data.
      * Note that in aux chain and aux scan response packets
@@ -2098,7 +2113,7 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
     out_evt->evt_type = aux_data->evt_type;
 
 done:
-    return pdu_len - i - 1;
+    return pdu_len - ext_hdr_len - 1;
 }
 
 static int
@@ -2126,7 +2141,7 @@ ble_ll_scan_get_addr_from_ext_adv(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr,
 
     if (aux_data) {
         /* If address has been provided, we do have it already in aux_data.*/
-        if (aux_data->flags & BLE_LL_AUX_HAS_ADDRA) {
+        if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
             *addr = aux_data->addr;
             *addr_type = aux_data->addr_type;
         }
@@ -2135,7 +2150,7 @@ ble_ll_scan_get_addr_from_ext_adv(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr,
             return 0;
         }
 
-        if (aux_data->flags & BLE_LL_AUX_HAS_DIR_ADDRA) {
+        if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
             *inita = aux_data->dir_addr;
             *inita_type = aux_data->dir_addr_type;
         }
@@ -2284,6 +2299,10 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
 
     ble_hdr = BLE_MBUF_HDR_PTR(rxpdu);
 
+    /* Get pdu type, pointer to address and address "type"  */
+    rxbuf = rxpdu->om_data;
+    pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
     if (scansm->cur_aux_data) {
         ble_hdr->rxinfo.user_data = scansm->cur_aux_data;
@@ -2293,6 +2312,13 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
             ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_AUX_INVALID;
             goto scan_rx_isr_exit;
         }
+
+        /* If we were expecting aux/chain and it not arrived,
+         * lets just exit here.
+         */
+        if (pdu_type != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+            goto scan_rx_isr_exit;
+        }
     }
 #endif
 
@@ -2304,10 +2330,6 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
         goto scan_rx_isr_exit;
     }
 
-    /* Get pdu type, pointer to address and address "type"  */
-    rxbuf = rxpdu->om_data;
-    pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
-
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
     if (pdu_type == BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
         if (!scansm->ext_scanning) {
@@ -2391,9 +2413,11 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
                 peer = g_ble_ll_resolv_list[index].rl_identity_addr;
                 peer_addr_type = g_ble_ll_resolv_list[index].rl_addr_type;
                 resolved = 1;
-                if (ble_ll_is_rpa(inita, inita_type) &&
-                    !ble_ll_resolv_rpa(inita, g_ble_ll_resolv_list[index].rl_local_irk)) {
-                    goto scan_rx_isr_exit;
+                if (ble_ll_is_rpa(inita, inita_type)) {
+                    if (!ble_ll_resolv_rpa(inita, g_ble_ll_resolv_list[index].rl_local_irk)) {
+                        goto scan_rx_isr_exit;
+                    }
+                    ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_INITA_RESOLVED;
                 }
             } else {
                 if (chk_wl) {
@@ -2405,13 +2429,19 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
                 }
             }
         } else if (chk_send_req && inita && ble_ll_is_rpa(inita, inita_type)) {
-            /* If remove is identity address but InitA is RPA, make sure we can resolve it.
+            /* If remote is identity address but InitA is RPA, make sure we can resolve it.
              * If not, nothing more to do here
              */
             rl = ble_ll_resolv_list_find(peer, peer_addr_type);
-            if (!rl || !ble_ll_resolv_rpa(inita, rl->rl_local_irk)) {
+            if (!rl) {
                 goto scan_rx_isr_exit;
             }
+
+            if (!ble_ll_resolv_rpa(inita, rl->rl_local_irk)) {
+                goto scan_rx_isr_exit;
+            }
+
+            ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_INITA_RESOLVED;
         }
     }
 #else
@@ -2637,6 +2667,18 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         }
     }
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
+    /* If RPA has been used, make sure we use correct address types
+     * in the advertising report.
+     */
+    if (BLE_MBUF_HDR_RESOLVED(hdr)) {
+        adva_type += 2;
+    }
+    if (BLE_MBUF_HDR_INITA_RESOLVED(hdr)) {
+        inita_type += 2;
+    }
+#endif
+
     datalen = ble_ll_scan_parse_ext_hdr(om, adva, adva_type, inita, inita_type, hdr, evt);
     if (datalen < 0) {
         /* XXX what should we do here? send some trimmed event? */
@@ -2668,9 +2710,9 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         if (offset < datalen) {
             /* Need another event for next fragment of this PDU */
             need_event = true;
-        } else if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+        } else if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
             need_event = false;
-        } else if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
+        } else if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
             /* Need another event for next PDU in chain */
             need_event = true;
         }
@@ -2689,14 +2731,14 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
                 evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_INCOMPLETE);
             } else {
                 evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
-                BLE_LL_SET_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+                BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
                 rc = -1;
             }
         } else if (aux_data ) {
-            if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+            if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
                 evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
                 rc = -1;
-            } else if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
+            } else if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
                 evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_INCOMPLETE);
             } else {
                 rc = 0;
@@ -2783,6 +2825,17 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
         goto scan_continue;
     }
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+    if (aux_data && ptype != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+        /* LL was scheduled for aux but received something different.
+         * Let's just ignore received event and send truncated for
+         * previous report if needed.
+         */
+        evt_possibly_truncated = 1;
+        goto scan_continue;
+    }
+#endif
+
     if ((ptype == BLE_ADV_PDU_TYPE_SCAN_REQ) || (ptype == BLE_ADV_PDU_TYPE_CONNECT_REQ)) {
         goto scan_continue;
     }
@@ -2892,19 +2945,19 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
         }
 
         /* If it is ignore it means event is already truncated, just unref aux */
-        if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT)) {
+        if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT)) {
             ble_ll_scan_aux_data_unref(aux_data);
             goto scan_continue;
         }
 
         /* Let's see if that packet contains aux ptr*/
         if (BLE_MBUF_HDR_WAIT_AUX(hdr)) {
-           BLE_LL_ASSERT(aux_data);
+            BLE_LL_ASSERT(aux_data);
             if (ble_ll_sched_aux_scan(hdr, scansm, hdr->rxinfo.user_data)) {
                 /* We are here when could not schedule the aux ptr */
                 hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_AUX_PTR_WAIT;
                 /* Mark that chain is trimmed */
-                aux_data->flags |= BLE_LL_AUX_INCOMPLETE_ERR_BIT;
+                BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT);
                 /* Note: aux_data unref will be done when truncated is sent to the host or
                  * below if we failed to schedule for the very first aux packet.
                  */
@@ -2918,8 +2971,8 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
              * for aux packet. However, if we was not able to schedule for first aux packet,
              * make sure to unref aux_data here
              */
-            if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
-                if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+            if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
+                if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
                     ble_ll_scan_aux_data_unref(aux_data);
                 }
                 goto scan_continue;
@@ -2944,7 +2997,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
                     ble_ll_scan_aux_data_unref(aux_data);
                 }
             }
-            aux_data->flags |= BLE_LL_AUX_IGNORE_BIT;
+            BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT);
         } else if ((rc == 0) && scansm->scan_filt_dups && aux_data && aux_data->adi) {
                 ble_ll_scan_add_dup_adv(ident_addr, ident_addr_type,
                                         BLE_HCI_LE_SUBEV_EXT_ADV_RPT,
diff --git a/nimble/include/nimble/ble.h b/nimble/include/nimble/ble.h
index d76603bf..703c6dc5 100644
--- a/nimble/include/nimble/ble.h
+++ b/nimble/include/nimble/ble.h
@@ -76,6 +76,7 @@ struct ble_mbuf_hdr_rxinfo
 };
 
 /* Flag definitions for rxinfo  */
+#define BLE_MBUF_HDR_F_INITA_RESOLVED   (0x2000)
 #define BLE_MBUF_HDR_F_EXT_ADV_SEC      (0x1000)
 #define BLE_MBUF_HDR_F_EXT_ADV          (0x0800)
 #define BLE_MBUF_HDR_F_RESOLVED         (0x0400)
@@ -134,6 +135,9 @@ struct ble_mbuf_hdr
 #define BLE_MBUF_HDR_RESOLVED(hdr)      \
     (!!((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_RESOLVED))
 
+#define BLE_MBUF_HDR_INITA_RESOLVED(hdr)      \
+    (!!((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_INITA_RESOLVED))
+
 #define BLE_MBUF_HDR_RX_STATE(hdr)      \
     ((uint8_t)((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_RXSTATE_MASK))
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services