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