X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsrc%2Fsmtp_out.c;h=d6cfbba7dedf1663e674ba81c5856b4d8f39c0c7;hb=6f7fe114793ad909b7bd859bdd03bb6a614602ad;hp=6b079c16f25920cc69a966861db8423359a1b67d;hpb=d7d7b7b91dd75cec636fc144da7e27eed860f971;p=exim.git diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 6b079c16f..d6cfbba7d 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/smtp_out.c,v 1.7 2006/02/07 11:19:00 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2006 */ +/* Copyright (c) University of Cambridge 1995 - 2009 */ /* See the file NOTICE for conditions of use and distribution. */ /* A number of functions for driving outgoing SMTP calls. */ @@ -241,7 +239,18 @@ if (save_errno != 0) else { + union sockaddr_46 interface_sock; + EXIM_SOCKLEN_T size = sizeof(interface_sock); HDEBUG(D_transport|D_acl|D_v) debug_printf("connected\n"); + if (getsockname(sock, (struct sockaddr *)(&interface_sock), &size) == 0) + sending_ip_address = host_ntoa(-1, &interface_sock, NULL, &sending_port); + else + { + log_write(0, LOG_MAIN | ((errno == ECONNRESET)? 0 : LOG_PANIC), + "getsockname() failed: %s", strerror(errno)); + close(sock); + return -1; + } if (keepalive) ip_keepalive(sock, host->address, TRUE); return sock; } @@ -307,7 +316,7 @@ Returns: 0 if command added to pipelining buffer, with nothing transmitted */ int -smtp_write_command(smtp_outblock *outblock, BOOL noflush, char *format, ...) +smtp_write_command(smtp_outblock *outblock, BOOL noflush, const char *format, ...) { int count; int rc = 0;