1rpcgen(1)                   General Commands Manual                  rpcgen(1)
2
3
4

NAME

6       rpcgen - an RPC protocol compiler
7

SYNOPSIS

9       rpcgen infile
10       rpcgen [-Dname[=value]] [-T] [-K secs] infile
11       rpcgen -c|-h|-l|-m|-M|-t [-o outfile ] infile
12       rpcgen [-I] -s nettype [-o outfile] infile
13       rpcgen -n netid [-o outfile] infile
14

DESCRIPTION

16       rpcgen  is  a  tool that generates C code to implement an RPC protocol.
17       The input to rpcgen is a language similar to C known  as  RPC  Language
18       (Remote Procedure Call Language).
19
20       rpcgen  is  normally  used  as  in the first synopsis where it takes an
21       input file and generates up to four output files.   If  the  infile  is
22       named  proto.x, then rpcgen will generate a header file in proto.h, XDR
23       routines in proto_xdr.c, server-side stubs in proto_svc.c, and  client-
24       side  stubs in proto_clnt.c.  With the -T option, it will also generate
25       the RPC dispatch table in proto_tbl.i.  With the -Sc  option,  it  will
26       also generate  sample code which would illustrate how to use the remote
27       procedures  on  the  client  side.  This  code  would  be  created   in
28       proto_client.c.   With  the  -Ss option, it will also generate a sample
29       server code which would illustrate how to write the remote  procedures.
30       This code would be created in proto_server.c.
31
32       The  server created can be started both by the port monitors (for exam‐
33       ple, inetd or listen) or by itself.  When it is started by a port moni‐
34       tor,  it  creates  servers  only  for  the transport for which the file
35       descriptor 0 was passed.  The name of the transport must  be  specified
36       by setting up the environmental variable PM_TRANSPORT.  When the server
37       generated by rpcgen is executed, it creates server handles for all  the
38       transports  specified  in  NETPATH  environment  variable,  or if it is
39       unset, it creates server handles for all the  visible  transports  from
40       /etc/netconfig  file.   Note: the transports are chosen at run time and
41       not at compile time.
42
43       When built for a port monitor (rpcgen -I), and that the server is self-
44       started,  it  backgrounds  itself  by default.  A special define symbol
45       RPC_SVC_FG can be used to run the server process in foreground.
46
47       The second synopsis provides special features which allow for the  cre‐
48       ation  of  more sophisticated RPC servers.  These features include sup‐
49       port for user provided #defines and RPC dispatch tables.   The  entries
50       in the RPC dispatch table contain:
51              ·  pointers  to the service routine corresponding to that proce‐
52                 dure,
53              ·  a pointer to the input and output arguments
54              ·  the size of these routines
55       A server can use the dispatch table to check authorization and then  to
56       execute  the  service routine; a client library may use it to deal with
57       the details of storage management and XDR data conversion.
58
59       The other three synopses shown above are used when one does not want to
60       generate  all  the output files, but only a particular one.  Some exam‐
61       ples of their usage is described in the EXAMPLE  section  below.   When
62       rpcgen is executed with the -s option, it creates servers for that par‐
63       ticular class of transports.  When executed with the -n option, it cre‐
64       ates  a  server for the transport specified by netid.  If infile is not
65       specified, rpcgen accepts the standard input.
66
67       The C preprocessor, cc -E [see cc(1)], is run on the input file  before
68       it  is  actually  interpreted by rpcgen.  For each type of output file,
69       rpcgen defines a special preprocessor symbol for use by the rpcgen pro‐
70       grammer:
71
72       RPC_HDR     defined when compiling into header files
73       RPC_XDR     defined when compiling into XDR routines
74       RPC_SVC     defined when compiling into server-side stubs
75       RPC_CLNT    defined when compiling into client-side stubs
76       RPC_TBL     defined when compiling into RPC dispatch tables
77
78       Any  line  beginning  with `%' is passed directly into the output file,
79       uninterpreted by rpcgen.
80
81       For every data type referred to in infile, rpcgen  assumes  that  there
82       exists a routine with the string xdr_ prepended to the name of the data
83       type.  If this routine does not exist in the RPC/XDR library,  it  must
84       be  provided.  Providing an undefined data type allows customization of
85       XDR routines.
86
87       The following options are available:
88
89       -a     Generate all the files including  sample  code  for  client  and
90              server side.
91
92       -b     This  generates  code  for  the SunOS4.1 style of rpc. It is for
93              backward compatibility.  This is the default.
94
95       -5     This generates code for the SysVr4 style of rpc. It is  used  by
96              the  Transport  Independent  RPC  that  is  in Svr4 systems.  By
97              default rpcgen generates code for SunOS4.1 stype of rpc.
98
99       -c     Compile into XDR routines.
100
101       -C     Generate code in ANSI C. This option also  generates  code  that
102              could be compiled with the C++ compiler.  This is the default.
103
104       -k     Generate code in K&R C.  The default is ANSI C.
105
106       -Dname[=value]
107              Define  a  symbol  name.  Equivalent to the #define directive in
108              the source.  If no value is given, value is defined as 1.   This
109              option may be specified more than once.
110
111       -h     Compile  into C data-definitions (a header file).  -T option can
112              be used in conjunction to produce a header file  which  supports
113              RPC dispatch tables.
114
115       -I     Generate  a service that can be started from inetd.  The default
116              is to generate a static service that handles transports selected
117              with -s.  Using -I allows starting a service by either method.
118
119       -K secs
120              By default, services created using rpcgen wait 120 seconds after
121              servicing a  request  before  exiting.   That  interval  can  be
122              changed  using the -K flag.  To create a server that exits imme‐
123              diately upon servicing a request, -K 0 can be used.  To create a
124              server that never exits, the appropriate argument is -K -1.
125
126              When  monitoring  for  a  server,  some  portmonitors, like lis‐
127              ten(1M), always spawn a new process in  response  to  a  service
128              request.   If it is known that a server will be used with such a
129              monitor, the server should exit immediately on completion.   For
130              such servers, rpcgen should be used with -K -1.
131
132       -l     Compile into client-side stubs.
133
134       -m     Compile  into  server-side  stubs,  but do not generate a “main”
135              routine.  This option is useful for doing callback-routines  and
136              for  users who need to write their own “main” routine to do ini‐
137              tialization.
138
139       -M     Generate  multithread-safe  stubs  for  passing  arguments   and
140              results  between  rpcgen-generated  code  and user written code.
141              This option is useful for users who want to use threads in their
142              code.
143
144       -n netid
145              Compile  into  server-side  stubs for the transport specified by
146              netid.  There should be an entry  for  netid  in  the  netconfig
147              database.  This option may be specified more than once, so as to
148              compile a server that serves multiple transports.
149
150       -N     Use the newstyle of rpcgen. This allows procedures to have  mul‐
151              tiple  arguments.   It  also uses the style of parameter passing
152              that closely resembles C. So, when  passing  an  argument  to  a
153              remote  procedure you do not have to pass a pointer to the argu‐
154              ment but the argument itself. This behaviour is  different  from
155              the  oldstyle  of rpcgen generated code. The newstyle is not the
156              default case because of backward compatibility.
157
158       -o outfile
159              Specify the name of the output  file.   If  none  is  specified,
160              standard  output is used (-c, -h, -l, -m, -n, -s, -Sc, -Sm, -Ss,
161              and -t modes only).
162
163       -s nettype
164              Compile into server-side stubs for all the transports  belonging
165              to  the class nettype.  The supported classes are netpath, visi‐
166              ble, circuit_n, circuit_v, datagram_n, datagram_v, tcp, and  udp
167              [see  rpc(3N)  for  the meanings associated with these classes].
168              This option may be specified more than once.  Note:  the  trans‐
169              ports are chosen at run time and not at compile time.
170
171       -Sc    Generate sample code to show the use of remote procedure and how
172              to bind to the server before calling the client side stubs  gen‐
173              erated by rpcgen.
174
175       -Sm    Generate  a  sample Makefile which can be used for compiling the
176              application.
177
178       -Ss    Generate skeleton code for the remote procedures on  the  server
179              side.  You  would need to fill in the actual code for the remote
180              procedures.
181
182       -t     Compile into RPC dispatch table.
183
184       -T     Generate the code to support RPC dispatch tables.
185
186       The options -c, -h, -l, -m, -s and -t are used exclusively to  generate
187       a  particular  type of file, while the options -D and -T are global and
188       can be used with the other options.
189

NOTES

191       The RPC Language does not support nesting of structures.   As  a  work-
192       around,  structures  can  be  declared at the top-level, and their name
193       used inside other structures in order to achieve the same effect.
194
195       Name clashes can occur when using program definitions, since the appar‐
196       ent  scoping  does  not  really apply.  Most of these can be avoided by
197       giving unique names for programs, versions, procedures and types.
198
199       The server code generated with -n option refers to the transport  indi‐
200       cated by netid and hence is very site specific.
201

EXAMPLE

203       The following example:
204
205              $ rpcgen -T prot.x
206
207       generates  the  five files: prot.h, prot_clnt.c, prot_svc.c, prot_xdr.c
208       and prot_tbl.i.
209
210       The following example sends the C data-definitions (header file) to the
211       standard output.
212
213              $ rpcgen -h prot.x
214
215       To  send  the test version of the -DTEST, server side stubs for all the
216       transport belonging to the class datagram_n to standard output, use:
217
218              $ rpcgen -s datagram_n -DTEST prot.x
219
220       To create the server side stubs for the transport  indicated  by  netid
221       tcp, use:
222
223              $ rpcgen -n tcp -o prot_svc.c prot.x
224

SEE ALSO

226       cc(1).
227
228
229
230                                                                            0a
Impressum