Put minor protocol version in connection options so other nodes can see it.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 17 Jul 2012 16:05:55 +0000 (18:05 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 17 Jul 2012 16:05:55 +0000 (18:05 +0200)
This allows two nodes that do not have a meta-connection with each other see
which version they are.

src/connection.h
src/info.c
src/net_setup.c
src/protocol.h
src/protocol_auth.c

index 2b6870e..4495576 100644 (file)
@@ -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 */
index 6d0435f..df5d11d 100644 (file)
@@ -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");
index 3285a32..5bcdfba 100644 (file)
@@ -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;
index 540a7c3..ee6f1f0 100644 (file)
@@ -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 */
 
index ccb7976..3fd80c4 100644 (file)
@@ -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) {