X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprotocol.c;h=ef6018020cd066f77d31801fefb459771b9aef09;hp=a8860fb2929c473d90c69f2e547478db68021189;hb=1e2bdc2b6d28c76c63fc9fd36169b90fa0994388;hpb=6365d0627b9b1e9a31371ec891db0d2cfb4d6ed4 diff --git a/src/protocol.c b/src/protocol.c index a8860fb2..ef601802 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.c,v 1.28.4.96 2001/07/01 09:21:01 guus Exp $ + $Id: protocol.c,v 1.28.4.98 2001/07/04 08:41:36 guus Exp $ */ #include "config.h" @@ -40,25 +40,14 @@ #include -#ifdef HAVE_OPENSSL_SHA_H -# include -#else -# include -#endif - -#ifdef HAVE_OPENSSL_RAND_H -# include -#else -# include -#endif +#include +#include +#include -#ifdef HAVE_OPENSSL_EVP_H -# include -#else -# include +#ifndef HAVE_RAND_PSEUDO_BYTES +#define RAND_pseudo_bytes RAND_bytes #endif - #include "conf.h" #include "net.h" #include "netutl.h" @@ -227,22 +216,22 @@ cp return -1; } - /* First check if the host we connected to is already in our + /* First check if the host is already in our connection list. If so, we are probably making a loop, which is not desirable. */ - if(cl->status.outgoing) + if((old = lookup_id(cl->name))) { - if((old = lookup_id(cl->name))) + if(debug_lvl >= DEBUG_CONNECTIONS) + syslog(LOG_NOTICE, _("%s (%s) is already in our connection list"), cl->name, cl->hostname); + if(cl->status.outgoing) { - if(debug_lvl >= DEBUG_CONNECTIONS) - syslog(LOG_NOTICE, _("Uplink %s (%s) is already in our connection list"), cl->name, cl->hostname); cl->status.outgoing = 0; old->status.outgoing = 1; - terminate_connection(cl); - return 0; } + terminate_connection(cl); + return 0; } /* Now we can add the name to the id tree */ @@ -1066,7 +1055,7 @@ int send_ping(connection_t *cl) cp cl->status.pinged = 1; cl->last_ping_time = time(NULL); - RAND_bytes(salt, SALTLEN); + RAND_pseudo_bytes(salt, SALTLEN); bin2hex(salt, salt, SALTLEN); salt[SALTLEN*2] = '\0'; cp @@ -1083,7 +1072,7 @@ int send_pong(connection_t *cl) { char salt[SALTLEN*2+1]; cp - RAND_bytes(salt, SALTLEN); + RAND_pseudo_bytes(salt, SALTLEN); bin2hex(salt, salt, SALTLEN); salt[SALTLEN*2] = '\0'; cp