-/// Utility function to establish connections based on condition check
-/** The function iterates over all nodes, but skips those that do
- * not pass the condition check.
- *
- * The condition check function is passed
- * a pointer to a random number r between 0 and rand_modulo, a pointer to the
- * current node index i, and the node pointer n. This function should return true
- * if a connection attempt to the node should be made.
- *
- * @param mesh A pointer to the mesh structure
- * @param rand_modulo Random index is selected between 0 and rand_modulo
- * @cond_check A function pointer. This function should return true
- * if a connection attempt to the node should be made
- */
-static void cond_add_connection(meshlink_handle_t *mesh, int rand_modulo, bool (*cond_check)(int*, int*, node_t*)) {
- int r = rand() % rand_modulo;
- int i = 0;
-
- for splay_each(node_t, n, mesh->nodes) {
- /* skip nodes that do not pass condition check */
- if(!(*cond_check)(&i, &r, n))
- continue;
-
- /* check if there is already a connection attempt to this node */
- bool found = false;
- for list_each(outgoing_t, outgoing, mesh->outgoings) {
- if(!strcmp(outgoing->name, n->name)) {
- found = true;
- break;
- }
- }
+// devclass asc, last_successfull_connection desc
+static int node_compare_devclass_asc_lsc_desc(const void *a, const void *b) {
+ const node_t *na = a, *nb = b;