]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink_internal.h
Refactor the non-blackbox test suite.
[meshlink] / src / meshlink_internal.h
index 3b7e66cdf93e374afed0f333faed4988de673d3e..f32e87e65b18a20959b26dcd1404fc4a46473437 100644 (file)
@@ -32,6 +32,7 @@
 #include "meshlink_queue.h"
 #include "sockaddr.h"
 #include "sptps.h"
+#include "xoshiro.h"
 
 #include <pthread.h>
 
@@ -130,6 +131,7 @@ struct meshlink_handle {
        timeout_t periodictimer;
 
        struct connection_t *everyone;
+       uint64_t prng_state[4];
 
        int next_pit;
        int pits[10];
@@ -247,13 +249,20 @@ typedef struct meshlink_packethdr {
        uint8_t source[16];
 } __attribute__((__packed__)) meshlink_packethdr_t;
 
-extern void meshlink_send_from_queue(event_loop_t *el, meshlink_handle_t *mesh);
+extern void meshlink_send_from_queue(event_loop_t *loop, void *mesh);
 extern void update_node_status(meshlink_handle_t *mesh, struct node_t *n);
 extern void update_node_pmtu(meshlink_handle_t *mesh, struct node_t *n);
 extern meshlink_log_level_t global_log_level;
 extern meshlink_log_cb_t global_log_cb;
-extern int check_port(meshlink_handle_t *mesh);
 extern void handle_duplicate_node(meshlink_handle_t *mesh, struct node_t *n);
 extern void handle_network_change(meshlink_handle_t *mesh, bool online);
 
+/// Per-instance PRNG
+static inline int prng(meshlink_handle_t *mesh, uint64_t max) {
+       return xoshiro(mesh->prng_state) % max;
+}
+
+/// Fudge value of ~0.1 seconds, in microseconds.
+static const unsigned int TIMER_FUDGE = 0x20000;
+
 #endif