removed dependency on service in RsGxsNetTunnel

This commit is contained in:
csoler 2018-04-25 18:29:49 +02:00
parent 1a9a7622a2
commit da4b382ede
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 46 additions and 65 deletions

View File

@ -574,7 +574,7 @@ void RsGxsNetService::syncWithPeers()
// Grab all online virtual peers of distant tunnels for the current service. // Grab all online virtual peers of distant tunnels for the current service.
std::list<RsGxsNetTunnelVirtualPeerId> vpids ; std::list<RsGxsNetTunnelVirtualPeerId> vpids ;
getVirtualPeers(mServType,vpids); getVirtualPeers(vpids);
for(auto it(vpids.begin());it!=vpids.end();++it) for(auto it(vpids.begin());it!=vpids.end();++it)
peers.insert(RsPeerId(*it)) ; peers.insert(RsPeerId(*it)) ;
@ -805,14 +805,14 @@ void RsGxsNetService::checkDistantSyncState()
if(at_least_one_friend_is_supplier) if(at_least_one_friend_is_supplier)
{ {
releaseDistantPeers(mServType,grpId); releaseDistantPeers(grpId);
#ifdef NXS_NET_DEBUG_8 #ifdef NXS_NET_DEBUG_8
GXSNETDEBUG___<< " Group " << grpId << ": suppliers among friends. Releasing peers." << std::endl; GXSNETDEBUG___<< " Group " << grpId << ": suppliers among friends. Releasing peers." << std::endl;
#endif #endif
} }
else else
{ {
requestDistantPeers(mServType,grpId); requestDistantPeers(grpId);
#ifdef NXS_NET_DEBUG_8 #ifdef NXS_NET_DEBUG_8
GXSNETDEBUG___<< " Group " << grpId << ": no suppliers among friends. Requesting peers." << std::endl; GXSNETDEBUG___<< " Group " << grpId << ": no suppliers among friends. Requesting peers." << std::endl;
#endif #endif
@ -1677,7 +1677,7 @@ RsItem *RsGxsNetService::generic_recvItem()
uint32_t size = 0 ; uint32_t size = 0 ;
RsGxsNetTunnelVirtualPeerId virtual_peer_id ; RsGxsNetTunnelVirtualPeerId virtual_peer_id ;
while(mAllowDistSync && receiveTunnelData(mServType,data,size,virtual_peer_id)) while(mAllowDistSync && receiveTunnelData(data,size,virtual_peer_id))
{ {
RsNxsItem *item = dynamic_cast<RsNxsItem*>(RsNxsSerialiser(mServType).deserialise(data,&size)) ; RsNxsItem *item = dynamic_cast<RsNxsItem*>(RsNxsSerialiser(mServType).deserialise(data,&size)) ;
item->PeerId(virtual_peer_id) ; item->PeerId(virtual_peer_id) ;

View File

@ -135,8 +135,7 @@ RsGxsNetTunnelService::~RsGxsNetTunnelService()
mVirtualPeers.clear(); mVirtualPeers.clear();
for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it) for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it)
for(auto it2((*it).second.begin());it2!=(*it).second.end();++it2) delete (*it).second;
delete (*it2).second;
mIncomingData.clear(); mIncomingData.clear();
} }
@ -148,11 +147,11 @@ bool RsGxsNetTunnelService::isDistantPeer(const RsGxsNetTunnelVirtualPeerId& vir
return mVirtualPeers.find(virtual_peer) != mVirtualPeers.end(); return mVirtualPeers.find(virtual_peer) != mVirtualPeers.end();
} }
bool RsGxsNetTunnelService::receiveTunnelData(uint16_t service_id,unsigned char *& data,uint32_t& data_len,RsGxsNetTunnelVirtualPeerId& virtual_peer) bool RsGxsNetTunnelService::receiveTunnelData(unsigned char *& data,uint32_t& data_len,RsGxsNetTunnelVirtualPeerId& virtual_peer)
{ {
RS_STACK_MUTEX(mGxsNetTunnelMtx); RS_STACK_MUTEX(mGxsNetTunnelMtx);
std::list<std::pair<RsGxsNetTunnelVirtualPeerId,RsTlvBinaryData*> >& lst(mIncomingData[service_id]) ; std::list<std::pair<RsGxsNetTunnelVirtualPeerId,RsTlvBinaryData*> >& lst(mIncomingData);
if(lst.empty()) if(lst.empty())
{ {
@ -212,7 +211,7 @@ bool RsGxsNetTunnelService::sendTunnelData(unsigned char *& data,uint32_t data_l
return true ; return true ;
} }
bool RsGxsNetTunnelService::getVirtualPeers(uint16_t service_id, std::list<RsGxsNetTunnelVirtualPeerId>& peers) bool RsGxsNetTunnelService::getVirtualPeers(std::list<RsGxsNetTunnelVirtualPeerId>& peers)
{ {
// This function has two effects: // This function has two effects:
// - return the virtual peers for this group // - return the virtual peers for this group
@ -223,17 +222,16 @@ bool RsGxsNetTunnelService::getVirtualPeers(uint16_t service_id, std::list<RsGxs
// update the hash entry if needed // update the hash entry if needed
for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it)
if(it->second.providing_set.find(service_id) != it->second.providing_set.end())
peers.push_back(it->first) ; peers.push_back(it->first) ;
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " service " << std::hex << service_id << std::dec << " returning " << peers.size() << " peers." << std::endl; GXS_NET_TUNNEL_DEBUG() << " returning " << peers.size() << " peers." << std::endl;
#endif #endif
return true ; return true ;
} }
bool RsGxsNetTunnelService::requestDistantPeers(uint16_t service_id,const RsGxsGroupId& group_id) bool RsGxsNetTunnelService::requestDistantPeers(const RsGxsGroupId& group_id)
{ {
RS_STACK_MUTEX(mGxsNetTunnelMtx); RS_STACK_MUTEX(mGxsNetTunnelMtx);
@ -243,19 +241,18 @@ bool RsGxsNetTunnelService::requestDistantPeers(uint16_t service_id,const RsGxsG
ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE; ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE;
ginfo.hash = calculateGroupHash(group_id) ; ginfo.hash = calculateGroupHash(group_id) ;
ginfo.service_id = service_id;
mHandledHashes[ginfo.hash] = group_id ; mHandledHashes[ginfo.hash] = group_id ;
// we dont set the group policy here. It will only be set if no peers, or too few peers are available. // we dont set the group policy here. It will only be set if no peers, or too few peers are available.
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " service " << std::hex << service_id << std::dec << " requesting peers for group " << group_id << std::endl; GXS_NET_TUNNEL_DEBUG() << " requesting peers for group " << group_id << std::endl;
#endif #endif
return true; return true;
} }
bool RsGxsNetTunnelService::releaseDistantPeers(uint16_t service_id, const RsGxsGroupId& group_id) bool RsGxsNetTunnelService::releaseDistantPeers(const RsGxsGroupId& group_id)
{ {
RS_STACK_MUTEX(mGxsNetTunnelMtx); RS_STACK_MUTEX(mGxsNetTunnelMtx);
@ -265,33 +262,31 @@ bool RsGxsNetTunnelService::releaseDistantPeers(uint16_t service_id, const RsGxs
ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE; ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE;
ginfo.hash = calculateGroupHash(group_id) ; ginfo.hash = calculateGroupHash(group_id) ;
ginfo.service_id = service_id;
mHandledHashes[ginfo.hash] = group_id ; // yes, we do not remove, because we're supposed to answer tunnel requests from other peers. mHandledHashes[ginfo.hash] = group_id ; // yes, we do not remove, because we're supposed to answer tunnel requests from other peers.
mTurtle->stopMonitoringTunnels(ginfo.hash) ; mTurtle->stopMonitoringTunnels(ginfo.hash) ;
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " service " << std::hex << service_id << std::dec << " releasing peers for group " << group_id << std::endl; GXS_NET_TUNNEL_DEBUG() << " releasing peers for group " << group_id << std::endl;
#endif #endif
return true; return true;
} }
RsGxsNetTunnelVirtualPeerId RsGxsNetTunnelService::locked_makeVirtualPeerId() const RsGxsNetTunnelVirtualPeerId RsGxsNetTunnelService::locked_makeVirtualPeerId(const RsGxsGroupId& group_id) const
{ {
assert(RsPeerId::SIZE_IN_BYTES <= Sha1CheckSum::SIZE_IN_BYTES) ; assert(RsPeerId::SIZE_IN_BYTES <= Sha1CheckSum::SIZE_IN_BYTES) ;// so that we can build the virtual PeerId from a SHA1 sum.
// We compute sha1( SSL_id | mRandomBias ) and trunk it to 16 bytes in order to compute a RsPeerId // We compute sha1( SSL_id | mRandomBias ) and trunk it to 16 bytes in order to compute a RsPeerId
RsPeerId ssl_id = rsPeers->getOwnId() ; RsPeerId ssl_id = rsPeers->getOwnId() ;
unsigned char mem[RsPeerId::SIZE_IN_BYTES /*+ RsGxsGroupId::SIZE_IN_BYTES */ + RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE]; unsigned char mem[RsGxsGroupId::SIZE_IN_BYTES + RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE];
memcpy(mem ,ssl_id.toByteArray() ,RsPeerId::SIZE_IN_BYTES) ; memcpy(mem ,group_id.toByteArray(),RsGxsGroupId::SIZE_IN_BYTES) ;
//memcpy(mem+RsPeerId::SIZE_IN_BYTES ,group_id.toByteArray(),RsGxsGroupId::SIZE_IN_BYTES) ; memcpy(mem+RsGxsGroupId::SIZE_IN_BYTES,mRandomBias ,RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE) ;
memcpy(mem+RsPeerId::SIZE_IN_BYTES /*+RsGxsGroupId::SIZE_IN_BYTES*/,mRandomBias ,RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE) ;
return RsGxsNetTunnelVirtualPeerId(RsDirUtil::sha1sum(mem,RsPeerId::SIZE_IN_BYTES+/*RsGxsGroupId::SIZE_IN_BYTES+*/ RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE).toByteArray()); return RsGxsNetTunnelVirtualPeerId(RsDirUtil::sha1sum(mem,RsGxsGroupId::SIZE_IN_BYTES+RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE).toByteArray());
} }
void RsGxsNetTunnelService::dump() const void RsGxsNetTunnelService::dump() const
@ -331,15 +326,13 @@ void RsGxsNetTunnelService::dump() const
std::cerr << "Virtual peers: " << std::endl; std::cerr << "Virtual peers: " << std::endl;
for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it)
{
std::cerr << " GXS Peer:" << it->first << " Turtle:" << it->second.turtle_virtual_peer_id std::cerr << " GXS Peer:" << it->first << " Turtle:" << it->second.turtle_virtual_peer_id
<< " status: " << vpid_status_str[it->second.vpid_status] << " direction: " << " status: " << vpid_status_str[it->second.vpid_status] << " direction: "
<< (int)it->second.side << " last seen " << time(NULL)-it->second.last_contact << " group_id: " << it->second.group_id
<< " direction: " << (int)it->second.side
<< " last seen " << time(NULL)-it->second.last_contact
<< " ekey: " << RsUtil::BinToHex(it->second.encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE,10) << std::endl; << " ekey: " << RsUtil::BinToHex(it->second.encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE,10) << std::endl;
for(auto it2(it->second.providing_set.begin());it2!=it->second.providing_set.end();++it2)
std::cerr << " service " << std::hex << it2->first << std::dec << " " << it2->second.provided_groups.size() << " groups" << std::endl;
}
std::cerr << "Virtual peer turtle => GXS conversion table: " << std::endl; std::cerr << "Virtual peer turtle => GXS conversion table: " << std::endl;
for(auto it(mTurtle2GxsPeer.begin());it!=mTurtle2GxsPeer.end();++it) for(auto it(mTurtle2GxsPeer.begin());it!=mTurtle2GxsPeer.end();++it)
std::cerr << " " << it->first << " => " << it->second << std::endl; std::cerr << " " << it->first << " => " << it->second << std::endl;
@ -350,8 +343,7 @@ void RsGxsNetTunnelService::dump() const
std::cerr << "Incoming data: " << std::endl; std::cerr << "Incoming data: " << std::endl;
for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it) for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it)
for(auto it2(it->second.begin());it2!=it->second.end();++it2) std::cerr << " peer id " << it->first << " " << (void*)it->second << std::endl;
std::cerr << " service " << std::hex << it->first << std::dec << " peer id " << it2->first << " " << (void*)it2->second << std::endl;
} }
//===========================================================================================================================================// //===========================================================================================================================================//
@ -428,12 +420,9 @@ void RsGxsNetTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *item,co
return ; return ;
} }
uint16_t service_id = mGroups[group_id].service_id ;
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " item is a virtual peer id item with vpid = "<< pid_item->virtual_peer_id GXS_NET_TUNNEL_DEBUG() << " item is a virtual peer id item with vpid = "<< pid_item->virtual_peer_id
<< " for group " << group_id << " in service " << std::hex << service_id << std::dec << " for group " << group_id << ". Setting virtual peer." << std::endl;
<< ". Setting virtual peer." << std::endl;
#endif #endif
// we receive a virtual peer id, so we need to update the local information for this peer id // we receive a virtual peer id, so we need to update the local information for this peer id
@ -444,7 +433,7 @@ void RsGxsNetTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *item,co
vp_info.vpid_status = RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE ; // status of the peer vp_info.vpid_status = RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE ; // status of the peer
vp_info.side = direction; // client/server vp_info.side = direction; // client/server
vp_info.last_contact = time(NULL); // last time some data was sent/recvd vp_info.last_contact = time(NULL); // last time some data was sent/recvd
vp_info.providing_set[service_id].provided_groups.insert(group_id); vp_info.group_id = group_id;
memcpy(vp_info.encryption_master_key,encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE); memcpy(vp_info.encryption_master_key,encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE);
@ -476,20 +465,18 @@ void RsGxsNetTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *item,co
return; return;
} }
uint16_t service_id = getRsItemService(getRsItemId(data)) ;
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << "item contains generic data for service " << std::hex << service_id << std::dec << " for VPID " << gxs_vpid << ". Storing in incoming list" << std::endl; GXS_NET_TUNNEL_DEBUG() << "item contains generic data for VPID " << gxs_vpid << ". Storing in incoming list" << std::endl;
#endif #endif
// push the data into the service incoming data list // push the data into the incoming data list
RsTlvBinaryData *bind = new RsTlvBinaryData; RsTlvBinaryData *bind = new RsTlvBinaryData;
bind->tlvtype = 0; bind->tlvtype = 0;
bind->bin_len = data_size; bind->bin_len = data_size;
bind->bin_data = data; bind->bin_data = data;
mIncomingData[service_id].push_back(std::make_pair(gxs_vpid,bind)) ; mIncomingData.push_back(std::make_pair(gxs_vpid,bind)) ;
} }
} }
@ -520,7 +507,7 @@ void RsGxsNetTunnelService::addVirtualPeer(const TurtleFileHash& hash, const Tur
// We need to send our own virtual peer id to the other end of the tunnel // We need to send our own virtual peer id to the other end of the tunnel
RsGxsNetTunnelVirtualPeerId net_service_virtual_peer = locked_makeVirtualPeerId(); RsGxsNetTunnelVirtualPeerId net_service_virtual_peer = locked_makeVirtualPeerId(group_id);
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " sending back virtual peer name " << net_service_virtual_peer << " to end of tunnel" << std::endl; GXS_NET_TUNNEL_DEBUG() << " sending back virtual peer name " << net_service_virtual_peer << " to end of tunnel" << std::endl;
@ -632,16 +619,17 @@ void RsGxsNetTunnelService::data_tick()
void RsGxsNetTunnelService::sendKeepAlivePackets() void RsGxsNetTunnelService::sendKeepAlivePackets()
{ {
RS_STACK_MUTEX(mGxsNetTunnelMtx); RS_STACK_MUTEX(mGxsNetTunnelMtx);
RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId() ;
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " sending keep-alive packets. Own GXS peer ID is " << own_gxs_vpid << std::endl; GXS_NET_TUNNEL_DEBUG() << " sending keep-alive packets. " << std::endl;
#endif #endif
// We send KA packets for each GXS virtual peer. The advantage is that unused tunnels will automatically die which eliminates duplicate tunnels // We send KA packets for each GXS virtual peer. The advantage is that unused tunnels will automatically die which eliminates duplicate tunnels
// automatically. We only send from the client side. // automatically. We only send from the client side.
for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it)
{
RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId(it->second.group_id) ;
if(own_gxs_vpid < it->first) if(own_gxs_vpid < it->first)
{ {
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
@ -662,6 +650,7 @@ void RsGxsNetTunnelService::sendKeepAlivePackets()
else else
GXS_NET_TUNNEL_DEBUG() << " ignoring virtual peer " << it->first << std::endl; GXS_NET_TUNNEL_DEBUG() << " ignoring virtual peer " << it->first << std::endl;
#endif #endif
}
} }
void RsGxsNetTunnelService::autowash() void RsGxsNetTunnelService::autowash()
@ -671,10 +660,9 @@ void RsGxsNetTunnelService::autowash()
#ifdef DEBUG_RSGXSNETTUNNEL #ifdef DEBUG_RSGXSNETTUNNEL
GXS_NET_TUNNEL_DEBUG() << " performing per-group consistency test." << std::endl; GXS_NET_TUNNEL_DEBUG() << " performing per-group consistency test." << std::endl;
#endif #endif
RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId() ;
for(auto it(mGroups.begin());it!=mGroups.end();++it) for(auto it(mGroups.begin());it!=mGroups.end();++it)
{ {
RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId(it->first) ;
RsGxsNetTunnelGroupInfo& ginfo(it->second) ; RsGxsNetTunnelGroupInfo& ginfo(it->second) ;
bool should_monitor_tunnels = false ; bool should_monitor_tunnels = false ;

View File

@ -100,11 +100,6 @@ typedef RsPeerId RsGxsNetTunnelVirtualPeerId ;
class RsGxsNetTunnelItem ; class RsGxsNetTunnelItem ;
struct RsGxsNetTunnelVirtualPeerProvidingSet
{
std::set<RsGxsGroupId> provided_groups ;
};
struct RsGxsNetTunnelVirtualPeerInfo struct RsGxsNetTunnelVirtualPeerInfo
{ {
enum { RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN = 0x00, // unknown status. enum { RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN = 0x00, // unknown status.
@ -122,7 +117,7 @@ struct RsGxsNetTunnelVirtualPeerInfo
TurtleVirtualPeerId turtle_virtual_peer_id ; // turtle peer to use when sending data to this vpid. TurtleVirtualPeerId turtle_virtual_peer_id ; // turtle peer to use when sending data to this vpid.
std::map<uint16_t,RsGxsNetTunnelVirtualPeerProvidingSet> providing_set; // partial list of groups provided by this virtual peer id, based on tunnel results, for each service RsGxsGroupId group_id ; // group that virtual peer is providing
}; };
struct RsGxsNetTunnelGroupInfo struct RsGxsNetTunnelGroupInfo
@ -140,13 +135,12 @@ struct RsGxsNetTunnelGroupInfo
RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE = 0x02, // group will explicitely request tunnels, if none available RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE = 0x02, // group will explicitely request tunnels, if none available
}; };
RsGxsNetTunnelGroupInfo() : group_policy(RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE),group_status(RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE),last_contact(0),service_id(0) {} RsGxsNetTunnelGroupInfo() : group_policy(RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE),group_status(RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE),last_contact(0) {}
GroupPolicy group_policy ; GroupPolicy group_policy ;
GroupStatus group_status ; GroupStatus group_status ;
time_t last_contact ; time_t last_contact ;
TurtleFileHash hash ; TurtleFileHash hash ;
uint16_t service_id ;
std::set<TurtleVirtualPeerId> virtual_peers ; // list of which virtual peers provide this group. Can me more than 1. std::set<TurtleVirtualPeerId> virtual_peers ; // list of which virtual peers provide this group. Can me more than 1.
}; };
@ -161,19 +155,19 @@ public:
* \brief Manage tunnels for this group * \brief Manage tunnels for this group
* @param group_id group for which tunnels should be released * @param group_id group for which tunnels should be released
*/ */
bool requestDistantPeers(uint16_t service_id, const RsGxsGroupId&group_id) ; bool requestDistantPeers(const RsGxsGroupId&group_id) ;
/*! /*!
* \brief Stop managing tunnels for this group * \brief Stop managing tunnels for this group
* @param group_id group for which tunnels should be released * @param group_id group for which tunnels should be released
*/ */
bool releaseDistantPeers(uint16_t service_id,const RsGxsGroupId&group_id) ; bool releaseDistantPeers(const RsGxsGroupId&group_id) ;
/*! /*!
* \brief Get the list of active virtual peers for a given group. This implies that a tunnel is up and * \brief Get the list of active virtual peers for a given group. This implies that a tunnel is up and
* alive. This function also "registers" the group which allows to handle tunnel requests in the server side. * alive. This function also "registers" the group which allows to handle tunnel requests in the server side.
*/ */
bool getVirtualPeers(uint16_t service_id, std::list<RsGxsNetTunnelVirtualPeerId>& peers) ; // returns the virtual peers for this group bool getVirtualPeers(std::list<RsGxsNetTunnelVirtualPeerId>& peers) ; // returns the virtual peers for this group
/*! /*!
* \brief sendData * \brief sendData
@ -187,15 +181,14 @@ public:
/*! /*!
* \brief receiveData * \brief receiveData
* returns the next piece of data received fro the given service, and the virtual GXS peer that sended it. * returns the next piece of data received, and the virtual GXS peer that sended it.
* \param service_id service that provide the data
* \param data memory check containing the data. Memory ownership belongs to the client. * \param data memory check containing the data. Memory ownership belongs to the client.
* \param data_len length of memory chunk * \param data_len length of memory chunk
* \param virtual_peer peer who sent the data * \param virtual_peer peer who sent the data
* \return * \return
* true if something is returned. If not, data is set to NULL, data_len to 0. * true if something is returned. If not, data is set to NULL, data_len to 0.
*/ */
bool receiveTunnelData(uint16_t service_id,unsigned char *& data,uint32_t& data_len,RsGxsNetTunnelVirtualPeerId& virtual_peer) ; bool receiveTunnelData(unsigned char *& data, uint32_t& data_len, RsGxsNetTunnelVirtualPeerId& virtual_peer) ;
/*! /*!
* \brief isDistantPeer * \brief isDistantPeer
@ -247,7 +240,7 @@ private:
std::list<std::pair<TurtleVirtualPeerId,RsTurtleGenericDataItem*> > mPendingTurtleItems ; // items that need to be sent off-turtle Mutex. std::list<std::pair<TurtleVirtualPeerId,RsTurtleGenericDataItem*> > mPendingTurtleItems ; // items that need to be sent off-turtle Mutex.
std::map<uint16_t,std::list<std::pair<RsGxsNetTunnelVirtualPeerId,RsTlvBinaryData *> > > mIncomingData; // list of incoming data items, per service. std::list<std::pair<RsGxsNetTunnelVirtualPeerId,RsTlvBinaryData *> > mIncomingData; // list of incoming data items
/*! /*!
* \brief Generates the hash to request tunnels for this group. This hash is only used by turtle, and is used to * \brief Generates the hash to request tunnels for this group. This hash is only used by turtle, and is used to
@ -261,7 +254,7 @@ private:
* tunnel ID and turtle virtual peer id. This allows RsGxsNetService to keep sync-ing the data consistently. * tunnel ID and turtle virtual peer id. This allows RsGxsNetService to keep sync-ing the data consistently.
*/ */
RsGxsNetTunnelVirtualPeerId locked_makeVirtualPeerId() const ; RsGxsNetTunnelVirtualPeerId locked_makeVirtualPeerId(const RsGxsGroupId& group_id) const ;
static void generateEncryptionKey(const RsGxsGroupId& group_id,const TurtleVirtualPeerId& vpid,unsigned char key[RS_GXS_TUNNEL_CONST_EKEY_SIZE]) ; static void generateEncryptionKey(const RsGxsGroupId& group_id,const TurtleVirtualPeerId& vpid,unsigned char key[RS_GXS_TUNNEL_CONST_EKEY_SIZE]) ;