]> git.meshlink.io Git - meshlink-tiny/blobdiff - src/meshlink_internal.h
Add a metering test.
[meshlink-tiny] / src / meshlink_internal.h
index af3a2501a646e37bc6d8c321f62ae4e998ada872..f77d700692f410ec34b6284583e5e253ee9de6de 100644 (file)
@@ -45,12 +45,7 @@ static const char meshlink_udp_label[] = "MeshLink UDP";
 #define MESHLINK_CONFIG_VERSION 2
 #define MESHLINK_INVITATION_VERSION 2
 
-typedef struct listen_socket_t {
-       struct io_t tcp;
-       struct io_t udp;
-       sockaddr_t sa;
-       sockaddr_t broadcast_sa;
-} listen_socket_t;
+#define CORE_MESH "."
 
 struct meshlink_open_params {
        char *confbase;
@@ -93,32 +88,18 @@ struct meshlink_handle {
 
        // The most important network-related members come first
        int reachable;
-       int listen_sockets;
-       listen_socket_t listen_socket[MAXSOCKETS];
 
        meshlink_receive_cb_t receive_cb;
        meshlink_queue_t outpacketqueue;
        signal_t datafromapp;
 
-       hash_t *node_udp_cache;
+       struct node_t *peer;
+       struct connection_t *connection;
+       struct outgoing_t *outgoing;
 
-       struct splay_tree_t *nodes;
-       struct splay_tree_t *edges;
-
-       struct list_t *connections;
-       struct list_t *outgoings;
-       struct list_t *submeshes;
-
-       // Meta-connection-related members
-       struct splay_tree_t *past_request_tree;
-       timeout_t past_request_timeout;
-
-       int connection_burst;
        int contradicting_add_edge;
        int contradicting_del_edge;
        int sleeptime;
-       time_t connection_burst_time;
-       time_t last_hard_try;
        time_t last_unreachable;
        timeout_t pingtimer;
        timeout_t periodictimer;
@@ -127,15 +108,9 @@ struct meshlink_handle {
        uint64_t prng_state[4];
        uint32_t session_id;
 
-       int next_pit;
-       int pits[10];
-
        // Infrequently used callbacks
        meshlink_node_status_cb_t node_status_cb;
        meshlink_node_status_cb_t meta_status_cb;
-       meshlink_node_pmtu_cb_t node_pmtu_cb;
-       meshlink_channel_listen_cb_t channel_listen_cb;
-       meshlink_channel_accept_cb_t channel_accept_cb;
        meshlink_node_duplicate_cb_t node_duplicate_cb;
        meshlink_connection_try_cb_t connection_try_cb;
        meshlink_error_cb_t error_cb;
@@ -148,8 +123,6 @@ struct meshlink_handle {
 
        dev_class_t devclass;
 
-       int udp_choice;
-
        dev_class_traits_t dev_class_traits[DEV_CLASS_COUNT];
 
        int netns;
@@ -167,29 +140,6 @@ struct meshlink_handle {
        pthread_t thread;
        pthread_cond_t cond;
        bool threadstarted;
-
-       // mDNS discovery
-       struct {
-               bool enabled;
-               io_t pfroute_io;
-               int *ifaces;
-               struct discovery_address *addresses;
-               int iface_count;
-               int address_count;
-               io_t sockets[2];
-               time_t last_update;
-#ifdef __APPLE__
-               pthread_t thread;
-               void *runloop;
-#endif
-       } discovery;
-
-       // ADNS
-       pthread_t adns_thread;
-       pthread_cond_t adns_cond;
-       meshlink_queue_t adns_queue;
-       meshlink_queue_t adns_done_queue;
-       signal_t adns_signal;
 };
 
 /// A handle for a MeshLink node.
@@ -198,48 +148,8 @@ struct meshlink_node {
        void *priv;
 };
 
-/// A handle for a node Sub-Mesh.
-struct meshlink_submesh {
-       const char *name;
-       void *priv;
-};
-
-/// An AIO buffer.
-typedef struct meshlink_aio_buffer {
-       const void *data;
-       int fd;
-       size_t len;
-       size_t done;
-       union {
-               meshlink_aio_cb_t buffer;
-               meshlink_aio_fd_cb_t fd;
-       } cb;
-       void *priv;
-       struct meshlink_aio_buffer *next;
-} meshlink_aio_buffer_t;
-
-/// A channel.
-struct meshlink_channel {
-       struct node_t *node;
-       void *priv;
-       bool in_callback;
-
-       struct utcp_connection *c;
-       meshlink_aio_buffer_t *aio_send;
-       meshlink_aio_buffer_t *aio_receive;
-       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];
-       uint8_t source[16];
-} __attribute__((__packed__)) meshlink_packethdr_t;
-
 void meshlink_send_from_queue(event_loop_t *loop, void *mesh);
 void update_node_status(meshlink_handle_t *mesh, struct node_t *n);
-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;
 void handle_duplicate_node(meshlink_handle_t *mesh, struct node_t *n);