Go to the documentation of this file.00001
00002
00003 #include "tao/DiffServPolicy/DiffServ_Network_Priority_Hook.h"
00004 #include "tao/PortableServer/Root_POA.h"
00005 #include "tao/PortableServer/POA_Policy_Set.h"
00006 #include "tao/DiffServPolicy/Server_Network_Priority_Policy.h"
00007 #include "tao/DiffServPolicy/DiffServPolicy.h"
00008 #include "tao/Service_Context.h"
00009 #include "tao/TAO_Server_Request.h"
00010 #include "tao/Network_Priority_Protocols_Hooks.h"
00011 #include "tao/ORB_Core.h"
00012 #include "tao/Connection_Handler.h"
00013 #include "tao/Transport.h"
00014
00015 ACE_RCSID(DiffServPolicy,
00016 DiffServ_Network_Priority_Hook,
00017 "$Id: DiffServ_Network_Priority_Hook.cpp 84281 2009-01-30 15:01:17Z wotte $")
00018
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022
00023 TAO_DiffServ_Network_Priority_Hook::~TAO_DiffServ_Network_Priority_Hook(void)
00024 {
00025 }
00026
00027 void
00028 TAO_DiffServ_Network_Priority_Hook::update_network_priority (
00029 TAO_Root_POA &poa, TAO_POA_Policy_Set &policy_set)
00030 {
00031 for (CORBA::ULong i = 0; i < policy_set.num_policies (); i++)
00032 {
00033 CORBA::Policy_var policy = policy_set.get_policy_by_index (i);
00034
00035 if (policy->policy_type () == TAO::NETWORK_PRIORITY_TYPE)
00036 {
00037 ::TAO::NetworkPriorityPolicy_var npp =
00038 ::TAO::NetworkPriorityPolicy::_narrow (policy.in ());
00039
00040 if (!CORBA::is_nil (npp.in ()))
00041 {
00042 TAO::NetworkPriorityModel network_priority_model =
00043 npp->network_priority_model ();
00044
00045 poa.cached_policies ().network_priority_model (
00046 TAO::Portable_Server::Cached_Policies::NetworkPriorityModel (
00047 network_priority_model));
00048
00049 TAO::DiffservCodepoint request_diffserv_codepoint =
00050 npp->request_diffserv_codepoint ();
00051
00052 TAO::DiffservCodepoint reply_diffserv_codepoint =
00053 npp->reply_diffserv_codepoint ();
00054
00055 poa.cached_policies ().request_diffserv_codepoint (
00056 request_diffserv_codepoint);
00057 poa.cached_policies ().reply_diffserv_codepoint (
00058 reply_diffserv_codepoint);
00059 }
00060 }
00061 }
00062 }
00063
00064 void
00065 TAO_DiffServ_Network_Priority_Hook::set_dscp_codepoint (
00066 TAO_ServerRequest &req, TAO_Root_POA &poa)
00067 {
00068 CORBA::Long dscp_codepoint = 0;
00069 TAO_Service_Context &request_service_context =
00070 req.request_service_context ();
00071
00072 TAO_Network_Priority_Protocols_Hooks *nph =
00073 poa.orb_core ().get_network_priority_protocols_hooks ();
00074
00075 TAO::Portable_Server::Cached_Policies::NetworkPriorityModel npm =
00076 poa.cached_policies ().network_priority_model ();
00077
00078 if (npm == TAO::Portable_Server::Cached_Policies::
00079 CLIENT_PROPAGATED_NETWORK_PRIORITY)
00080 {
00081 if (nph != 0)
00082 {
00083 dscp_codepoint = nph->get_dscp_codepoint (request_service_context);
00084 }
00085 }
00086 else if (npm == TAO::Portable_Server::Cached_Policies::
00087 SERVER_DECLARED_NETWORK_PRIORITY)
00088 {
00089 dscp_codepoint = poa.cached_policies ().reply_diffserv_codepoint ();
00090 }
00091
00092 TAO_Connection_Handler *connection_handler =
00093 req.transport ()->connection_handler ();
00094 connection_handler->set_dscp_codepoint (dscp_codepoint);
00095 }
00096
00097
00098 ACE_FACTORY_DEFINE (TAO_DiffServPolicy, TAO_DiffServ_Network_Priority_Hook)
00099 ACE_STATIC_SVC_DEFINE (TAO_DiffServ_Network_Priority_Hook,
00100 ACE_TEXT ("TAO_Network_Priority_Hook"),
00101 ACE_SVC_OBJ_T,
00102 &ACE_SVC_NAME (TAO_DiffServ_Network_Priority_Hook),
00103 ACE_Service_Type::DELETE_THIS
00104 | ACE_Service_Type::DELETE_OBJ,
00105 0)
00106 TAO_END_VERSIONED_NAMESPACE_DECL