@ -830,15 +830,14 @@ void CUnifiedNetwork::addService(const string &name, const vector<CInetAddress>
// first we have to look if we have a network that can established the connection
// first we have to look if we have a network that can established the connection
uint j = 0 ;
uint j = 0 ;
// it s 127.0.0.1, it s ok
if ( ! addr [ i ] . is 127001 ( ) )
if ( ! addr [ i ] . is loopbackIPAddress ( ) ) { // it 's loopback ip address, it s ok
{
for ( j = 0 ; j < laddr . size ( ) ; j + + )
for ( j = 0 ; j < laddr . size ( ) ; j + + )
{
{
if ( laddr [ j ] . internalNetAddress ( ) = = addr [ i ] . internalNetAddress ( ) )
if ( laddr [ j ] . internalNetAddress ( ) = = addr [ i ] . internalNetAddress ( ) )
{
{
// it's ok, we can try
break ; // it's ok, we can try
break ;
}
}
}
}
@ -1272,8 +1271,7 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid)
uint8 connectionId = _IdCnx [ sid . get ( ) ] . DefaultNetwork ;
uint8 connectionId = _IdCnx [ sid . get ( ) ] . DefaultNetwork ;
if ( nid = = 0xFF )
if ( nid = = 0xFF )
{
{ // default network
// it s often happen because they didn't set a good network configuration, so it s in debug to disable it easily
//nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId);
//nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId);
}
}
else if ( nid > = _IdCnx [ sid . get ( ) ] . NetworkConnectionAssociations . size ( ) )
else if ( nid > = _IdCnx [ sid . get ( ) ] . NetworkConnectionAssociations . size ( ) )
@ -1294,8 +1292,9 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid)
if ( connectionId > = _IdCnx [ sid . get ( ) ] . Connections . size ( ) | | ! _IdCnx [ sid . get ( ) ] . Connections [ connectionId ] . valid ( ) | | ! _IdCnx [ sid . get ( ) ] . Connections [ connectionId ] . CbNetBase - > connected ( ) )
if ( connectionId > = _IdCnx [ sid . get ( ) ] . Connections . size ( ) | | ! _IdCnx [ sid . get ( ) ] . Connections [ connectionId ] . valid ( ) | | ! _IdCnx [ sid . get ( ) ] . Connections [ connectionId ] . CbNetBase - > connected ( ) )
{
{
// there's a problem with the selected connectionID, so try to find a valid one
nlwarning ( " HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id " , ( uint16 ) connectionId , _IdCnx [ sid . get ( ) ] . ServiceName . c_str ( ) ) ;
if ( nid ! = 0xFF ) // not a default network. There's a problem with the selected connectionID, so try to find a valid one
nlwarning ( " HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id " , ( uint16 ) connectionId , _IdCnx [ sid . get ( ) ] . ServiceName . c_str ( ) ) ;
for ( connectionId = 0 ; connectionId < _IdCnx [ sid . get ( ) ] . Connections . size ( ) ; connectionId + + )
for ( connectionId = 0 ; connectionId < _IdCnx [ sid . get ( ) ] . Connections . size ( ) ; connectionId + + )
{
{
@ -1303,6 +1302,14 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid)
{
{
// we found one at last, use this one
// we found one at last, use this one
//nldebug ("HNETL5: Ok, we found a valid connectionid, use %hu", (uint16)connectionId);
//nldebug ("HNETL5: Ok, we found a valid connectionid, use %hu", (uint16)connectionId);
if ( nid < _IdCnx [ sid . get ( ) ] . NetworkConnectionAssociations . size ( ) ) {
_IdCnx [ sid . get ( ) ] . NetworkConnectionAssociations [ nid ] = connectionId ; // we set the preferred networkConnectionAssociation
} else {
if ( nid = = 0xFF ) {
_IdCnx [ sid . get ( ) ] . DefaultNetwork = connectionId ;
}
}
nlwarning ( " HNETL5: selected connection id %hu from network %hu to send message to %s " , ( uint16 ) connectionId , ( uint16 ) nid , _IdCnx [ sid . get ( ) ] . ServiceName . c_str ( ) ) ;
break ;
break ;
}
}
}
}
@ -1782,7 +1789,7 @@ bool CUnifiedNetwork::isServiceLocal (TServiceId sid)
{
{
for ( uint j = 0 ; j < _IdCnx [ sid . get ( ) ] . ExtAddress . size ( ) ; j + + )
for ( uint j = 0 ; j < _IdCnx [ sid . get ( ) ] . ExtAddress . size ( ) ; j + + )
{
{
if ( _IdCnx [ sid . get ( ) ] . ExtAddress [ j ] . is 127001 ( ) )
if ( _IdCnx [ sid . get ( ) ] . ExtAddress [ j ] . is loopbackIPAddress ( ) )
return true ;
return true ;
if ( _IdCnx [ sid . get ( ) ] . ExtAddress [ j ] . internalIPAddress ( ) = = laddr [ i ] . internalIPAddress ( ) )
if ( _IdCnx [ sid . get ( ) ] . ExtAddress [ j ] . internalIPAddress ( ) = = laddr [ i ] . internalIPAddress ( ) )