]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink_internal.h
Avoid allocating packet buffers unnecessarily.
[meshlink] / src / meshlink_internal.h
index bad5825591968f4d5bba0ebe88f42108bc70bbc6..f324c10645b556cc20760b3d9227691341e05a0b 100644 (file)
@@ -42,8 +42,8 @@ static const char meshlink_invitation_label[] = "MeshLink invitation";
 static const char meshlink_tcp_label[] = "MeshLink TCP";
 static const char meshlink_udp_label[] = "MeshLink UDP";
 
-#define MESHLINK_CONFIG_VERSION 1
-#define MESHLINK_INVITATION_VERSION 1
+#define MESHLINK_CONFIG_VERSION 2
+#define MESHLINK_INVITATION_VERSION 2
 
 struct CattaServer;
 struct CattaSServiceBrowser;
@@ -55,7 +55,6 @@ typedef struct listen_socket_t {
        struct io_t udp;
        sockaddr_t sa;
        sockaddr_t broadcast_sa;
-       bool bindto;
 } listen_socket_t;
 
 typedef enum proxytype_t {
@@ -82,6 +81,7 @@ struct meshlink_open_params {
 typedef struct {
        int pinginterval;
        int pingtimeout;
+       int fast_retry_period;
        unsigned int min_connects;
        unsigned int max_connects;
        int edge_weight;
@@ -99,8 +99,10 @@ struct meshlink_handle {
        struct node_t *self;
        meshlink_log_cb_t log_cb;
        meshlink_log_level_t log_level;
+       void *packet;
 
        // The most important network-related members come first
+       int reachable;
        int listen_sockets;
        listen_socket_t listen_socket[MAXSOCKETS];
 
@@ -126,8 +128,8 @@ struct meshlink_handle {
        int contradicting_del_edge;
        int sleeptime;
        time_t connection_burst_time;
-       time_t last_config_check;
        time_t last_hard_try;
+       time_t last_unreachable;
        timeout_t pingtimer;
        timeout_t periodictimer;
 
@@ -165,12 +167,14 @@ struct meshlink_handle {
 
        bool default_blacklist;
        bool discovery;         // Whether Catta is enabled or not
-
+       bool inviter_commits_first;
 
        // Configuration
        char *confbase;
-       FILE *conffile;
+       FILE *lockfile;
        void *config_key;
+       char *external_address_url;
+       struct list_t *invitation_addresses;
 
        // Thread management
        pthread_t thread;
@@ -189,17 +193,6 @@ struct meshlink_handle {
        char *catta_servicetype;
        unsigned int catta_interfaces;
 
-       // State used for meshlink_join()
-       int sock;
-       char cookie[18], hash[18];
-       bool success;
-       sptps_t sptps;
-       char *data;
-       size_t thedatalen;
-       size_t blen;
-       char line[4096];
-       char buffer[4096];
-
        // Proxy configuration, currently not exposed.
        char *proxyhost;
        char *proxyport;
@@ -267,6 +260,6 @@ static inline int prng(meshlink_handle_t *mesh, uint64_t max) {
 }
 
 /// Fudge value of ~0.1 seconds, in microseconds.
-static const unsigned int TIMER_FUDGE = 0x20000;
+static const unsigned int TIMER_FUDGE = 0x8000000;
 
 #endif