ONC+ Developer's Guide

Opaque Data

In some protocols, handles are passed from a server to the client. The client passes the handle back to the server at some later time. Handles are never inspected by clients; they are obtained and submitted. That is, handles are opaque. The xdr_opaque() primitive is used for describing fixed-sized opaque bytes.

xdr_opaque(xdrs, p, len)
   XDR *xdrs;
   char *p;
   u_int len;

The parameter p is the location of the bytes, len is the number of bytes in the opaque object. By definition, the actual data contained in the opaque object is not machine portable.

In the SunOS/SVR4 system is another routine for manipulating opaque data. This routine, the xdr_netobj, sends counted opaque data, much like xdr_opaque(). The following code example illustrates the syntax of xdr_netobj().

Example A–10 xdr_netobj Routine

struct netobj {
	u_int   n_len;
	char    *n_bytes;
typedef struct netobj netobj;

xdr_netobj(xdrs, np)
	XDR *xdrs;
	struct netobj *np;

The xdr_netobj() routine is a filter primitive that translates between variable-length opaque data and its external representation. The parameter np is the address of the netobj structure containing both a length and a pointer to the opaque data. The length may be no more than MAX_NETOBJ_SZ bytes. This routine returns TRUE if it succeeds, FALSE otherwise.