From: Etienne Dechamps Date: Sun, 28 Dec 2014 17:29:03 +0000 (+0000) Subject: Move try_sptps() closer to try_tx(). X-Git-Tag: release-1.1pre12~245 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=5d6478b9fbb7379fe6017b2b74c0f1ccb3d2501f Move try_sptps() closer to try_tx(). This moves related functions together. try_tx() is at the right place since its only caller is send_packet(). This is a pure cut-and-paste change. The reason it was not done in the previous commit is because it would have made the diff harder to review. --- diff --git a/src/net_packet.c b/src/net_packet.c index 1eda53e8..51237d20 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -517,26 +517,6 @@ void receive_tcppacket(connection_t *c, const char *buffer, int len) { receive_packet(c->node, &outpkt); } -// This function tries to get SPTPS keys, if they aren't already known. -// This function makes no guarantees - it is up to the caller to check the node's state to figure out if the keys are available. -static void try_sptps(node_t *n) { - if(n->status.validkey) - return; - - logger(DEBUG_TRAFFIC, LOG_INFO, "No valid key known yet for %s (%s)", n->name, n->hostname); - - if(!n->status.waitingforkey) - send_req_key(n); - else if(n->last_req_key + 10 < now.tv_sec) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "No key from %s after 10 seconds, restarting SPTPS", n->name); - sptps_stop(&n->sptps); - n->status.waitingforkey = false; - send_req_key(n); - } - - return; -} - static void send_sptps_packet(node_t *n, vpn_packet_t *origpkt) { if(!n->status.validkey && !n->connection) return; @@ -935,6 +915,26 @@ bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t return true; } +// This function tries to get SPTPS keys, if they aren't already known. +// This function makes no guarantees - it is up to the caller to check the node's state to figure out if the keys are available. +static void try_sptps(node_t *n) { + if(n->status.validkey) + return; + + logger(DEBUG_TRAFFIC, LOG_INFO, "No valid key known yet for %s (%s)", n->name, n->hostname); + + if(!n->status.waitingforkey) + send_req_key(n); + else if(n->last_req_key + 10 < now.tv_sec) { + logger(DEBUG_ALWAYS, LOG_DEBUG, "No key from %s after 10 seconds, restarting SPTPS", n->name); + sptps_stop(&n->sptps); + n->status.waitingforkey = false; + send_req_key(n); + } + + return; +} + // This function tries to establish a tunnel to a node (or its relay) so that packets can be sent (e.g. get SPTPS keys). // If a tunnel is already established, it tries to improve it (e.g. by trying to establish a UDP tunnel instead of TCP). // This function makes no guarantees - it is up to the caller to check the node's state to figure out if TCP and/or UDP is usable.