00001 // $Id: DiffServ_Service_Context_Handler.cpp 84866 2009-03-17 11:10:49Z johnnyw $ 00002 00003 #include "tao/DiffServPolicy/DiffServ_Service_Context_Handler.h" 00004 00005 ACE_RCSID (DiffServPolicy, 00006 DiffServ_Service_Context_Handler, 00007 "$Id: DiffServ_Service_Context_Handler.cpp 84866 2009-03-17 11:10:49Z johnnyw $") 00008 00009 #include "tao/DiffServPolicy/Client_Network_Priority_Policy.h" 00010 #include "tao/CDR.h" 00011 #include "tao/TAO_Server_Request.h" 00012 #include "tao/Transport.h" 00013 #include "tao/ORB_Core.h" 00014 #include "tao/GIOP_Message_Base.h" 00015 #include "tao/operation_details.h" 00016 #include "tao/Transport_Mux_Strategy.h" 00017 #include "tao/Stub.h" 00018 00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00020 00021 int 00022 TAO_DiffServ_Service_Context_Handler::process_service_context ( 00023 TAO_Transport&, 00024 const IOP::ServiceContext&) 00025 { 00026 return 0; 00027 } 00028 00029 int 00030 TAO_DiffServ_Service_Context_Handler::generate_service_context ( 00031 TAO_Stub *stub, 00032 TAO_Transport&, 00033 TAO_Operation_Details &opdetails, 00034 TAO_Target_Specification &, 00035 TAO_OutputCDR &) 00036 { 00037 if (stub) 00038 { 00039 CORBA::Policy_var cnpp = 00040 stub->get_cached_policy (TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY); 00041 00042 TAO::NetworkPriorityPolicy_var cnp = 00043 TAO::NetworkPriorityPolicy::_narrow (cnpp.in ()); 00044 00045 if (!CORBA::is_nil (cnp.in ())) 00046 { 00047 TAO::DiffservCodepoint const reply_diffserv_codepoint = 00048 cnp->reply_diffserv_codepoint (); 00049 00050 CORBA::Long const rep_dscp_codepoint = reply_diffserv_codepoint; 00051 00052 TAO_OutputCDR cdr; 00053 if (!(cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) 00054 || !(cdr << rep_dscp_codepoint)) 00055 { 00056 throw CORBA::MARSHAL (); 00057 } 00058 00059 opdetails.request_service_context ().set_context (IOP::REP_NWPRIORITY, cdr); 00060 } 00061 } 00062 00063 return 0; 00064 } 00065 00066 TAO_END_VERSIONED_NAMESPACE_DECL