X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=d37f2202c23f5fdedfdb70634c1fd49fdef1d936;hb=d2b03f006f98d504e3e30f2d4b91ce02abd19c51;hp=217518061a15a30a15837e5fe7d1afd9b3f95a86;hpb=ca989c0c8b19901cbd7664a9d2b42aa85c9c176e;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index 21751806..d37f2202 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -30,6 +30,7 @@ #include LZO1X_H #endif +#include "address_cache.h" #include "cipher.h" #include "conf.h" #include "connection.h" @@ -138,7 +139,8 @@ static void send_udp_probe_reply(node_t *n, vpn_packet_t *packet, length_t len) static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { if(!DATA(packet)[0]) { logger(DEBUG_TRAFFIC, LOG_INFO, "Got UDP probe request %d from %s (%s)", packet->len, n->name, n->hostname); - return send_udp_probe_reply(n, packet, len); + send_udp_probe_reply(n, packet, len); + return; } if(DATA(packet)[0] == 2) { @@ -153,7 +155,16 @@ static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { /* It's a valid reply: now we know bidirectional communication is possible using the address and socket that the reply packet used. */ - n->status.udp_confirmed = true; + if(!n->status.udp_confirmed) { + n->status.udp_confirmed = true; + fprintf(stderr, "Updating address cache...\n"); + + if(!n->address_cache) { + n->address_cache = open_address_cache(n); + } + + reset_address_cache(n->address_cache, &n->address); + } // Reset the UDP ping timer. n->udp_ping_sent = now; @@ -680,7 +691,8 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { } if(n->status.sptps) { - return send_sptps_packet(n, origpkt); + send_sptps_packet(n, origpkt); + return; } #ifdef DISABLE_LEGACY @@ -869,7 +881,7 @@ bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_ if(relay_supported) { if(direct) { /* Inform the recipient that this packet was sent directly. */ - node_id_t nullid = {}; + node_id_t nullid = {{0}}; memcpy(buf_ptr, &nullid, sizeof(nullid)); buf_ptr += sizeof(nullid); } else { @@ -1347,7 +1359,8 @@ static void try_tx_sptps(node_t *n, bool mtu) { return; } - return try_tx(via, mtu); + try_tx(via, mtu); + return; } /* Otherwise, try to establish UDP connectivity. */ @@ -1569,7 +1582,7 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { static void handle_incoming_vpn_packet(listen_socket_t *ls, vpn_packet_t *pkt, sockaddr_t *addr) { char *hostname; - node_id_t nullid = {}; + node_id_t nullid = {{0}}; node_t *from, *to; bool direct = false;