libmsrpc for Samba 3

Gerald (Jerry) Carter jerry at
Wed Jul 20 13:15:18 GMT 2005

Hash: SHA1

tridge at wrote:

| There are similarities between the two approaches,
| but one is not based on the other. The API in Samba4
| is based directly on the IDL files.

I meant to say "basically", not "based".  I'll blame that
one my my spell checker.  If anything, I've stolen from
Samba 4. :-)

| So to make the above call a client does this:
| 	struct svcctl_EnumServicesStatusW io;
| = h;
| = 0;
| = &resume_handle;
| io.out.resume_handle = &resume_handle;
| status = dcerpc_svcctl_EnumServicesStatusW(p, mem_ctx, &io);
| At first you might think it is easier to have a
| conventional function interface, and have a win32 style
| function with 8 parameters, but I have found that it
| is in fact much easier to program with the in.* and
| out.* interface than the win32 style interface.
| The reason is that with so many parameters of the same
| type it is incredibly easy to get the call mixed up.
| By explicitly naming the parameters as you set them
| you end up with much less error prone code.

Yeah.  I can see this.  I'm still thinking about it.

| Unless you adopted the auto-generated code from pidl
| I think it would be a huge task to make a new rpc
| library for Samba3 be compatible with the Samba4 API.
| What you perhaps could do is make the APIs as close as
| possible so that it is less painful for users of the
| library to transition between the two.
| I don't think there is any question that the
| future of RPC in Samba has got to be based on
| auto-generation from IDL.

I agree about the importance of IDL.  But I'm still
thinking about your proposal.  You are calling the
client API the point at which structures get [un]marshalled.

In Samba 3, I have this:

WERROR cli_spoolss_open_printer_ex( struct cli_state *cli, ....)
~        make_spoolss_q_open_printer_ex( &in, printername, datatype,
		access_required, station, username );

	            in, out,
	            qbuf, rbuf,
	            WERR_GENERAL_FAILURE );

	memcpy( pol, &out.handle, sizeof(POLICY_HND) );

	return out.status;

The make_spoolss_q_open_printer_ex() call does what you
do by assigning the structure elements necessary for
the outgoing call.  So what you call the client interface
the the CLI_DO_RPC macro I've used above.

This is the cooresponding code from Samba 4:       = talloc_asprintf(ctx,
				  dcerpc_server_name(ctx->p));          = NULL; NULL;       = 0;
	op.out.handle           = &ctx->server_handle;

	status = dcerpc_spoolss_OpenPrinter(ctx->p, ctx, &op);

What I'm still considering is whether or not this
low level API is really best for application writers.
I'm just not totally convinced yet, but am still thinking
about it.  Parts of it I like but parts of it I'm still
pondering.  At least now I do know that I understand your
original suggestion.

Chris, You want to weigh in here ?  Got any observations
or comments?

cheers, jerry
Alleviating the pain of Windows(tm)      -------
GnuPG Key                -----
"I never saved anything for the swim back."     Ethan Hawk in Gattaca
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -


More information about the samba-technical mailing list