static void forwarding_test (test, argc, argv) int test; int argc; char *argv[]; { handle_t rh; char name[256]; unsigned_char_p_t name2; unsigned32 st; idl_boolean global; #define FSIZE 4000 unsigned32 d[FSIZE]; int i; unsigned32 sum, rsum; idl_char result[256]; unsigned_char_p_t pstring; DO_NOT_CLOBBER(rh); DO_NOT_CLOBBER(rsum); if (argc < 4) { usage(test); } global = argv[3][0] == 'y'; rh = binding_from_string_binding(NULL, argv[2]); /* * Tell server to register the "perfb" interface. */ perf_register_b(rh, global, &st); if (st != 0) { fprintf(stderr, "*** Can't register \"perfb\" interface - %s\n", error_text(st)); exit(1); } TRY { if (! compat_mode) { /* * Clear the binding to the server and call resolve_binding. */ binding_reset(rh); rpc_ep_resolve_binding(rh, perfb_v1_0_c_ifspec, &st); if (st != rpc_s_ok) { fprintf(stderr, "*** Can't resolve \"perfb\" interface - %s\n", error_text(st)); exit(1); } binding_to_string_binding(rh, &pstring, &st); printf(" binding resolved to: %s\n", pstring); rpc_string_free(&pstring, &st); } /* * Clear binding to server and make a simple call to the "perfb" interface. */ binding_reset(rh); perfb_init(rh, (idl_char *) name); printf(" result of forwarded call = \"%s\"\n", name); /* * Clear binding again and make a call that's too big to fit in a * single pkt to make sure multi-pkt forwarding works. Note that old * perf servers don't handle this call so catch that sort of error. */ binding_reset(rh); for (i = 0, rsum = 0; i < FSIZE; i++) { d[i] = i; rsum += d[i]; } TRY { perfb_in(rh, d, FSIZE, true, &sum); if (sum != rsum) { fprintf(stderr, "*** Sum mismatch in large forwarded call (%lu, %lu)\n", sum, rsum); } else { printf(" large forwarded call completed OK\n"); } } CATCH (rpc_x_op_rng_error) { printf (" warning: server doesn't implement \"perfb_in\" procedure "); printf ("(probably an old server)\n"); printf (" large forwarded call test skipped\n"); } ENDTRY if (! compat_mode) { /* * Test forwarded mgmt calls. */ forwarding_mgmt_test (rh, &NilTypeObj, "nil type object"); forwarding_mgmt_test (rh, &FooObj1, "non-nil type object"); } /* * Clear binding again and make a broadcast call. */ binding_reset(rh); rpc_binding_set_object(rh, NULL, &st); if (st != 0) { fprintf(stderr, "*** Can't reset object in binding to nil - %s\n", error_text(st)); exit(1); } TRY { perfb_brd(rh, result); binding_to_string_binding (rh, &name2); printf(" broadcast forwarded call completed OK\n"); printf(" bound to \"%s\", result=\"%s\"\n", name2, result); } CATCH (rpc_x_invalid_call_opt) { printf (" warning: can't do broadcast\n"); } CATCH (rpc_x_op_rng_error) { printf (" warning: server doesn't implement \"perfb_brd\" procedure "); printf ("(probably an old server)\n"); printf (" broadcast call test skipped\n"); } CATCH (rpc_x_comm_failure) { printf (" warning: communications failure (may be an old server)\n"); printf (" broadcast call test skipped\n"); } CATCH_ALL { exc_report(THIS_CATCH); fprintf (stderr, "*** Unknown exception raised in during broadcast forwarded call\n"); RERAISE; } ENDTRY } FINALLY { /* * Tell server to unregister the "perfb" interface. */ rh = binding_from_string_binding(NULL, argv[2]); perf_unregister_b(rh, &st); if (st != 0) { fprintf(stderr, "*** Can't unregister \"perfb\" interface - %s\n", error_text(st)); exit(1); } } ENDTRY }