ATM_Connector.cpp

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

Generated on Thu Nov 9 09:41:46 2006 for ACE by doxygen 1.3.6