summaryrefslogtreecommitdiff
path: root/usr.sbin/amd/rpcx/amq_svc.c
blob: fff6090fd08a723c6800b28a66ae9ad81c21c6cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#include "amq.h"
#include "am.h"
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>/* getenv, exit */
#include <rpc/pmap_clnt.h> /* for pmap_unset */
#include <string.h> /* strcmp */ 
#include <netdb.h>
#include <signal.h>
#include <sys/ttycom.h>/* TIOCNOTTY */
#ifdef __cplusplus
#include <sysent.h> /* getdtablesize, open */
#endif /* __cplusplus */
#include <memory.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <syslog.h>
#include <errno.h>

#ifdef __STDC__
#define SIG_PF void(*)(int)
#endif

#ifdef DEBUG
#define RPC_SVC_FG
#endif

#define _RPCSVC_CLOSEDOWN 120
extern int _rpcpmstart;		/* Started by a port monitor ? */
extern int _rpcfdtype;		/* Whether Stream or Datagram ? */


void	amq_program_1(struct svc_req *rqstp, SVCXPRT *transp);

void
amq_program_1(struct svc_req *rqstp, SVCXPRT *transp)
{
	union {
		amq_string amqproc_mnttree_1_arg;
		amq_string amqproc_umnt_1_arg;
		amq_setopt amqproc_setopt_1_arg;
		amq_string amqproc_mount_1_arg;
	} argument;
	char *result;
	xdrproc_t xdr_argument, xdr_result;
	char *(*local)(char *, struct svc_req *);
	extern SVCXPRT *lamqp;

	if (transp != lamqp) {
		struct sockaddr_in *fromsin = svc_getcaller(transp);

		syslog(LOG_WARNING,
		    "non-local amq attempt (might be from %s)",
		    inet_ntoa(fromsin->sin_addr));
		svcerr_noproc(transp);
		return;
	}

	switch (rqstp->rq_proc) {
	case AMQPROC_NULL:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_void;
		local = (char *(*)(char *, struct svc_req *)) amqproc_null_1_svc;
		break;

	case AMQPROC_MNTTREE:
		xdr_argument = (xdrproc_t) xdr_amq_string;
		xdr_result = (xdrproc_t) xdr_amq_mount_tree_p;
		local = (char *(*)(char *, struct svc_req *)) amqproc_mnttree_1_svc;
		break;

	case AMQPROC_UMNT:
		xdr_argument = (xdrproc_t) xdr_amq_string;
		xdr_result = (xdrproc_t) xdr_void;
		local = (char *(*)(char *, struct svc_req *)) amqproc_umnt_1_svc;
		break;

	case AMQPROC_STATS:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_amq_mount_stats;
		local = (char *(*)(char *, struct svc_req *)) amqproc_stats_1_svc;
		break;

	case AMQPROC_EXPORT:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_amq_mount_tree_list;
		local = (char *(*)(char *, struct svc_req *)) amqproc_export_1_svc;
		break;

	case AMQPROC_SETOPT:
		xdr_argument = (xdrproc_t) xdr_amq_setopt;
		xdr_result = (xdrproc_t) xdr_int;
		local = (char *(*)(char *, struct svc_req *)) amqproc_setopt_1_svc;
		break;

	case AMQPROC_GETMNTFS:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_amq_mount_info_list;
		local = (char *(*)(char *, struct svc_req *)) amqproc_getmntfs_1_svc;
		break;

	case AMQPROC_MOUNT:
		xdr_argument = (xdrproc_t) xdr_amq_string;
		xdr_result = (xdrproc_t) xdr_int;
		local = (char *(*)(char *, struct svc_req *)) amqproc_mount_1_svc;
		break;

	case AMQPROC_GETVERS:
		xdr_argument = (xdrproc_t) xdr_void;
		xdr_result = (xdrproc_t) xdr_amq_string;
		local = (char *(*)(char *, struct svc_req *)) amqproc_getvers_1_svc;
		break;

	default:
		svcerr_noproc(transp);
		return;
	}
	(void) memset((char *)&argument, 0, sizeof (argument));
	if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
		svcerr_decode(transp);
		return;
	}
	result = (*local)((char *)&argument, rqstp);
	if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
		svcerr_systemerr(transp);
	}
	if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
		plog(XLOG_FATAL, "unable to free rpc arguments in amqprog");
		going_down(1);
	}
	return;
}