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