ccollins476ad commented on a change in pull request #279: BLE Host - Policy for 
SM key overflow
URL: 
https://github.com/apache/incubator-mynewt-core/pull/279#discussion_r122791440
 
 

 ##########
 File path: net/nimble/host/src/ble_sm.c
 ##########
 @@ -892,6 +895,72 @@ ble_sm_key_dist(struct ble_sm_proc *proc,
     }
 }
 
+static int
+ble_sm_chk_store_overflow_once(int is_our_sec, uint16_t conn_handle)
+{
+#if !MYNEWT_VAL(BLE_SM_BONDING)
+    return 0;
+#endif
+
+    struct ble_store_status_event event;
+    int obj_type;
+    int count;
+    int rc;
+
+    if (is_our_sec) {
+        obj_type = BLE_STORE_OBJ_TYPE_OUR_SEC;
+    } else {
+        obj_type = BLE_STORE_OBJ_TYPE_PEER_SEC;
+    }
+
+    rc = ble_store_util_count(obj_type, &count);
+    if (rc != 0) {
+        return rc;
+    }
+
+    /* Pessimistically assume all active procs will persist bonds. */
+    ble_hs_lock();
+    count += ble_sm_num_procs();
+    ble_hs_unlock();
+
+    if (count < MYNEWT_VAL(BLE_STORE_MAX_BONDS)) {
+        /* There is sufficient capacity for another bond. */
+        return 0;
+    }
+
+    /* No capacity for an additional bond.  Tell the application to make
+     * room.
+     */
+    memset(&event, 0, sizeof event);
+    event.obj_type = obj_type;
 
 Review comment:
   OK, I understand.  Thanks, that is a good idea.  I have added two functions:
   
   ```
   int ble_store_overflow_event(int obj_type, const union ble_store_value 
*value);
   int ble_store_overflow_next_event(int obj_type, uint16_t conn_handle);
   ```
   
   and made `ble_store_status` static.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to