[evolution-data-server/camel-socks-proxy] Oops, struct sockaddr_in is already in network byte order.



commit 0395a0cc500b373423de890aa21c274847eaebb8
Author: Federico Mena Quintero <federico novell com>
Date:   Mon May 31 16:47:48 2010 -0500

    Oops, struct sockaddr_in is already in network byte order.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-tcp-stream-raw.c |    8 ++------
 camel/camel-tcp-stream-ssl.c |    8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 3250fc3..a8b6d4b 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -413,7 +413,6 @@ connect_to_socks4_proxy (const gchar *proxy_host, gint proxy_port, struct addrin
 	gint fd;
 	gchar request[9];
 	struct sockaddr_in *sin;
-	guint32 network_address;
 	gchar reply[8];
 
 	g_assert (proxy_host != NULL);
@@ -436,14 +435,11 @@ connect_to_socks4_proxy (const gchar *proxy_host, gint proxy_port, struct addrin
 
 	g_assert (connect_addr->ai_addr->sa_family == AF_INET); /* FIXME: what to do about IPv6?  Are we just screwed with SOCKS4? */
 	sin = (struct sockaddr_in *) connect_addr->ai_addr;
-	network_address = sin->sin_addr.s_addr;
-	network_address = htonl (network_address);
 
 	request[0] = 0x04;				/* SOCKS4 */
 	request[1] = 0x01;				/* CONNECT */
-	request[2] = sin->sin_port >> 8;		/* high byte of port */
-	request[3] = sin->sin_port & 0x00ff;		/* low byte of port */
-	memcpy (request + 4, &network_address, 4);	/* address in network byte order */
+	memcpy (request + 2, &sin->sin_port, 2);	/* port in network byte order */
+	memcpy (request + 4, &sin->sin_addr.s_addr, 4);	/* address in network byte order */
 	request[8] = 0x00;				/* terminator */
 
 	if (camel_write_socket (fd, request, sizeof (request)) != sizeof (request))
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index aca1a30..a7610d3 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -1241,7 +1241,6 @@ connect_to_socks4_proxy (CamelTcpStreamSSL *ssl, const gchar *proxy_host, gint p
 	PRFileDesc *fd;
 	gchar request[9];
 	struct sockaddr_in *sin;
-	guint32 network_address;
 	gchar reply[8];
 
 	g_assert (proxy_host != NULL);
@@ -1264,14 +1263,11 @@ connect_to_socks4_proxy (CamelTcpStreamSSL *ssl, const gchar *proxy_host, gint p
 
 	g_assert (connect_addr->ai_addr->sa_family == AF_INET); /* FIXME: what to do about IPv6?  Are we just screwed with SOCKS4? */
 	sin = (struct sockaddr_in *) connect_addr->ai_addr;
-	network_address = sin->sin_addr.s_addr;
-	network_address = htonl (network_address);
 
 	request[0] = 0x04;				/* SOCKS4 */
 	request[1] = 0x01;				/* CONNECT */
-	request[2] = sin->sin_port >> 8;		/* high byte of port */
-	request[3] = sin->sin_port & 0x00ff;		/* low byte of port */
-	memcpy (request + 4, &network_address, 4);	/* address in network byte order */
+	memcpy (request + 2, &sin->sin_port, 2);	/* port in network byte order */
+	memcpy (request + 4, &sin->sin_addr.s_addr, 4);	/* address in network byte order */
 	request[8] = 0x00;				/* terminator */
 
 	if (write_to_prfd (fd, request, sizeof (request)) != sizeof (request))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]