Changes to integrate bitdht into libretroshare.

Mainly re-organising tcponudp... 
	tests->test area
	network->trash (uses libbitdht classes).
	new udp interfaces (udppeer + udpstunner)

Changes include:
	* p3bitdht: added "addReceiver() call, and more debugging. 
	* p3bitdht: added DO_IDLE flag so searches are continous.
	* p3bitdht/pqiassist: matched up Assist interface.
	* fixed pqiNetListener interface.
	* rsinit/p3connmgr: setup udp init
	* tcpstream: switched to new udp receiver.
	* added "blogs" switch in libretroshare.pro (was stopping compiling ;)
	* added "bitdht" switch in libretroshare.pro 



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3323 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-07-31 18:14:10 +00:00
parent c1b624832f
commit fcdd7ee113
34 changed files with 627 additions and 1770 deletions

View file

@ -430,6 +430,10 @@ void p3ConnectMgr::netReset()
* NB: (*it)->reset_listener must be out of the mutex,
* as it calls back to p3ConnMgr.
*/
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
struct sockaddr_in iaddr = mOwnState.currentlocaladdr;
#ifdef CONN_DEBUG_RESET
std::cerr << "p3ConnectMgr::netReset() resetting listeners" << std::endl;
@ -437,7 +441,7 @@ void p3ConnectMgr::netReset()
std::list<pqiNetListener *>::const_iterator it;
for(it = mNetListeners.begin(); it != mNetListeners.end(); it++)
{
(*it)->reset_listener();
(*it)->resetListener(iaddr);
#ifdef CONN_DEBUG_RESET
std::cerr << "p3ConnectMgr::netReset() reset listener" << std::endl;
#endif
@ -741,8 +745,10 @@ void p3ConnectMgr::netTick()
void p3ConnectMgr::netUdpInit()
{
// All functionality has been moved elsewhere (pqiNetListener interface)
#if 0
#if defined(CONN_DEBUG_RESET)
std::cerr << "p3ConnectMgr::netUdpInit()" << std::endl;
std::cerr << "p3ConnectMgr::netUdpInit() Does nothing!" << std::endl;
#endif
connMtx.lock(); /* LOCK MUTEX */
@ -750,8 +756,12 @@ void p3ConnectMgr::netUdpInit()
connMtx.unlock(); /* UNLOCK MUTEX */
/* udp port now controlled by udpstack (from libbitdht) */
mUdpStack->resetAddress(iaddr);
/* open our udp port */
tou_init((struct sockaddr *) &iaddr, sizeof(iaddr));
#endif
}
@ -3349,11 +3359,13 @@ bool p3ConnectMgr::netAssistSetAddress( struct sockaddr_in &laddr,
struct sockaddr_in &eaddr,
uint32_t mode)
{
#if 0
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
for(it = mDhts.begin(); it != mDhts.end(); it++)
{
(it->second)->setExternalInterface(laddr, eaddr, mode);
}
#endif
return true;
}

View file

@ -94,28 +94,33 @@ class pqiNetAssistConnect: public pqiNetAssist
* for the DHT, and must be non-blocking and return quickly
*/
#if 0
virtual void setBootstrapAllowed(bool on) = 0;
virtual bool getBootstrapAllowed() = 0;
/* set key data */
virtual bool setExternalInterface(struct sockaddr_in laddr,
struct sockaddr_in raddr, uint32_t type) = 0;
#endif
/* add / remove peers */
virtual bool findPeer(std::string id) = 0;
virtual bool dropPeer(std::string id) = 0;
/* post DHT key saying we should connect (callback when done) */
virtual bool notifyPeer(std::string id) = 0;
/* extract current peer status */
virtual bool getPeerStatus(std::string id,
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
uint32_t &type, uint32_t &mode) = 0;
#if 0
/* post DHT key saying we should connect (callback when done) */
virtual bool notifyPeer(std::string id) = 0;
/* stun */
virtual bool enableStun(bool on) = 0;
virtual bool addStun(std::string id) = 0;
#endif
protected:
std::string mPeerId;

View file

@ -138,7 +138,7 @@ virtual void peerConnectRequest(std::string id,
class pqiNetListener
{
public:
virtual int reset_listener() = 0;
virtual bool resetListener(struct sockaddr_in &local) = 0;
};

View file

@ -184,38 +184,30 @@ int pqipersongrp::init_listener()
return 1;
}
int pqipersongrp::restart_listener()
bool pqipersongrp::resetListener(struct sockaddr_in &local)
{
#ifdef PGRP_DEBUG
std::cerr << "pqipersongrp::restart_listener()" << std::endl;
std::cerr << "pqipersongrp::resetListener()" << std::endl;
#endif
// stop it,
// change the address.
// restart.
bool haveListener = false;
{ RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
haveListener = (pqil != NULL);
} /* UNLOCKED */
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
if (haveListener)
if (pqil != NULL)
{
#ifdef PGRP_DEBUG
std::cerr << "pqipersongrp::restart_listener() haveListener" << std::endl;
std::cerr << "pqipersongrp::resetListener() haveListener" << std::endl;
#endif
peerConnectState state;
mConnMgr->getOwnNetStatus(state);
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
pqil -> resetlisten();
pqil -> setListenAddr(state.currentlocaladdr);
pqil -> setListenAddr(local);
pqil -> setuplisten();
#ifdef PGRP_DEBUG
std::cerr << "pqipersongrp::restart_listener() done!" << std::endl;
std::cerr << "pqipersongrp::resetListener() done!" << std::endl;
#endif
}

View file

@ -54,9 +54,8 @@ class pqipersongrp: public pqihandler, public pqiMonitor, public p3ServiceServer
/*************************** Setup *************************/
/* pqilistener */
virtual int reset_listener() { return restart_listener(); }
virtual bool resetListener(struct sockaddr_in &local); // overloaded from pqiNetListener
int init_listener();
int restart_listener();
int setConfig(p3GeneralConfig *cfg);
int save_config();