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

NOTES

181       The RPC Language does not support nesting of structures.   As  a  work-
182       around,  structures  can  be  declared at the top-level, and their name
183       used inside other structures in order to achieve the same effect.
184
185       Name clashes can occur when using program definitions, since the appar‐
186       ent  scoping  does  not  really apply.  Most of these can be avoided by
187       giving unique names for programs, versions, procedures and types.
188
189       The server code generated with -n option refers to the transport  indi‐
190       cated by netid and hence is very site specific.
191

EXAMPLE

193       The following example:
194
195              $ rpcgen -T prot.x
196
197       generates  the  five files: prot.h, prot_clnt.c, prot_svc.c, prot_xdr.c
198       and prot_tbl.i.
199
200       The following example sends the C data-definitions (header file) to the
201       standard output.
202
203              $ rpcgen -h prot.x
204
205       To  send  the test version of the -DTEST, server side stubs for all the
206       transport belonging to the class datagram_n to standard output, use:
207
208              $ rpcgen -s datagram_n -DTEST prot.x
209
210       To create the server side stubs for the transport  indicated  by  netid
211       tcp, use:
212
213              $ rpcgen -n tcp -o prot_svc.c prot.x
214

SEE ALSO

216       gcc(1).
217
218
219
220                                                                            0a
Impressum