Add a minor number to the protocol version.

This commit is contained in:
Guus Sliepen 2011-07-05 21:19:48 +02:00
parent b99656d84a
commit 9708bbfa8e
6 changed files with 17 additions and 16 deletions

View file

@ -56,7 +56,8 @@ typedef struct connection_t {
union sockaddr_t address; /* his real (internet) ip */ union sockaddr_t address; /* his real (internet) ip */
char *hostname; /* the hostname of its real ip */ char *hostname; /* the hostname of its real ip */
int protocol_version; /* used protocol */ int protocol_major; /* used protocol */
int protocol_minor; /* used protocol */
int socket; /* socket used for this connection */ int socket; /* socket used for this connection */
uint32_t options; /* options for this connection */ uint32_t options; /* options for this connection */

View file

@ -239,7 +239,8 @@ static bool setup_myself(void) {
myself->connection->hostname = xstrdup("MYSELF"); myself->connection->hostname = xstrdup("MYSELF");
myself->connection->options = 0; myself->connection->options = 0;
myself->connection->protocol_version = PROT_CURRENT; myself->connection->protocol_major = PROT_MAJOR;
myself->connection->protocol_minor = PROT_MINOR;
if(!get_config_string(lookup_config(config_tree, "Name"), &name)) { /* Not acceptable */ if(!get_config_string(lookup_config(config_tree, "Name"), &name)) { /* Not acceptable */
logger(LOG_ERR, "Name for tinc daemon required!"); logger(LOG_ERR, "Name for tinc daemon required!");

View file

@ -21,11 +21,10 @@
#ifndef __TINC_PROTOCOL_H__ #ifndef __TINC_PROTOCOL_H__
#define __TINC_PROTOCOL_H__ #define __TINC_PROTOCOL_H__
/* Protocol version. Different versions are incompatible, /* Protocol version. Different major versions are incompatible. */
incompatible version have different protocols.
*/
#define PROT_CURRENT 17 #define PROT_MAJOR 17
#define PROT_MINOR 0
/* Silly Windows */ /* Silly Windows */

View file

@ -40,14 +40,14 @@
bool send_id(connection_t *c) { bool send_id(connection_t *c) {
gettimeofday(&c->start, NULL); gettimeofday(&c->start, NULL);
return send_request(c, "%d %s %d", ID, myself->connection->name, return send_request(c, "%d %s %d.%d", ID, myself->connection->name,
myself->connection->protocol_version); myself->connection->protocol_major, myself->connection->protocol_minor);
} }
bool id_h(connection_t *c, char *request) { bool id_h(connection_t *c, char *request) {
char name[MAX_STRING_SIZE]; char name[MAX_STRING_SIZE];
if(sscanf(request, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) { if(sscanf(request, "%*d " MAX_STRING " %d.%d", name, &c->protocol_major, &c->protocol_minor) < 2) {
logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name, logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name,
c->hostname); c->hostname);
return false; return false;
@ -86,9 +86,9 @@ bool id_h(connection_t *c, char *request) {
/* Check if version matches */ /* Check if version matches */
if(c->protocol_version != myself->connection->protocol_version) { if(c->protocol_major != myself->connection->protocol_major) {
logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d", logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d.%d",
c->name, c->hostname, c->protocol_version); c->name, c->hostname, c->protocol_major, c->protocol_minor);
return false; return false;
} }

View file

@ -497,8 +497,8 @@ int main(int argc, char *argv[], char *envp[]) {
make_names(); make_names();
if(show_version) { if(show_version) {
printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE, printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT); VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR);
printf("Copyright (C) 1998-2009 Ivo Timmermans, Guus Sliepen and others.\n" printf("Copyright (C) 1998-2009 Ivo Timmermans, Guus Sliepen and others.\n"
"See the AUTHORS file for a complete list.\n\n" "See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"

View file

@ -356,8 +356,8 @@ int main(int argc, char **argv) {
make_names(); make_names();
if(show_version) { if(show_version) {
printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE, printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT); VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR);
printf("Copyright (C) 1998-2011 Ivo Timmermans, Guus Sliepen and others.\n" printf("Copyright (C) 1998-2011 Ivo Timmermans, Guus Sliepen and others.\n"
"See the AUTHORS file for a complete list.\n\n" "See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"