2013-11-02 10:35:33 -04:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: rsgrouter.h
|
|
|
|
*
|
|
|
|
* Services for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2013 by Cyril Soler
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "csoler@users.sourceforge.net".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util/rsdir.h"
|
2014-03-29 10:18:05 -04:00
|
|
|
#include "retroshare/rsids.h"
|
|
|
|
|
|
|
|
typedef GRouterKeyIdType GRouterKeyId ; // we use SSLIds, so that it's easier in the GUI to mix up peer ids with grouter ids.
|
2014-04-12 15:58:45 -04:00
|
|
|
typedef uint32_t GRouterServiceId ;
|
|
|
|
typedef uint64_t GRouterMsgPropagationId ;
|
2013-11-02 10:35:33 -04:00
|
|
|
|
|
|
|
class GRouterClientService ;
|
2013-12-24 11:41:07 -05:00
|
|
|
class RsGRouterGenericDataItem ;
|
2013-11-02 10:35:33 -04:00
|
|
|
|
2014-03-29 10:18:05 -04:00
|
|
|
class RsGRouter
|
2013-11-02 10:35:33 -04:00
|
|
|
{
|
2014-03-29 10:18:05 -04:00
|
|
|
public:
|
|
|
|
// This is the interface file for the global router service.
|
|
|
|
//
|
|
|
|
struct GRouterRoutingCacheInfo
|
|
|
|
{
|
|
|
|
GRouterMsgPropagationId mid ;
|
|
|
|
RsPeerId local_origin;
|
|
|
|
GRouterKeyId destination ;
|
|
|
|
time_t time_stamp ;
|
|
|
|
uint32_t status ;
|
|
|
|
uint32_t data_size ;
|
|
|
|
};
|
2013-11-02 10:35:33 -04:00
|
|
|
|
2014-03-29 10:18:05 -04:00
|
|
|
struct GRouterPublishedKeyInfo
|
|
|
|
{
|
|
|
|
std::string description_string ;
|
|
|
|
uint32_t service_id ;
|
|
|
|
};
|
2013-11-02 10:35:33 -04:00
|
|
|
|
2014-03-29 10:18:05 -04:00
|
|
|
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
|
|
|
|
//
|
|
|
|
std::map<GRouterKeyId,GRouterPublishedKeyInfo> published_keys ;
|
|
|
|
};
|
2013-11-02 10:35:33 -04:00
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// Debugging info //
|
|
|
|
//===================================================//
|
|
|
|
|
2014-04-07 17:36:43 -04:00
|
|
|
virtual bool getRoutingCacheInfo(std::vector<GRouterRoutingCacheInfo>& infos) =0;
|
|
|
|
virtual bool getRoutingMatrixInfo(GRouterRoutingMatrixInfo& info) =0;
|
2013-11-02 10:35:33 -04:00
|
|
|
|
|
|
|
// retrieve the routing probabilities
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// Communication to other services. //
|
|
|
|
//===================================================//
|
|
|
|
|
2013-12-24 11:41:07 -05:00
|
|
|
virtual void sendData(const GRouterKeyId& destination, RsGRouterGenericDataItem *item) =0;
|
2014-03-29 10:18:05 -04:00
|
|
|
virtual bool registerKey(const GRouterKeyId& key,const GRouterServiceId& client_id,const std::string& description_string) =0;
|
2013-11-02 10:35:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// To access the GRouter from anywhere
|
|
|
|
//
|
|
|
|
extern RsGRouter *rsGRouter ;
|