3.2.4 Serialization

  1. This is a sample of Sun rpc and its associated data representation, xdr. Sun rpc is described in rfc 1831, whilst the concrete syntax for sun xdr is available in rfc 1832.

    Some bits of the answer - the remaining is for you to fill in.

    struct rpc_msg {
             unsigned int xid;
             union switch (msg_type mtype) {
             case CALL:
                call_body cbody;
             case REPLY:
                reply_body rbody;
             } body;
          };
    
    struct call_body {
             unsigned int rpcvers;       /* must be equal to two (2) */
             unsigned int prog;
             unsigned int vers;
             unsigned int proc;
             opaque_auth  cred;
             opaque_auth  verf;
             /* procedure specific parameters start here */
          };
    
    union reply_body switch (reply_stat stat) {
          case MSG_ACCEPTED:
             accepted_reply areply;
          case MSG_DENIED:
             rejected_reply rreply;
          } reply;
    
    struct accepted_reply {
             opaque_auth verf;
             union switch (accept_stat stat) {
             case SUCCESS:
                opaque results[0];
                /*
                 * procedure-specific results start here
                 */
              case PROG_MISMATCH:
                 struct {
                    unsigned int low;
                    unsigned int high;
                 } mismatch_info;
              default:
                 /*
                  * Void.  Cases include PROG_UNAVAIL, PROC_UNAVAIL,
                  * GARBAGE_ARGS, and SYSTEM_ERR.
                  */
                 void;
              } reply_data;
          };
    
  2. This is Java Serialization. The tricky bits are how to represent Java objects efficiently.

Ian Wakeman 2005-02-22