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

ATM_Connector.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // ATM_Connector.cpp
00003 // $Id: ATM_Connector.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:20 chad Exp $
00004 
00005 #include "ace/ATM_Connector.h"
00006 #if defined (ACE_HAS_ATM)
00007 
00008 #include "ace/Handle_Set.h"
00009 
00010 ACE_RCSID(ace, ATM_Connector, "$Id: ATM_Connector.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:20 chad Exp $")
00011 
00012 #if !defined (__ACE_INLINE__)
00013 #include "ace/ATM_Connector.i"
00014 #endif /* __ACE_INLINE__ */
00015 
00016 ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
00017 
00018 void
00019 ACE_ATM_Connector::dump (void) const
00020 {
00021   ACE_TRACE ("ACE_ATM_Connector::dump");
00022 }
00023 
00024 ACE_ATM_Connector::ACE_ATM_Connector (void)
00025 {
00026   ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
00027 }
00028 
00029 // Actively connect and produce a new ACE_ATM_Stream if things go well...
00030 // Connect the <new_stream> to the <remote_sap>, waiting up to
00031 // <timeout> amount of time if necessary.
00032 
00033 int
00034 ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, 
00035                             const ACE_ATM_Addr &remote_sap, 
00036                             ACE_ATM_Params params,
00037                             ACE_ATM_QoS options,
00038                             ACE_Time_Value *timeout,
00039                             const ACE_ATM_Addr &local_sap, 
00040                             int reuse_addr,
00041                             int flags,
00042                             int perms)
00043 {
00044   ACE_TRACE ("ACE_ATM_Connector::connect");
00045 #if defined (ACE_HAS_FORE_ATM_XTI)
00046   return connector_.connect(new_stream.get_stream(),
00047                             remote_sap,
00048                             timeout,
00049                             local_sap,
00050                             reuse_addr,
00051                             flags,
00052                             perms,
00053                             params.get_device(),
00054                             params.get_info(),
00055                             params.get_rw_flag(),
00056                             params.get_user_data(),
00057                             &options.get_qos());
00058 #elif defined (ACE_HAS_FORE_ATM_WS2)
00059   ACE_DEBUG(LM_DEBUG,
00060             ACE_LIB_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
00061 
00062   ACE_HANDLE s = new_stream.get_handle();
00063   struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
00064   ACE_QoS cqos = options.get_qos();
00065 
00066   ACE_QoS_Params qos_params = ACE_QoS_Params(0,
00067                                              0,
00068                                              &cqos,
00069                                              0,
00070                                              0);
00071 
00072   ACE_DEBUG(LM_DEBUG,
00073             ACE_LIB_TEXT ("ATM_Connector(connect): connecting...\n"));
00074 
00075   int result = ACE_OS::connect( s, 
00076                                 ( struct sockaddr *)saddr, 
00077                                 sizeof( struct sockaddr_atm ), 
00078                                 qos_params );
00079   
00080   if ( result != 0 ) 
00081     ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n", 
00082                     ::WSAGetLastError());
00083   
00084   return result;
00085 #elif defined (ACE_HAS_LINUX_ATM)
00086   ACE_UNUSED_ARG (params);
00087   ACE_UNUSED_ARG (timeout);
00088   ACE_UNUSED_ARG (reuse_addr);
00089   ACE_UNUSED_ARG (perms);
00090   ACE_UNUSED_ARG (flags);
00091 
00092   ACE_HANDLE handle = new_stream.get_handle();
00093   ATM_QoS qos =options.get_qos();
00094   ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
00095     *remote_addr=(ATM_Addr*)remote_sap.get_addr();
00096 
00097   if (ACE_OS::setsockopt(handle,
00098                          SOL_ATM,
00099                          SO_ATMSAP,
00100                          ACE_reinterpret_cast(char*,
00101                                               &(local_addr->atmsap)),
00102                          sizeof(local_addr->atmsap)) < 0) {
00103     ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
00104                     errno);
00105   }
00106   if (ACE_OS::setsockopt(handle,
00107                          SOL_ATM,
00108                          SO_ATMQOS,
00109                          ACE_reinterpret_cast(char*,
00110                                               &qos),
00111                          sizeof(qos)) < 0) {
00112     ACE_DEBUG((LM_DEBUG,ACE_LIB_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
00113                errno));
00114     return -1;
00115   }
00116 
00117   int result = ACE_OS::connect(handle,
00118                                (struct sockaddr *)&(remote_addr->sockaddratmsvc), 
00119                                sizeof( remote_addr->sockaddratmsvc));
00120   
00121   if ( result != 0 )
00122     ACE_DEBUG(LM_DEBUG,
00123               ACE_LIB_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
00124               errno);
00125 
00126   return result;
00127 #else
00128   ACE_UNUSED_ARG (new_stream);
00129   ACE_UNUSED_ARG (remote_sap);
00130   ACE_UNUSED_ARG (params);
00131   ACE_UNUSED_ARG (options);
00132   ACE_UNUSED_ARG (timeout);
00133   ACE_UNUSED_ARG (local_sap);
00134   ACE_UNUSED_ARG (reuse_addr);
00135   ACE_UNUSED_ARG (flags);
00136   ACE_UNUSED_ARG (perms);
00137   return 0;
00138 #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
00139 }
00140 
00141 #endif /* ACE_HAS_ATM */
00142 

Generated on Mon Jun 16 11:19:08 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002