63 ConnectionMap connectionsSnapshot;
66 connectionsSnapshot.insert( m_connections.begin(), m_connections.end() );
69 ConnectionMap::const_iterator it = connectionsSnapshot.begin();
70 for( ; it != connectionsSnapshot.end(); ++it )
72 (*it).first->recv( timeout );
74 connectionsSnapshot.clear();
151 const std::string& data )
154 ConnectionMap::iterator it = m_connections.find(
const_cast<ConnectionBase*
>( connection ) );
155 if( it == m_connections.end() )
162 switch( (*it).second.state )
164 case StateDisconnected:
165 (*it).first->disconnect();
167 case StateUnnegotiated:
171 c[1] =
static_cast<char>( 0xFF );
172 (*it).second.state = StateDisconnected;
174 if( data.length() >= 3 && data[0] == 0x05 )
176 unsigned int sz = ( data.length() - 2 <
static_cast<unsigned int>( data[1] ) )
177 ?
static_cast<unsigned int>( data.length() - 2 )
178 :
static_cast<unsigned int>( data[1] );
179 for(
unsigned int i = 2; i < sz + 2; ++i )
181 if( data[i] == 0x00 )
184 (*it).second.state = StateAuthAccepted;
189 (*it).first->send( std::string( c, 2 ) );
192 case StateAuthmethodAccepted:
195 case StateAuthAccepted:
197 std::string reply = data;
198 if( reply.length() < 2 )
203 (*it).second.state = StateDisconnected;
205 if( data.length() == 47 && data[0] == 0x05 && data[1] == 0x01 && data[2] == 0x00
206 && data[3] == 0x03 && data[4] == 0x28 && data[45] == 0x00 && data[46] == 0x00 )
208 const std::string hash = data.substr( 5, 40 );
211 HashMap::const_iterator ith = m_hashes.begin();
212 for( ; ith != m_hashes.end() && (*ith) != hash; ++ith )
215 if( ith != m_hashes.end() )
218 (*it).second.hash = hash;
219 (*it).second.state = StateDestinationAccepted;
223 (*it).first->send( reply );
226 case StateDestinationAccepted: