X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/4e910c01eea401e36044816744691789ef4656fa..a5ffa9b475a426bc73366db01f7cc92a3811bc3a:/src/src/smtp_out.c diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 7ade9ba67..253d7670d 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -100,7 +100,7 @@ smtp_get_port(uschar *rstring, address_item *addr, int *port, uschar *msg) { uschar *pstring = expand_string(rstring); -if (pstring == NULL) +if (!pstring) { addr->transport_return = PANIC; addr->message = string_sprintf("failed to expand \"%s\" (\"port\" option) " @@ -124,7 +124,7 @@ if (isdigit(*pstring)) else { struct servent *smtp_service = getservbyname(CS pstring, "tcp"); - if (smtp_service == NULL) + if (!smtp_service) { addr->transport_return = PANIC; addr->message = string_sprintf("TCP port \"%s\" is not defined for %s", @@ -243,6 +243,24 @@ else } } + + + + +void +smtp_port_for_connect(host_item * host, int port) +{ +if (host->port != PORT_NONE) + { + HDEBUG(D_transport|D_acl|D_v) + debug_printf_indent("Transport port=%d replaced by host-specific port=%d\n", port, + host->port); + port = host->port; + } +else host->port = port; /* Set the port actually used */ +} + + /************************************************* * Connect to remote host * *************************************************/ @@ -252,15 +270,9 @@ detected by checking for a colon in the address. AF_INET6 is defined even on non-IPv6 systems, to enable the code to be less messy. However, on such systems host->address will always be an IPv4 address. -The port field in the host item is used if it is set (usually router from SRV -records or elsewhere). In other cases, the default passed as an argument is -used, and the host item is updated with its value. - Arguments: - host host item containing name and address (and sometimes port) + host host item containing name and address and port host_af AF_INET or AF_INET6 - port default remote port to connect to, in host byte order, for those - hosts whose port setting is PORT_NONE interface outgoing interface address or NULL timeout timeout value or 0 tb transport @@ -269,23 +281,15 @@ Returns: connected socket number, or -1 with errno set */ int -smtp_connect(host_item *host, int host_af, int port, uschar *interface, +smtp_connect(host_item *host, int host_af, uschar *interface, int timeout, transport_instance * tb) { +int port = host->port; #ifdef SUPPORT_SOCKS smtp_transport_options_block * ob = (smtp_transport_options_block *)tb->options_block; #endif -if (host->port != PORT_NONE) - { - HDEBUG(D_transport|D_acl|D_v) - debug_printf_indent("Transport port=%d replaced by host-specific port=%d\n", port, - host->port); - port = host->port; - } -else host->port = port; /* Set the port actually used */ - callout_address = string_sprintf("[%s]:%d", host->address, port); HDEBUG(D_transport|D_acl|D_v) @@ -319,7 +323,7 @@ pipelining. Argument: outblock the SMTP output block - mode more-expected, or plain + mode further data expected, or plain Returns: TRUE if OK, FALSE on error, with errno set */ @@ -329,18 +333,19 @@ flush_buffer(smtp_outblock * outblock, int mode) { int rc; int n = outblock->ptr - outblock->buffer; +BOOL more = mode == SCMD_MORE; HDEBUG(D_transport|D_acl) debug_printf_indent("cmd buf flush %d bytes%s\n", n, - mode == SCMD_MORE ? " (with MORE annotation)" : ""); + more ? " (more expected)" : ""); #ifdef SUPPORT_TLS if (tls_out.active == outblock->sock) - rc = tls_write(FALSE, outblock->buffer, n); + rc = tls_write(FALSE, outblock->buffer, n, more); else #endif rc = send(outblock->sock, outblock->buffer, n, #ifdef MSG_MORE - mode == SCMD_MORE ? MSG_MORE : 0 + more ? MSG_MORE : 0 #else 0 #endif