Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_ATM_Acceptor Class Reference

Defines the member functions for ACE_ATM_Acceptor abstraction. More...

#include <ATM_Acceptor.h>

List of all members.

Public Types

typedef ACE_ATM_Addr PEER_ADDR
typedef ACE_ATM_Stream PEER_STREAM

Public Methods

 ACE_ATM_Acceptor (void)
 Default constructor. More...

 ~ACE_ATM_Acceptor ()
 ACE_ATM_Acceptor (const ACE_Addr &remote_sap, int backlog=ACE_DEFAULT_BACKLOG, ACE_ATM_Params params=ACE_ATM_Params())
 Initiate a passive mode connection. More...

ACE_HANDLE open (const ACE_Addr &remote_sap, int backlog=ACE_DEFAULT_BACKLOG, ACE_ATM_Params params=ACE_ATM_Params())
 Initiate a passive mode socket. More...

int close (void)
 Close down the acceptor and release resources. More...

int accept (ACE_ATM_Stream &new_sap, ACE_Addr *remote_addr=0, ACE_Time_Value *timeout=0, int restart=1, int reset_new_handle=0, ACE_ATM_Params params=ACE_ATM_Params(), ACE_ATM_QoS qos=ACE_ATM_QoS())
 Accept a new data transfer connection. A <timeout> of 0 means block forever, a <timeout> of {0, 0} means poll. <restart> == 1 means "restart if interrupted.". More...

int get_local_addr (ACE_ATM_Addr &local_addr)
 Get the local address currently listening on. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Attributes

ATM_Acceptor acceptor_


Detailed Description

Defines the member functions for ACE_ATM_Acceptor abstraction.

This class wraps up the ACE_SOCK_Acceptor and ACE_TLI_Acceptor to make the mechanism for the ATM protocol transparent.

Definition at line 51 of file ATM_Acceptor.h.


Member Typedef Documentation

typedef ACE_ATM_Addr ACE_ATM_Acceptor::PEER_ADDR
 

Definition at line 91 of file ATM_Acceptor.h.

typedef ACE_ATM_Stream ACE_ATM_Acceptor::PEER_STREAM
 

Definition at line 92 of file ATM_Acceptor.h.


Constructor & Destructor Documentation

ACE_ATM_Acceptor::ACE_ATM_Acceptor void   
 

Default constructor.

Definition at line 29 of file ATM_Acceptor.cpp.

References ACE_TRACE.

00030 {
00031   ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
00032 }

ACE_ATM_Acceptor::~ACE_ATM_Acceptor  
 

Definition at line 34 of file ATM_Acceptor.cpp.

References ACE_TRACE.

00035 {
00036   ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor");
00037 }

ACE_INLINE ACE_ATM_Acceptor::ACE_ATM_Acceptor const ACE_Addr   remote_sap,
int    backlog = ACE_DEFAULT_BACKLOG,
ACE_ATM_Params    params = ACE_ATM_Params()
 

Initiate a passive mode connection.

Definition at line 6 of file ATM_Acceptor.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and open.

00009 {
00010   ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
00011   if (open (remote_sap,
00012             backlog,
00013             params) < 0)
00014     ACE_ERROR ((LM_ERROR,
00015                 ACE_LIB_TEXT ("%p\n"),
00016                 ACE_LIB_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor")));
00017 }


Member Function Documentation

int ACE_ATM_Acceptor::accept ACE_ATM_Stream   new_sap,
ACE_Addr   remote_addr = 0,
ACE_Time_Value   timeout = 0,
int    restart = 1,
int    reset_new_handle = 0,
ACE_ATM_Params    params = ACE_ATM_Params(),
ACE_ATM_QoS    qos = ACE_ATM_QoS()
 

Accept a new data transfer connection. A <timeout> of 0 means block forever, a <timeout> of {0, 0} means poll. <restart> == 1 means "restart if interrupted.".

Definition at line 239 of file ATM_Acceptor.cpp.

References ACE_OS::accept, acceptor_, ACE_TRACE, ATM_QoS, ACE_ATM_QoS::get_qos, ACE_ATM_Params::get_rw_flag, ACE_ATM_Stream::get_stream, ACE_ATM_Params::get_user_data, ACE_OS::printf, and ACE_OS::setsockopt.

00246 {
00247   ACE_TRACE ("ACE_ATM_Acceptor::accept");
00248 #if defined (ACE_HAS_FORE_ATM_XTI)
00249   ATM_QoS optbuf = qos.get_qos ();
00250 
00251   return (acceptor_.accept (new_sap.get_stream (),
00252                            remote_addr,
00253                            timeout,
00254                            restart,
00255                            reset_new_handle,
00256                            params.get_rw_flag (),
00257                            params.get_user_data (),
00258                            &optbuf));
00259 #elif defined (ACE_HAS_FORE_ATM_WS2)
00260   ACE_HANDLE n_handle;
00261   ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
00262   struct sockaddr_atm *cli_addr 
00263     = (struct sockaddr_atm *)remote_addr -> get_addr ();
00264   int caddr_len = sizeof (struct sockaddr_atm); 
00265 
00266   do {
00267     n_handle = ACE_OS::accept (s_handle,
00268                               ACE_reinterpret_cast (struct sockaddr *,
00269                                                    cli_addr),
00270                               &caddr_len);
00271   } while (n_handle == ACE_INVALID_HANDLE && errno == EINTR);
00272 
00273  ((ACE_ATM_Addr *)remote_addr) -> set (cli_addr,
00274  ((ACE_ATM_Addr *)remote_addr) -> get_selector ());
00275  ((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle);
00276 
00277   return 0;
00278 #elif defined (ACE_HAS_LINUX_ATM)
00279   ACE_UNUSED_ARG (params);
00280 
00281   ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
00282   struct atm_qos accept_qos = qos.get_qos ();
00283 
00284   if (ACE_OS::setsockopt (s_handle,
00285                          SOL_ATM,
00286                          SO_ATMQOS,
00287                          ACE_reinterpret_cast (char*,
00288                                               &accept_qos),
00289                          sizeof (accept_qos)) < 0) {
00290     ACE_OS::printf ("Acceptor (accept): error setting Qos"); 
00291   }
00292 
00293   return (acceptor_.accept (new_sap.get_stream (),
00294                           remote_addr,
00295                           timeout,
00296                           restart,
00297                           reset_new_handle));
00298 #else
00299   ACE_UNUSED_ARG (new_sap);
00300   ACE_UNUSED_ARG (remote_addr);
00301   ACE_UNUSED_ARG (timeout);
00302   ACE_UNUSED_ARG (restart);
00303   ACE_UNUSED_ARG (reset_new_handle);
00304   ACE_UNUSED_ARG (params);
00305   ACE_UNUSED_ARG (qos);
00306   return (0);
00307 #endif /* ACE_HAS_FORE_ATM_XTI */
00308 }

ACE_INLINE int ACE_ATM_Acceptor::close void   
 

Close down the acceptor and release resources.

Definition at line 21 of file ATM_Acceptor.i.

References acceptor_.

00022 {
00023 #if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
00024   return (acceptor_.close());
00025 #else
00026   return 0;
00027 #endif // ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
00028 }

void ACE_ATM_Acceptor::dump void    const
 

Dump the state of an object.

Definition at line 24 of file ATM_Acceptor.cpp.

References ACE_TRACE.

00025 {
00026   ACE_TRACE ("ACE_ATM_Acceptor::dump");
00027 }

int ACE_ATM_Acceptor::get_local_addr ACE_ATM_Addr   local_addr
 

Get the local address currently listening on.

Definition at line 40 of file ATM_Acceptor.cpp.

References acceptor_, ACE_DEBUG, ACE_LIB_TEXT, ACE_TRACE, ATM_Addr, ACE_ATM_Addr::get_addr, ACE_OS::getsockname, LM_DEBUG, ACE_OS_String::memcpy, and ACE_OS::printf.

00041 {
00042   ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr");
00043 
00044 #if defined (ACE_HAS_FORE_ATM_WS2)
00045   unsigned long ret = 0;
00046   DWORD deviceID = 0;
00047   ATM_ADDRESS addr;
00048   struct sockaddr_atm *laddr;
00049 
00050   if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (), 
00051                 SIO_GET_ATM_ADDRESS, 
00052  (LPVOID) &deviceID, 
00053                 sizeof (DWORD), 
00054  (LPVOID)&addr,
00055                 sizeof (ATM_ADDRESS),
00056                 &ret,
00057                 0,
00058                 0) == SOCKET_ERROR) {
00059     ACE_OS::printf ("ATM_Acceptor (get_local_addr): WSIoctl: %d\n", 
00060                     ::WSAGetLastError ());
00061     return -1;
00062   }
00063 
00064   laddr = (struct sockaddr_atm *)local_addr.get_addr ();
00065   ACE_OS::memcpy ((void *)& (laddr -> satm_number), 
00066  (void *)&addr, 
00067                  ATM_ADDR_SIZE - 1);
00068 
00069   return 0;
00070 #elif defined (ACE_HAS_FORE_ATM_XTI)
00071   ACE_UNUSED_ARG (local_addr);
00072   
00073   return 0;
00074 #elif defined (ACE_HAS_LINUX_ATM)
00075   ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr ();
00076   int addrlen = sizeof (myaddr->sockaddratmsvc);
00077   
00078   if (ACE_OS::getsockname (acceptor_.get_handle (),
00079  (struct sockaddr *) & (myaddr->sockaddratmsvc),
00080                           &addrlen) < 0) {
00081     ACE_DEBUG ((LM_DEBUG,
00082                ACE_LIB_TEXT ("ATM_Acceptor (get_local_addr): ioctl: %d\n"),
00083                errno));
00084     return -1;
00085   }
00086 
00087   return (0);
00088 #else
00089   ACE_UNUSED_ARG (local_addr);
00090 
00091   return 0;
00092 #endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */
00093 }

ACE_HANDLE ACE_ATM_Acceptor::open const ACE_Addr   remote_sap,
int    backlog = ACE_DEFAULT_BACKLOG,
ACE_ATM_Params    params = ACE_ATM_Params()
 

Initiate a passive mode socket.

Definition at line 96 of file ATM_Acceptor.cpp.

References acceptor_, ACE_DEBUG, ACE_FLAG_MULTIPOINT_C_LEAF, ACE_FLAG_MULTIPOINT_D_LEAF, ACE_LIB_TEXT, ACE_TRACE, ATM_Addr, ATM_QoS, ACE_OS::bind, ACE_ATM_Addr::get_addr, ACE_ATM_Params::get_device, ACE_ATM_Params::get_flags, ACE_ATM_Params::get_info, ACE_ATM_Params::get_oflag, ACE_ATM_Params::get_protocol, ACE_ATM_Params::get_protocol_family, ACE_ATM_Params::get_protocol_info, ACE_ATM_QoS::get_qos, ACE_ATM_Params::get_reuse_addr, ACE_ATM_Params::get_sock_group, ACE_ATM_Params::get_type, ACE_OS::ioctl, ACE_OS::listen, LM_DEBUG, ACE_OS_String::memset, ACE_OS::perror, ACE_OS::printf, ACE_ATM_Addr::set_selector, ACE_OS::setsockopt, and ACE_OS::socket.

Referenced by ACE_ATM_Acceptor.

00099 {
00100   ACE_TRACE ("ACE_ATM_Acceptor::open");
00101 #if defined (ACE_HAS_FORE_ATM_XTI)
00102   ACE_HANDLE handle = acceptor_.open (remote_sap,
00103                                       params.get_reuse_addr (),
00104                                       params.get_oflag (),
00105                                       params.get_info (),
00106                                       backlog,
00107                                       params.get_device ());
00108   return (handle == ACE_INVALID_HANDLE ? -1 : 0);
00109 #elif defined (ACE_HAS_FORE_ATM_WS2)
00110   struct sockaddr_atm local_atm_addr;
00111   ACE_HANDLE ret;
00112   DWORD flags = 0;
00113 
00114   /* Create a local endpoint of communication */
00115 
00116   // Only leaves can listen.
00117   flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF;
00118 
00119   if ((ret = ACE_OS::socket (AF_ATM,
00120                              SOCK_RAW,
00121                              ATMPROTO_AAL5,
00122                              0,
00123                              0,
00124                              flags))
00125       == ACE_INVALID_HANDLE) {
00126     ACE_OS::printf ("Acceptor (open): socket %d\n",
00127                     ::WSAGetLastError ());
00128     return (ret);
00129   }
00130 
00131  ((ACE_SOCK_Acceptor *)this) -> set_handle (ret);
00132 
00133   /* Set up the address information to become a server */
00134   ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr);
00135   local_atm_addr.satm_family = AF_ATM;
00136   local_atm_addr.satm_number.AddressType = SAP_FIELD_ANY_AESA_REST;
00137   local_atm_addr.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] 
00138     = ((ACE_ATM_Addr *)&remote_sap) -> get_selector ();
00139   local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY;
00140   local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
00141   local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
00142 
00143   /* Associate address with endpoint */
00144   if (ACE_OS::bind (( (ACE_SOCK_Acceptor *)this) -> get_handle (),
00145                     ACE_reinterpret_cast (struct sockaddr *, &local_atm_addr),
00146                     sizeof local_atm_addr) == -1) {
00147     ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ()); 
00148     return (ACE_INVALID_HANDLE);
00149   }
00150 
00151   /* Make endpoint listen for service requests */
00152   if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (), 
00153                       backlog) 
00154                     == -1) {
00155     ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ());
00156     return (ACE_INVALID_HANDLE);
00157   }
00158 
00159   return 0;
00160 #elif defined (ACE_HAS_LINUX_ATM)
00161   //we need to set the qos before binding to the socket
00162   //use remote_sap as local_sap
00163 
00164   ACE_ATM_Addr local_sap;
00165   ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr ();
00166   ACE_ATM_QoS def_qos;
00167   ATM_QoS qos = def_qos.get_qos ();
00168 
00169   ACE_HANDLE handle;
00170   if ((handle = ACE_OS::socket (params.get_protocol_family (), 
00171                                 params.get_type (), 
00172                                 params.get_protocol (), 
00173                                 params.get_protocol_info (), 
00174                                 params.get_sock_group (), 
00175                                 params.get_flags () 
00176                                ))
00177       == ACE_INVALID_HANDLE) {
00178     ACE_DEBUG (LM_DEBUG,
00179               ACE_LIB_TEXT ("Acceptor (socket): socket %d\n"),
00180               errno);
00181     return (ACE_INVALID_HANDLE);
00182   }
00183    
00184  ((ACE_SOCK_Acceptor *)this) -> set_handle (handle);
00185   if (ACE_OS::setsockopt (handle,
00186                          SOL_ATM,
00187                          SO_ATMQOS,
00188                          ACE_reinterpret_cast (char*, &qos),
00189                          sizeof (qos)) < 0) {
00190     ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n",
00191                    errno);
00192   }
00193 
00194   struct atmif_sioc req;
00195   struct sockaddr_atmsvc aux_addr[1024];
00196 
00197   req.number = 0;
00198   req.arg = aux_addr;
00199   req.length = sizeof (aux_addr);
00200   if (ACE_OS::ioctl (handle,
00201                     ATM_GETADDR,
00202                     &req) < 0) {
00203     ACE_OS::perror ("Acceptor (setsockopt): ioctl:");
00204   }
00205   else {
00206     local_sap_addr->sockaddratmsvc = aux_addr[0];
00207   }
00208   local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ());
00209 
00210   if (ACE_OS::bind (handle,
00211                     ACE_reinterpret_cast (struct sockaddr *,
00212                                          & (local_sap_addr->sockaddratmsvc)),
00213                     sizeof (local_sap_addr->sockaddratmsvc)
00214                    ) == -1) {
00215     ACE_DEBUG (LM_DEBUG,
00216               ACE_LIB_TEXT ("Acceptor (open): bind %d\n"),
00217               errno);
00218     return -1;
00219   }
00220   // Make endpoint listen for service requests
00221   if (ACE_OS::listen (handle,
00222                       backlog) 
00223       == -1) {
00224     ACE_DEBUG (LM_DEBUG,
00225               ACE_LIB_TEXT ("Acceptor (listen): listen %d\n"),
00226               errno);
00227     return -1;
00228   }
00229 
00230   return 0;
00231 #else
00232   ACE_UNUSED_ARG (remote_sap);
00233   ACE_UNUSED_ARG (backlog);
00234   ACE_UNUSED_ARG (params);
00235 #endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
00236 }


Member Data Documentation

ATM_Acceptor ACE_ATM_Acceptor::acceptor_ [private]
 

Definition at line 101 of file ATM_Acceptor.h.

Referenced by accept, close, get_local_addr, and open.

ACE_ATM_Acceptor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 98 of file ATM_Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:45:53 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002