[jcifs] RPC Stub Format Changes

Michael B Allen mba2000 at ioplex.com
Mon Aug 16 00:38:38 GMT 2004


I think recursively nesting class definitions in stubs was clearly wrong.
Instead of having a separate classfile for each operations there I'm going
to change the compiler to generate a file for each interface with a single
nested class def for each struct/union. This is much more consistent with
C stubs and we could also generate class defs for common types. For
example we could have an interface 'rpc':

[
    pointer_default(?)
]
interface rpc {

    typedef struct {
        unsigned32          time_low;
        unsigned16          time_mid;
        unsigned16          time_hi_and_version;
        unsigned8           clock_seq_hi_and_reserved;
        unsigned8           clock_seq_low;
        byte                node[6];
    } uuid_t, *uuid_p_t;

...

which would result in an rpc.java classfile like this:

public class rpc {

    public static class uuid_t {
        int time_low;
        short time_mid;
        short time_hi_and_version;
        byte clock_seq_hi_and_reserved;
        byte clock_seq_low;
        byte[] node;

        void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws
NdrException {
            time_low = src.dec_ndr_long();
            time_mid = src.dec_ndr_short();
            time_hi_and_version = src.dec_ndr_short();
            clock_seq_hi_and_reserved = src.dec_ndr_small();
            clock_seq_low = src.dec_ndr_small();
            if (node == null) {
                node = new node[6];
            }
            for (int i = 0; i < 6; i++) {
                node[i] = src.dec_ndr_small();
            }
        }
        ... encode ...
    }

    public static class p_syntax_id_t {
        rpc.uuid_t if_uuid;
        int if_version;

        void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws
NdrException {
            if (if_uuid == null) {
                if_uuid = new rpc.uuid_t();
            }
            if_uuid.decode(ndr, src);
        }
        ... encode ...
    }

I don't think we can generate the PDUs with IDL. For example the Bind PDU
response body's differ and you cannot use a union to switch on the PTYPE
field because that would encode a discriminent that does not exist in the
real PDUs (probably why PIDL the has 'nodiscriminent' attribute
extension).

But we can use these objects throughout the code. For example instead of:

    PresentationSyntax syntax = getSyntax();
    uuid = syntax.getUuid();
    ndr.writeElement((uuid != null) ? uuid : new UUID(UUID.NIL_UUID));
    uuid = getActivity();
    ndr.writeElement((uuid != null) ? uuid : new UUID(UUID.NIL_UUID));

We could generate p_syntax_id_t and do:

    rpc.p_syntax_id_t syntax = getSyntax();
    uuid = syntax.if_uuid != null ? syntax.if_uuid : NIL_UUID;
    uuid.encode(ndr, ndr.getBuffer());
    uuid = getActivity();
    uuid = uuid != null ? uuid : NIL_UUID;
    uuid.encode(ndr, ndr.getBuffer());

I guess it's not a big difference in PDU code though.

Mike


More information about the jcifs mailing list