2 #include "ace/Get_Opt.h"
3 #include "tao/Policy_Manager.h"
4 #include "tao/DiffServPolicy/DiffServPolicy.h"
5 #include "tao/DiffServPolicy/Client_Network_Priority_Policy.h"
6 #include "tao/DiffServPolicy/Server_Network_Priority_Policy.h"
8 static const ACE_TCHAR
*ior
= ACE_TEXT("file://simple_servant.ior");
9 static int iterations
= 1;
11 #define IPDSFIELD_DSCP_DEFAULT 0x00
12 #define IPDSFIELD_DSCP_CS1 0x08
13 #define IPDSFIELD_DSCP_CS2 0x10
14 #define IPDSFIELD_DSCP_CS3 0x18
15 #define IPDSFIELD_DSCP_CS4 0x20
16 #define IPDSFIELD_DSCP_CS5 0x28
17 #define IPDSFIELD_DSCP_CS6 0x30
18 #define IPDSFIELD_DSCP_CS7 0x38
19 #define IPDSFIELD_DSCP_AF11 0x0A
20 #define IPDSFIELD_DSCP_AF12 0x0C
21 #define IPDSFIELD_DSCP_AF13 0x0E
22 #define IPDSFIELD_DSCP_AF21 0x12
23 #define IPDSFIELD_DSCP_AF22 0x14
24 #define IPDSFIELD_DSCP_AF23 0x16
25 #define IPDSFIELD_DSCP_AF31 0x1A
26 #define IPDSFIELD_DSCP_AF32 0x1C
27 #define IPDSFIELD_DSCP_AF33 0x1E
28 #define IPDSFIELD_DSCP_AF41 0x22
29 #define IPDSFIELD_DSCP_AF42 0x24
30 #define IPDSFIELD_DSCP_AF43 0x26
31 #define IPDSFIELD_ECT_MASK 0x02
32 #define IPDSFIELD_CE_MASK 0x01
33 #define IPDSFIELD_DSCP_EF 0x2E
35 static int const dscp
[] =
37 IPDSFIELD_DSCP_DEFAULT
,
61 parse_args (int argc
, ACE_TCHAR
*argv
[])
63 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:x:"));
66 while ((c
= get_opts ()) != -1)
70 ior
= get_opts
.opt_arg ();
73 // number of itarations
75 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
79 ACE_ERROR_RETURN ((LM_ERROR
,
81 "\t-k <ior> [default is %s]\n"
82 "\t-n <number of invocations> [defaults to %d]\n"
94 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
99 CORBA::ORB_init (argc
, argv
);
101 if (parse_args (argc
, argv
) != 0)
104 // Initialize and obtain reference to the Test object.
105 CORBA::Object_var client_object
=
106 orb
->string_to_object (ior
);
109 Test::_narrow (client_object
.in ());
111 TAO::DiffservCodepoint request_dscp
;
112 TAO::DiffservCodepoint reply_dscp
;
113 int request_array_slot
= 12;
114 int reply_array_slot
= 13;
115 long request_dscp_codepoint
= dscp
[request_array_slot
];
116 long reply_dscp_codepoint
= dscp
[reply_array_slot
];
117 request_dscp
= request_dscp_codepoint
;
118 reply_dscp
= reply_dscp_codepoint
;
120 CORBA::PolicyList policy_list
;
121 policy_list
.length (1);
123 CORBA::Policy_var client_network_policy
=
124 orb
->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE
);
126 TAO::NetworkPriorityPolicy_var nw_priority
=
127 TAO::NetworkPriorityPolicy::_narrow (client_network_policy
.in ());
129 nw_priority
->request_diffserv_codepoint (
132 nw_priority
->reply_diffserv_codepoint (
135 nw_priority
->network_priority_model (
136 TAO::CLIENT_PROPAGATED_NETWORK_PRIORITY
);
138 policy_list
[0] = TAO::NetworkPriorityPolicy::_duplicate (nw_priority
.in ());
140 CORBA::Object_var over_ridden_object
= server
->_set_policy_overrides (
141 policy_list
, CORBA::SET_OVERRIDE
);
143 policy_list
[0]->destroy ();
145 server
= Test::_narrow (over_ridden_object
.in ());
147 // Make several invocation,
148 for (int i
= 0; i
< iterations
; ++i
)
150 server
->test_method ();
153 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Calling shutdown on server\n"));
157 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Destroying ORB\n"));
161 catch (const CORBA::Exception
& ex
)
163 ex
._tao_print_exception ("Caught exception:");