diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-07-31 09:03:10 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-07-31 09:03:10 +0800 |
commit | 8137a35173541e4a5a3ed180b6493f2166d08ac1 (patch) | |
tree | d4d0070718afbcc8375585429f55c08a7160017e /camel/camel-tcp-stream-ssl.c | |
parent | 61d063ada03ee98f167197b4d067c568232ace24 (diff) | |
download | gsoc2013-evolution-8137a35173541e4a5a3ed180b6493f2166d08ac1.tar.gz 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/camel-tcp-stream-ssl.c')
-rw-r--r-- | camel/camel-tcp-stream-ssl.c | 51 |
1 files changed, 41 insertions, 10 deletions
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 */ |