2 meshlink_internal.h -- Internal parts of the public API.
3 Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
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.
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.
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.
20 #ifndef MESHLINK_INTERNAL_H
21 #define MESHLINK_INTERNAL_H
34 #define MAXSOCKETS 8 /* Probably overkill... */
37 struct AvahiSServiceBrowser;
38 struct AvahiSimplePoll;
39 struct AvahiSEntryGroup;
41 typedef struct listen_socket_t {
48 typedef enum proxytype_t {
57 typedef struct outpacketqueue {
58 meshlink_node_t *destination;
63 /// A handle for an instance of MeshLink.
64 struct meshlink_handle {
72 meshlink_receive_cb_t receive_cb;
73 meshlink_node_status_cb_t node_status_cb;
74 meshlink_log_cb_t log_cb;
75 meshlink_log_level_t log_level;
79 pthread_mutex_t outpacketqueue_mutex;
80 pthread_mutex_t nodes_mutex;
82 listen_socket_t listen_socket[MAXSOCKETS];
88 struct splay_tree_t *config;
89 struct splay_tree_t *edges;
90 struct splay_tree_t *nodes;
92 struct list_t *connections;
93 struct list_t *outgoings;
95 struct list_t *outpacketqueue;
97 struct splay_tree_t *past_request_tree;
98 timeout_t past_request_timeout;
100 int contradicting_add_edge;
101 int contradicting_del_edge;
103 time_t last_config_check;
105 timeout_t periodictimer;
113 proxytype_t proxytype;
116 sockaddr_t localdiscovery_address;
118 hash_t *node_udp_cache;
119 struct connection_t *everyone;
120 struct ecdsa *invitation_key;
123 int pinginterval; /* seconds between pings */
124 int pingtimeout; /* seconds to wait for response */
129 char cookie[18], hash[18];
137 pthread_t discovery_thread;
138 bool discovery_threadstarted;
139 struct AvahiServer *avahi_server;
140 struct AvahiSServiceBrowser *avahi_browser;
141 struct AvahiSimplePoll *avahi_poll;
142 struct AvahiSEntryGroup *avahi_group;
143 char* avahi_servicetype;
146 /// A handle for a MeshLink node.
147 struct meshlink_node {
152 /// Header for data packets routed between nodes
153 typedef struct meshlink_packethdr {
154 uint8_t destination[16];
156 } __attribute__ ((__packed__)) meshlink_packethdr_t;
158 extern void meshlink_send_from_queue(event_loop_t* el,meshlink_handle_t *mesh);
161 #endif // MESHLINK_INTERNAL_H