6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libnisdb / ldap_cto.c
blob73c3183c3e59663c9a14b602e80c569309d3cdb6
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/tcp.h>
32 #include <errno.h>
33 #include <dlfcn.h>
34 #include <rpcsvc/nis.h>
36 #include "ldap_util.h"
38 #include "nis_parse_ldap_conf.h"
41 * Interpose socket(3SOCKET), so that we can set the connect timeout.
42 * Obviously, this will affect every socket in the application. However,
43 * NIS+ (or, rather, RPC) uses TLI, not sockets, so the only sockets
44 * should be those used by libldap.
46 int
47 socket(int domain, int type, int protocol) {
48 int ret;
49 static int (*fptr)() = 0;
50 int timeout = 1000 * proxyInfo.bind_timeout.tv_sec +
51 proxyInfo.bind_timeout.tv_usec / 1000;
53 if (fptr == 0) {
54 fptr = (int (*)())dlsym(RTLD_NEXT, "socket");
55 if (fptr == 0) {
56 logmsg(MSG_NOTIMECHECK, LOG_ERR,
57 "socket: load error: %s",
58 dlerror());
59 return (-1);
63 ret = (*fptr) (domain, type, protocol);
65 if (ret >= 0 && timeout > 0) {
66 if (setsockopt(ret, IPPROTO_TCP, TCP_CONN_ABORT_THRESHOLD,
67 &timeout, sizeof (timeout)) != 0)
68 logmsg(MSG_NOTIMECHECK, LOG_ERR,
69 "setsockopt(IPPROTO_TCP/TCP_CONN_ABORT_THRESHOLD, %d) => errno = %d",
70 timeout, errno);
73 return (ret);