1 |
|
|
/* |
2 |
|
|
* Please do not edit this file. |
3 |
|
|
* It was generated using rpcgen. |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
#include "bootparam_prot.h" |
7 |
|
|
#include <unistd.h> |
8 |
|
|
#include <stdio.h> |
9 |
|
|
#include <stdlib.h>/* getenv, exit */ |
10 |
|
|
#include <rpc/pmap_clnt.h> /* for pmap_unset */ |
11 |
|
|
#include <string.h> /* strcmp */ |
12 |
|
|
#include <netdb.h> |
13 |
|
|
#include <signal.h> |
14 |
|
|
#include <sys/ttycom.h>/* TIOCNOTTY */ |
15 |
|
|
#ifdef __cplusplus |
16 |
|
|
#include <sysent.h> /* getdtablesize, open */ |
17 |
|
|
#endif /* __cplusplus */ |
18 |
|
|
#include <memory.h> |
19 |
|
|
#include <sys/socket.h> |
20 |
|
|
#include <netinet/in.h> |
21 |
|
|
#include <syslog.h> |
22 |
|
|
#include <errno.h> |
23 |
|
|
|
24 |
|
|
#ifdef __STDC__ |
25 |
|
|
#define SIG_PF void(*)(int) |
26 |
|
|
#endif |
27 |
|
|
|
28 |
|
|
#ifdef DEBUG |
29 |
|
|
#define RPC_SVC_FG |
30 |
|
|
#endif |
31 |
|
|
|
32 |
|
|
#define _RPCSVC_CLOSEDOWN 120 |
33 |
|
|
extern int _rpcpmstart; /* Started by a port monitor ? */ |
34 |
|
|
extern int _rpcfdtype; /* Whether Stream or Datagram ? */ |
35 |
|
|
extern int _rpcsvcdirty; /* Still serving ? */ |
36 |
|
|
|
37 |
|
|
static |
38 |
|
|
void _msgout(char *msg) |
39 |
|
|
{ |
40 |
|
|
#ifdef RPC_SVC_FG |
41 |
|
|
if (_rpcpmstart) |
42 |
|
|
syslog(LOG_ERR, "%s", msg); |
43 |
|
|
else { |
44 |
|
|
(void) write(STDERR_FILENO, msg, strlen(msg)); |
45 |
|
|
(void) write(STDERR_FILENO, "\n", 1); |
46 |
|
|
} |
47 |
|
|
#else |
48 |
|
|
syslog(LOG_ERR, "%s", msg); |
49 |
|
|
#endif |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
void bootparamprog_1(struct svc_req *rqstp, SVCXPRT *transp); |
53 |
|
|
|
54 |
|
|
void |
55 |
|
|
bootparamprog_1(struct svc_req *rqstp, SVCXPRT *transp) |
56 |
|
|
{ |
57 |
|
|
union { |
58 |
|
|
bp_whoami_arg bootparamproc_whoami_1_arg; |
59 |
|
|
bp_getfile_arg bootparamproc_getfile_1_arg; |
60 |
|
|
} argument; |
61 |
|
|
char *result; |
62 |
|
|
xdrproc_t xdr_argument, xdr_result; |
63 |
|
|
char *(*local)(char *, struct svc_req *); |
64 |
|
|
|
65 |
|
|
_rpcsvcdirty = 1; |
66 |
|
|
switch (rqstp->rq_proc) { |
67 |
|
|
case NULLPROC: |
68 |
|
|
(void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL); |
69 |
|
|
_rpcsvcdirty = 0; |
70 |
|
|
return; |
71 |
|
|
|
72 |
|
|
case BOOTPARAMPROC_WHOAMI: |
73 |
|
|
xdr_argument = (xdrproc_t) xdr_bp_whoami_arg; |
74 |
|
|
xdr_result = (xdrproc_t) xdr_bp_whoami_res; |
75 |
|
|
local = (char *(*)(char *, struct svc_req *)) bootparamproc_whoami_1_svc; |
76 |
|
|
break; |
77 |
|
|
|
78 |
|
|
case BOOTPARAMPROC_GETFILE: |
79 |
|
|
xdr_argument = (xdrproc_t) xdr_bp_getfile_arg; |
80 |
|
|
xdr_result = (xdrproc_t) xdr_bp_getfile_res; |
81 |
|
|
local = (char *(*)(char *, struct svc_req *)) bootparamproc_getfile_1_svc; |
82 |
|
|
break; |
83 |
|
|
|
84 |
|
|
default: |
85 |
|
|
svcerr_noproc(transp); |
86 |
|
|
_rpcsvcdirty = 0; |
87 |
|
|
return; |
88 |
|
|
} |
89 |
|
|
(void) memset((char *)&argument, 0, sizeof (argument)); |
90 |
|
|
if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) { |
91 |
|
|
svcerr_decode(transp); |
92 |
|
|
_rpcsvcdirty = 0; |
93 |
|
|
return; |
94 |
|
|
} |
95 |
|
|
result = (*local)((char *)&argument, rqstp); |
96 |
|
|
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { |
97 |
|
|
svcerr_systemerr(transp); |
98 |
|
|
} |
99 |
|
|
if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) { |
100 |
|
|
_msgout("unable to free arguments"); |
101 |
|
|
exit(1); |
102 |
|
|
} |
103 |
|
|
_rpcsvcdirty = 0; |
104 |
|
|
return; |
105 |
|
|
} |