2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 #include "tao/DiffServPolicy/DiffServPolicy.h"
6 #include "tao/DiffServPolicy/Server_Network_Priority_Policy.h"
7 #include "tao/DiffServPolicy/Client_Network_Priority_Policy.h"
9 #define IPDSFIELD_DSCP_DEFAULT 0x00
10 #define IPDSFIELD_DSCP_CS1 0x08
11 #define IPDSFIELD_DSCP_CS2 0x10
12 #define IPDSFIELD_DSCP_CS3 0x18
13 #define IPDSFIELD_DSCP_CS4 0x20
14 #define IPDSFIELD_DSCP_CS5 0x28
15 #define IPDSFIELD_DSCP_CS6 0x30
16 #define IPDSFIELD_DSCP_CS7 0x38
17 #define IPDSFIELD_DSCP_AF11 0x0A
18 #define IPDSFIELD_DSCP_AF12 0x0C
19 #define IPDSFIELD_DSCP_AF13 0x0E
20 #define IPDSFIELD_DSCP_AF21 0x12
21 #define IPDSFIELD_DSCP_AF22 0x14
22 #define IPDSFIELD_DSCP_AF23 0x16
23 #define IPDSFIELD_DSCP_AF31 0x1A
24 #define IPDSFIELD_DSCP_AF32 0x1C
25 #define IPDSFIELD_DSCP_AF33 0x1E
26 #define IPDSFIELD_DSCP_AF41 0x22
27 #define IPDSFIELD_DSCP_AF42 0x24
28 #define IPDSFIELD_DSCP_AF43 0x26
29 #define IPDSFIELD_ECT_MASK 0x02
30 #define IPDSFIELD_CE_MASK 0x01
31 #define IPDSFIELD_DSCP_EF 0x2E
33 static int const dscp
[] =
35 IPDSFIELD_DSCP_DEFAULT
,
59 class Test_i
: public POA_Test
62 Test_i (CORBA::ORB_ptr orb
);
66 //FUZZ: disable check_for_lack_ACE_OS
68 //FUZZ: enable check_for_lack_ACE_OS
74 Test_i::Test_i (CORBA::ORB_ptr orb
)
75 : orb_ (CORBA::ORB::_duplicate (orb
))
80 Test_i::test_method ()
83 "Test_i::test_method\n"));
89 this->orb_
->shutdown (false);
92 static const ACE_TCHAR
*simple_servant_ior_file
= ACE_TEXT("simple_servant.ior");
95 parse_args (int argc
, ACE_TCHAR
*argv
[])
97 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
100 while ((c
= get_opts ()) != -1)
104 simple_servant_ior_file
= get_opts
.opt_arg ();
107 // Indicates successful parsing of the command line
112 create_object (PortableServer::POA_ptr poa
,
115 const ACE_TCHAR
*filename
)
117 // Register with poa.
118 PortableServer::ObjectId_var id
=
119 poa
->activate_object (servant
);
121 CORBA::Object_var object
=
122 poa
->id_to_reference (id
.in ());
124 CORBA::String_var ior
=
125 orb
->object_to_string (object
.in ());
127 ACE_DEBUG ((LM_DEBUG
, "<%C>\n\n", ior
.in ()));
129 FILE *output_file
= ACE_OS::fopen (filename
, "w");
130 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
131 ACE_OS::fclose (output_file
);
135 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
140 CORBA::ORB_init (argc
, argv
);
142 if (parse_args (argc
, argv
) != 0)
146 CORBA::Object_var object
=
147 orb
->resolve_initial_references ("RootPOA");
149 PortableServer::POA_var root_poa
=
150 PortableServer::POA::_narrow (object
.in ());
152 PortableServer::POAManager_var poa_manager
=
153 root_poa
->the_POAManager ();
155 TAO::DiffservCodepoint request_dscp
;
156 TAO::DiffservCodepoint reply_dscp
;
157 int request_array_slot
= 3;
158 int reply_array_slot
= 2;
159 long request_dscp_codepoint
= dscp
[request_array_slot
];
160 long reply_dscp_codepoint
= dscp
[reply_array_slot
];
161 request_dscp
= request_dscp_codepoint
;
162 reply_dscp
= reply_dscp_codepoint
;
164 TAO::NetworkPriorityModel npm
= TAO::CLIENT_PROPAGATED_NETWORK_PRIORITY
;
166 CORBA::PolicyList policy_list
;
167 policy_list
.length (1);
169 CORBA::Policy_var npp
=
170 orb
->_create_policy (TAO::NETWORK_PRIORITY_TYPE
);
172 TAO::NetworkPriorityPolicy_var nw_priority
=
173 TAO::NetworkPriorityPolicy::_narrow (npp
.in ());
175 nw_priority
->network_priority_model (npm
);
177 nw_priority
->request_diffserv_codepoint (request_dscp
);
179 nw_priority
->reply_diffserv_codepoint (reply_dscp
);
181 policy_list
[0] = TAO::NetworkPriorityPolicy::_duplicate (nw_priority
.in ());
183 PortableServer::POA_var child_poa
=
184 root_poa
->create_POA ("Child_POA",
188 policy_list
[0]->destroy ();
191 Test_i
servant (orb
.in ());
193 // Create the first object in Root POA
194 create_object (child_poa
.in (),
197 simple_servant_ior_file
);
199 // Activate POA manager.
200 poa_manager
->activate ();
202 // Start ORB event loop.
205 ACE_DEBUG ((LM_DEBUG
, "Server ORB event loop finished\n\n"));
207 root_poa
->destroy (true, true);
211 catch (const CORBA::Exception
& ex
)
213 ex
._tao_print_exception ("Unexpected exception caught:");