Problem compiling tinc-1.0.8 on gcc-2.95

Unknown borg at uu3.net
Tue Sep 30 13:26:08 CEST 2008


Hello.

I found that anonymous structures does not work on gcc-2.95.
If you guys want to support a bit older platforms I suggest
fixing it.

You can check out patch I created to fix this issue.
I just added 2 extra structures to remove anonymous
structs inside connection_status_t and node_status_t.

Patch is here:
ftp://borg.uu3.net/pub/unix/tinc/tinc.patch

Attaching it as well.

Regards,
Borg
-------------- next part --------------
diff -ubr tinc-1.0.8/src/connection.h tinc-1.0.8.my/src/connection.h
--- tinc-1.0.8/src/connection.h	Thu Aug 10 00:27:26 2006
+++ tinc-1.0.8.my/src/connection.h	Thu Sep 25 10:25:12 2008
@@ -32,8 +32,7 @@
 #define OPTION_TCPONLY		0x0002
 #define OPTION_PMTU_DISCOVERY	0x0004
 
-typedef union connection_status_t {
-	struct {
+struct status_bits_s {
 		int pinged:1;				/* sent ping */
 		int active:1;				/* 1 if active.. */
 		int connecting:1;			/* 1 if we are waiting for a non-blocking connect() to finish */
@@ -44,7 +43,10 @@
 		int decryptin:1;			/* 1 if we have to decrypt incoming traffic */
 		int mst:1;				/* 1 if this connection is part of a minimum spanning tree */
 		int unused:23;
-	};
+};
+	
+typedef union connection_status_t {
+	struct status_bits_s st;
 	uint32_t value;
 } connection_status_t;
 
diff -ubr tinc-1.0.8/src/graph.c tinc-1.0.8.my/src/graph.c
--- tinc-1.0.8/src/graph.c	Fri Jan  5 13:37:51 2007
+++ tinc-1.0.8.my/src/graph.c	Thu Sep 25 11:56:40 2008
@@ -81,7 +81,7 @@
 
 	for(node = connection_tree->head; node; node = node->next) {
 		c = node->data;
-		c->status.mst = false;
+		c->status.st.mst = false;
 	}
 
 	/* Do we have something to do at all? */
@@ -95,7 +95,7 @@
 
 	for(node = node_tree->head; node; node = node->next) {
 		n = node->data;
-		n->status.visited = false;
+		n->status.st.visited = false;
 		nodes++;
 	}
 
@@ -103,8 +103,8 @@
 
 	for(node = edge_weight_tree->head; node; node = node->next) {
 		e = node->data;
-		if(e->from->status.reachable) {
-			e->from->status.visited = true;
+		if(e->from->status.st.reachable) {
+			e->from->status.st.visited = true;
 			break;
 		}
 	}
@@ -115,19 +115,19 @@
 		next = node->next;
 		e = node->data;
 
-		if(!e->reverse || e->from->status.visited == e->to->status.visited) {
+		if(!e->reverse || e->from->status.st.visited == e->to->status.st.visited) {
 			skipped = true;
 			continue;
 		}
 
-		e->from->status.visited = true;
-		e->to->status.visited = true;
+		e->from->status.st.visited = true;
+		e->to->status.st.visited = true;
 
 		if(e->connection)
-			e->connection->status.mst = true;
+			e->connection->status.st.mst = true;
 
 		if(e->reverse->connection)
-			e->reverse->connection->status.mst = true;
+			e->reverse->connection->status.st.mst = true;
 
 		safe_edges++;
 
@@ -170,14 +170,14 @@
 
 	for(node = node_tree->head; node; node = node->next) {
 		n = node->data;
-		n->status.visited = false;
-		n->status.indirect = true;
+		n->status.st.visited = false;
+		n->status.st.indirect = true;
 	}
 
 	/* Begin with myself */
 
-	myself->status.visited = true;
-	myself->status.indirect = false;
+	myself->status.st.visited = true;
+	myself->status.st.indirect = false;
 	myself->nexthop = myself;
 	myself->via = myself;
 	list_insert_head(todo_list, myself);
@@ -213,15 +213,15 @@
 			     of nodes behind it.
 			 */
 
-			indirect = n->status.indirect || e->options & OPTION_INDIRECT
+			indirect = n->status.st.indirect || e->options & OPTION_INDIRECT
 				|| ((n != myself) && sockaddrcmp(&n->address, &e->reverse->address));
 
-			if(e->to->status.visited
-			   && (!e->to->status.indirect || indirect))
+			if(e->to->status.st.visited
+			   && (!e->to->status.st.indirect || indirect))
 				continue;
 
-			e->to->status.visited = true;
-			e->to->status.indirect = indirect;
+			e->to->status.st.visited = true;
+			e->to->status.st.indirect = indirect;
 			e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop;
 			e->to->via = indirect ? n->via : e->to;
 			e->to->options = e->options;
@@ -243,7 +243,7 @@
 					e->to->mtuprobes = 0;
 					e->to->minmtu = 0;
 					e->to->maxmtu = MTU;
-					if(e->to->status.validkey)
+					if(e->to->status.st.validkey)
 						send_mtu_probe(e->to);
 				}
 			}
@@ -263,10 +263,10 @@
 		next = node->next;
 		n = node->data;
 
-		if(n->status.visited != n->status.reachable) {
-			n->status.reachable = !n->status.reachable;
+		if(n->status.st.visited != n->status.st.reachable) {
+			n->status.st.reachable = !n->status.st.reachable;
 
-			if(n->status.reachable) {
+			if(n->status.st.reachable) {
 				ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"),
 					   n->name, n->hostname);
 				avl_insert(node_udp_tree, n);
@@ -276,8 +276,8 @@
 				avl_delete(node_udp_tree, n);
 			}
 
-			n->status.validkey = false;
-			n->status.waitingforkey = false;
+			n->status.st.validkey = false;
+			n->status.st.waitingforkey = false;
 
 			n->maxmtu = MTU;
 			n->minmtu = 0;
@@ -292,10 +292,10 @@
 			asprintf(&envp[5], "REMOTEPORT=%s", port);
 			envp[6] = NULL;
 
-			execute_script(n->status.reachable ? "host-up" : "host-down", envp);
+			execute_script(n->status.st.reachable ? "host-up" : "host-down", envp);
 
 			asprintf(&name,
-					 n->status.reachable ? "hosts/%s-up" : "hosts/%s-down",
+					 n->status.st.reachable ? "hosts/%s-up" : "hosts/%s-down",
 					 n->name);
 			execute_script(name, envp);
 
@@ -306,7 +306,7 @@
 			for(i = 0; i < 6; i++)
 				free(envp[i]);
 
-			subnet_update(n, NULL, n->status.reachable);
+			subnet_update(n, NULL, n->status.st.reachable);
 		}
 	}
 }
