X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Fip.c;h=b0c98878b6736b9f3365129d50a11ee10a22af4a;hp=2be68240c4975efe75bb345879f615e972ed7162;hb=a5f239e4959d4df6a4a341d8855e14d17399d671;hpb=2a1b36b3082412c6723ec29c1fc1ef02589bd3b3 diff --git a/src/src/ip.c b/src/src/ip.c index 2be68240c..b0c98878b 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -347,8 +347,10 @@ for (;;) close down of the connection), set errno to zero; otherwise leave it alone. */ #ifdef SUPPORT_TLS -if (tls_active == sock) - rc = tls_read(buffer, buffsize); +if (tls_out.active == sock) + rc = tls_read(FALSE, buffer, buffsize); +else if (tls_in.active == sock) + rc = tls_read(TRUE, buffer, buffsize); else #endif rc = recv(sock, buffer, buffsize, 0); @@ -361,6 +363,37 @@ return -1; +/************************************************* +* Lookup address family of potential socket * +*************************************************/ + +/* Given a file-descriptor, check to see if it's a socket and, if so, +return the address family; detects IPv4 vs IPv6. If not a socket then +return -1. + +The value 0 is typically AF_UNSPEC, which should not be seen on a connected +fd. If the return is -1, the errno will be from getsockname(); probably +ENOTSOCK or ECONNRESET. + +Arguments: socket-or-not fd +Returns: address family or -1 +*/ + +int +ip_get_address_family(int fd) +{ +struct sockaddr_storage ss; +socklen_t sslen = sizeof(ss); + +if (getsockname(fd, (struct sockaddr *) &ss, &sslen) < 0) + return -1; + +return (int) ss.ss_family; +} + + + + /************************************************* * Lookup DSCP settings for a socket * *************************************************/