Changeset 5151 for source/ariba/SideportListener.cpp
- Timestamp:
- Jul 21, 2009, 1:54:55 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/SideportListener.cpp
r4751 r5151 40 40 41 41 #include "ariba/overlay/BaseOverlay.h" 42 #include "ariba/overlay/LinkDescriptor.h" 43 44 using ariba::overlay::LinkDescriptor; 42 45 43 46 namespace ariba { … … 71 74 } 72 75 73 //****************************************************** 74 // 75 // JUST EXPERIMENTAL WITH RANDOM RESULTS 76 // 76 bool SideportListener::isRelayedNode(const NodeID& node){ 77 77 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 } 83 88 84 89 bool SideportListener::isRelayingNode(const NodeID& node){ 85 90 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 ){ 88 92 89 relayingnodes.insert( std::make_pair( node, rand()%3 ) ); 90 } 93 if( (!link->localRelay.isUnspecified()) && link->localRelay == node && link->up) { 94 return true; 95 } 91 96 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;104 97 } 105 98 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; 115 100 } 116 101 117 102 SideportListener::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); 123 104 } 124 125 //126 //127 //******************************************************128 105 129 106 void SideportListener::configure( overlay::BaseOverlay* _overlay ) {
Note:
See TracChangeset
for help on using the changeset viewer.