I have been looking through several websites on the Internet and actually wanted to know how do we write specification in a .x file to generate equivalent functions in .c file for RPC. Every site I visited suggested to use following kind of specification in *.x file:
program ADD_PROG {
version ADD_VERS {
int ADD(intpair) = 1;
} = 1;
} = 0x23451111;
So, to understand practically, I obtained gm_protocol.x from an open-source project known as ganglia and generated equivalent C source code (gm_protocol_xdr.c) and C header file (gm_protocol.h) using rpcgen.
[rohit@ganglia-server rpc]$ rpcgen -C gm_protocol.x
[rohit@ganglia-server rpc]$
[rohit@ganglia-server rpc]$ ll
total 24
-rw-rw-r-- 1 rohit rohit 5786 Oct 28 17:52 gm_protocol.h
-rw-rw-r-- 1 rohit rohit 3485 Oct 28 15:04 gm_protocol.x
-rw-rw-r-- 1 rohit rohit 8213 Oct 28 17:52 gm_protocol_xdr.c
To my surprise, from what I have learned and understood, gm_protocol.x doesn't contain any such RPC specifications shown as code above but still it can generate too many functions in the file gm_protocol_xdr.c.
It is pretty much sure that I am not able to understand the XDR specifications because either I have consulted wrong sources or they are outdated. I could not find any tutorial which could explain the way to generate functions (Although I have found specifications to generate struct, enum, union, etc).
Please help to learn these specifications.