diff -ubr tinc-1.0.8/src/meta.c tinc-1.0.8.my/src/meta.c
--- tinc-1.0.8/src/meta.c	Tue Nov 14 14:28:11 2006
+++ tinc-1.0.8.my/src/meta.c	Thu Sep 25 11:19:53 2008
@@ -59,7 +59,7 @@
 	}
 
 	/* Add our data to buffer */
-	if(c->status.encryptout) {
+	if(c->status.st.encryptout) {
 		result = EVP_EncryptUpdate(c->outctx, (unsigned char *)c->outbuf + c->outbufstart + c->outbuflen,
 				&outlen, (unsigned char *)buffer, length);
 		if(!result || outlen < length) {
@@ -126,7 +126,7 @@
 	for(node = connection_tree->head; node; node = node->next) {
 		c = node->data;
 
-		if(c != from && c->status.active)
+		if(c != from && c->status.st.active)
 			send_meta(c, buffer, length);
 	}
 }
@@ -170,7 +170,7 @@
 	while(lenin > 0) {
 		/* Decrypt */
 
-		if(c->status.decryptin && !decrypted) {
+		if(c->status.st.decryptin && !decrypted) {
 			result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin);
 			if(!result || lenout != lenin) {
 				logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"),
diff -ubr tinc-1.0.8/src/net.c tinc-1.0.8.my/src/net.c
--- tinc-1.0.8/src/net.c	Wed Feb 14 11:20:27 2007
+++ tinc-1.0.8.my/src/net.c	Thu Sep 25 11:19:53 2008
@@ -65,7 +65,7 @@
 		nnext = nnode->next;
 		n = nnode->data;
 
-		if(!n->status.reachable) {
+		if(!n->status.st.reachable) {
 			ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Purging node %s (%s)"), n->name,
 					   n->hostname);
 
@@ -93,7 +93,7 @@
 		nnext = nnode->next;
 		n = nnode->data;
 
-		if(!n->status.reachable) {
+		if(!n->status.st.reachable) {
 			for(enode = edge_weight_tree->head; enode; enode = enext) {
 				enext = enode->next;
 				e = enode->data;
@@ -127,7 +127,7 @@
 		next = node->next;
 		c = node->data;
 
-		if(c->status.remove) {
+		if(c->status.st.remove) {
 			connection_del(c);
 			if(!connection_tree->head)
 				purge();
@@ -167,14 +167,14 @@
 {
 	cp();
 
-	if(c->status.remove)
+	if(c->status.st.remove)
 		return;
 
 	ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Closing connection with %s (%s)"),
 			   c->name, c->hostname);
 
-	c->status.remove = true;
-	c->status.active = false;
+	c->status.st.remove = true;
+	c->status.st.active = false;
 
 	if(c->node)
 		c->node->connection = NULL;
@@ -194,7 +194,7 @@
 
 		/* If the node is not reachable anymore but we remember it had an edge to us, clean it up */
 
-		if(report && !c->node->status.reachable) {
+		if(report && !c->node->status.st.reachable) {
 			edge_t *e;
 			e = lookup_edge(c->node, myself);
 			if(e) {
@@ -239,17 +239,17 @@
 		c = node->data;
 
 		if(c->last_ping_time + pingtimeout < now) {
-			if(c->status.active) {
-				if(c->status.pinged) {
+			if(c->status.st.active) {
+				if(c->status.st.pinged) {
 					ifdebug(CONNECTIONS) logger(LOG_INFO, _("%s (%s) didn't respond to PING in %ld seconds"),
 							   c->name, c->hostname, now - c->last_ping_time);
-					c->status.timeout = true;
+					c->status.st.timeout = true;
 					terminate_connection(c, true);
 				} else if(c->last_ping_time + pinginterval < now) {
 					send_ping(c);
 				}
 			} else {
-				if(c->status.remove) {
+				if(c->status.st.remove) {
 					logger(LOG_WARNING, _("Old connection_t for %s (%s) status %04x still lingering, deleting..."),
 						   c->name, c->hostname, c->status.value);
 					connection_del(c);
@@ -257,8 +257,8 @@
 				}
 				ifdebug(CONNECTIONS) logger(LOG_WARNING, _("Timeout from %s (%s) during authentication"),
 						   c->name, c->hostname);
-				if(c->status.connecting) {
-					c->status.connecting = false;
+				if(c->status.st.connecting) {
+					c->status.st.connecting = false;
 					closesocket(c->socket);
 					do_outgoing_connection(c);
 				} else {
@@ -268,11 +268,11 @@
 		}
 
 		if(c->outbuflen > 0 && c->last_flushed_time + pingtimeout < now) {
-			if(c->status.active) {
+			if(c->status.st.active) {
 				ifdebug(CONNECTIONS) logger(LOG_INFO,
 						_("%s (%s) could not flush for %ld seconds (%d bytes remaining)"),
 						c->name, c->hostname, now - c->last_flushed_time, c->outbuflen);
-				c->status.timeout = true;
+				c->status.st.timeout = true;
 				terminate_connection(c, true);
 			}
 		}
@@ -303,12 +303,12 @@
 	for(node = connection_tree->head; node; node = node->next) {
 		c = node->data;
 
-		if(c->status.remove)
+		if(c->status.st.remove)
 			continue;
 
 		if(FD_ISSET(c->socket, readset)) {
-			if(c->status.connecting) {
-				c->status.connecting = false;
+			if(c->status.st.connecting) {
+				c->status.st.connecting = false;
 				getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len);
 
 				if(!result)
@@ -324,14 +324,14 @@
 			}
 
 			if(!receive_meta(c)) {
-				terminate_connection(c, c->status.active);
+				terminate_connection(c, c->status.st.active);
 				continue;
 			}
 		}
 
 		if(FD_ISSET(c->socket, writeset)) {
 			if(!flush_meta(c)) {
-				terminate_connection(c, c->status.active);
+				terminate_connection(c, c->status.st.active);
 				continue;
 			}
 		}
@@ -466,7 +466,7 @@
 				
 				asprintf(&fname, "%s/hosts/%s", confbase, c->name);
 				if(stat(fname, &s) || s.st_mtime > last_config_check)
-					terminate_connection(c, c->status.active);
+					terminate_connection(c, c->status.st.active);
 				free(fname);
 			}
 
diff -ubr tinc-1.0.8/src/net_packet.c tinc-1.0.8.my/src/net_packet.c
--- tinc-1.0.8/src/net_packet.c	Sat Dec 16 13:46:40 2006
+++ tinc-1.0.8.my/src/net_packet.c	Thu Sep 25 11:56:40 2008
@@ -303,7 +303,7 @@
 
 	/* Make sure we have a valid key */
 
-	if(!n->status.validkey) {
+	if(!n->status.st.validkey) {
 		ifdebug(TRAFFIC) logger(LOG_INFO,
 				   _("No valid key known yet for %s (%s), queueing packet"),
 				   n->name, n->hostname);
@@ -317,10 +317,10 @@
 		if(n->queue->count > MAXQUEUELENGTH)
 			list_delete_head(n->queue);
 
-		if(!n->status.waitingforkey)
+		if(!n->status.st.waitingforkey)
 			send_req_key(n->nexthop->connection, myself, n);
 
-		n->status.waitingforkey = true;
+		n->status.st.waitingforkey = true;
 
 		return;
 	}
@@ -427,7 +427,7 @@
 	ifdebug(TRAFFIC) logger(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
 			   packet->len, n->name, n->hostname);
 
-	if(!n->status.reachable) {
+	if(!n->status.st.reachable) {
 		ifdebug(TRAFFIC) logger(LOG_INFO, _("Node %s (%s) is not reachable"),
 				   n->name, n->hostname);
 		return;
@@ -464,7 +464,7 @@
 	for(node = connection_tree->head; node; node = node->next) {
 		c = node->data;
 
-		if(c->status.active && c->status.mst && c != from->nexthop->connection)
+		if(c->status.st.active && c->status.st.mst && c != from->nexthop->connection)
 			send_packet(c->node, packet);
 	}
 }
diff -ubr tinc-1.0.8/src/net_setup.c tinc-1.0.8.my/src/net_setup.c
--- tinc-1.0.8/src/net_setup.c	Sat Dec 16 13:46:40 2006
+++ tinc-1.0.8.my/src/net_setup.c	Thu Sep 25 11:19:53 2008
@@ -437,7 +437,7 @@
 
 	myself->nexthop = myself;
 	myself->via = myself;
-	myself->status.reachable = true;
+	myself->status.st.reachable = true;
 	node_add(myself);
 
 	graph();
diff -ubr tinc-1.0.8/src/net_socket.c tinc-1.0.8.my/src/net_socket.c
--- tinc-1.0.8/src/net_socket.c	Wed May 16 16:42:14 2007
+++ tinc-1.0.8.my/src/net_socket.c	Thu Sep 25 11:19:53 2008
@@ -281,7 +281,7 @@
 		if(!c->outgoing->cfg) {
 			ifdebug(CONNECTIONS) logger(LOG_ERR, _("Could not set up a meta connection to %s"),
 					   c->name);
-			c->status.remove = true;
+			c->status.st.remove = true;
 			retry_outgoing(c->outgoing);
 			return;
 		}
@@ -339,7 +339,7 @@
 		   || WSAGetLastError() == WSAEWOULDBLOCK
 #endif
 		) {
-			c->status.connecting = true;
+			c->status.st.connecting = true;
 			return;
 		}
 
diff -ubr tinc-1.0.8/src/node.h tinc-1.0.8.my/src/node.h
--- tinc-1.0.8/src/node.h	Sat Nov 11 15:43:07 2006
+++ tinc-1.0.8.my/src/node.h	Thu Sep 25 11:56:40 2008
@@ -29,8 +29,7 @@
 #include "list.h"
 #include "subnet.h"
 
-typedef union node_status_t {
-	struct {
+struct node_st_bits {
 		int unused_active:1;			/* 1 if active (not used for nodes) */
 		int validkey:1;				/* 1 if we currently have a valid key for him */
 		int waitingforkey:1;			/* 1 if we already sent out a request */
@@ -38,7 +37,10 @@
 		int reachable:1;			/* 1 if this node is reachable in the graph */
 		int indirect:1;				/* 1 if this node is not directly reachable by us */
 		int unused:26;
-	};
+};
+
+typedef union node_status_t {
+	struct node_st_bits st;
 	uint32_t value;
 } node_status_t;
 
diff -ubr tinc-1.0.8/src/protocol_auth.c tinc-1.0.8.my/src/protocol_auth.c
--- tinc-1.0.8/src/protocol_auth.c	Wed May 16 16:42:14 2007
+++ tinc-1.0.8.my/src/protocol_auth.c	Thu Sep 25 11:19:53 2008
@@ -196,7 +196,7 @@
 			return false;
 		}
 
-		c->status.encryptout = true;
+		c->status.st.encryptout = true;
 	}
 
 	return x;
@@ -272,7 +272,7 @@
 			return false;
 		}
 
-		c->status.decryptin = true;
+		c->status.st.decryptin = true;
 	} else {
 		c->incipher = NULL;
 	}
@@ -572,7 +572,7 @@
 	/* Activate this connection */
 
 	c->allow_request = ALL;
-	c->status.active = true;
+	c->status.st.active = true;
 
 	ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection with %s (%s) activated"), c->name,
 			   c->hostname);
diff -ubr tinc-1.0.8/src/protocol_edge.c tinc-1.0.8.my/src/protocol_edge.c
--- tinc-1.0.8/src/protocol_edge.c	Wed Apr 26 15:53:05 2006
+++ tinc-1.0.8.my/src/protocol_edge.c	Thu Sep 25 11:19:53 2008
@@ -260,7 +260,7 @@
 
 	/* If the node is not reachable anymore but we remember it had an edge to us, clean it up */
 
-	if(!to->status.reachable) {
+	if(!to->status.st.reachable) {
 		e = lookup_edge(to, myself);
 		if(e) {
 			if(!tunnelserver)
diff -ubr tinc-1.0.8/src/protocol_key.c tinc-1.0.8.my/src/protocol_key.c
--- tinc-1.0.8/src/protocol_key.c	Wed Apr 26 15:53:05 2006
+++ tinc-1.0.8.my/src/protocol_key.c	Thu Sep 25 11:56:40 2008
@@ -75,8 +75,8 @@
 		return false;
 	}
 
-	n->status.validkey = false;
-	n->status.waitingforkey = false;
+	n->status.st.validkey = false;
+	n->status.st.waitingforkey = false;
 
 	/* Tell the others */
 
@@ -210,8 +210,8 @@
 	hex2bin(from->key, from->key, from->keylength);
 	from->key[from->keylength] = '\0';
 
-	from->status.validkey = true;
-	from->status.waitingforkey = false;
+	from->status.st.validkey = true;
+	from->status.st.waitingforkey = false;
 	from->sent_seqno = 0;
 
 	/* Check and lookup cipher and digest algorithms */
diff -ubr tinc-1.0.8/src/protocol_misc.c tinc-1.0.8.my/src/protocol_misc.c
--- tinc-1.0.8/src/protocol_misc.c	Wed Apr 26 15:53:05 2006
+++ tinc-1.0.8.my/src/protocol_misc.c	Thu Sep 25 11:19:53 2008
@@ -90,7 +90,7 @@
 	ifdebug(ERROR) logger(LOG_NOTICE, _("Error message from %s (%s): %d: %s"),
 			   c->name, c->hostname, err, errorstring);
 
-	terminate_connection(c, c->status.active);
+	terminate_connection(c, c->status.st.active);
 
 	return true;
 }
@@ -106,7 +106,7 @@
 {
 	cp();
 
-	terminate_connection(c, c->status.active);
+	terminate_connection(c, c->status.st.active);
 
 	return true;
 }
@@ -115,7 +115,7 @@
 {
 	cp();
 
-	c->status.pinged = true;
+	c->status.st.pinged = true;
 	c->last_ping_time = now;
 
 	return send_request(c, "%d", PING);
@@ -139,7 +139,7 @@
 {
 	cp();
 
-	c->status.pinged = false;
+	c->status.st.pinged = false;
 
 	/* Succesful connection, reset timeout if this is an outgoing connection. */
 
diff -ubr tinc-1.0.8/src/protocol_subnet.c tinc-1.0.8.my/src/protocol_subnet.c
--- tinc-1.0.8/src/protocol_subnet.c	Wed Apr 26 15:53:05 2006
+++ tinc-1.0.8.my/src/protocol_subnet.c	Thu Sep 25 11:19:53 2008
@@ -134,7 +134,7 @@
 	*(new = new_subnet()) = s;
 	subnet_add(owner, new);
 
-	if(owner->status.reachable)
+	if(owner->status.st.reachable)
 		subnet_update(owner, new, true);
 
 	/* Tell the rest */
@@ -232,7 +232,7 @@
 
 	/* Finally, delete it. */
 
-	if(owner->status.reachable)
+	if(owner->status.st.reachable)
 		subnet_update(owner, find, false);
 
 	subnet_del(owner, find);
diff -ubr tinc-1.0.8/src/route.c tinc-1.0.8.my/src/route.c
--- tinc-1.0.8/src/route.c	Thu Aug 10 00:31:33 2006
+++ tinc-1.0.8.my/src/route.c	Thu Sep 25 11:19:53 2008
@@ -122,7 +122,7 @@
 
 		for(node = connection_tree->head; node; node = node->next) {
 			c = node->data;
-			if(c->status.active)
+			if(c->status.st.active)
 				send_add_subnet(c, subnet);
 		}
 	}
@@ -151,7 +151,7 @@
 
 			for(node2 = connection_tree->head; node2; node2 = node2->next) {
 				c = node2->data;
-				if(c->status.active)
+				if(c->status.st.active)
 					send_del_subnet(c, s);
 			}
 
@@ -346,7 +346,7 @@
 		return;
 	}
 
-	if(!subnet->owner->status.reachable)
+	if(!subnet->owner->status.st.reachable)
 		route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_UNREACH);
 
 	if(priorityinheritance)
@@ -490,7 +490,7 @@
 		return;
 	}
 
-	if(!subnet->owner->status.reachable)
+	if(!subnet->owner->status.st.reachable)
 		route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE);
 
 	via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via;


More information about the tinc-devel mailing list