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
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <stdlib.h> /* getenv, exit */
34 #include <sys/types.h>
37 #include <netconfig.h>
41 #define SIG_PF void(*)(int)
49 int _rpcpmstart
; /* Started by a port monitor ? */
50 int _rpcfdtype
; /* Whether Stream or Datagram ? */
51 int _rpcsvcdirty
; /* Still serving ? */
53 static void _msgout(/*char *msg*/);
54 static void closedown();
56 extern void rstatprog_4(/*struct svc_req *rqstp, SVCXPRT *transp*/);
57 extern void rstatprog_3(/*struct svc_req *rqstp, SVCXPRT *transp*/);
58 extern void rstatprog_2(/*struct svc_req *rqstp, SVCXPRT *transp*/);
61 main(int argc
, char *argv
[])
67 * If stdin looks like a TLI endpoint, we assume
68 * that we were started by a port monitor. If
69 * t_getstate fails with TBADF, this is not a
72 if (t_getstate(0) != -1 || t_errno
!= TBADF
) {
74 struct netconfig
*nconf
= NULL
;
78 openlog("rstatd", LOG_PID
, LOG_DAEMON
);
79 if ((netid
= getenv("NLSPROVIDER")) == NULL
) {
81 _msgout("cannot get transport name");
83 } else if ((nconf
= getnetconfigent(netid
)) == NULL
) {
85 _msgout("cannot get transport info");
88 if ((transp
= svc_tli_create(0, nconf
, NULL
, 0, 0)) == NULL
) {
89 _msgout("cannot create server handle");
93 freenetconfigent(nconf
);
94 if (!svc_reg(transp
, RSTATPROG
, RSTATVERS_VAR
, rstatprog_4
,
96 _msgout("unable to register "
97 "(RSTATPROG, RSTATVERS_VAR).");
100 if (!svc_reg(transp
, RSTATPROG
, RSTATVERS_TIME
, rstatprog_3
,
102 _msgout("unable to register "
103 "(RSTATPROG, RSTATVERS_TIME).");
106 if (!svc_reg(transp
, RSTATPROG
, RSTATVERS_SWTCH
, rstatprog_2
,
108 _msgout("unable to register "
109 "(RSTATPROG, RSTATVERS_SWTCH).");
119 perror("cannot fork");
125 i
= open("/dev/console", 2);
129 openlog("rstatd", LOG_PID
, LOG_DAEMON
);
132 if (!svc_create(rstatprog_4
, RSTATPROG
, RSTATVERS_VAR
, "datagram_v")) {
133 _msgout("unable to create (RSTATPROG, RSTATVERS_VAR) "
137 if (!svc_create(rstatprog_3
, RSTATPROG
, RSTATVERS_TIME
,
139 _msgout("unable to create (RSTATPROG, RSTATVERS_TIME) "
143 if (!svc_create(rstatprog_4
, RSTATPROG
, RSTATVERS_VAR
, "circuit_v")) {
144 _msgout("unable to create (RSTATPROG, RSTATVERS_VAR) "
148 if (!svc_create(rstatprog_3
, RSTATPROG
, RSTATVERS_TIME
, "circuit_v")) {
149 _msgout("unable to create (RSTATPROG, RSTATVERS_TIME) "
155 * V2 supported on datagram transports *only*
157 if (!svc_create(rstatprog_2
, RSTATPROG
, RSTATVERS_SWTCH
,
159 _msgout("unable to create (RSTATPROG, RSTATVERS_SWTCH) "
165 _msgout("svc_run returned");
175 syslog(LOG_ERR
, msg
);
177 (void) fprintf(stderr
, "%s\n", msg
);
179 syslog(LOG_ERR
, msg
);