From b1b809031f5a11223d97ee02d21fb6bb3693a367 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 11 Mar 2002 00:53:49 +0000 Subject: 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 --- camel/camel-tcp-stream-ssl.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'camel/camel-tcp-stream-ssl.c') 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 */ -- cgit