xref: /illumos-gate/usr/src/lib/libwrap/fromhost.c (revision 1da57d55)
1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6  /*
7   * On socket-only systems, fromhost() is nothing but an alias for the
8   * socket-specific sock_host() function.
9   *
10   * On systems with sockets and TLI, fromhost() determines the type of API
11   * (sockets, TLI), then invokes the appropriate API-specific routines.
12   *
13   * Diagnostics are reported through syslog(3).
14   *
15   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
16   */
17 
18 #ifndef lint
19 static char sccsid[] = "@(#) fromhost.c 1.17 94/12/28 17:42:23";
20 #endif
21 
22 #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
23 
24 /* System libraries. */
25 
26 #include <sys/types.h>
27 #include <sys/tiuser.h>
28 #include <stropts.h>
29 
30 /* Local stuff. */
31 
32 #include "tcpd.h"
33 
34 /* fromhost - find out what network API we should use */
35 
fromhost(request)36 void    fromhost(request)
37 struct request_info *request;
38 {
39 
40     /*
41      * On systems with streams support the IP network protocol family may be
42      * accessible via more than one programming interface: Berkeley sockets
43      * and the Transport Level Interface (TLI).
44      *
45      * Thus, we must first find out what programming interface to use: sockets
46      * or TLI. On some systems, sockets are not part of the streams system,
47      * so if request->fd is not a stream we simply assume sockets.
48      */
49 
50     if (ioctl(request->fd, I_FIND, "timod") > 0) {
51 	tli_host(request);
52     } else {
53 	sock_host(request);
54     }
55 }
56 
57 #endif /* TLI || PTX || TLI_SEQUENT */
58