+
+ /* Assure that the ID does not exist already */
+ while (1) {
+ if (!silc_idlist_find_client_by_id(server->local_list,
+ *new_id, FALSE, NULL))
+ if (!silc_idlist_find_client_by_id(server->global_list,
+ *new_id, FALSE, NULL))
+ break;
+
+ /* The ID exists, start increasing the rnd from 0 until we find a
+ ID that does not exist. If we wrap and it still exists then we
+ will return FALSE and the caller must send some other nickname
+ since this cannot be used anymore. */
+ (*new_id)->rnd++;
+
+ if (finding && (*new_id)->rnd == 0)
+ return FALSE;
+
+ if (!finding) {
+ (*new_id)->rnd = 0;
+ finding = TRUE;
+ }
+ }
+
+ SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_CLIENT)));
+
+ return TRUE;