rymanluk 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_r121058416
 
 

 ##########
 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:
   I was hoping to extract that part of code as a helper which sends overflow 
event, but maybe we can do it when see need to construct same events in more 
places. 
 
----------------------------------------------------------------
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