From: Guus Sliepen Date: Sat, 24 Oct 2009 14:15:24 +0000 (+0200) Subject: Use uint32_t instead of long int for connection options. X-Git-Tag: release-1.0.11~11 X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=5cbddc68bade0d1f8ded1b784bb27bb44c5dc5dc;hp=468f393c4fabf9223a1bd15adfb3906cde90d547 Use uint32_t instead of long int for connection options. Options should have a fixed width anyway, but this also fixes a possible MinGW compiler bug where %lx tries to print a 64 bit value, even though a long int is only 32 bits. --- diff --git a/src/connection.c b/src/connection.c index 6e942f8e..9a26ec9d 100644 --- a/src/connection.c +++ b/src/connection.c @@ -120,7 +120,7 @@ void dump_connections(void) { for(node = connection_tree->head; node; node = node->next) { c = node->data; - logger(LOG_DEBUG, " %s at %s options %lx socket %d status %04x outbuf %d/%d/%d", + logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d", c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof c->status), c->outbufsize, c->outbufstart, c->outbuflen); } diff --git a/src/connection.h b/src/connection.h index 24c95f4c..b3a7e33f 100644 --- a/src/connection.h +++ b/src/connection.h @@ -56,7 +56,7 @@ typedef struct connection_t { int protocol_version; /* used protocol */ int socket; /* socket used for this connection */ - long int options; /* options for this connection */ + uint32_t options; /* options for this connection */ connection_status_t status; /* status info */ int estimated_weight; /* estimation for the weight of the edge for this connection */ struct timeval start; /* time this connection was started, used for above estimation */ diff --git a/src/edge.c b/src/edge.c index 9e1b31eb..e42dbd17 100644 --- a/src/edge.c +++ b/src/edge.c @@ -118,7 +118,7 @@ void dump_edges(void) { for(node2 = n->edge_tree->head; node2; node2 = node2->next) { e = node2->data; address = sockaddr2hostname(&e->address); - logger(LOG_DEBUG, " %s to %s at %s options %lx weight %d", + logger(LOG_DEBUG, " %s to %s at %s options %x weight %d", e->from->name, e->to->name, address, e->options, e->weight); free(address); } diff --git a/src/edge.h b/src/edge.h index dc5cf461..4c65213b 100644 --- a/src/edge.h +++ b/src/edge.h @@ -31,7 +31,7 @@ typedef struct edge_t { struct node_t *to; sockaddr_t address; - long int options; /* options turned on for this edge */ + uint32_t options; /* options turned on for this edge */ int weight; /* weight of this edge */ struct connection_t *connection; /* connection associated with this edge, if available */ diff --git a/src/node.c b/src/node.c index c1f12194..b323dca3 100644 --- a/src/node.c +++ b/src/node.c @@ -162,7 +162,7 @@ void dump_nodes(void) { for(node = node_tree->head; node; node = node->next) { n = node->data; - logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s pmtu %d (min %d max %d)", + logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)", n->name, n->hostname, n->outcipher ? n->outcipher->nid : 0, n->outdigest ? n->outdigest->type : 0, n->outmaclength, n->outcompression, n->options, bitfield_to_int(&n->status, sizeof n->status), n->nexthop ? n->nexthop->name : "-", diff --git a/src/node.h b/src/node.h index 619baa94..a621a0a2 100644 --- a/src/node.h +++ b/src/node.h @@ -39,7 +39,7 @@ typedef struct node_status_t { typedef struct node_t { char *name; /* name of this node */ - long int options; /* options turned on for this node */ + uint32_t options; /* options turned on for this node */ sockaddr_t address; /* his real (internet) ip to send UDP packets to */ char *hostname; /* the hostname of its real ip */ diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 24f591a7..c2df4cd8 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -455,7 +455,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 %lx", ACK, myport, c->estimated_weight, c->options); + return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, c->options); } static void send_everything(connection_t *c) { @@ -494,10 +494,10 @@ bool ack_h(connection_t *c) { char hisport[MAX_STRING_SIZE]; char *hisaddress, *dummy; int weight, mtu; - long int options; + uint32_t options; node_t *n; - if(sscanf(c->buffer, "%*d " MAX_STRING " %d %lx", hisport, &weight, &options) != 3) { + if(sscanf(c->buffer, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, c->hostname); return false; diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 9d439225..300333b6 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -41,7 +41,7 @@ bool send_add_edge(connection_t *c, const edge_t *e) { sockaddr2str(&e->address, &address, &port); - x = send_request(c, "%d %x %s %s %s %s %lx %d", ADD_EDGE, rand(), + x = send_request(c, "%d %x %s %s %s %s %x %d", ADD_EDGE, rand(), e->from->name, e->to->name, address, port, e->options, e->weight); free(address); @@ -58,10 +58,10 @@ bool add_edge_h(connection_t *c) { char to_address[MAX_STRING_SIZE]; char to_port[MAX_STRING_SIZE]; sockaddr_t address; - long int options; + uint32_t options; int weight; - if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %lx %d", + if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d", from_name, to_name, to_address, to_port, &options, &weight) != 6) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name, c->hostname);