[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sun RPC libraries and other stories



* Simon Phipps:

> On Nov 18, 2008, at 03:52, Ben Hutchings wrote:
>
>> Many of the functions in portmap.c seem to correspond to
>> rpcbind (usr/src/cmd/rpcbind) in OpenSolaris:
>
> Is it just the function prototypes that are derived, or is there
> derived source defining them too?

>From our portmap.c:

| /*
|  * Stuff for the rmtcall service
|  */
| #define ARGSIZE 9000
|
| struct encap_parms {
|         u_int arglen;
|         char *args;
| };
|
| static bool_t
| xdr_encap_parms(XDR *xdrs, struct encap_parms *epp)
| {
|
|         return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE));
| }
|
| struct rmtcallargs {
|         u_long  rmt_prog;
|         u_long  rmt_vers;
|         u_long  rmt_port;
|         u_long  rmt_proc;
|         struct encap_parms rmt_args;
| };
|
| static bool_t
| xdr_rmtcall_args(XDR *xdrs, struct rmtcallargs *cap)
| {
|
|         /* does not get a port number */
|         if (xdr_u_long(xdrs, &(cap->rmt_prog)) &&
|             xdr_u_long(xdrs, &(cap->rmt_vers)) &&
|             xdr_u_long(xdrs, &(cap->rmt_proc))) {
|                 return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|         }
|         return (FALSE);
| }
|
| static bool_t
| xdr_rmtcall_result(XDR *xdrs, struct rmtcallargs *cap)
| {
|         if (xdr_u_long(xdrs, &(cap->rmt_port)))
|                 return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|         return (FALSE);
| }
| 
| /*
|  * only worries about the struct encap_parms part of struct rmtcallargs.
|  * The arglen must already be set!!
|  */
| static bool_t
| xdr_opaque_parms(XDR *xdrs, struct rmtcallargs *cap)
| {
| 
|         return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen));
| }

>From <http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/rpcbind/rpcb_svc_com.c>:

| /*
|  * Stuff for the rmtcall service
|  */
| struct encap_parms {
|       ulong_t arglen;
|       char *args;
| };
|
| static bool_t
| xdr_encap_parms(xdrs, epp)
|       XDR *xdrs;
|       struct encap_parms *epp;
| {
|       return (xdr_bytes(xdrs, &(epp->args), (uint_t *)&(epp->arglen), ~0));
| }
|
|
| struct r_rmtcall_args {
|       ulong_t         rmt_prog;
|       ulong_t         rmt_vers;
|       ulong_t         rmt_proc;
|       int     rmt_localvers;  /* whether to send port # or uaddr */
|       char    *rmt_uaddr;
|       struct encap_parms rmt_args;
| };
|
| /*
|  * XDR remote call arguments.  It ignores the address part.
|  * written for XDR_DECODE direction only
|  */
| static bool_t
| xdr_rmtcall_args(xdrs, cap)
|       register XDR *xdrs;
|       register struct r_rmtcall_args *cap;
| {
|       /* does not get the address or the arguments */
|       if (xdr_u_long(xdrs, &(cap->rmt_prog)) &&
|           xdr_u_long(xdrs, &(cap->rmt_vers)) &&
|           xdr_u_long(xdrs, &(cap->rmt_proc))) {
|               return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|       }
|       return (FALSE);
| }
|
| /*
|  * XDR remote call results along with the address.  Ignore
|  * program number, version  number and proc number.
|  * Written for XDR_ENCODE direction only.
|  */
| static bool_t
| xdr_rmtcall_result(xdrs, cap)
|       register XDR *xdrs;
|       register struct r_rmtcall_args *cap;
| {
|       bool_t result;
|
| #ifdef PORTMAP
|       if (cap->rmt_localvers == PMAPVERS) {
|               int h1, h2, h3, h4, p1, p2;
|               ulong_t port;
|
|               /* interpret the universal address for TCP/IP */
|               if (sscanf(cap->rmt_uaddr, "%d.%d.%d.%d.%d.%d",
|                       &h1, &h2, &h3, &h4, &p1, &p2) != 6)
|                       return (FALSE);
|               port = ((p1 & 0xff) << 8) + (p2 & 0xff);
|               result = xdr_u_long(xdrs, &port);
|       } else
| #endif
|               if ((cap->rmt_localvers == RPCBVERS) ||
|                   (cap->rmt_localvers == RPCBVERS4)) {
|               result = xdr_wrapstring(xdrs, &(cap->rmt_uaddr));
|       } else {
|               return (FALSE);
|       }
|       if (result == TRUE)
|               return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|       return (FALSE);
| }
| 
| /*
|  * only worries about the struct encap_parms part of struct r_rmtcall_args.
|  * The arglen must already be set!!
|  */
| static bool_t
| xdr_opaque_parms(xdrs, cap)
| 	XDR *xdrs;
| 	struct r_rmtcall_args *cap;
| {
| 	return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen));
| }

So there's certainly some overlap, and it's not just prototypes.


Reply to: