diff options
3 files changed, 682 insertions, 3 deletions
diff --git a/testprogs/win32/midltests/midltests.idl b/testprogs/win32/midltests/midltests.idl index 0c0bbf8d3d..26ef9397ca 100644 --- a/testprogs/win32/midltests/midltests.idl +++ b/testprogs/win32/midltests/midltests.idl @@ -22,7 +22,7 @@ cpp_quote("#define CONNECT_IP \"172.31.9.1\"") * For testing it might be needed to allow downgrades * to NDR32. This is needed when you use 'pipe'. */ -//cpp_quote("#define DONOT_FORCE_NDR64 1") +cpp_quote("#define DONOT_FORCE_NDR64 1") [ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"), @@ -30,22 +30,267 @@ cpp_quote("#define CONNECT_IP \"172.31.9.1\"") ] interface midltests { + typedef pipe char pipe_char; + typedef pipe hyper pipe_hyper; + typedef struct { + long l; + short s; + } structtype; + typedef pipe structtype pipe_structtype; + + struct msg { + long l; + [size_is(l)] char *m; + }; + long midltests_fn( + [out,ref] struct msg *out1, + [out] pipe_structtype outp, + [in] pipe_structtype inp, + [in] struct msg in1 ); + + long midltests_ping( [in] struct msg in1); + } #elif MIDLTESTS_C_CODE +struct pipe_char_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_char_pull( + char * _state, + unsigned char * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_char_push( + char * _state, + unsigned char * buf, + unsigned long ecount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_char_alloc( + char * _state, + unsigned long bsize, + unsigned char * * buf, + unsigned long * bcount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} + +struct pipe_hyper_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_hyper_pull( + char * _state, + hyper * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_hyper_push( + char * _state, + hyper * buf, + unsigned long ecount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_hyper_alloc( + char * _state, + unsigned long bsize, + hyper * * buf, + unsigned long * bcount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} +struct pipe_structtype_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_structtype_pull( + char * _state, + structtype * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_structtype_push( + char * _state, + structtype * buf, + unsigned long ecount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_structtype_alloc( + char * _state, + unsigned long bsize, + structtype * * buf, + unsigned long * bcount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} static void midltests(void) { - cli_midltests_fn(); + struct msg out1; + unsigned char out1b[3]; + struct pipe_structtype_state outs; + pipe_structtype outp; + struct pipe_structtype_state ins; + pipe_structtype inp; + struct msg in1; + unsigned char in1b[3]; + + in1.l = sizeof(in1b); + memset(&in1b, 0xAA, sizeof(in1b)); + in1.m = in1b; + + memset(&outs, 0, sizeof(outs)); + outs.name = "outp"; + memset(&outp, 0, sizeof(outp)); + outp.pull = pipe_structtype_pull; + outp.push = pipe_structtype_push; + outp.alloc = pipe_structtype_alloc; + outp.state = (char *)&outs; + + memset(&ins, 0, sizeof(ins)); + ins.name = "inp"; + ins.count = 1; + memset(&inp, 0, sizeof(inp)); + inp.pull = pipe_structtype_pull; + inp.push = pipe_structtype_push; + inp.alloc = pipe_structtype_alloc; + inp.state = (char *)&ins; + + out1.l = sizeof(out1b); + memset(&out1b, 0xFF, sizeof(out1b)); + out1.m = out1b; + + cli_midltests_ping(in1); + cli_midltests_fn(&out1, outp, inp, in1); } -long srv_midltests_fn(void) +long srv_midltests_fn( + /* [ref][out] */ struct msg *out1, + /* [out] */ pipe_structtype outp, + /* [in] */ pipe_structtype inp, + /* [in] */ struct msg in1) { + structtype inb[500]; + unsigned long inb_len = 0; + structtype *outb = NULL; + unsigned long outb_size = 0; + unsigned long outb_len = 0; + printf("srv_midltests_fn: Start\n"); + + do { + inp.pull(inp.state, inb, sizeof(inb), &inb_len); + printf("pull inp_len[%u]\n", inb_len); + } while (inb_len > 0); + + outb_size = 5; + do { + outp.alloc(outp.state, outb_size, &outb, &outb_len); + memset(outb, 0xCC, outb_len * sizeof(*outb)); + outp.push(outp.state, outb, outb_len); + printf("push outb_len[%u]\n", outb_len); + //Sleep(1000); + outb_size--; + } while (outb_len > 0); + + out1->l = 3; + out1->m = (unsigned char *)malloc(out1->l); + memset(out1->m, 0xBB, out1->l); printf("srv_midltests_fn: End\n"); return 0x65757254; } +long srv_midltests_ping( + /* [in] */ struct msg in1) +{ + printf("srv_midltests_fn: Start\n"); + printf("srv_midltests_fn: End\n"); + return 0x65757254; +} #endif diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl new file mode 100644 index 0000000000..26ef9397ca --- /dev/null +++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl @@ -0,0 +1,296 @@ +#ifndef MIDLTESTS_C_CODE + +/* + * For midltests_tcp.exe you may want to + * redirect the traffic via rinetd + * with a /etc/rinetd.conf like this: + * + * 172.31.9.1 5032 172.31.9.8 5032 + * 172.31.9.1 5064 172.31.9.8 5064 + * + * This is useful to watch the traffic with + * a network sniffer. + */ +/* +cpp_quote("#define LISTEN_IP \"0.0.0.0\"") +cpp_quote("#define FORWARD_IP \"127.0.0.1\"") +cpp_quote("#define CONNECT_IP \"172.31.9.1\"") +*/ + +/* + * With midltests_tcp.exe NDR64 is enforced by default. + * For testing it might be needed to allow downgrades + * to NDR32. This is needed when you use 'pipe'. + */ +cpp_quote("#define DONOT_FORCE_NDR64 1") + +[ + uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"), + pointer_default(unique) +] +interface midltests +{ + typedef pipe char pipe_char; + typedef pipe hyper pipe_hyper; + typedef struct { + long l; + short s; + } structtype; + typedef pipe structtype pipe_structtype; + + struct msg { + long l; + [size_is(l)] char *m; + }; + + long midltests_fn( + [out,ref] struct msg *out1, + [out] pipe_structtype outp, + [in] pipe_structtype inp, + [in] struct msg in1 + ); + + long midltests_ping( [in] struct msg in1); + +} + +#elif MIDLTESTS_C_CODE + +struct pipe_char_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_char_pull( + char * _state, + unsigned char * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_char_push( + char * _state, + unsigned char * buf, + unsigned long ecount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_char_alloc( + char * _state, + unsigned long bsize, + unsigned char * * buf, + unsigned long * bcount) +{ + struct pipe_char_state *state = (struct pipe_char_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} + +struct pipe_hyper_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_hyper_pull( + char * _state, + hyper * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_hyper_push( + char * _state, + hyper * buf, + unsigned long ecount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_hyper_alloc( + char * _state, + unsigned long bsize, + hyper * * buf, + unsigned long * bcount) +{ + struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} +struct pipe_structtype_state { + const char *name; + unsigned long count; + unsigned long sleep; +}; + +void pipe_structtype_pull( + char * _state, + structtype * buf, + unsigned long esize, + unsigned long * ecount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("pull1:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); + *ecount = state->count--; + if (*ecount > esize) { + *ecount = esize; + } + memset(buf, 0xDD, *ecount * sizeof(*buf)); + printf("pull2:%s: esize[%u] ecount[%u]\n", + state->name, esize, *ecount); +} + +void pipe_structtype_push( + char * _state, + structtype * buf, + unsigned long ecount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("push:%s: ecount[%u]\n", + state->name, ecount); +} + +void pipe_structtype_alloc( + char * _state, + unsigned long bsize, + structtype * * buf, + unsigned long * bcount) +{ + struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state; + + printf("alloc1:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); + *bcount = bsize / sizeof(**buf); + *buf = malloc(*bcount * sizeof(**buf)); + printf("alloc2:%s: bsize[%u], bcount[%u]\n", + state->name, bsize, *bcount); +} +static void midltests(void) +{ + struct msg out1; + unsigned char out1b[3]; + struct pipe_structtype_state outs; + pipe_structtype outp; + struct pipe_structtype_state ins; + pipe_structtype inp; + struct msg in1; + unsigned char in1b[3]; + + in1.l = sizeof(in1b); + memset(&in1b, 0xAA, sizeof(in1b)); + in1.m = in1b; + + memset(&outs, 0, sizeof(outs)); + outs.name = "outp"; + memset(&outp, 0, sizeof(outp)); + outp.pull = pipe_structtype_pull; + outp.push = pipe_structtype_push; + outp.alloc = pipe_structtype_alloc; + outp.state = (char *)&outs; + + memset(&ins, 0, sizeof(ins)); + ins.name = "inp"; + ins.count = 1; + memset(&inp, 0, sizeof(inp)); + inp.pull = pipe_structtype_pull; + inp.push = pipe_structtype_push; + inp.alloc = pipe_structtype_alloc; + inp.state = (char *)&ins; + + out1.l = sizeof(out1b); + memset(&out1b, 0xFF, sizeof(out1b)); + out1.m = out1b; + + cli_midltests_ping(in1); + cli_midltests_fn(&out1, outp, inp, in1); +} + +long srv_midltests_fn( + /* [ref][out] */ struct msg *out1, + /* [out] */ pipe_structtype outp, + /* [in] */ pipe_structtype inp, + /* [in] */ struct msg in1) +{ + structtype inb[500]; + unsigned long inb_len = 0; + structtype *outb = NULL; + unsigned long outb_size = 0; + unsigned long outb_len = 0; + + printf("srv_midltests_fn: Start\n"); + + do { + inp.pull(inp.state, inb, sizeof(inb), &inb_len); + printf("pull inp_len[%u]\n", inb_len); + } while (inb_len > 0); + + outb_size = 5; + do { + outp.alloc(outp.state, outb_size, &outb, &outb_len); + memset(outb, 0xCC, outb_len * sizeof(*outb)); + outp.push(outp.state, outb, outb_len); + printf("push outb_len[%u]\n", outb_len); + //Sleep(1000); + outb_size--; + } while (outb_len > 0); + + out1->l = 3; + out1->m = (unsigned char *)malloc(out1->l); + memset(out1->m, 0xBB, out1->l); + printf("srv_midltests_fn: End\n"); + return 0x65757254; +} + +long srv_midltests_ping( + /* [in] */ struct msg in1) +{ + printf("srv_midltests_fn: Start\n"); + printf("srv_midltests_fn: End\n"); + return 0x65757254; +} +#endif diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt new file mode 100644 index 0000000000..1c8d003fac --- /dev/null +++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt @@ -0,0 +1,138 @@ +Wait for setup of server threads + +Test NDR32 + +ndr32: disable NDR64 + +ndr32:in => out: ptype[request] flen[39] plen[15] + +[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA ........ ....... + +srv_midltests_fn: Start +srv_midltests_fn: End + +ndr32:out => in: ptype[response] flen[28] plen[4] + +[000] 54 72 75 65 True + +ndr32: got NDR32 + +alloc1:inp: bsize[5000], bcount[0] +alloc2:inp: bsize[5000], bcount[625] +pull1:inp: esize[78] ecount[78] +pull2:inp: esize[78] ecount[1] +alloc1:inp: bsize[5000], bcount[625] +alloc2:inp: bsize[5000], bcount[625] +pull1:inp: esize[78] ecount[78] +pull2:inp: esize[78] ecount[0] +ndr32:in => out: ptype[alter_req] flen[72] call[3] contexts[1] + + +ndr32:out => in: ptype[alter_ack] flen[56] call[3] + +ndr32:in => out: ptype[request] flen[56] plen[32] + +[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA 00 ........ ........ +[010] 01 00 00 00 DD DD DD DD DD DD 08 00 00 00 00 00 ........ ........ + +srv_midltests_fn: Start +pull inp_len[1] +pull inp_len[0] +push outb_len[5] +push outb_len[4] +push outb_len[3] +push outb_len[2] +push outb_len[1] +push outb_len[0] +srv_midltests_fn: End + +ndr32:out => in: ptype[response] flen[188] plen[164] + +[000] 05 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[020] CC CC CC CC CC CC CC CC CC CC 00 00 04 00 00 00 ........ ........ +[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........ +[050] 03 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[060] CC CC CC CC CC CC CC CC CC CC 00 00 02 00 00 00 ........ ........ +[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........ +[080] 01 00 00 00 CC CC CC CC CC CC 00 00 00 00 00 00 ........ ........ +[090] 03 00 00 00 00 00 02 00 03 00 00 00 BB BB BB 00 ........ ........ +[0A0] 54 72 75 65 True + +alloc1:outp: bsize[6664], bcount[1] +alloc2:outp: bsize[6664], bcount[833] +push:outp: ecount[15] +push:outp: ecount[0] +NDRTcpThread[ndr32] stop + +Test NDR64 + +ndr64: got NDR64 + +ndr64:in => out: ptype[request] flen[51] plen[27] + +[000] 03 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 ........ ........ +[010] 03 00 00 00 00 00 00 00 AA AA AA ........ ... + +srv_midltests_fn: Start +srv_midltests_fn: End + +ndr64:out => in: ptype[response] flen[28] plen[4] + +[000] 54 72 75 65 True + + +ndr64: got NDR32 downgrade + + +alloc1:inp: bsize[5000], bcount[0] +alloc2:inp: bsize[5000], bcount[625] +pull1:inp: esize[78] ecount[78] +pull2:inp: esize[78] ecount[1] +alloc1:inp: bsize[5000], bcount[625] +alloc2:inp: bsize[5000], bcount[625] +pull1:inp: esize[78] ecount[78] +pull2:inp: esize[78] ecount[0] +ndr64:in => out: ptype[alter_req] flen[72] call[3] contexts[1] + + +ndr64:out => in: ptype[alter_ack] flen[56] call[3] + +ndr64:in => out: ptype[request] flen[56] plen[32] + +[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA 00 ........ ........ +[010] 01 00 00 00 DD DD DD DD DD DD 00 00 00 00 00 00 ........ ........ + +srv_midltests_fn: Start +pull inp_len[1] +pull inp_len[0] +push outb_len[5] +push outb_len[4] +push outb_len[3] +push outb_len[2] +push outb_len[1] +push outb_len[0] +srv_midltests_fn: End + +ndr64:out => in: ptype[response] flen[188] plen[164] + +[000] 05 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[020] CC CC CC CC CC CC CC CC CC CC 00 00 04 00 00 00 ........ ........ +[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........ +[050] 03 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........ +[060] CC CC CC CC CC CC CC CC CC CC 00 00 02 00 00 00 ........ ........ +[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........ +[080] 01 00 00 00 CC CC CC CC CC CC 00 00 00 00 00 00 ........ ........ +[090] 03 00 00 00 00 00 02 00 03 00 00 00 BB BB BB 00 ........ ........ +[0A0] 54 72 75 65 True + +alloc1:outp: bsize[6664], bcount[1] +alloc2:outp: bsize[6664], bcount[833] +push:outp: ecount[15] +push:outp: ecount[0] +NDRTcpThread[ndr64] stop + +Test OK |