Public Member Functions | Protected Attributes

TAO_AV_UDP_Flow_Handler Class Reference

Flow Handler for UDP flows. More...

#include <UDP.h>

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

List of all members.

Public Member Functions

 TAO_AV_UDP_Flow_Handler (void)
virtual ~TAO_AV_UDP_Flow_Handler (void)
int open (ACE_Addr &address)
int close (void)
virtual TAO_AV_Transporttransport (void)
virtual int set_remote_address (ACE_Addr *address)
virtual ACE_HANDLE get_handle (void) const
virtual int handle_input (ACE_HANDLE fd)
virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg=0)
const ACE_SOCK_Dgramget_socket (void) const
virtual ACE_Event_Handlerevent_handler (void)
virtual int change_qos (AVStreams::QoS)
 Change the QoS.

Protected Attributes

TAO_AV_Coreav_core_
ACE_INET_Addr peer_addr_
ACE_SOCK_Dgram sock_dgram_

Detailed Description

Flow Handler for UDP flows.

Definition at line 110 of file UDP.h.


Constructor & Destructor Documentation

TAO_AV_UDP_Flow_Handler::TAO_AV_UDP_Flow_Handler ( void   ) 

Ctor Dtor

Definition at line 24 of file UDP.cpp.

TAO_AV_UDP_Flow_Handler::~TAO_AV_UDP_Flow_Handler ( void   )  [virtual]

Definition at line 30 of file UDP.cpp.

{
  // remove the event handler from the reactor.
  TAO_AV_CORE::instance()->reactor ()->remove_handler (this->event_handler(),
                                              ACE_Event_Handler::READ_MASK);

  // close the socket.
  this->close ();
  delete this->transport_;
}


Member Function Documentation

int TAO_AV_UDP_Flow_Handler::change_qos ( AVStreams::QoS  qos  )  [virtual]

Change the QoS.

Definition at line 86 of file UDP.cpp.

{
  if( TAO_debug_level > 0 )
    {
      ACE_DEBUG ((LM_DEBUG,
                  "(%N,%l) TAO_AV_UDP_Flow_Handler::change_qos\n"));
    }

  unsigned int i=0;

  int ret = 0;
  CORBA::Long dscp = 0;
  CORBA::Long ecn = 0;
  int dscp_flag=0;
  for(i=0; i < qos.QoSParams.length(); i++)
    {

      if( ACE_OS::strcmp( qos.QoSParams[i].property_name.in(), "Diffserv_Codepoint") == 0)
        {
          qos.QoSParams[i].property_value >>= dscp;
          dscp_flag=1;
          // DSCP value can only be 6 bits wide
          if(!((dscp >= 0) && (dscp <= 63)))
            {
              dscp_flag = 0;
              ACE_DEBUG((LM_DEBUG, "(%N,%l) ECN value can only be (0-3) not %d\n", ecn));
              return -1;
            }
        }

      if( ACE_OS::strcmp( qos.QoSParams[i].property_name.in(), "ECN") == 0)
        {
          qos.QoSParams[i].property_value >>= ecn;
          // ECN value can only occupy bits 6 and 7 of the
          // IP Diffserv byte
          if(!((ecn >= 0) && (ecn <= 3)))
            {
              ACE_DEBUG((LM_DEBUG, "(%N,%l) ECN value can only be (0-3) not %d\n", ecn));
              ecn = 0;
            }

        }
    }
      // Set the Diffserv byte only if we specified
      // the Diffserv Codepoint (DSCP) or ECN via QoSParams
      // passed into this method
      if(dscp_flag || ecn)
        {
          int tos;
          tos = (int)(dscp << 2);
          if(ecn)
            {
              tos |= ecn;
            }
          ret = sock_dgram_.set_option(IPPROTO_IP, IP_TOS, (int *)&tos , (int)sizeof(tos));

          if(TAO_debug_level > 1)
            {
              ACE_DEBUG((LM_DEBUG, "(%N,%l) set tos: ret: %d\n", ret));
            }
        }

      if(TAO_debug_level > 1)
        {
           if(ret < 0 )
             {
                ACE_DEBUG((LM_DEBUG, "(%N,%l) errno: %p\n"));
             }
        }
      return ret;
}

int TAO_AV_UDP_Flow_Handler::close ( void   ) 

Definition at line 27 of file UDP.inl.

{
  return  this->sock_dgram_.close ();
}

virtual ACE_Event_Handler* TAO_AV_UDP_Flow_Handler::event_handler ( void   )  [inline, virtual]

Definition at line 127 of file UDP.h.

{ return this; }

ACE_HANDLE TAO_AV_UDP_Flow_Handler::get_handle ( void   )  const [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 75 of file UDP.cpp.

{
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "TAO_AV_UDP_Flow_Handler::get_handle:%d\n",
                this->sock_dgram_.get_handle ()));

  return this->sock_dgram_.get_handle () ;
}

const ACE_SOCK_Dgram * TAO_AV_UDP_Flow_Handler::get_socket ( void   )  const

Definition at line 13 of file UDP.inl.

{
  return &this->sock_dgram_;
}

int TAO_AV_UDP_Flow_Handler::handle_input ( ACE_HANDLE  fd  )  [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 48 of file UDP.cpp.

{
  return this->protocol_object_->handle_input ();
}

int TAO_AV_UDP_Flow_Handler::handle_timeout ( const ACE_Time_Value tv,
const void *  arg = 0 
) [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 54 of file UDP.cpp.

int TAO_AV_UDP_Flow_Handler::open ( ACE_Addr address  ) 

Definition at line 20 of file UDP.inl.

{
  return this->sock_dgram_.open (address);
}

int TAO_AV_UDP_Flow_Handler::set_remote_address ( ACE_Addr address  )  [virtual]

Definition at line 61 of file UDP.cpp.

{
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_Flow_Handler::set_remote_address\n"));

  ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (address);
  this->peer_addr_ = *inet_addr;
  TAO_AV_UDP_Transport *transport = dynamic_cast<TAO_AV_UDP_Transport*> (this->transport_);

  return transport->set_remote_address (*inet_addr);
}

TAO_AV_Transport * TAO_AV_UDP_Flow_Handler::transport ( void   )  [virtual]

Definition at line 42 of file UDP.cpp.

{
  return this->transport_;
}


Member Data Documentation

Definition at line 132 of file UDP.h.

Definition at line 133 of file UDP.h.

Definition at line 134 of file UDP.h.


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