2
* $Id: rstat_main.c,v 1.2 2002/01/14 12:24:48 andik Exp $
4
* rpc.rstatd version 3.07 rpc remote statistics daemon.
5
* Copyright (C) 1995 Adam Migus, Memorial University of Newfoundland
7
* Copyright (C) 2001 Andreas Klingler, University of Erlangen-Nuernberg
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 1, or (at your option)
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
* If you make modifications to the source, I would be happy to have
24
* them to include in future releases. Feel free to send them to:
29
* Modified by Adam Migus (amigus@cs.mun.ca)
30
* Modified by Andreas Klingler (andreas.klingler@cyber-wizard.com)
33
* Copyright (c) 1993, John Brezak
34
* All rights reserved.
36
**************************************************************************/
44
static char * id = "@(#) $Id: rstat_main.c,v 1.2 2002/01/14 12:24:48 andik Exp $ $Revision: 1.2 $";
46
extern void rstat_service();
47
extern void test_connect();
49
int inetd_connect = 1;
69
(void) pmap_unset(RSTATPROG, RSTATVERS_USERS);
70
(void) pmap_unset(RSTATPROG, RSTATVERS_TIME);
71
(void) pmap_unset(RSTATPROG, RSTATVERS_SWTCH);
72
(void) pmap_unset(RSTATPROG, RSTATVERS_ORIG);
84
int fromlen, sock = 0, proto = 0;
85
struct sockaddr_in from;
91
if (strcmp("-d", argv[count]) == 0)
96
ninterfaces = argc - count; /* everything on the commandline besides -d */
97
interfaces = &argv[count]; /* is interpreted as interface names */
100
if (getsockname(sock,(struct sockaddr *)&from, &fromlen) < 0) {
106
if (!(inetd_connect)) {
107
(void)pmap_unset(RSTATPROG, RSTATVERS_USERS);
108
(void)pmap_unset(RSTATPROG, RSTATVERS_TIME);
109
(void)pmap_unset(RSTATPROG, RSTATVERS_SWTCH);
110
(void)pmap_unset(RSTATPROG, RSTATVERS_ORIG);
111
(void) signal(SIGINT, cleanup);
112
(void) signal(SIGTERM, cleanup);
113
(void) signal(SIGHUP, cleanup);
114
openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON);
115
if (!debug) background();
117
(void)signal(SIGALRM, test_connect);
119
transp = svcudp_create(sock);
120
if (transp == NULL) {
121
syslog(LOG_ERR, "cannot create udp service.");
124
if (!svc_register(transp, RSTATPROG, RSTATVERS_USERS, rstat_service, proto)) {
125
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_USERS, udp).");
128
if (!svc_register(transp, RSTATPROG, RSTATVERS_TIME, rstat_service, proto)) {
129
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, udp).");
132
if (!svc_register(transp, RSTATPROG, RSTATVERS_SWTCH, rstat_service, proto)) {
133
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, udp).");
136
if (!svc_register(transp, RSTATPROG, RSTATVERS_ORIG, rstat_service, proto)) {
137
syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, udp).");
142
syslog(LOG_ERR, "svc_run returned");