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



commit f21219c65df4580dd6ede9dc7492abe1f945e464
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 8612778..a7724fd 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -385,7 +385,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);
@@ -408,14 +407,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 17cad0a..899d26b 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -1100,7 +1100,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);
@@ -1123,14 +1122,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]