Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / DiffServPolicy / DiffServ_Network_Priority_Hook.cpp
blob442e933b3af5ded9c9cfe855e2cbbe1167e3f808
1 // -*- C++ -*-
2 #include "tao/DiffServPolicy/DiffServ_Network_Priority_Hook.h"
3 #include "tao/PortableServer/Root_POA.h"
4 #include "tao/PortableServer/POA_Policy_Set.h"
5 #include "tao/DiffServPolicy/Server_Network_Priority_Policy.h"
6 #include "tao/DiffServPolicy/DiffServPolicy.h"
7 #include "tao/Service_Context.h"
8 #include "tao/TAO_Server_Request.h"
9 #include "tao/Network_Priority_Protocols_Hooks.h"
10 #include "tao/ORB_Core.h"
11 #include "tao/Connection_Handler.h"
12 #include "tao/Transport.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 TAO_DiffServ_Network_Priority_Hook::~TAO_DiffServ_Network_Priority_Hook()
21 void
22 TAO_DiffServ_Network_Priority_Hook::update_network_priority (
23 TAO_Root_POA &poa, TAO_POA_Policy_Set &policy_set)
25 for (CORBA::ULong i = 0; i < policy_set.num_policies (); i++)
27 CORBA::Policy_var policy = policy_set.get_policy_by_index (i);
29 if (policy->policy_type () == TAO::NETWORK_PRIORITY_TYPE)
31 ::TAO::NetworkPriorityPolicy_var npp =
32 ::TAO::NetworkPriorityPolicy::_narrow (policy.in ());
34 if (!CORBA::is_nil (npp.in ()))
36 TAO::NetworkPriorityModel network_priority_model =
37 npp->network_priority_model ();
39 poa.cached_policies ().network_priority_model (
40 TAO::Portable_Server::Cached_Policies::NetworkPriorityModel (
41 network_priority_model));
43 TAO::DiffservCodepoint request_diffserv_codepoint =
44 npp->request_diffserv_codepoint ();
46 TAO::DiffservCodepoint reply_diffserv_codepoint =
47 npp->reply_diffserv_codepoint ();
49 poa.cached_policies ().request_diffserv_codepoint (
50 request_diffserv_codepoint);
51 poa.cached_policies ().reply_diffserv_codepoint (
52 reply_diffserv_codepoint);
58 void
59 TAO_DiffServ_Network_Priority_Hook::set_dscp_codepoint (
60 TAO_ServerRequest &req, TAO_Root_POA &poa)
62 CORBA::Long dscp_codepoint = 0;
63 TAO_Service_Context &request_service_context =
64 req.request_service_context ();
66 TAO_Network_Priority_Protocols_Hooks *nph =
67 poa.orb_core ().get_network_priority_protocols_hooks ();
69 TAO::Portable_Server::Cached_Policies::NetworkPriorityModel npm =
70 poa.cached_policies ().network_priority_model ();
72 if (npm == TAO::Portable_Server::Cached_Policies::
73 CLIENT_PROPAGATED_NETWORK_PRIORITY)
75 if (nph != 0)
77 dscp_codepoint = nph->get_dscp_codepoint (request_service_context);
80 else if (npm == TAO::Portable_Server::Cached_Policies::
81 SERVER_DECLARED_NETWORK_PRIORITY)
83 dscp_codepoint = poa.cached_policies ().reply_diffserv_codepoint ();
86 TAO_Connection_Handler *connection_handler =
87 req.transport ()->connection_handler ();
88 connection_handler->set_dscp_codepoint (dscp_codepoint);
92 ACE_FACTORY_DEFINE (TAO_DiffServPolicy, TAO_DiffServ_Network_Priority_Hook)
93 ACE_STATIC_SVC_DEFINE (TAO_DiffServ_Network_Priority_Hook,
94 ACE_TEXT ("TAO_Network_Priority_Hook"),
95 ACE_SVC_OBJ_T,
96 &ACE_SVC_NAME (TAO_DiffServ_Network_Priority_Hook),
97 ACE_Service_Type::DELETE_THIS
98 | ACE_Service_Type::DELETE_OBJ,
100 TAO_END_VERSIONED_NAMESPACE_DECL