Public Member Functions | Protected Attributes

TAO_DS_Network_Priority_Protocols_Hooks Class Reference

#include <DiffServ_Protocols_Hooks.h>

Inheritance diagram for TAO_DS_Network_Priority_Protocols_Hooks:
Inheritance graph
[legend]
Collaboration diagram for TAO_DS_Network_Priority_Protocols_Hooks:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_DS_Network_Priority_Protocols_Hooks (void)
 Constructor.
virtual ~TAO_DS_Network_Priority_Protocols_Hooks (void)
 Destructor.
void init_hooks (TAO_ORB_Core *orb_core)
 Initialize the network priority protocols hooks instance.
CORBA::Long get_dscp_codepoint (TAO_Stub *stub, CORBA::Object *object)
CORBA::Long get_dscp_codepoint (TAO_Service_Context &sc)

Protected Attributes

TAO_ORB_Coreorb_core_

Detailed Description

Definition at line 31 of file DiffServ_Protocols_Hooks.h.


Constructor & Destructor Documentation

TAO_DS_Network_Priority_Protocols_Hooks::TAO_DS_Network_Priority_Protocols_Hooks ( void   ) 

Constructor.

Definition at line 18 of file DiffServ_Protocols_Hooks.cpp.

  : orb_core_ (0)
{
}

TAO_DS_Network_Priority_Protocols_Hooks::~TAO_DS_Network_Priority_Protocols_Hooks ( void   )  [virtual]

Destructor.

Definition at line 25 of file DiffServ_Protocols_Hooks.cpp.

{
}


Member Function Documentation

CORBA::Long TAO_DS_Network_Priority_Protocols_Hooks::get_dscp_codepoint ( TAO_Stub stub,
CORBA::Object object 
) [virtual]

This function is used by the client side ORB to figure out the DiffServ codepoint that needs to be added to the request to be sent to the server.

Implements TAO_Network_Priority_Protocols_Hooks.

Definition at line 66 of file DiffServ_Protocols_Hooks.cpp.

{
  CORBA::Long dscp = 0;
  TAO::DiffservCodepoint diffserv_codepoint;
  CORBA::Policy_var server_nw_priority_policy;

  CORBA::Policy_var client_nw_priority_policy =
    stub->get_cached_policy (
        TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY);

  if (CORBA::is_nil (client_nw_priority_policy.in ()))
    {
      TAO_Stub *server_stub = object->_stubobj ();
      TAO_MProfile server_profiles = server_stub->base_profiles ();
      CORBA::PolicyList_var policy_list =
        server_profiles.policy_list ();

      CORBA::ULong length = policy_list->length ();

      for (CORBA::ULong i = 0; i < length; ++i)
        {
          if (policy_list[i]->policy_type () == TAO::NETWORK_PRIORITY_TYPE)
            {
              server_nw_priority_policy =
                CORBA::Policy::_duplicate (policy_list[i]);
            }
        }

      if (CORBA::is_nil (server_nw_priority_policy.in ()))
        {
          return dscp;
        }
      else
        {
          TAO::NetworkPriorityPolicy_var npp =
            TAO::NetworkPriorityPolicy::_narrow (
              server_nw_priority_policy.in ());

          if (!CORBA::is_nil (npp.in ()))
            {
              TAO::NetworkPriorityModel network_priority_model =
                npp->network_priority_model ();

              if (network_priority_model ==
                  TAO::SERVER_DECLARED_NETWORK_PRIORITY)
                {
                  diffserv_codepoint =
                    npp->request_diffserv_codepoint ();
                  dscp = diffserv_codepoint;
                  return dscp;
                }
            }
        }
    }
  else
    {
      TAO::NetworkPriorityPolicy_var client_nw_priority =
        TAO::NetworkPriorityPolicy::_narrow (client_nw_priority_policy.in ());

      if (!CORBA::is_nil (client_nw_priority.in ()))
        {
          diffserv_codepoint =
            client_nw_priority->request_diffserv_codepoint ();
          dscp = diffserv_codepoint;
          return dscp;
        }
    }

  return dscp;
}

CORBA::Long TAO_DS_Network_Priority_Protocols_Hooks::get_dscp_codepoint ( TAO_Service_Context sc  )  [virtual]

This function is used by the server side to figure out the DiffServ codepoint that is attached and sent as part of the service context of the request from the client side. Specifically, when CLIENT_PROPAGATED networ priority model is followed, the clients sent the DiffServ codepoint, they want the server to use in the reply, as a service context entry in the request.

Implements TAO_Network_Priority_Protocols_Hooks.

Definition at line 36 of file DiffServ_Protocols_Hooks.cpp.

{
  CORBA::Long dscp_codepoint = 0;
  const IOP::ServiceContext *context = 0;

  if (sc.get_context (IOP::REP_NWPRIORITY, &context) == 1)
    {
      TAO_InputCDR cdr (reinterpret_cast
                        <const char*>
                        (context->context_data.get_buffer ()),
                        context->context_data.length ());

      CORBA::Boolean byte_order;
      if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
        {
          throw CORBA::MARSHAL ();
        }
      cdr.reset_byte_order (static_cast<int> (byte_order));

      if ((cdr >> dscp_codepoint) == 0)
        {
          throw CORBA::MARSHAL ();
        }
    }

  return dscp_codepoint;
}

void TAO_DS_Network_Priority_Protocols_Hooks::init_hooks ( TAO_ORB_Core orb_core  )  [virtual]

Initialize the network priority protocols hooks instance.

Implements TAO_Network_Priority_Protocols_Hooks.

Definition at line 30 of file DiffServ_Protocols_Hooks.cpp.

{
  this->orb_core_ = orb_core;
}


Member Data Documentation

Definition at line 63 of file DiffServ_Protocols_Hooks.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines