2018-11-10 14:45:05 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/retroshare: rsgrouter.h *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
2018-11-11 20:42:48 +01:00
|
|
|
* Copyright 2013 by Cyril Soler <retroshare.project@gmail.com> *
|
2018-11-10 14:45:05 +01:00
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2013-11-02 14:35:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util/rsdir.h"
|
2020-01-04 20:39:43 +01:00
|
|
|
#include "util/rsdeprecate.h"
|
2014-03-29 14:18:05 +00:00
|
|
|
#include "retroshare/rsids.h"
|
2015-01-11 22:18:28 +00:00
|
|
|
#include "retroshare/rsgxsifacetypes.h"
|
2020-01-04 20:39:43 +01:00
|
|
|
#include "rsitems/rsserviceids.h"
|
2014-03-29 14:18:05 +00:00
|
|
|
|
2015-01-11 22:18:28 +00:00
|
|
|
typedef RsGxsId GRouterKeyId ; // we use SSLIds, so that it's easier in the GUI to mix up peer ids with grouter ids.
|
2014-04-12 19:58:45 +00:00
|
|
|
typedef uint32_t GRouterServiceId ;
|
|
|
|
typedef uint64_t GRouterMsgPropagationId ;
|
2013-11-02 14:35:33 +00:00
|
|
|
|
|
|
|
class GRouterClientService ;
|
2013-12-24 16:41:07 +00:00
|
|
|
class RsGRouterGenericDataItem ;
|
2013-11-02 14:35:33 +00:00
|
|
|
|
2014-03-29 14:18:05 +00:00
|
|
|
class RsGRouter
|
2013-11-02 14:35:33 +00:00
|
|
|
{
|
2015-01-22 14:33:19 +00:00
|
|
|
public:
|
|
|
|
// This is the interface file for the global router service.
|
|
|
|
//
|
|
|
|
struct GRouterRoutingCacheInfo
|
|
|
|
{
|
|
|
|
GRouterMsgPropagationId mid ;
|
2015-04-18 19:59:27 +00:00
|
|
|
std::set<RsPeerId> local_origin;
|
2015-01-22 14:33:19 +00:00
|
|
|
GRouterKeyId destination ;
|
2018-10-07 01:34:05 +02:00
|
|
|
rstime_t routing_time;
|
|
|
|
rstime_t last_tunnel_attempt_time;
|
|
|
|
rstime_t last_sent_time;
|
2015-01-23 12:13:13 +00:00
|
|
|
bool receipt_available ;
|
2016-01-30 20:27:56 -05:00
|
|
|
uint32_t duplication_factor ;
|
2015-01-23 12:13:13 +00:00
|
|
|
uint32_t data_status ;
|
|
|
|
uint32_t tunnel_status ;
|
2015-01-22 14:33:19 +00:00
|
|
|
uint32_t data_size ;
|
2015-04-18 19:59:27 +00:00
|
|
|
Sha1CheckSum item_hash ;
|
2015-01-22 14:33:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GRouterPublishedKeyInfo
|
|
|
|
{
|
|
|
|
std::string description_string ;
|
|
|
|
RsGxsId authentication_key ;
|
|
|
|
uint32_t service_id ;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GRouterRoutingMatrixInfo
|
|
|
|
{
|
|
|
|
// Probabilities of reaching a given key for each friend.
|
|
|
|
// This concerns all known keys.
|
|
|
|
//
|
|
|
|
std::map<GRouterKeyId, std::vector<float> > per_friend_probabilities ;
|
|
|
|
|
|
|
|
// List of friend ids in the same order. Should roughly correspond to the friends that are currently online.
|
|
|
|
//
|
|
|
|
std::vector<RsPeerId> friend_ids ;
|
|
|
|
|
|
|
|
// List of own published keys, with associated service ID
|
|
|
|
//
|
2015-01-23 12:13:13 +00:00
|
|
|
std::map<Sha1CheckSum,GRouterPublishedKeyInfo> published_keys ;
|
2015-01-22 14:33:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// Debugging info //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
virtual bool getRoutingCacheInfo(std::vector<GRouterRoutingCacheInfo>& infos) =0;
|
|
|
|
virtual bool getRoutingMatrixInfo(GRouterRoutingMatrixInfo& info) =0;
|
|
|
|
|
|
|
|
// retrieve the routing probabilities
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// Communication to other services. //
|
|
|
|
//===================================================//
|
|
|
|
|
2015-01-23 15:16:04 +00:00
|
|
|
virtual bool sendData(const RsGxsId& destination, const GRouterServiceId& client_id, const uint8_t *data, uint32_t data_size, const RsGxsId& signing_id, GRouterMsgPropagationId& id) =0;
|
2015-01-22 14:33:19 +00:00
|
|
|
virtual bool cancel(GRouterMsgPropagationId mid) =0;
|
|
|
|
|
|
|
|
virtual bool registerKey(const RsGxsId& authentication_id, const GRouterServiceId& client_id,const std::string& description_string)=0 ;
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// Routage feedback from other services //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
virtual void addRoutingClue(const GRouterKeyId& destination, const RsPeerId& source) =0;
|
2013-11-02 14:35:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// To access the GRouter from anywhere
|
|
|
|
//
|
|
|
|
extern RsGRouter *rsGRouter ;
|