]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink_internal.h
Add meta-connection attempt callback feature
[meshlink] / src / meshlink_internal.h
index 492e2b2bd4d1c617a7fdff51ded5bfe5e6a64532..a40de535a8dbc911f80ef10507354bbb9936e8ec 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
     meshlink_internal.h -- Internal parts of the public API.
-    Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
+    Copyright (C) 2014-2019 Guus Sliepen <guus@meshlink.io>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#ifdef MESHLINK_H
+#error You must not include both meshlink.h and meshlink_internal.h!
+#endif
+
 #include "system.h"
 
 #include "event.h"
@@ -55,9 +59,17 @@ typedef enum proxytype_t {
        PROXY_SOCKS4A,
        PROXY_SOCKS5,
        PROXY_HTTP,
-       PROXY_EXEC,
 } proxytype_t;
 
+struct meshlink_open_params {
+       char *confbase;
+       char *appname;
+       char *name;
+       dev_class_t devclass;
+
+       int netns;
+};
+
 /// A handle for an instance of MeshLink.
 struct meshlink_handle {
        char *name;
@@ -67,6 +79,7 @@ struct meshlink_handle {
        dev_class_t devclass;
 
        char *confbase;
+       FILE *conffile;
 
        meshlink_receive_cb_t receive_cb;
        meshlink_node_status_cb_t node_status_cb;
@@ -74,10 +87,11 @@ struct meshlink_handle {
        meshlink_log_level_t log_level;
 
        meshlink_channel_accept_cb_t channel_accept_cb;
+       meshlink_node_duplicate_cb_t node_duplicate_cb;
+       meshlink_connection_try_cb_t connection_try_cb;
 
        pthread_t thread;
        bool threadstarted;
-       pthread_mutex_t outpacketqueue_mutex;
        pthread_mutex_t mesh_mutex;
        event_loop_t loop;
        listen_socket_t listen_socket[MAXSOCKETS];
@@ -92,6 +106,7 @@ struct meshlink_handle {
 
        struct list_t *connections;
        struct list_t *outgoings;
+       struct list_t *submeshes;
 
        meshlink_queue_t outpacketqueue;
 
@@ -122,6 +137,7 @@ struct meshlink_handle {
        hash_t *node_udp_cache;
        struct connection_t *everyone;
        struct ecdsa *invitation_key;
+       int invitation_timeout;
 
        int pinginterval;       /* seconds between pings */
        int pingtimeout;        /* seconds to wait for response */
@@ -143,7 +159,9 @@ struct meshlink_handle {
        struct CattaSServiceBrowser *catta_browser;
        struct CattaSimplePoll *catta_poll;
        struct CattaSEntryGroup *catta_group;
-       char* catta_servicetype;
+       char *catta_servicetype;
+
+       int netns;
 };
 
 /// A handle for a MeshLink node.
@@ -152,6 +170,12 @@ struct meshlink_node {
        void *priv;
 };
 
+/// A handle for a node Sub-Mesh.
+struct meshlink_submesh {
+       const char *name;
+       void *priv;
+};
+
 /// A channel.
 struct meshlink_channel {
        struct node_t *node;
@@ -168,10 +192,12 @@ 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 *el, meshlink_handle_t *mesh);
 extern void update_node_status(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);
 
 /// Device class traits
 typedef struct {