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_r121185868
 
 

 ##########
 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:
   Isn't that what ble_store_status() does?  Or were you thinking this function 
would take parameters and fill the event object in itself?
 
----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to