Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / ATM_Connector.cpp
blob42dd0f7a725470dafdfd4c4df32f5d5a6205a523
1 // ATM_Connector.cpp
2 #include "ace/ATM_Connector.h"
3 #if defined (ACE_HAS_ATM)
5 #include "ace/Handle_Set.h"
7 #if !defined (__ACE_INLINE__)
8 #include "ace/ATM_Connector.inl"
9 #endif /* __ACE_INLINE__ */
11 // Open versioned namespace, if enabled by the user.
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
16 ACE_ATM_Connector::ACE_ATM_Connector (void)
18 ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
21 // Actively connect and produce a new ACE_ATM_Stream if things go well...
22 // Connect the <new_stream> to the <remote_sap>, waiting up to
23 // <timeout> amount of time if necessary.
25 int
26 ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
27 const ACE_ATM_Addr &remote_sap,
28 ACE_ATM_Params params,
29 ACE_ATM_QoS options,
30 ACE_Time_Value *timeout,
31 const ACE_ATM_Addr &local_sap,
32 int reuse_addr,
33 int flags,
34 int perms)
36 ACE_TRACE ("ACE_ATM_Connector::connect");
37 #if defined (ACE_HAS_FORE_ATM_XTI)
38 return connector_.connect(new_stream.get_stream(),
39 remote_sap,
40 timeout,
41 local_sap,
42 reuse_addr,
43 flags,
44 perms,
45 params.get_device(),
46 params.get_info(),
47 params.get_rw_flag(),
48 params.get_user_data(),
49 &options.get_qos());
50 #elif defined (ACE_HAS_FORE_ATM_WS2)
51 ACELIB_DEBUG(LM_DEBUG,
52 ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
54 ACE_HANDLE s = new_stream.get_handle();
55 struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
56 ACE_QoS cqos = options.get_qos();
58 ACE_QoS_Params qos_params = ACE_QoS_Params(0,
60 &cqos,
62 0);
64 ACELIB_DEBUG(LM_DEBUG,
65 ACE_TEXT ("ATM_Connector(connect): connecting...\n"));
67 int result = ACE_OS::connect( s,
68 ( struct sockaddr *)saddr,
69 sizeof( struct sockaddr_atm ),
70 qos_params );
72 if ( result != 0 )
73 ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n",
74 ::WSAGetLastError());
76 return result;
77 #elif defined (ACE_HAS_LINUX_ATM)
78 ACE_UNUSED_ARG (params);
79 ACE_UNUSED_ARG (timeout);
80 ACE_UNUSED_ARG (reuse_addr);
81 ACE_UNUSED_ARG (perms);
82 ACE_UNUSED_ARG (flags);
84 ACE_HANDLE handle = new_stream.get_handle();
85 ATM_QoS qos =options.get_qos();
86 ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
87 *remote_addr=(ATM_Addr*)remote_sap.get_addr();
89 if (ACE_OS::setsockopt(handle,
90 SOL_ATM,
91 SO_ATMSAP,
92 reinterpret_cast<char*> (&(local_addr->atmsap)),
93 sizeof(local_addr->atmsap)) < 0) {
94 ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
95 errno);
97 if (ACE_OS::setsockopt(handle,
98 SOL_ATM,
99 SO_ATMQOS,
100 reinterpret_cast<char*> (&qos),
101 sizeof(qos)) < 0) {
102 ACELIB_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
103 errno));
104 return -1;
107 int result = ACE_OS::connect(handle,
108 (struct sockaddr *)&(remote_addr->sockaddratmsvc),
109 sizeof( remote_addr->sockaddratmsvc));
111 if ( result != 0 )
112 ACELIB_DEBUG(LM_DEBUG,
113 ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
114 errno);
116 return result;
117 #else
118 ACE_UNUSED_ARG (new_stream);
119 ACE_UNUSED_ARG (remote_sap);
120 ACE_UNUSED_ARG (params);
121 ACE_UNUSED_ARG (options);
122 ACE_UNUSED_ARG (timeout);
123 ACE_UNUSED_ARG (local_sap);
124 ACE_UNUSED_ARG (reuse_addr);
125 ACE_UNUSED_ARG (flags);
126 ACE_UNUSED_ARG (perms);
127 return 0;
128 #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
131 // Close versioned namespace, if enabled by the user.
132 ACE_END_VERSIONED_NAMESPACE_DECL
134 #endif /* ACE_HAS_ATM */