#include <zlib.h>
#endif
-#include "cipher.h"
#include "conf.h"
#include "connection.h"
#include "crypto.h"
-#include "digest.h"
#include "graph.h"
#include "logger.h"
#include "meshlink_internal.h"
*/
-static void send_mtu_probe_handler(void *data) {
+static void send_mtu_probe_handler(event_loop_t *loop, void *data) {
node_t *n = data;
int timeout = 1;
if(n->mtuprobes > 32) {
if(!n->minmtu) {
n->mtuprobes = 31;
- timeout = pinginterval;
+ timeout = mesh->pinginterval;
goto end;
}
}
if(n->mtuprobes == 31) {
- timeout = pinginterval;
+ timeout = mesh->pinginterval;
goto end;
} else if(n->mtuprobes == 32) {
- timeout = pingtimeout;
+ timeout = mesh->pingtimeout;
}
for(int i = 0; i < 4 + mesh->localdiscovery; i++) {
len = 64;
vpn_packet_t packet;
+ packet.probe = true;
memset(packet.data, 0, 14);
randomize(packet.data + 14, len - 14);
packet.len = len;
n->prev_received = n->received;
end:
- timeout_set(&n->mtutimeout, &(struct timeval){timeout, rand() % 100000});
+ timeout_set(&mesh->loop, &n->mtutimeout, &(struct timeval){timeout, rand() % 100000});
}
void send_mtu_probe(node_t *n) {
- timeout_add(&n->mtutimeout, send_mtu_probe_handler, n, &(struct timeval){1, 0});
- send_mtu_probe_handler(n);
+ timeout_add(&mesh->loop, &n->mtutimeout, send_mtu_probe_handler, n, &(struct timeval){1, 0});
+ send_mtu_probe_handler(&mesh->loop, n);
}
static void mtu_probe_h(node_t *n, vpn_packet_t *packet, uint16_t len) {
return n;
}
-void handle_incoming_vpn_data(void *data, int flags) {
+void handle_incoming_vpn_data(event_loop_t *loop, void *data, int flags) {
listen_socket_t *ls = data;
vpn_packet_t pkt;
char *hostname;
n = try_harder(&from, &pkt);
if(n)
update_node_udp(n, &from);
- else if(debug_level >= DEBUG_PROTOCOL) {
+ else if(mesh->debug_level >= DEBUG_PROTOCOL) {
hostname = sockaddr2hostname(&from);
logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet from unknown source %s", hostname);
free(hostname);