]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink_internal.h
Add a function to set the default white/blacklisting behaviour.
[meshlink] / src / meshlink_internal.h
index 6b47481f879e972fb4a83f5d801fe9b985cd2382..b3ac72c40a2833f74abd78f68cb292b4a54f2e20 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "event.h"
 #include "hash.h"
-#include "logger.h"
 #include "meshlink.h"
 #include "meshlink_queue.h"
 #include "sockaddr.h"
@@ -55,30 +54,27 @@ typedef enum proxytype_t {
        PROXY_EXEC,
 } proxytype_t;
 
-typedef struct outpacketqueue {
-       meshlink_node_t *destination;
-       const void *data;
-       unsigned int len;
-} outpacketqueue_t;
-
 /// A handle for an instance of MeshLink.
 struct meshlink_handle {
        char *name;
        void *priv;
 
-       char *confbase;
-
        char *appname;
+       dev_class_t devclass;
+
+       char *confbase;
 
        meshlink_receive_cb_t receive_cb;
        meshlink_node_status_cb_t node_status_cb;
        meshlink_log_cb_t log_cb;
        meshlink_log_level_t log_level;
 
+       meshlink_channel_accept_cb_t channel_accept_cb;
+
        pthread_t thread;
        bool threadstarted;
        pthread_mutex_t outpacketqueue_mutex;
-       pthread_mutex_t nodes_mutex;
+       pthread_mutex_t mesh_mutex;
        event_loop_t loop;
        listen_socket_t listen_socket[MAXSOCKETS];
        int listen_sockets;
@@ -116,11 +112,12 @@ struct meshlink_handle {
        bool localdiscovery;
        sockaddr_t localdiscovery_address;
 
+       bool default_blacklist;
+
        hash_t *node_udp_cache;
        struct connection_t *everyone;
        struct ecdsa *invitation_key;
 
-       debug_t debug_level;
        int pinginterval;       /* seconds between pings */
        int pingtimeout;        /* seconds to wait for response */
        int maxtimeout;
@@ -150,6 +147,16 @@ struct meshlink_node {
        void *priv;
 };
 
+/// A channel.
+struct meshlink_channel {
+       struct node_t *node;
+       void *priv;
+
+       struct utcp_connection *c;
+       meshlink_channel_receive_cb_t receive_cb;
+       meshlink_channel_poll_cb_t poll_cb;
+};
+
 /// Header for data packets routed between nodes
 typedef struct meshlink_packethdr {
        uint8_t destination[16];
@@ -157,6 +164,17 @@ typedef struct meshlink_packethdr {
 } __attribute__ ((__packed__)) meshlink_packethdr_t;
 
 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;
+
+/// Device class traits
+typedef struct {
+       unsigned int min_connects;
+       unsigned int max_connects;
+       int edge_weight;
+} dev_class_traits_t;
+
+extern dev_class_traits_t dev_class_traits[];
 
 #endif // MESHLINK_INTERNAL_H