From: Guus Sliepen Date: Tue, 17 Jul 2012 16:05:55 +0000 (+0200) Subject: Put minor protocol version in connection options so other nodes can see it. X-Git-Tag: release-1.1pre3~101 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=76a3ada4eb4032172c3d780915a07680f9954d42;p=oweals%2Ftinc.git Put minor protocol version in connection options so other nodes can see it. This allows two nodes that do not have a meta-connection with each other see which version they are. --- diff --git a/src/connection.h b/src/connection.h index 2b6870e..4495576 100644 --- a/src/connection.h +++ b/src/connection.h @@ -32,6 +32,7 @@ #define OPTION_TCPONLY 0x0002 #define OPTION_PMTU_DISCOVERY 0x0004 #define OPTION_CLAMP_MSS 0x0008 +#define OPTION_VERSION(x) ((x) >> 24) /* Top 8 bits are for protocol minor version */ typedef struct connection_status_t { unsigned int pinged:1; /* sent ping */ diff --git a/src/info.c b/src/info.c index 6d0435f..df5d11d 100644 --- a/src/info.c +++ b/src/info.c @@ -117,6 +117,7 @@ static int info_node(int fd, const char *item) { if(options & OPTION_CLAMP_MSS) printf(" clamp_mss"); printf("\n"); + printf("Protocol: %d.%d\n", PROT_MAJOR, OPTION_VERSION(options)); printf("Reachability: "); if(!*port) printf("can reach itself\n"); diff --git a/src/net_setup.c b/src/net_setup.c index 3285a32..5bcdfba 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -411,6 +411,8 @@ static bool setup_myself(void) { myself->connection->protocol_major = PROT_MAJOR; myself->connection->protocol_minor = PROT_MINOR; + myself->options |= PROT_MINOR << 24; + if(!(name = get_name())) { logger(DEBUG_ALWAYS, LOG_ERR, "Name for tinc daemon required!"); return false; diff --git a/src/protocol.h b/src/protocol.h index 540a7c3..ee6f1f0 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -24,7 +24,7 @@ /* Protocol version. Different major versions are incompatible. */ #define PROT_MAJOR 17 -#define PROT_MINOR 2 +#define PROT_MINOR 2 /* Should not exceed 255! */ /* Silly Windows */ diff --git a/src/protocol_auth.c b/src/protocol_auth.c index ccb7976..3fd80c4 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -506,7 +506,7 @@ bool send_ack(connection_t *c) { get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight); - return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, c->options); + return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (PROT_MINOR << 24)); } static void send_everything(connection_t *c) {