1 #ifndef MIDLTESTS_C_CODE
4 * For midltests_tcp.exe you may want to
5 * redirect the traffic via rinetd
6 * with a /etc/rinetd.conf like this:
8 * 172.31.9.1 5032 172.31.9.8 5032
9 * 172.31.9.1 5064 172.31.9.8 5064
11 * This is useful to watch the traffic with
15 cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
16 cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
17 cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
21 * With midltests_tcp.exe NDR64 is enforced by default.
22 * For testing it might be needed to allow downgrades
23 * to NDR32. This is needed when you use 'pipe'.
25 cpp_quote("#define DONOT_FORCE_NDR64 1")
28 uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
29 pointer_default(unique)
33 typedef pipe char pipe_char;
34 typedef pipe hyper pipe_hyper;
39 typedef pipe structtype pipe_structtype;
47 [out,ref] struct msg *out1,
48 [out] pipe_structtype outp,
49 [in] pipe_structtype inp,
53 long midltests_ping( [in] struct msg in1);
57 #elif MIDLTESTS_C_CODE
59 struct pipe_char_state {
69 unsigned long * ecount)
71 struct pipe_char_state *state = (struct pipe_char_state *)_state;
73 printf("pull1:%s: esize[%u] ecount[%u]\n",
74 state->name, esize, *ecount);
75 *ecount = state->count--;
76 if (*ecount > esize) {
79 memset(buf, 0xDD, *ecount * sizeof(*buf));
80 printf("pull2:%s: esize[%u] ecount[%u]\n",
81 state->name, esize, *ecount);
89 struct pipe_char_state *state = (struct pipe_char_state *)_state;
91 printf("push:%s: ecount[%u]\n",
98 unsigned char * * buf,
99 unsigned long * bcount)
101 struct pipe_char_state *state = (struct pipe_char_state *)_state;
103 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
104 state->name, bsize, *bcount);
105 *bcount = bsize / sizeof(**buf);
106 *buf = malloc(*bcount * sizeof(**buf));
107 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
108 state->name, bsize, *bcount);
111 struct pipe_hyper_state {
117 void pipe_hyper_pull(
121 unsigned long * ecount)
123 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
125 printf("pull1:%s: esize[%u] ecount[%u]\n",
126 state->name, esize, *ecount);
127 *ecount = state->count--;
128 if (*ecount > esize) {
131 memset(buf, 0xDD, *ecount * sizeof(*buf));
132 printf("pull2:%s: esize[%u] ecount[%u]\n",
133 state->name, esize, *ecount);
136 void pipe_hyper_push(
139 unsigned long ecount)
141 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
143 printf("push:%s: ecount[%u]\n",
144 state->name, ecount);
147 void pipe_hyper_alloc(
151 unsigned long * bcount)
153 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
155 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
156 state->name, bsize, *bcount);
157 *bcount = bsize / sizeof(**buf);
158 *buf = malloc(*bcount * sizeof(**buf));
159 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
160 state->name, bsize, *bcount);
162 struct pipe_structtype_state {
168 void pipe_structtype_pull(
172 unsigned long * ecount)
174 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
176 printf("pull1:%s: esize[%u] ecount[%u]\n",
177 state->name, esize, *ecount);
178 *ecount = state->count--;
179 if (*ecount > esize) {
182 memset(buf, 0xDD, *ecount * sizeof(*buf));
183 printf("pull2:%s: esize[%u] ecount[%u]\n",
184 state->name, esize, *ecount);
187 void pipe_structtype_push(
190 unsigned long ecount)
192 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
194 printf("push:%s: ecount[%u]\n",
195 state->name, ecount);
198 void pipe_structtype_alloc(
202 unsigned long * bcount)
204 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
206 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
207 state->name, bsize, *bcount);
208 *bcount = bsize / sizeof(**buf);
209 *buf = malloc(*bcount * sizeof(**buf));
210 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
211 state->name, bsize, *bcount);
213 static void midltests(void)
216 unsigned char out1b[3];
217 struct pipe_structtype_state outs;
218 pipe_structtype outp;
219 struct pipe_structtype_state ins;
222 unsigned char in1b[5000];
224 in1.l = sizeof(in1b);
225 memset(&in1b, 0xAA, sizeof(in1b));
228 memset(&outs, 0, sizeof(outs));
230 memset(&outp, 0, sizeof(outp));
231 outp.pull = pipe_structtype_pull;
232 outp.push = pipe_structtype_push;
233 outp.alloc = pipe_structtype_alloc;
234 outp.state = (char *)&outs;
236 memset(&ins, 0, sizeof(ins));
239 memset(&inp, 0, sizeof(inp));
240 inp.pull = pipe_structtype_pull;
241 inp.push = pipe_structtype_push;
242 inp.alloc = pipe_structtype_alloc;
243 inp.state = (char *)&ins;
245 out1.l = sizeof(out1b);
246 memset(&out1b, 0xFF, sizeof(out1b));
249 cli_midltests_ping(in1);
250 cli_midltests_fn(&out1, outp, inp, in1);
253 long srv_midltests_fn(
254 /* [ref][out] */ struct msg *out1,
255 /* [out] */ pipe_structtype outp,
256 /* [in] */ pipe_structtype inp,
257 /* [in] */ struct msg in1)
260 unsigned long inb_len = 0;
261 structtype *outb = NULL;
262 unsigned long outb_size = 0;
263 unsigned long outb_len = 0;
265 printf("srv_midltests_fn: Start\n");
268 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
269 printf("pull inp_len[%u]\n", inb_len);
270 } while (inb_len > 0);
274 outp.alloc(outp.state, outb_size, &outb, &outb_len);
275 memset(outb, 0xCC, outb_len * sizeof(*outb));
276 outp.push(outp.state, outb, outb_len);
277 printf("push outb_len[%u]\n", outb_len);
280 } while (outb_len > 0);
283 out1->m = (unsigned char *)malloc(out1->l);
284 memset(out1->m, 0xBB, out1->l);
285 printf("srv_midltests_fn: End\n");
289 long srv_midltests_ping(
290 /* [in] */ struct msg in1)
292 printf("srv_midltests_fn: Start\n");
293 printf("srv_midltests_fn: End\n");