aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-tcp-stream-ssl.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2002-03-11 08:53:49 +0800
committerDan Winship <danw@src.gnome.org>2002-03-11 08:53:49 +0800
commitb1b809031f5a11223d97ee02d21fb6bb3693a367 (patch)
tree60bdae233e7421dde0564d0296c9767550f372c1 /camel/camel-tcp-stream-ssl.c
parent592ec9daac1b91f89036d2a3598f7f1fa6b6cbaa (diff)
downloadgsoc2013-evolution-b1b809031f5a11223d97ee02d21fb6bb3693a367.tar.gz
gsoc2013-evolution-b1b809031f5a11223d97ee02d21fb6bb3693a367.tar.zst
gsoc2013-evolution-b1b809031f5a11223d97ee02d21fb6bb3693a367.zip
Remove this: it couldn't be generically used, because different subclasses
* camel-tcp-stream.c (camel_tcp_stream_get_socket): Remove this: it couldn't be generically used, because different subclasses returned entirely different types of data. (camel_tcp_stream_get_local_address, camel_tcp_stream_get_remote_address): Add these to replace what get_socket was being used for. (camel_tcp_address_new, camel_tcp_address_free): Utility functions for get_{local,remote}_address. * providers/smtp/camel-smtp-transport.c: Change localaddr to a CamelTcpAddress *. (connect_to_server): Call camel_tcp_stream_get_local_address to get the local IP address. (smtp_disconnect): free localaddr. (smtp_helo): Update for localaddr change. * camel-tcp-stream-raw.c (stream_get_socket): Remove (stream_get_local_address, stream_get_remote_address): Implement. * camel-tcp-stream-ssl.c (stream_get_socket): Remove (stream_get_local_address, stream_get_remote_address): Implement. * camel-tcp-stream-openssl.c (stream_get_socket): Remove (stream_get_local_address, stream_get_remote_address): Implement. svn path=/trunk/; revision=16092
Diffstat (limited to 'camel/camel-tcp-stream-ssl.c')
-rw-r--r--camel/camel-tcp-stream-ssl.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 7f914c8734..ac78cc92cb 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -65,7 +65,8 @@ static PRFileDesc *enable_ssl (CamelTcpStreamSSL *ssl, PRFileDesc *fd);
static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port);
static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
-static gpointer stream_get_socket (CamelTcpStream *stream);
+static CamelTcpAddress *stream_get_local_address (CamelTcpStream *stream);
+static CamelTcpAddress *stream_get_remote_address (CamelTcpStream *stream);
struct _CamelTcpStreamSSLPrivate {
PRFileDesc *sockfd;
@@ -94,7 +95,8 @@ camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_cl
camel_tcp_stream_class->connect = stream_connect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
- camel_tcp_stream_class->get_socket = stream_get_socket;
+ camel_tcp_stream_class->get_local_address = stream_get_local_address;
+ camel_tcp_stream_class->get_remote_address = stream_get_remote_address;
}
static void
@@ -613,10 +615,32 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
return 0;
}
-static gpointer
-stream_get_socket (CamelTcpStream *stream)
+static CamelTcpAddress *
+stream_get_local_address (CamelTcpStream *stream)
{
- return (gpointer) CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
+ PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
+ PRNetAddr addr;
+
+ PR_GetSockName (sockfd, &addr);
+ if (addr.inet.family != PR_AF_INET)
+ return NULL;
+
+ return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, addr.inet.port,
+ 4, &addr.inet.ip);
+}
+
+static CamelTcpAddress *
+stream_get_remote_address (CamelTcpStream *stream)
+{
+ PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
+ PRNetAddr addr;
+
+ PR_GetPeerName (sockfd, &addr);
+ if (addr.inet.family != PR_AF_INET)
+ return NULL;
+
+ return camel_tcp_address_new (CAMEL_TCP_ADDRESS_IPV4, addr.inet.port,
+ 4, &addr.inet.ip);
}
#endif /* HAVE_NSS */