]> git.meshlink.io Git - meshlink/blob - src/meshlink_internal.h
Move node_udp_cache, everyone and invitation_key to mesh.
[meshlink] / src / meshlink_internal.h
1 /*
2     meshlink_internal.h -- Internal parts of the public API.
3     Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MESHLINK_INTERNAL_H
21 #define MESHLINK_INTERNAL_H
22
23 #include "system.h"
24
25 #include "event.h"
26 #include "hash.h"
27 #include "meshlink.h"
28 #include "sockaddr.h"
29
30 #define MAXSOCKETS 8    /* Probably overkill... */
31
32 typedef struct listen_socket_t {
33         struct io_t tcp;
34         struct io_t udp;
35         sockaddr_t sa;
36         bool bindto;
37 } listen_socket_t;
38
39 typedef enum proxytype_t {
40         PROXY_NONE = 0,
41         PROXY_SOCKS4,
42         PROXY_SOCKS4A,
43         PROXY_SOCKS5,
44         PROXY_HTTP,
45         PROXY_EXEC,
46 } proxytype_t;
47
48 /// A handle for an instance of MeshLink.
49 struct meshlink_handle {
50         char *confbase;
51         char *name;
52
53         meshlink_receive_cb_t receive_cb;
54         meshlink_node_status_cb_t node_status_cb;
55         meshlink_log_cb_t log_cb;
56         meshlink_log_level_t log_level;
57
58         pthread_t thread;
59         listen_socket_t listen_socket[MAXSOCKETS];
60         int listen_sockets;
61
62         struct node_t *self;
63
64         struct splay_tree_t *config;
65         struct splay_tree_t *edges;
66         struct splay_tree_t *nodes;
67
68         struct list_t *connections;
69         struct list_t *outgoings;
70
71         int contradicting_add_edge;
72         int contradicting_del_edge;
73         int sleeptime;
74         time_t last_config_check;
75         timeout_t pingtimer;
76         timeout_t periodictimer;
77
78         char *myport;
79
80         char *proxyhost;
81         char *proxyport;
82         char *proxyuser;
83         char *proxypass;
84         proxytype_t proxytype;
85
86         bool localdiscovery;
87         sockaddr_t localdiscovery_address;
88
89         hash_t *node_udp_cache;
90         struct connection_t *everyone;
91         struct ecdsa *invitation_key;
92 };
93
94 /// A handle for a MeshLink node.
95 struct meshlink_node {
96         const char *name;
97         void *priv;
98 };
99
100 // This is a *temporary* global variable which will keep the compiler happy
101 // while refactoring the code to get rid of global variables.
102 // TODO: remove this when no other global variables remain.
103
104 extern meshlink_handle_t *mesh;
105
106 #endif // MESHLINK_INTERNAL_H