]> git.meshlink.io Git - meshlink/blob - src/meshlink_internal.h
Move localdiscovery variables 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 "meshlink.h"
27 #include "sockaddr.h"
28
29 typedef enum proxytype_t {
30         PROXY_NONE = 0,
31         PROXY_SOCKS4,
32         PROXY_SOCKS4A,
33         PROXY_SOCKS5,
34         PROXY_HTTP,
35         PROXY_EXEC,
36 } proxytype_t;
37
38 /// A handle for an instance of MeshLink.
39 struct meshlink_handle {
40         char *confbase;
41         char *name;
42
43         meshlink_receive_cb_t receive_cb;
44         meshlink_node_status_cb_t node_status_cb;
45         meshlink_log_cb_t log_cb;
46         meshlink_log_level_t log_level;
47
48         pthread_t thread;
49         struct list_t *sockets;
50
51         struct node_t *self;
52
53         struct splay_tree_t *config;
54         struct splay_tree_t *edges;
55         struct splay_tree_t *nodes;
56
57         struct list_t *connections;
58         struct list_t *outgoings;
59
60         int contradicting_add_edge;
61         int contradicting_del_edge;
62         int sleeptime;
63         time_t last_config_check;
64         timeout_t pingtimer;
65         timeout_t periodictimer;
66
67         char *myport;
68
69         char *proxyhost;
70         char *proxyport;
71         char *proxyuser;
72         char *proxypass;
73         proxytype_t proxytype;
74
75         bool localdiscovery;
76         sockaddr_t localdiscovery_address;
77 };
78
79 /// A handle for a MeshLink node.
80 struct meshlink_node {
81         const char *name;
82         void *priv;
83 };
84
85 // This is a *temporary* global variable which will keep the compiler happy
86 // while refactoring the code to get rid of global variables.
87 // TODO: remove this when no other global variables remain.
88
89 extern meshlink_handle_t *mesh;
90
91 #endif // MESHLINK_INTERNAL_H