-
Notifications
You must be signed in to change notification settings - Fork 0
/
fchan_svc.c
102 lines (89 loc) · 2.6 KB
/
fchan_svc.c
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
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "fchan.h"
#include <stdio.h>
#include <stdlib.h>
#include <rpc/pmap_clnt.h>
#include <string.h>
#include <memory.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef SIG_PF
#define SIG_PF void(*)(int)
#endif
static void
fchan_prog_1(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
fchan_msg sendmsg1_1_arg;
} argument;
union {
fchan_res sendmsg1_1_res;
int bind_conn_to_session1_1_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case SENDMSG1:
_xdr_argument = (xdrproc_t) xdr_fchan_msg;
_xdr_result = (xdrproc_t) xdr_fchan_res;
local = (bool_t (*) (char *, void *, struct svc_req *))sendmsg1_1_svc;
break;
case BIND_CONN_TO_SESSION1:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))bind_conn_to_session1_1_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!fchan_prog_1_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
int
main (int argc, char **argv)
{
register SVCXPRT *transp;
svc_init_params svc_params;
pmap_unset (FCHAN_PROG, FCHANV);
/* New tirpc init function must be called to initialize the
* library. */
svc_params.flags = SVC_INIT_EPOLL; /* use EPOLL event mgmt */
svc_params.max_connections = 1024;
svc_params.max_events = 300; /* don't know good values for this */
svc_init(&svc_params);
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
if (transp == NULL) {
fprintf (stderr, "%s", "cannot create tcp service.");
exit(1);
}
if (!svc_register(transp, FCHAN_PROG, FCHANV, fchan_prog_1, IPPROTO_TCP)) {
fprintf (stderr, "%s", "unable to register (FCHAN_PROG, FCHANV, tcp).");
exit(1);
}
svc_run ();
fprintf (stderr, "%s", "svc_run returned");
exit (1);
/* NOTREACHED */
}