Ignore:
Timestamp:
Jul 21, 2009, 1:54:55 PM (15 years ago)
Author:
Christoph Mayer
Message:

begin merge back from relay branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/SideportListener.cpp

    r4751 r5151  
    4040
    4141#include "ariba/overlay/BaseOverlay.h"
     42#include "ariba/overlay/LinkDescriptor.h"
     43
     44using ariba::overlay::LinkDescriptor;
    4245
    4346namespace ariba {
     
    7174}
    7275
    73 //******************************************************
    74 //
    75 // JUST EXPERIMENTAL WITH RANDOM RESULTS
    76 //
     76bool SideportListener::isRelayedNode(const NodeID& node){
    7777
    78 // 0 = normal node    --> directly accessible
    79 // 1 = relaying node  --> node that is relaying for us (must also be 0)
    80 // 2 = relayed node   --> node that we cannot access directly
    81 static map<NodeID,short> relayingnodes;
    82 static map<NodeID,SideportListener::Protocol> protocolnodes;
     78        BOOST_FOREACH( LinkDescriptor* link, overlay->links ){
     79
     80                if( (!link->localRelay.isUnspecified()) && link->remoteRelay == node && link->up) {
     81                        return true;
     82                }
     83
     84        }
     85
     86        return false;
     87}
    8388
    8489bool SideportListener::isRelayingNode(const NodeID& node){
    8590
    86         map<NodeID,short>::iterator i = relayingnodes.find(node);
    87         if(i != relayingnodes.end()) return (i->second == 1);
     91        BOOST_FOREACH( LinkDescriptor* link, overlay->links ){
    8892
    89         relayingnodes.insert( std::make_pair( node, rand()%3 ) );
    90 }
     93                if( (!link->localRelay.isUnspecified()) && link->localRelay == node && link->up) {
     94                        return true;
     95                }
    9196
    92 bool SideportListener::isRelayedNode(const NodeID& node){
    93 
    94         map<NodeID,short>::iterator i = relayingnodes.find(node);
    95         if(i != relayingnodes.end()) return (i->second == 2);
    96 
    97         relayingnodes.insert( std::make_pair( node, rand()%3 ) );
    98 }
    99 
    100 SideportListener::Protocol generateRandomProtocol(){
    101 
    102         if( (rand() % 3) == 0 ){
    103                 return SideportListener::rfcomm;
    10497        }
    10598
    106         int ret = SideportListener::undefined;
    107 
    108         if( (rand() % 2) == 0 ) ret |= SideportListener::ipv4;
    109         else                                    ret |= SideportListener::ipv6;
    110 
    111         if( (rand() % 2) == 0 ) ret |= SideportListener::udp;
    112         else                                    ret |= SideportListener::tcp;
    113 
    114         return (SideportListener::Protocol)ret;
     99        return false;
    115100}
    116101
    117102SideportListener::Protocol SideportListener::getReachabilityProtocol(const NodeID& node){
    118 
    119         map<NodeID,Protocol>::iterator i = protocolnodes.find(node);
    120         if(i != protocolnodes.end()) return i->second;
    121 
    122         protocolnodes.insert( std::make_pair(node, generateRandomProtocol()) );
     103        return (SideportListener::Protocol)(ipv4 | tcp);
    123104}
    124 
    125 //
    126 //
    127 //******************************************************
    128105
    129106void SideportListener::configure( overlay::BaseOverlay* _overlay ) {
Note: See TracChangeset for help on using the changeset viewer.