summaryrefslogtreecommitdiff
path: root/ace/ATM_Connector.i
blob: f67ca3414ca38991a88589f3b22cc9fe6f72796e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* -*- C++ -*- */
// $Id$

// ATM_Connector.i

ACE_INLINE
ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream, 
																      const ACE_ATM_Addr &remote_sap, 
                                      ACE_ATM_Params params,
                                      ACE_ATM_QoS options,
																      ACE_Time_Value *timeout,
																			const ACE_ATM_Addr &local_sap, 
																			int reuse_addr, 
																			int flags,
																			int perms)
{
  ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
  if ((ACE_HANDLE)this->connect (new_stream,
                                 remote_sap,
                                 params,
                                 options,
                                 timeout,
                                 local_sap,
                                 reuse_addr, 
		                             flags,
                                 perms) == ACE_INVALID_HANDLE
      && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
    ACE_ERROR ((LM_ERROR,  ASYS_TEXT ("%p\n"),  
               ASYS_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream")));
}

// Connect the <new_stream> to the <remote_sap>, waiting up to
// <timeout> amount of time if necessary.

//ACE_INLINE
//int
//ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, 
//												    const ACE_ATM_Addr &remote_sap, 
//                            ACE_ATM_Params params,
//                            ACE_ATM_QoS options,
//														ACE_Time_Value *timeout,
//														const ACE_ATM_Addr &local_sap, 
//														int reuse_addr,
//														int flags,
//														int perms)
//{
//  ACE_TRACE ("ACE_ATM_Connector::connect");
//#if defined (ACE_HAS_FORE_ATM_XTI)
//  return connector_.connect(new_stream.get_stream(),
//                            remote_sap,
//                            timeout,
//                            local_sap,
//                            reuse_addr,
//                            flags,
//                            perms,
//                            params.get_device(),
//                            params.get_info(),
//                            params.get_rw_flag(),
//                            params.get_user_data(),
//                            &options.get_qos());
//#elif defined (ACE_HAS_FORE_ATM_WS2)
//  ACE_OS::printf( "ATM_Connector(connect): to connect\n" );
//
//  return connector_.connect(new_stream.get_stream(),
//                            remote_sap,
//                            options.get_option_params(),
//                            timeout,
//                            local_sap,
//                            0,
//                            0,
//                            flags,
//                            reuse_addr,
//                            perms,
//                            params.get_protocol_family(),
//                            params.get_protocol());
//#else
//  ACE_UNUSED_ARG (new_stream);
//  ACE_UNUSED_ARG (remote_sap);
//  ACE_UNUSED_ARG (params);
//  ACE_UNUSED_ARG (options);
//  ACE_UNUSED_ARG (timeout);
//  ACE_UNUSED_ARG (local_sap);
//  ACE_UNUSED_ARG (reuse_addr);
//  ACE_UNUSED_ARG (flags);
//  ACE_UNUSED_ARG (perms);
//  return 0;
//#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2 */
//}

// Try to complete a non-blocking connection.

ACE_INLINE
int
ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream, 
			     ACE_ATM_Addr *remote_sap,
			     ACE_Time_Value *tv)
{
  ACE_TRACE ("ACE_ATM_Connector::complete");
#if defined (ACE_HAS_ATM)
  return connector_.complete(new_stream.get_stream(),
                             remote_sap,
                             tv);
#else
  ACE_UNUSED_ARG(new_stream);
  ACE_UNUSED_ARG(remote_sap);
  ACE_UNUSED_ARG(tv);
  return 0;
#endif
}

ACE_INLINE
int
ACE_ATM_Connector::add_leaf (ACE_ATM_Stream &current_stream,
                             const ACE_Addr &remote_sap,
                             ACE_INT32 leaf_id,
                             ACE_Time_Value *timeout)
{
  ACE_TRACE ("ACE_ATM_Connector::add_leaf");
#if defined (ACE_HAS_FORE_ATM_XTI)
  return connector_.add_leaf(current_stream.get_stream(),
                             remote_sap,
                             leaf_id,
                             timeout);
#elif defined (ACE_HAS_FORE_ATM_WS2)
  ACE_UNUSED_ARG(leaf_id);
  ACE_UNUSED_ARG(timeout);

  SOCKET ns;
  int len = sizeof( struct sockaddr_atm );
  struct sockaddr_atm *laddr;
  laddr = ( struct sockaddr_atm *)remote_sap.get_addr();

  ns = ::WSAJoinLeaf(( SOCKET )current_stream.get_handle(),
                     ( struct sockaddr FAR *)laddr,
                     //( struct sockaddr *)remote_sap.get_addr(),
                     len, 
                     NULL,  // caller data
                     NULL,  // callee data
                     NULL,  // SQos
                     NULL,  // GQos
                     JL_SENDER_ONLY );

  if ( ns == INVALID_SOCKET ) {
    ACE_OS::printf( "Connector(add_leaf): WSAJoinLeaf %d\n", 
                    ::WSAGetLastError());
    return -1;
  }

//  ACE_HANDLE nah;

//  nah = ACE_OS::join_leaf( current_stream.get_handle(),
//                           ( struct sockaddr *)remote_sap.get_addr(),
//                           NULL );
              
  return 0;
#else
  ACE_UNUSED_ARG(current_stream);
  ACE_UNUSED_ARG(remote_sap);
  ACE_UNUSED_ARG(leaf_id);
  ACE_UNUSED_ARG(timeout);
  return 0;
#endif
}

ACE_INLINE
int
ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle)
{
#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
  // Reset the event association 
  return ::WSAEventSelect ((SOCKET) handle,
                           NULL,
                           0);    
#else /* !defined ACE_HAS_WINSOCK2 */
  ACE_UNUSED_ARG (handle);
  return 0;
#endif /* ACE_WIN32 */
}