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