X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_packet.c;h=63d6e4eaf6f2f7aad8ec3593cd617fd1ef1e983a;hb=93f89bcae11e8d250831896bc5694ee8bd2ad22b;hp=a8c8b03619924bfe0e18e493c8e8f221a6891942;hpb=068746e6cb8df6c197f415e09d3ade8426c2db5f;p=meshlink diff --git a/src/net_packet.c b/src/net_packet.c index a8c8b036..63d6e4ea 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -23,11 +23,9 @@ #include #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" @@ -62,7 +60,7 @@ unsigned replaywin = 16; */ -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; @@ -77,7 +75,7 @@ static void send_mtu_probe_handler(void *data) { if(n->mtuprobes > 32) { if(!n->minmtu) { n->mtuprobes = 31; - timeout = pinginterval; + timeout = mesh->pinginterval; goto end; } @@ -104,10 +102,10 @@ static void send_mtu_probe_handler(void *data) { } 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++) { @@ -127,6 +125,7 @@ static void send_mtu_probe_handler(void *data) { len = 64; vpn_packet_t packet; + packet.probe = true; memset(packet.data, 0, 14); randomize(packet.data + 14, len - 14); packet.len = len; @@ -154,12 +153,12 @@ static void send_mtu_probe_handler(void *data) { 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) { @@ -624,7 +623,7 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { 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; @@ -651,7 +650,7 @@ void handle_incoming_vpn_data(void *data, int flags) { 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);