mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Changes required to get Retroshare V0.4 working under windows.
Most of these changes relate to: (1) rand() is different (2) sleep() don't exist on Windows. (3) networking headers are different - these need to be cleaned up in general. (4) disabled tests that won't compile on Windows. Will probably have to rollback some of these changes for Unix later. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@372 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9e954e9c0f
commit
9bdd44d0f5
@ -24,11 +24,14 @@
|
|||||||
#ifndef MRK_CACHE_STRAPPER_H
|
#ifndef MRK_CACHE_STRAPPER_H
|
||||||
#define MRK_CACHE_STRAPPER_H
|
#define MRK_CACHE_STRAPPER_H
|
||||||
|
|
||||||
|
#include "pqi/p3cfgmgr.h"
|
||||||
|
#include "pqi/pqimonitor.h"
|
||||||
|
#include "util/rsthreads.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "util/rsthreads.h"
|
|
||||||
|
|
||||||
/******************* CacheStrapper and Related Classes *******************
|
/******************* CacheStrapper and Related Classes *******************
|
||||||
* A generic Cache Update system.
|
* A generic Cache Update system.
|
||||||
@ -268,8 +271,6 @@ class CachePair
|
|||||||
|
|
||||||
bool operator<(const CachePair &a, const CachePair &b);
|
bool operator<(const CachePair &a, const CachePair &b);
|
||||||
|
|
||||||
#include "pqi/pqimonitor.h"
|
|
||||||
#include "pqi/p3cfgmgr.h"
|
|
||||||
|
|
||||||
class p3AuthMgr;
|
class p3AuthMgr;
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#ifndef FILE_INDEX_MONITOR_H
|
#ifndef FILE_INDEX_MONITOR_H
|
||||||
#define FILE_INDEX_MONITOR_H
|
#define FILE_INDEX_MONITOR_H
|
||||||
|
|
||||||
#include "dbase/findex.h"
|
|
||||||
#include "dbase/cachestrapper.h"
|
#include "dbase/cachestrapper.h"
|
||||||
|
#include "dbase/findex.h"
|
||||||
#include "util/rsthreads.h"
|
#include "util/rsthreads.h"
|
||||||
|
|
||||||
/******************************************************************************************
|
/******************************************************************************************
|
||||||
|
@ -17,16 +17,16 @@ all: librs tests
|
|||||||
|
|
||||||
#dhttest is OLD
|
#dhttest is OLD
|
||||||
dhttest: $(OBJ) dhttest.o
|
dhttest: $(OBJ) dhttest.o
|
||||||
$(CC) $(CFLAGS) -o dhttest $(OBJ) dhttest.o $(RSLIBS)
|
$(CC) $(CFLAGS) -o dhttest $(OBJ) dhttest.o $(LIBS)
|
||||||
|
|
||||||
odhtpost_test: $(OBJ) odhtpost_test.o
|
odhtpost_test: $(OBJ) odhtpost_test.o
|
||||||
$(CC) $(CFLAGS) -o odhtpost_test $(OBJ) odhtpost_test.o $(RSLIBS)
|
$(CC) $(CFLAGS) -o odhtpost_test $(OBJ) odhtpost_test.o $(LIBS)
|
||||||
|
|
||||||
odhtstr_test: $(OBJ) odhtstr_test.o
|
odhtstr_test: $(OBJ) odhtstr_test.o
|
||||||
$(CC) $(CFLAGS) -o odhtstr_test $(OBJ) odhtstr_test.o $(RSLIBS)
|
$(CC) $(CFLAGS) -o odhtstr_test $(OBJ) odhtstr_test.o $(LIBS)
|
||||||
|
|
||||||
odhtmgr_test: $(OBJ) odhtmgr_test.o
|
odhtmgr_test: $(OBJ) odhtmgr_test.o
|
||||||
$(CC) $(CFLAGS) -o odhtmgr_test $(OBJ) odhtmgr_test.o $(RSLIBS)
|
$(CC) $(CFLAGS) -o odhtmgr_test $(OBJ) odhtmgr_test.o $(LIBS)
|
||||||
|
|
||||||
# Extra Rule...
|
# Extra Rule...
|
||||||
.c.o:
|
.c.o:
|
||||||
|
@ -27,17 +27,18 @@
|
|||||||
|
|
||||||
/***** Test for the new DHT system *****/
|
/***** Test for the new DHT system *****/
|
||||||
|
|
||||||
|
#include "pqi/p3dhtmgr.h"
|
||||||
|
#include "pqi/pqimonitor.h"
|
||||||
|
#include "dht/opendhtmgr.h"
|
||||||
|
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
#include "util/rsthreads.h"
|
#include "util/rsthreads.h"
|
||||||
#include "util/rsprint.h"
|
#include "util/rsprint.h"
|
||||||
|
|
||||||
#include "pqi/p3dhtmgr.h"
|
|
||||||
#include "pqi/pqimonitor.h"
|
|
||||||
#include "dht/opendhtmgr.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
void usage(char *name)
|
void usage(char *name)
|
||||||
{
|
{
|
||||||
@ -87,7 +88,14 @@ int main(int argc, char **argv)
|
|||||||
dhtTester.start();
|
dhtTester.start();
|
||||||
|
|
||||||
/* wait for a little before switching on */
|
/* wait for a little before switching on */
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
|
|
||||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||||
dhtTester.setDhtOn(true);
|
dhtTester.setDhtOn(true);
|
||||||
@ -104,7 +112,13 @@ int main(int argc, char **argv)
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
std::cerr << "Main waiting..." << std::endl;
|
std::cerr << "Main waiting..." << std::endl;
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
#else
|
||||||
|
Sleep(3000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
if (!haveOwnAddress)
|
if (!haveOwnAddress)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,13 @@ int main()
|
|||||||
|
|
||||||
dht.publishKey(key, value, ttl);
|
dht.publishKey(key, value, ttl);
|
||||||
|
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(10);
|
sleep(10);
|
||||||
|
#else
|
||||||
|
Sleep(10000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
std::list<std::string> values;
|
std::list<std::string> values;
|
||||||
dht.searchKey(key, values);
|
dht.searchKey(key, values);
|
||||||
|
@ -29,15 +29,17 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
#include "util/rsprint.h"
|
#include "util/rsprint.h"
|
||||||
|
|
||||||
const std::string openDHT_Client = "Retroshare V0.4";
|
const std::string openDHT_Client = "Retroshare V0.4";
|
||||||
const std::string openDHT_Agent = "RS-HTTP-V0.4";
|
const std::string openDHT_Agent = "RS-HTTP-V0.4";
|
||||||
|
|
||||||
#define MAX_DHT_PEER_FAILS 5
|
#define MAX_DHT_PEER_FAILS 2 /* then discard */
|
||||||
#define MAX_DHT_TOTAL_FAILS 5
|
#define MAX_DHT_TOTAL_FAILS 10 /* in a row -> think we're not connected! */
|
||||||
#define MAX_DHT_ATTEMPTS 5
|
#define MAX_DHT_ATTEMPTS 10 /* attempts per search/publish */
|
||||||
#define MIN_DHT_SERVERS 5
|
#define MIN_DHT_SERVERS 5
|
||||||
|
|
||||||
#define OPENDHT_DEBUG 1
|
#define OPENDHT_DEBUG 1
|
||||||
@ -174,6 +176,16 @@ bool OpenDHTClient::getServer(std::string &host, uint16_t &port, struct sockaddr
|
|||||||
/* randomly choose one */
|
/* randomly choose one */
|
||||||
dhtMutex.lock(); /**** LOCK ****/
|
dhtMutex.lock(); /**** LOCK ****/
|
||||||
|
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* WINDOWS don't randomise properly so we'll do it ourselves...
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t randomize = timeGetTime();
|
||||||
|
srand(randomize);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t len = mServers.size();
|
uint32_t len = mServers.size();
|
||||||
uint32_t rnd = len * (rand() / (RAND_MAX + 1.0));
|
uint32_t rnd = len * (rand() / (RAND_MAX + 1.0));
|
||||||
|
|
||||||
@ -334,6 +346,11 @@ bool OpenDHTClient::publishKey(std::string key, std::string value, uint32_t ttl)
|
|||||||
|
|
||||||
bool OpenDHTClient::searchKey(std::string key, std::list<std::string> &values)
|
bool OpenDHTClient::searchKey(std::string key, std::list<std::string> &values)
|
||||||
{
|
{
|
||||||
|
#ifdef OPENDHT_DEBUG
|
||||||
|
std::cerr << "OpenDHTClient::openDHT_searchKey() key: 0x" << RsUtil::BinToHex(key);
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* create request */
|
/* create request */
|
||||||
std::string getmsg = createOpenDHT_get(key, 1024, openDHT_Client);
|
std::string getmsg = createOpenDHT_get(key, 1024, openDHT_Client);
|
||||||
std::string response;
|
std::string response;
|
||||||
@ -510,7 +527,13 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
/* now wait for the response */
|
/* now wait for the response */
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
int recvsize = 51200; /* 50kb */
|
int recvsize = 51200; /* 50kb */
|
||||||
char *inbuf = (char *) malloc(recvsize);
|
char *inbuf = (char *) malloc(recvsize);
|
||||||
@ -520,7 +543,6 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
|
|||||||
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
|
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
|
||||||
std::cerr << " Recvd Chunk:" << size;
|
std::cerr << " Recvd Chunk:" << size;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
idx += size;
|
idx += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,12 +553,16 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
|
|||||||
free(inbuf);
|
free(inbuf);
|
||||||
|
|
||||||
/* print it out */
|
/* print it out */
|
||||||
|
std::cerr << "HTTP What We Sent ***************" << std::endl;
|
||||||
|
std::cerr << putheader;
|
||||||
|
std::cerr << msg;
|
||||||
|
std::cerr << std::endl;
|
||||||
std::cerr << "HTTP response *******************" << std::endl;
|
std::cerr << "HTTP response *******************" << std::endl;
|
||||||
std::cerr << response;
|
std::cerr << response;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "HTTP response *******************" << std::endl;
|
std::cerr << "HTTP response *******************" << std::endl;
|
||||||
|
|
||||||
close(sockfd);
|
unix_close(sockfd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -607,7 +633,13 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
/* now wait for the response */
|
/* now wait for the response */
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
int recvsize = 51200; /* 50kb */
|
int recvsize = 51200; /* 50kb */
|
||||||
char *inbuf = (char *) malloc(recvsize);
|
char *inbuf = (char *) malloc(recvsize);
|
||||||
@ -617,7 +649,6 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
|||||||
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
|
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
|
||||||
std::cerr << " Recvd Chunk:" << size;
|
std::cerr << " Recvd Chunk:" << size;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
idx += size;
|
idx += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +664,7 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "HTTP response *******************" << std::endl;
|
std::cerr << "HTTP response *******************" << std::endl;
|
||||||
|
|
||||||
close(sockfd);
|
unix_close(sockfd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ extern "C" void* doDhtPublish(void* p)
|
|||||||
|
|
||||||
delete data;
|
delete data;
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +73,8 @@ extern "C" void* doDhtSearch(void* p)
|
|||||||
if ((!data) || (!data->mgr) || (!data->client))
|
if ((!data) || (!data->mgr) || (!data->client))
|
||||||
{
|
{
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search it! */
|
/* search it! */
|
||||||
@ -88,6 +92,8 @@ extern "C" void* doDhtSearch(void* p)
|
|||||||
|
|
||||||
delete data;
|
delete data;
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,9 +31,11 @@ RSOBJ = $(BASE_OBJ) $(LOOP_OBJ) \
|
|||||||
$(UDP_OBJ) \
|
$(UDP_OBJ) \
|
||||||
$(GRP_OBJ)
|
$(GRP_OBJ)
|
||||||
|
|
||||||
TESTOBJ = net_test.o dht_test.o conn_test.o
|
TESTOBJ = net_test.o dht_test.o
|
||||||
|
#conn_test.o
|
||||||
|
|
||||||
TESTS = net_test dht_test conn_test
|
TESTS = net_test dht_test
|
||||||
|
#conn_test
|
||||||
|
|
||||||
|
|
||||||
all: librs tests
|
all: librs tests
|
||||||
|
@ -302,7 +302,13 @@ int main()
|
|||||||
dhtTester.start();
|
dhtTester.start();
|
||||||
|
|
||||||
/* wait for a little before switching on */
|
/* wait for a little before switching on */
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||||
dhtTester.setDhtOn(true);
|
dhtTester.setDhtOn(true);
|
||||||
@ -310,7 +316,13 @@ int main()
|
|||||||
/* wait loop */
|
/* wait loop */
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
connMgr.tick();
|
connMgr.tick();
|
||||||
pqipg->tick();
|
pqipg->tick();
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
/***** Test for the new DHT system *****/
|
/***** Test for the new DHT system *****/
|
||||||
|
|
||||||
|
|
||||||
|
#include "pqi/pqinetwork.h"
|
||||||
|
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
#include "util/rsthreads.h"
|
#include "util/rsthreads.h"
|
||||||
#include "util/rsprint.h"
|
#include "util/rsprint.h"
|
||||||
@ -218,7 +220,13 @@ int main()
|
|||||||
dhtTester.start();
|
dhtTester.start();
|
||||||
|
|
||||||
/* wait for a little before switching on */
|
/* wait for a little before switching on */
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||||
dhtTester.setDhtOn(true);
|
dhtTester.setDhtOn(true);
|
||||||
@ -234,7 +242,14 @@ int main()
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
std::cerr << "Main waiting..." << std::endl;
|
std::cerr << "Main waiting..." << std::endl;
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
#else
|
||||||
|
Sleep(3000);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
|
|
||||||
/* handle async search */
|
/* handle async search */
|
||||||
frmMtx.lock(); /* LOCK TEST FRAMEWORK MUTEX */
|
frmMtx.lock(); /* LOCK TEST FRAMEWORK MUTEX */
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "util/rsnet.h"
|
|
||||||
#include "pqi/pqinetwork.h"
|
#include "pqi/pqinetwork.h"
|
||||||
|
#include "util/rsnet.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -457,8 +457,14 @@ void p3DhtMgr::run()
|
|||||||
break; /* speed up config modifications */
|
break; /* speed up config modifications */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
sleep(waittime);
|
sleep(waittime);
|
||||||
|
#else
|
||||||
|
Sleep(1000 * waittime);
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1148,6 +1154,10 @@ bool p3DhtMgr::resultDHT(std::string key, std::string value)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef DHT_DEBUG
|
||||||
|
std::cerr << "p3DhtMgr::resultDHT() key: " << key << " value: " << value << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* variables for dhtResult() call */
|
/* variables for dhtResult() call */
|
||||||
struct sockaddr_in laddr;
|
struct sockaddr_in laddr;
|
||||||
struct sockaddr_in raddr;
|
struct sockaddr_in raddr;
|
||||||
|
@ -354,7 +354,7 @@ in_addr_t inet_netof(struct in_addr addr)
|
|||||||
|
|
||||||
// This returns in Host Byte Order. (as the man page says)
|
// This returns in Host Byte Order. (as the man page says)
|
||||||
// Again, to be consistent with Linux.
|
// Again, to be consistent with Linux.
|
||||||
in_addr_t inet_network(char *inet_name)
|
in_addr_t inet_network(const char *inet_name)
|
||||||
{
|
{
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
if (inet_aton(inet_name, &addr))
|
if (inet_aton(inet_name, &addr))
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#ifndef MRK_PQI_NETWORKING_HEADER
|
#ifndef MRK_PQI_NETWORKING_HEADER
|
||||||
#define MRK_PQI_NETWORKING_HEADER
|
#define MRK_PQI_NETWORKING_HEADER
|
||||||
|
|
||||||
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
|
|
||||||
@ -47,20 +48,21 @@
|
|||||||
/* This defines the platform to be WinXP or later...
|
/* This defines the platform to be WinXP or later...
|
||||||
* and is needed for getaddrinfo.... (not used anymore)
|
* and is needed for getaddrinfo.... (not used anymore)
|
||||||
*
|
*
|
||||||
#define _WIN32_WINNT 0x0501
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _WIN32_WINNT 0x0501
|
||||||
|
|
||||||
|
#include "util/rsnet.h" /* more generic networking header */
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
typedef unsigned long in_addr_t;
|
//typedef unsigned long in_addr_t;
|
||||||
|
|
||||||
// Some Network functions that are missing from windows.
|
// Some Network functions that are missing from windows.
|
||||||
|
|
||||||
in_addr_t inet_netof(struct in_addr addr);
|
in_addr_t inet_netof(struct in_addr addr);
|
||||||
in_addr_t inet_network(char *inet_name);
|
in_addr_t inet_network(const char *inet_name);
|
||||||
int inet_aton(const char *name, struct in_addr *addr);
|
int inet_aton(const char *name, struct in_addr *addr);
|
||||||
|
|
||||||
extern int errno; /* Define extern errno, to duplicate unix behaviour */
|
extern int errno; /* Define extern errno, to duplicate unix behaviour */
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "util/rsnet.h"
|
|
||||||
|
|
||||||
#include "pqi/pqissl.h"
|
#include "pqi/pqissl.h"
|
||||||
#include "pqi/pqinetwork.h"
|
#include "pqi/pqinetwork.h"
|
||||||
|
|
||||||
|
#include "util/rsnet.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
|
@ -34,7 +34,12 @@ LIBRS = $(LIBDIR)/libretroshare.a
|
|||||||
|
|
||||||
# Unix: Linux/Cygwin
|
# Unix: Linux/Cygwin
|
||||||
INCLUDE = -I $(RS_TOP_DIR) -I$(KADC_DIR)
|
INCLUDE = -I $(RS_TOP_DIR) -I$(KADC_DIR)
|
||||||
CFLAGS = -Wall -g $(INCLUDE)
|
|
||||||
|
ifdef PQI_DEBUG
|
||||||
|
CFLAGS = -Wall -g $(INCLUDE)
|
||||||
|
else
|
||||||
|
CFLAGS = -Wall -O2 $(INCLUDE)
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef PQI_USE_XPGP
|
ifdef PQI_USE_XPGP
|
||||||
INCLUDE += -I $(SSL_DIR)/include
|
INCLUDE += -I $(SSL_DIR)/include
|
||||||
@ -59,6 +64,16 @@ endif
|
|||||||
|
|
||||||
RSCFLAGS = -Wall -g $(INCLUDE)
|
RSCFLAGS = -Wall -g $(INCLUDE)
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# OS Compile Options
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
# For the SSL BIO compilation. (Copied from OpenSSL compilation flags)
|
||||||
|
BIOCC = gcc
|
||||||
|
|
||||||
|
# Cygwin - ?same? as Linux flags
|
||||||
|
BIOCFLAGS = -I $(SSL_DIR)/include -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# OS specific Linking.
|
# OS specific Linking.
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@ -69,7 +84,7 @@ WININC += -mno-cygwin -mwindows -fno-exceptions
|
|||||||
WININC += -DWINDOWS_SYS
|
WININC += -DWINDOWS_SYS
|
||||||
|
|
||||||
WINLIB = -lws2_32 -luuid -lole32 -liphlpapi
|
WINLIB = -lws2_32 -luuid -lole32 -liphlpapi
|
||||||
WINLIB += -lcrypt32
|
WINLIB += -lcrypt32 -lwinmm
|
||||||
|
|
||||||
CFLAGS += -I$(PTHREADS_DIR) $(WININC)
|
CFLAGS += -I$(PTHREADS_DIR) $(WININC)
|
||||||
CFLAGS += -I$(ZLIB_DIR)
|
CFLAGS += -I$(ZLIB_DIR)
|
||||||
@ -83,11 +98,7 @@ LIBS += -lssl -lcrypto
|
|||||||
LIBS += -L$(KADC_DIR) -lKadC
|
LIBS += -L$(KADC_DIR) -lKadC
|
||||||
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
||||||
LIBS += -L$(ZLIB_DIR) -lz
|
LIBS += -L$(ZLIB_DIR) -lz
|
||||||
|
LIBS += -L$(PTHREADS_DIR) -lpthreadGC2d
|
||||||
RSLIBS += $(LIBS)
|
|
||||||
RSLIBS += -L$(PTHREADS_DIR) -lpthreadGC2d
|
|
||||||
|
|
||||||
RSLIBS += $(WINLIB)
|
|
||||||
LIBS += $(WINLIB)
|
LIBS += $(WINLIB)
|
||||||
|
|
||||||
RSCFLAGS += $(WININC)
|
RSCFLAGS += $(WININC)
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
#Define OS.
|
#Define OS.
|
||||||
#
|
#
|
||||||
OS = Linux
|
#OS = Linux
|
||||||
#OS = MacOSX
|
#OS = MacOSX
|
||||||
#OS = Cygwin
|
OS = Cygwin
|
||||||
#OS = Win # MinGw.
|
#OS = Win # MinGw.
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include "serialiser/rsbaseserial.h"
|
#include "serialiser/rsbaseserial.h"
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
#include "serialiser/rstlvbase.h"
|
#include "serialiser/rstlvbase.h"
|
||||||
#include "util/utest.h"
|
#include "util/utest.h"
|
||||||
|
#include "util/rsnet.h"
|
||||||
|
|
||||||
INITTEST();
|
INITTEST();
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "services/p3gameservice.h"
|
#include "services/p3gameservice.h"
|
||||||
#include "pqi/pqidebug.h"
|
#include "pqi/pqidebug.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
/* global variable for GUI */
|
/* global variable for GUI */
|
||||||
RsGameLauncher *rsGameLauncher = NULL;
|
RsGameLauncher *rsGameLauncher = NULL;
|
||||||
@ -131,13 +132,27 @@ std::string generateRandomGameId()
|
|||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << std::hex;
|
out << std::hex;
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
out << std::setw(8) << std::setfill('0');
|
||||||
uint32_t rint = random();
|
uint32_t rint = random();
|
||||||
out << rint;
|
out << rint;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
srand(time(NULL));
|
||||||
|
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||||
|
for(int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
out << std::setw(4) << std::setfill('0');
|
||||||
|
uint16_t rint = rand(); /* only gives 16 bits */
|
||||||
|
out << rint;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "serialiser/rsrankitems.h"
|
#include "serialiser/rsrankitems.h"
|
||||||
#include "services/p3ranking.h"
|
#include "services/p3ranking.h"
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/p3authmgr.h"
|
#include "pqi/p3authmgr.h"
|
||||||
@ -823,13 +824,26 @@ std::string generateRandomLinkId()
|
|||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << std::hex;
|
out << std::hex;
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
out << std::setw(8) << std::setfill('0');
|
||||||
uint32_t rint = random();
|
uint32_t rint = random();
|
||||||
out << rint;
|
out << rint;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
srand(time(NULL));
|
||||||
|
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||||
|
for(int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
out << std::setw(4) << std::setfill('0');
|
||||||
|
uint16_t rint = rand(); /* only gives 16 bits */
|
||||||
|
out << rint;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ RSOBJ += tcppacket.o tcpstream.o tou.o $(BIOOBJ)
|
|||||||
EXECS = librs udpsock_test udpsort_test udp_server
|
EXECS = librs udpsock_test udpsort_test udp_server
|
||||||
#test_tou pair_tou reset_tou internal_tou largefile_tou
|
#test_tou pair_tou reset_tou internal_tou largefile_tou
|
||||||
|
|
||||||
TESTOBJ = udpsock_test.o udpsort_test.o udp_server.o test_tou.o
|
#TESTOBJ = udpsock_test.o udpsort_test.o udp_server.o test_tou.o
|
||||||
TESTOBJ += pair_tou.o reset_tou.o largefile_tou.o
|
#TESTOBJ += pair_tou.o reset_tou.o largefile_tou.o
|
||||||
#internal_tou.o
|
#internal_tou.o
|
||||||
|
|
||||||
TESTS = udpsock_test udpsort_test udp_server test_tou
|
#TESTS = udpsock_test udpsort_test udp_server test_tou
|
||||||
TESTS += pair_tou reset_tou largefile_tou
|
#TESTS += pair_tou reset_tou largefile_tou
|
||||||
#internal_tou
|
#internal_tou
|
||||||
|
|
||||||
all: librs tests
|
all: librs tests
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
#ifndef TOU_UNIVERSAL_NETWORK_HEADER
|
#ifndef TOU_UNIVERSAL_NETWORK_HEADER
|
||||||
#define TOU_UNIVERSAL_NETWORK_HEADER
|
#define TOU_UNIVERSAL_NETWORK_HEADER
|
||||||
|
|
||||||
|
/* Some Types need to be defined before the interface can be declared
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util/rsnet.h"
|
||||||
|
|
||||||
/* C Interface */
|
/* C Interface */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -58,32 +63,6 @@ extern "C" {
|
|||||||
* int tounet_checkTTL(); a check if we can modify the ttl
|
* int tounet_checkTTL(); a check if we can modify the ttl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Some Types need to be defined before the interface can be declared
|
|
||||||
*/
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
#ifndef WINDOWS_SYS
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
|
|
||||||
#include <stdio.h> /* for ssize_t */
|
|
||||||
typedef int socklen_t;
|
|
||||||
typedef unsigned long in_addr_t;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
|
|
||||||
|
|
||||||
/* the universal interface */
|
/* the universal interface */
|
||||||
int tounet_errno(); /* for internal networking errors */
|
int tounet_errno(); /* for internal networking errors */
|
||||||
|
@ -20,7 +20,7 @@ TESTS = upnptest
|
|||||||
all: librs tests
|
all: librs tests
|
||||||
|
|
||||||
upnptest: $(OBJ) upnptest.o
|
upnptest: $(OBJ) upnptest.o
|
||||||
$(CC) $(CFLAGS) -o upnptest $(OBJ) upnptest.o $(RSLIBS)
|
$(CC) $(CFLAGS) -o upnptest $(OBJ) upnptest.o $(LIBS)
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||||
|
@ -10,8 +10,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
/* This stuff is actually C */
|
/* This stuff is actually C */
|
||||||
|
|
||||||
#include "upnp/upnputil.h"
|
|
||||||
#include "upnp/upnphandler.h"
|
#include "upnp/upnphandler.h"
|
||||||
|
#include "upnp/upnputil.h"
|
||||||
|
|
||||||
class uPnPConfigData
|
class uPnPConfigData
|
||||||
{
|
{
|
||||||
|
@ -139,8 +139,12 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
|
|||||||
else
|
else
|
||||||
printf("GetExternalIPAddress failed.\n");
|
printf("GetExternalIPAddress failed.\n");
|
||||||
|
|
||||||
|
// Unix at the moment!
|
||||||
|
// r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
||||||
|
// eport, iport, iaddr, 0, leaseDuration, proto);
|
||||||
|
|
||||||
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
||||||
eport, iport, iaddr, 0, leaseDuration, proto);
|
eport, iport, iaddr, 0, proto);
|
||||||
if(r==0)
|
if(r==0)
|
||||||
{
|
{
|
||||||
printf("AddPortMapping(%s, %s, %s) failed\n", eport, iport, iaddr);
|
printf("AddPortMapping(%s, %s, %s) failed\n", eport, iport, iaddr);
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* enforce LITTLE_ENDIAN on Windows */
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
#define BYTE_ORDER 1234
|
||||||
|
#define LITTLE_ENDIAN 1234
|
||||||
|
#define BIG_ENDIAN 4321
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t ntohll(uint64_t x)
|
uint64_t ntohll(uint64_t x)
|
||||||
{
|
{
|
||||||
|
@ -45,9 +45,11 @@
|
|||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
#include <stdio.h> /* for ssize_t */
|
#include <stdio.h> /* for ssize_t */
|
||||||
typedef uint32_t socklen_t;
|
//typedef uint32_t socklen_t;
|
||||||
typedef uint32_t in_addr_t;
|
typedef uint32_t in_addr_t;
|
||||||
|
|
||||||
|
int inet_aton(const char *name, struct in_addr *addr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
######################################################################
|
######################################################################
|
||||||
# Automatically generated by qmake (2.00a) Fr 18. Aug 22:48:56 2006
|
# Automatically generated by qmake (2.00a) Fr 18. Aug 22:48:56 2006
|
||||||
######################################################################
|
#######################################################################
|
||||||
OBJECTS_DIR = temp/obj
|
#OBJECTS_DIR = temp/obj
|
||||||
RCC_DIR = temp/qrc
|
#RCC_DIR = temp/qrc
|
||||||
UI_DIR = temp/ui
|
#UI_DIR = temp/ui
|
||||||
MOC_DIR = temp/moc
|
#MOC_DIR = temp/moc
|
||||||
|
|
||||||
CONFIG += qt release
|
CONFIG += qt release
|
||||||
QT += network xml
|
QT += network xml
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
@ -313,8 +314,9 @@ win32 {
|
|||||||
|
|
||||||
RC_FILE = gui/images/retroshare_win.rc
|
RC_FILE = gui/images/retroshare_win.rc
|
||||||
|
|
||||||
"LIBS += -L"../../winlibs" -lretroshare -lssl -lcrypto -lpthreadGC2d -lKadC -lminiupnpc -lz -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lskin -lqcheckers -lsmplayer -lgdi32
|
LIBS += -L"../../../../lib" -lretroshare -lssl -lcrypto -lpthreadGC2d -lKadC -lminiupnpc -lz
|
||||||
CONFIG += qt release"
|
LIBS += -lqcheckers -lsmplayer
|
||||||
|
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32-cygwin -gdi32
|
||||||
LIBS += -lole32
|
LIBS += -lole32
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user