aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-31 09:03:10 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-31 09:03:10 +0800
commit8137a35173541e4a5a3ed180b6493f2166d08ac1 (patch)
treed4d0070718afbcc8375585429f55c08a7160017e /camel
parent61d063ada03ee98f167197b4d067c568232ace24 (diff)
downloadgsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.gz
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.bz2
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.lz
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.xz
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.zst
gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.zip
Update the comment.
2002-07-30 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream.c (camel_tcp_address_new): Update the comment. * camel-tcp-stream-raw.c (socket_connect): If building with IPv6 support and the address is an IPv6 address, connect using a sockaddr_in6 otherwise use the standard IPv4 sockaddr_in structure. (stream_get_local_address): Fix to work with IPv6 addresses. (stream_get_remote_address): Same. * camel-tcp-stream-openssl.c (socket_connect): Same as above. (stream_get_local_address): Fix to work with IPv6 addresses. (stream_get_remote_address): Same. * camel-tcp-stream-ssl.c (stream_connect): If building with IPv6 support and the address is an IPv6 address, initialise the PRNetAddr accordingly. (stream_get_local_address): Fix to work with IPv6 addresses. (stream_get_remote_address): Same. svn path=/trunk/; revision=17651
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog21
-rw-r--r--camel/camel-folder.c2
-rw-r--r--camel/camel-tcp-stream-openssl.c103
-rw-r--r--camel/camel-tcp-stream-raw.c96
-rw-r--r--camel/camel-tcp-stream-ssl.c51
-rw-r--r--camel/camel-tcp-stream.c13
-rw-r--r--camel/camel-tcp-stream.h4
7 files changed, 231 insertions, 59 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 4e91482c38..6063f1a344 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,26 @@
2002-07-30 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-tcp-stream.c (camel_tcp_address_new): Update the comment.
+
+ * camel-tcp-stream-raw.c (socket_connect): If building with IPv6
+ support and the address is an IPv6 address, connect using a
+ sockaddr_in6 otherwise use the standard IPv4 sockaddr_in
+ structure.
+ (stream_get_local_address): Fix to work with IPv6 addresses.
+ (stream_get_remote_address): Same.
+
+ * camel-tcp-stream-openssl.c (socket_connect): Same as above.
+ (stream_get_local_address): Fix to work with IPv6 addresses.
+ (stream_get_remote_address): Same.
+
+ * camel-tcp-stream-ssl.c (stream_connect): If building with IPv6
+ support and the address is an IPv6 address, initialise the
+ PRNetAddr accordingly.
+ (stream_get_local_address): Fix to work with IPv6 addresses.
+ (stream_get_remote_address): Same.
+
+2002-07-30 Jeffrey Stedfast <fejj@ximian.com>
+
* camel-tcp-stream-openssl.c (ssl_verify): X509_digest() needs a
pointer to an int len. Also fixed some other compiler errors.
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 89c5bc2e14..99b9af5bc9 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -695,7 +695,7 @@ set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 s
camel_folder_summary_info_free(folder->summary, info);
return;
}
-
+
info->flags = new | CAMEL_MESSAGE_FOLDER_FLAGGED;
camel_folder_summary_touch(folder->summary);
camel_folder_summary_info_free(folder->summary, info);
diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c
index 06d1a93c5a..324e58dd08 100644
--- a/camel/camel-tcp-stream-openssl.c
+++ b/camel/camel-tcp-stream-openssl.c
@@ -455,12 +455,15 @@ stream_close (CamelStream *stream)
static int
socket_connect (struct hostent *h, int port)
{
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 sin6;
+#endif
struct sockaddr_in sin;
- int fd;
- int ret;
- socklen_t len;
+ struct sockaddr *saddr;
struct timeval tv;
+ socklen_t len;
int cancel_fd;
+ int ret, fd;
/* see if we're cancelled yet */
if (camel_operation_cancel_check (NULL)) {
@@ -469,15 +472,29 @@ socket_connect (struct hostent *h, int port)
}
/* setup connect, we do it using a nonblocking socket so we can poll it */
- sin.sin_port = htons (port);
- sin.sin_family = h->h_addrtype;
- memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
+#ifdef ENABLE_IPv6
+ if (h->h_addrtype == AF_INET6) {
+ sin6.sin6_port = htons (port);
+ sin6.sin6_family = h->h_addrtype;
+ memcpy (&sin6.sin6_addr, h->h_addr, sizeof (sin6.sin6_addr));
+ saddr = (struct sockaddr *) &sin6;
+ len = sizeof (sin6);
+ } else {
+#endif
+ sin.sin_port = htons (port);
+ sin.sin_family = h->h_addrtype;
+ memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
+ saddr = (struct sockaddr *) &sin;
+ len = sizeof (sin);
+#ifdef ENABLE_IPv6
+ }
+#endif
fd = socket (h->h_addrtype, SOCK_STREAM, 0);
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
- ret = connect (fd, (struct sockaddr *)&sin, sizeof (sin));
+ ret = connect (fd, saddr, len);
if (ret == -1) {
close (fd);
return -1;
@@ -491,7 +508,7 @@ socket_connect (struct hostent *h, int port)
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
- ret = connect (fd, (struct sockaddr *)&sin, sizeof (sin));
+ ret = connect (fd, saddr, len);
if (ret == 0) {
fcntl (fd, F_SETFL, flags);
return fd;
@@ -862,32 +879,74 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
sizeof (data->value));
}
+#ifdef ENABLE_IPv6
+#define MIN_SOCKADDR_BUFLEN (sizeof (struct sockaddr_in6))
+#else
+#define MIN_SOCKADDR_BUFLEN (sizeof (struct sockaddr_in))
+#endif
+
static CamelTcpAddress *
stream_get_local_address (CamelTcpStream *stream)
{
- struct sockaddr_in sin;
+ unsigned char buf[MIN_SOCKADDR_BUFLEN];
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) buf;
+#endif
+ struct sockaddr_in *sin = (struct sockaddr_in *) buf;
+ struct sockaddr *saddr = (struct sockaddr *) buf;
+ gpointer address;
socklen_t len;
-
- if (getsockname (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd,
- (struct sockaddr *)&sin, &len) == -1)
+ int family;
+
+ len = MIN_SOCKADDR_BUFLEN;
+
+ if (getsockname (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, saddr, &len) == -1)
return NULL;
-
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, sin.sin_port,
- 4, &sin.sin_addr);
+
+ if (saddr->sa_family == AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &sin->sin_addr;
+#ifdef ENABLE_IPv6
+ } else if (saddr->sa_family == AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &sin6->sin6_addr;
+#endif
+ } else
+ return NULL;
+
+ return camel_tcp_address_new (family, sin->sin_port, len, address);
}
static CamelTcpAddress *
stream_get_remote_address (CamelTcpStream *stream)
{
- struct sockaddr_in sin;
+ unsigned char buf[MIN_SOCKADDR_BUFLEN];
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) buf;
+#endif
+ struct sockaddr_in *sin = (struct sockaddr_in *) buf;
+ struct sockaddr *saddr = (struct sockaddr *) buf;
+ gpointer address;
socklen_t len;
-
- if (getpeername (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd,
- (struct sockaddr *)&sin, &len) == -1)
+ int family;
+
+ len = MIN_SOCKADDR_BUFLEN;
+
+ if (getpeername (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, saddr, &len) == -1)
return NULL;
-
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, sin.sin_port,
- 4, &sin.sin_addr);
+
+ if (saddr->sa_family == AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &sin->sin_addr;
+#ifdef ENABLE_IPv6
+ } else if (saddr->sa_family == AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &sin6->sin6_addr;
+#endif
+ } else
+ return NULL;
+
+ return camel_tcp_address_new (family, sin->sin_port, len, address);
}
#endif /* HAVE_OPENSSL */
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 8b6a868b47..b8e6426c49 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -20,6 +20,7 @@
*
*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -380,12 +381,15 @@ stream_close (CamelStream *stream)
static int
socket_connect (struct hostent *h, int port)
{
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 sin6;
+#endif
struct sockaddr_in sin;
- int fd;
- int ret;
- socklen_t len;
+ struct sockaddr *saddr;
struct timeval tv;
+ socklen_t len;
int cancel_fd;
+ int ret, fd;
/* see if we're cancelled yet */
if (camel_operation_cancel_check (NULL)) {
@@ -394,15 +398,29 @@ socket_connect (struct hostent *h, int port)
}
/* setup connect, we do it using a nonblocking socket so we can poll it */
- sin.sin_port = htons (port);
- sin.sin_family = h->h_addrtype;
- memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
+#ifdef ENABLE_IPv6
+ if (h->h_addrtype == AF_INET6) {
+ sin6.sin6_port = htons (port);
+ sin6.sin6_family = h->h_addrtype;
+ memcpy (&sin6.sin6_addr, h->h_addr, sizeof (sin6.sin6_addr));
+ saddr = (struct sockaddr *) &sin6;
+ len = sizeof (sin6);
+ } else {
+#endif
+ sin.sin_port = htons (port);
+ sin.sin_family = h->h_addrtype;
+ memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
+ saddr = (struct sockaddr *) &sin;
+ len = sizeof (sin);
+#ifdef ENABLE_IPv6
+ }
+#endif
fd = socket (h->h_addrtype, SOCK_STREAM, 0);
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
- ret = connect (fd, (struct sockaddr *)&sin, sizeof (sin));
+ ret = connect (fd, saddr, len);
if (ret == -1) {
close (fd);
return -1;
@@ -416,7 +434,7 @@ socket_connect (struct hostent *h, int port)
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
- ret = connect (fd, (struct sockaddr *) &sin, sizeof (sin));
+ ret = connect (fd, saddr, len);
if (ret == 0) {
fcntl (fd, F_SETFL, flags);
return fd;
@@ -585,30 +603,72 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
sizeof (data->value));
}
+#ifdef ENABLE_IPv6
+#define MIN_SOCKADDR_BUFLEN (sizeof (struct sockaddr_in6))
+#else
+#define MIN_SOCKADDR_BUFLEN (sizeof (struct sockaddr_in))
+#endif
+
static CamelTcpAddress *
stream_get_local_address (CamelTcpStream *stream)
{
- struct sockaddr_in sin;
+ unsigned char buf[MIN_SOCKADDR_BUFLEN];
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) buf;
+#endif
+ struct sockaddr_in *sin = (struct sockaddr_in *) buf;
+ struct sockaddr *saddr = (struct sockaddr *) buf;
+ gpointer address;
socklen_t len;
+ int family;
+
+ len = MIN_SOCKADDR_BUFLEN;
+
+ if (getsockname (CAMEL_TCP_STREAM_RAW (stream)->sockfd, saddr, &len) == -1)
+ return NULL;
- if (getsockname (CAMEL_TCP_STREAM_RAW (stream)->sockfd,
- (struct sockaddr *) &sin, &len) == -1)
+ if (saddr->sa_family == AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &sin->sin_addr;
+#ifdef ENABLE_IPv6
+ } else if (saddr->sa_family == AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &sin6->sin6_addr;
+#endif
+ } else
return NULL;
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, sin.sin_port,
- 4, &sin.sin_addr);
+ return camel_tcp_address_new (family, sin->sin_port, len, address);
}
static CamelTcpAddress *
stream_get_remote_address (CamelTcpStream *stream)
{
- struct sockaddr_in sin;
+ unsigned char buf[MIN_SOCKADDR_BUFLEN];
+#ifdef ENABLE_IPv6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) buf;
+#endif
+ struct sockaddr_in *sin = (struct sockaddr_in *) buf;
+ struct sockaddr *saddr = (struct sockaddr *) buf;
+ gpointer address;
socklen_t len;
+ int family;
+
+ len = MIN_SOCKADDR_BUFLEN;
- if (getpeername (CAMEL_TCP_STREAM_RAW (stream)->sockfd,
- (struct sockaddr *) &sin, &len) == -1)
+ if (getpeername (CAMEL_TCP_STREAM_RAW (stream)->sockfd, saddr, &len) == -1)
+ return NULL;
+
+ if (saddr->sa_family == AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &sin->sin_addr;
+#ifdef ENABLE_IPv6
+ } else if (saddr->sa_family == AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &sin6->sin6_addr;
+#endif
+ } else
return NULL;
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, sin.sin_port,
- 4, &sin.sin_addr);
+ return camel_tcp_address_new (family, sin->sin_port, len, address);
}
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 15b3dcd8fb..ed539451ad 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -611,7 +611,14 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
g_return_val_if_fail (host != NULL, -1);
memset ((void *) &netaddr, 0, sizeof (PRNetAddr));
+#ifdef ENABLE_IPv6
+ if (h->addrtype == AF_INET6)
+ memcpy (&netaddr.ipv6.ip, host->h_addr, sizeof (netaddr.ipv6.ip));
+ else
+ memcpy (&netaddr.inet.ip, host->h_addr, sizeof (netaddr.inet.ip));
+#else
memcpy (&netaddr.inet.ip, host->h_addr, sizeof (netaddr.inet.ip));
+#endif
if (PR_InitializeNetAddr (PR_IpAddrNull, port, &netaddr) == PR_FAILURE) {
set_errno (PR_GetError ());
@@ -723,28 +730,52 @@ static CamelTcpAddress *
stream_get_local_address (CamelTcpStream *stream)
{
PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
+ int family, length;
+ gpointer address;
PRNetAddr addr;
-
+
PR_GetSockName (sockfd, &addr);
- if (addr.inet.family != PR_AF_INET)
+
+ if (addr.inet.family == PR_AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &addr.inet.ip;
+ length = 4;
+#ifdef ENABLE_IPv6
+ } else if (addr.inet.family == PR_AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &addr.ipv6.ip;
+ length = 16;
+#endif
+ } else
return NULL;
-
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, addr.inet.port,
- 4, &addr.inet.ip);
+
+ return camel_tcp_address_new (family, addr.inet.port, length, address);
}
static CamelTcpAddress *
stream_get_remote_address (CamelTcpStream *stream)
{
PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
+ int family, length;
+ gpointer address;
PRNetAddr addr;
-
+
PR_GetPeerName (sockfd, &addr);
- if (addr.inet.family != PR_AF_INET)
+
+ if (addr.inet.family == PR_AF_INET) {
+ family = CAMEL_TCP_ADDRESS_IPv4;
+ address = &addr.inet.ip;
+ length = sizeof (addr.inet.ip);
+#ifdef ENABLE_IPv6
+ } else if (addr.inet.family == PR_AF_INET6) {
+ family = CAMEL_TCP_ADDRESS_IPv6;
+ address = &addr.ipv6.ip;
+ length = sizeof (addr.ipv6.ip);
+#endif
+ } else
return NULL;
-
- return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, addr.inet.port,
- 4, &addr.inet.ip);
+
+ return camel_tcp_address_new (family, addr.inet.port, length, address);
}
#endif /* HAVE_NSS */
diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c
index 78a7c4551c..fbbcbec451 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -213,7 +213,7 @@ camel_tcp_stream_get_remote_address (CamelTcpStream *stream)
/**
* camel_tcp_address_new:
- * @family: the address family (currently must be CAMEL_TCP_ADDRESS_IPV4)
+ * @family: the address family
* @port: the port number (in network byte order)
* @length: the length of @address
* @address: the address data (family dependent, in network byte order)
@@ -221,20 +221,21 @@ camel_tcp_stream_get_remote_address (CamelTcpStream *stream)
* Return value: a new CamelTcpAddress.
**/
CamelTcpAddress *
-camel_tcp_address_new (CamelTcpAddressFamily family, gushort port,
- gushort length, gpointer address)
+camel_tcp_address_new (CamelTcpAddressFamily family, gushort port,
+ gushort length, gpointer address)
{
CamelTcpAddress *addr;
-
+
addr = g_malloc (sizeof (CamelTcpAddress) + length - 1);
addr->family = family;
- addr->port = port;
+ addr->port = port;
addr->length = length;
memcpy (&addr->address, address, length);
-
+
return addr;
}
+
/**
* camel_tcp_address_free:
* @address: the address
diff --git a/camel/camel-tcp-stream.h b/camel/camel-tcp-stream.h
index 2c4d022168..9472da10ee 100644
--- a/camel/camel-tcp-stream.h
+++ b/camel/camel-tcp-stream.h
@@ -89,8 +89,8 @@ typedef struct _CamelSockOptData {
} CamelSockOptData;
typedef enum {
- CAMEL_TCP_ADDRESS_IPV4,
- CAMEL_TCP_ADDRESS_IPV6
+ CAMEL_TCP_ADDRESS_IPv4,
+ CAMEL_TCP_ADDRESS_IPv6
} CamelTcpAddressFamily;
typedef struct {