[ds6-devel] nc6/src connection.c,1.16,1.17 connection.h,1.8,1.9 parser.c,1.28,1.29

chris at deepspace6.net chris@deepspace6.net
Fri Jan 3 09:30:22 CET 2003


Update of /cvs/nc6/src

Modified Files:
	connection.c connection.h parser.c 
Log Message:
Changed connection_attributes sock_protocol to sock_family and sock_type to
sock_protocol, since that's what they really are.


Index: connection.c
===================================================================
RCS file: /cvs/nc6/src/connection.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- connection.c	3 Jan 2003 00:14:39 -0000	1.16
+++ connection.c	3 Jan 2003 09:30:20 -0000	1.17
@@ -38,8 +38,8 @@
 {
 	assert(attrs != NULL);
 
-	attrs->proto = PROTO_UNSPECIFIED;
-	attrs->type  = TCP_SOCKET;
+	attrs->family    = PROTO_UNSPECIFIED;
+	attrs->protocol  = TCP_PROTOCOL;
 
 	address_init(&(attrs->remote_address));
 	address_init(&(attrs->local_address));
@@ -87,7 +87,7 @@
 	assert(ainfo != NULL);
 	assert(attrs != NULL);
 
-	switch (attrs->proto) {
+	switch (attrs->family) {
 		case PROTO_IPv6:
 #ifdef ENABLE_IPV6
 			ainfo->ai_family = PF_INET6;
@@ -105,8 +105,8 @@
 			fatal("internal error: unknown socket domain");
 	}
 	
-	switch (attrs->type) {
-		case UDP_SOCKET:
+	switch (attrs->protocol) {
+		case UDP_PROTOCOL:
 			ainfo->ai_protocol = IPPROTO_UDP;
 			/* strictly speaking, this should not be required
 			 * since UDP implies a DGRAM type socket.  However, on
@@ -114,7 +114,7 @@
 			 * IPPROTO_UDP and don't set this */
 			ainfo->ai_socktype = SOCK_DGRAM;
 			break;
-		case TCP_SOCKET:
+		case TCP_PROTOCOL:
 			ainfo->ai_protocol = IPPROTO_TCP;
 			/* strictly speaking, this should not be required
 			 * since TCP implies a STREAM type socket.  However,
Index: connection.h
===================================================================
RCS file: /cvs/nc6/src/connection.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- connection.h	3 Jan 2003 09:11:59 -0000	1.8
+++ connection.h	3 Jan 2003 09:30:20 -0000	1.9
@@ -26,16 +26,16 @@
 #include <netdb.h>
 #include <sys/time.h>
 
-typedef enum sock_type_t {
-	TCP_SOCKET,
-	UDP_SOCKET
-} sock_type;
-
-typedef enum sock_protocol_t {
+typedef enum sock_family_t {
 	PROTO_UNSPECIFIED,
 	PROTO_IPv6,
 	PROTO_IPv4
-} sock_proto;
+} sock_family;
+
+typedef enum sock_protocol_t {
+	TCP_PROTOCOL,
+	UDP_PROTOCOL
+} sock_protocol;
 
 typedef struct address_t
 {
@@ -47,8 +47,8 @@
 
 typedef struct connection_attributes_t
 {
-	sock_proto proto;
-	sock_type  type;
+	sock_family   family;
+	sock_protocol protocol;
 	address remote_address;
 	address local_address;
 	circ_buf remote_buffer;
@@ -58,8 +58,8 @@
 	int connect_timeout;
 } connection_attributes;
 
-#define ca_set_protocol(CA, PROTO)	((CA)->proto = (PROTO))
-#define ca_set_socket_type(CA, ST)	((CA)->type = (ST))
+#define ca_set_family(CA, FAMILY)	((CA)->family = (FAMILY))
+#define ca_set_protocol(CA, PROTO)	((CA)->protocol = (PROTO))
 #define ca_set_remote_addr(CA, ADDR)	((CA)->remote_address = (ADDR))
 #define ca_set_local_addr(CA, ADDR)	((CA)->local_address  = (ADDR))
 
Index: parser.c
===================================================================
RCS file: /cvs/nc6/src/parser.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- parser.c	3 Jan 2003 09:11:59 -0000	1.28
+++ parser.c	3 Jan 2003 09:30:20 -0000	1.29
@@ -104,8 +104,8 @@
 	size_t remote_buffer_size = 0;
 	size_t local_buffer_size = 0;
 	int option_index = 0;
-	sock_proto protocol;
-	sock_type socket_type;
+	sock_family family;
+	sock_protocol protocol;
 	int connect_timeout = -1;
 	address local_address, remote_address;
 	bool half_close = FALSE;
@@ -115,8 +115,8 @@
 	address_init(&local_address);
 
 	/* set socket types to default values */
-	protocol = PROTO_UNSPECIFIED;
-	socket_type = TCP_SOCKET;
+	family = PROTO_UNSPECIFIED;
+	protocol = TCP_PROTOCOL;
 
 	/* option recognition loop */
 	while ((c = getopt_long(argc, argv, "46hlnp:q:s:uvw:x",
@@ -157,14 +157,14 @@
 			}
 			break;
 		case '4':
-			if (protocol != PROTO_UNSPECIFIED) 
+			if (family != PROTO_UNSPECIFIED) 
 			    fatal("cannot specify the address family twice");
-			protocol = PROTO_IPv4;
+			family = PROTO_IPv4;
 			break;
 		case '6':	
-			if (protocol != PROTO_UNSPECIFIED) 
+			if (family != PROTO_UNSPECIFIED) 
 			    fatal("cannot specify the address family twice");
-			protocol = PROTO_IPv6;
+			family = PROTO_IPv6;
 			set_flag(STRICT_IPV6);
 			break;
 		case 'h':	
@@ -190,7 +190,7 @@
 			local_address.address = xstrdup(optarg);
 			break;	
 		case 'u':	
-			socket_type = UDP_SOCKET;
+			protocol = UDP_PROTOCOL;
 			/* set remote buffer sizes and mtu's, iff they haven't
 			 * already been set */
 			if (remote_mtu == 0)
@@ -312,8 +312,8 @@
 	}
 
 	/* setup attrs */
+	ca_set_family(attrs, family);
 	ca_set_protocol(attrs, protocol);
-	ca_set_socket_type(attrs, socket_type);
 	ca_set_remote_addr(attrs, remote_address);
 	ca_set_local_addr(attrs, local_address);
 



More information about the ds6-devel mailing list