Use uint32_t instead of long int for connection options.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 24 Oct 2009 14:15:24 +0000 (16:15 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 24 Oct 2009 14:15:24 +0000 (16:15 +0200)
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.

src/connection.c
src/connection.h
src/edge.c
src/edge.h
src/node.c
src/node.h
src/protocol_auth.c
src/protocol_edge.c

index 6e942f8eb96a03a92b7e122a59b2a133cdab5f37..9a26ec9d44cc86df6f3d8f3aa830f93eabf8db88 100644 (file)
@@ -120,7 +120,7 @@ void dump_connections(void) {
 
        for(node = connection_tree->head; node; node = node->next) {
                c = node->data;
 
        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);
        }
                           c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof c->status),
                           c->outbufsize, c->outbufstart, c->outbuflen);
        }
index 24c95f4cb422881999119b658fd02be4d53f34c4..b3a7e33ff1d391a9d5953cded8dc932d31016943 100644 (file)
@@ -56,7 +56,7 @@ typedef struct connection_t {
        int protocol_version;           /* used protocol */
 
        int socket;                                     /* socket used for this connection */
        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 */
        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 */
index 9e1b31ebcf262ba001d3bf3809395841f24a4a9d..e42dbd1739d5e6a24b7c496fce9df03652169266 100644 (file)
@@ -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);
                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);
                }
                                   e->from->name, e->to->name, address, e->options, e->weight);
                        free(address);
                }
index dc5cf461e7351b57c13c5e56c64ef410d1abc695..4c65213b9f1dba9a0d9db39e76d7946bbe448286 100644 (file)
@@ -31,7 +31,7 @@ typedef struct edge_t {
        struct node_t *to;
        sockaddr_t address;
 
        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 */
        int weight;                                     /* weight of this edge */
 
        struct connection_t *connection;        /* connection associated with this edge, if available */
index c1f1219435dad33747cf0974e3b5a7f1674b24fc..b323dca3f3c52de8bdde53811c4adda33757e416 100644 (file)
@@ -162,7 +162,7 @@ void dump_nodes(void) {
 
        for(node = node_tree->head; node; node = node->next) {
                n = node->data;
 
        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 : "-",
                           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 : "-",
index 619baa942c8e24e9717d6bd4f2f8eebe76f607dc..a621a0a204023214ca0604ea07653c8d74439b62 100644 (file)
@@ -39,7 +39,7 @@ typedef struct node_status_t {
 
 typedef struct node_t {
        char *name;                             /* name of this node */
 
 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 */
 
        sockaddr_t address;                     /* his real (internet) ip to send UDP packets to */
        char *hostname;                         /* the hostname of its real ip */
index 24f591a7b7ef693329c25255fcf5f85f70837c65..c2df4cd83badc6e478af94f36167ceaac809e357 100644 (file)
@@ -455,7 +455,7 @@ bool send_ack(connection_t *c) {
 
        get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight);
 
 
        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) {
 }
 
 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;
        char hisport[MAX_STRING_SIZE];
        char *hisaddress, *dummy;
        int weight, mtu;
-       long int options;
+       uint32_t options;
        node_t *n;
 
        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;
                logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name,
                           c->hostname);
                return false;
index 9d439225678b12d1afdfcd66774c8ef2d346be73..300333b6b42b9567bbc21f4d21c903267982616d 100644 (file)
@@ -41,7 +41,7 @@ bool send_add_edge(connection_t *c, const edge_t *e) {
 
        sockaddr2str(&e->address, &address, &port);
 
 
        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);
                                         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;
        char to_address[MAX_STRING_SIZE];
        char to_port[MAX_STRING_SIZE];
        sockaddr_t address;
-       long int options;
+       uint32_t options;
        int weight;
 
        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);
                          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);