2 #include "tao/DiffServPolicy/DiffServ_Protocols_Hooks.h"
4 #include "tao/Profile.h"
5 #include "tao/ORB_Core.h"
6 #include "tao/Service_Context.h"
8 #include "tao/SystemException.h"
9 #include "tao/DiffServPolicy/Client_Network_Priority_Policy.h"
10 #include "ace/OS_NS_string.h"
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 TAO_DS_Network_Priority_Protocols_Hooks::
15 TAO_DS_Network_Priority_Protocols_Hooks ()
21 TAO_DS_Network_Priority_Protocols_Hooks::
22 ~TAO_DS_Network_Priority_Protocols_Hooks ()
27 TAO_DS_Network_Priority_Protocols_Hooks::init_hooks (TAO_ORB_Core
*orb_core
)
29 this->orb_core_
= orb_core
;
33 TAO_DS_Network_Priority_Protocols_Hooks::get_dscp_codepoint (
34 TAO_Service_Context
&sc
)
36 CORBA::Long dscp_codepoint
= 0;
37 const IOP::ServiceContext
*context
= 0;
39 if (sc
.get_context (IOP::REP_NWPRIORITY
, &context
) == 1)
41 TAO_InputCDR
cdr (reinterpret_cast
43 (context
->context_data
.get_buffer ()),
44 context
->context_data
.length ());
46 CORBA::Boolean byte_order
;
47 if ((cdr
>> ACE_InputCDR::to_boolean (byte_order
)) == 0)
49 throw CORBA::MARSHAL ();
51 cdr
.reset_byte_order (static_cast<int> (byte_order
));
53 if ((cdr
>> dscp_codepoint
) == 0)
55 throw CORBA::MARSHAL ();
59 return dscp_codepoint
;
63 TAO_DS_Network_Priority_Protocols_Hooks::get_dscp_codepoint (
64 TAO_Stub
*stub
, CORBA::Object
*object
)
67 TAO::DiffservCodepoint diffserv_codepoint
;
68 CORBA::Policy_var server_nw_priority_policy
;
70 CORBA::Policy_var client_nw_priority_policy
=
71 stub
->get_cached_policy (
72 TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY
);
74 if (CORBA::is_nil (client_nw_priority_policy
.in ()))
76 TAO_Stub
*server_stub
= object
->_stubobj ();
77 TAO_MProfile server_profiles
= server_stub
->base_profiles ();
78 CORBA::PolicyList_var policy_list
=
79 server_profiles
.policy_list ();
81 CORBA::ULong length
= policy_list
->length ();
83 for (CORBA::ULong i
= 0; i
< length
; ++i
)
85 if (policy_list
[i
]->policy_type () == TAO::NETWORK_PRIORITY_TYPE
)
87 server_nw_priority_policy
=
88 CORBA::Policy::_duplicate (policy_list
[i
]);
92 if (CORBA::is_nil (server_nw_priority_policy
.in ()))
98 TAO::NetworkPriorityPolicy_var npp
=
99 TAO::NetworkPriorityPolicy::_narrow (
100 server_nw_priority_policy
.in ());
102 if (!CORBA::is_nil (npp
.in ()))
104 TAO::NetworkPriorityModel network_priority_model
=
105 npp
->network_priority_model ();
107 if (network_priority_model
==
108 TAO::SERVER_DECLARED_NETWORK_PRIORITY
)
111 npp
->request_diffserv_codepoint ();
112 dscp
= diffserv_codepoint
;
120 TAO::NetworkPriorityPolicy_var client_nw_priority
=
121 TAO::NetworkPriorityPolicy::_narrow (client_nw_priority_policy
.in ());
123 if (!CORBA::is_nil (client_nw_priority
.in ()))
126 client_nw_priority
->request_diffserv_codepoint ();
127 dscp
= diffserv_codepoint
;
136 ACE_STATIC_SVC_DEFINE (TAO_DS_Network_Priority_Protocols_Hooks
,
137 ACE_TEXT ("DS_Network_Priority_Protocols_Hooks"),
139 &ACE_SVC_NAME (TAO_DS_Network_Priority_Protocols_Hooks
),
140 ACE_Service_Type::DELETE_THIS
141 | ACE_Service_Type::DELETE_OBJ
,
143 ACE_FACTORY_DEFINE (TAO_DiffServPolicy
,
144 TAO_DS_Network_Priority_Protocols_Hooks
)
145 TAO_END_VERSIONED_NAMESPACE_DECL