X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprotocol_key.c;h=1a184fb8f3ba817dccb4553a051361a4bf4b61a9;hp=b326b8d70a1fb75657f95080dec51079fa876ab1;hb=236b0ba4ebba01e22e382e79897100338a039bbb;hpb=9e3ca397735077f85bbde48c36e1b3e0fa950988 diff --git a/src/protocol_key.c b/src/protocol_key.c index b326b8d7..1a184fb8 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -1,7 +1,7 @@ /* protocol_key.c -- handle the meta-protocol, key exchange Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2010 Guus Sliepen + 2000-2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,13 +34,13 @@ #include "utils.h" #include "xalloc.h" -bool mykeyused = false; +static bool mykeyused = false; -void send_key_changed() { +void send_key_changed(void) { avl_node_t *node; connection_t *c; - send_request(broadcast, "%d %x %s", KEY_CHANGED, rand(), myself->name); + send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), myself->name); /* Immediately send new keys to directly connected nodes to keep UDP mappings alive */ @@ -163,7 +163,7 @@ bool send_ans_key(node_t *to) { // Reset sequence number and late packet window mykeyused = true; to->received_seqno = 0; - memset(to->late, 0, sizeof(to->late)); + if(replaywin) memset(to->late, 0, replaywin); // Convert to hexadecimal and send char key[2 * to->inkeylength + 1]; @@ -242,8 +242,6 @@ bool ans_key_h(connection_t *c) { /* Update our copy of the origin's packet key */ from->outkey = xrealloc(from->outkey, strlen(key) / 2); - - from->outkey = xstrdup(key); from->outkeylength = strlen(key) / 2; hex2bin(key, from->outkey, from->outkeylength); @@ -310,7 +308,7 @@ bool ans_key_h(connection_t *c) { update_node_udp(from, &sa); } - if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuprobes) + if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuevent) send_mtu_probe(from); return true;