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
|
||||
#define MRK_CACHE_STRAPPER_H
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
/******************* CacheStrapper and Related Classes *******************
|
||||
* A generic Cache Update system.
|
||||
@ -268,8 +271,6 @@ class CachePair
|
||||
|
||||
bool operator<(const CachePair &a, const CachePair &b);
|
||||
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
class p3AuthMgr;
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
#ifndef FILE_INDEX_MONITOR_H
|
||||
#define FILE_INDEX_MONITOR_H
|
||||
|
||||
#include "dbase/findex.h"
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "dbase/findex.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
/******************************************************************************************
|
||||
|
@ -17,16 +17,16 @@ all: librs tests
|
||||
|
||||
#dhttest is OLD
|
||||
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
|
||||
$(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
|
||||
$(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
|
||||
$(CC) $(CFLAGS) -o odhtmgr_test $(OBJ) odhtmgr_test.o $(RSLIBS)
|
||||
$(CC) $(CFLAGS) -o odhtmgr_test $(OBJ) odhtmgr_test.o $(LIBS)
|
||||
|
||||
# Extra Rule...
|
||||
.c.o:
|
||||
|
@ -27,17 +27,18 @@
|
||||
|
||||
/***** Test for the new DHT system *****/
|
||||
|
||||
#include "pqi/p3dhtmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "dht/opendhtmgr.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
#include "pqi/p3dhtmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "dht/opendhtmgr.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
void usage(char *name)
|
||||
{
|
||||
@ -87,7 +88,14 @@ int main(int argc, char **argv)
|
||||
dhtTester.start();
|
||||
|
||||
/* wait for a little before switching on */
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
|
||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||
dhtTester.setDhtOn(true);
|
||||
@ -104,7 +112,13 @@ int main(int argc, char **argv)
|
||||
while(1)
|
||||
{
|
||||
std::cerr << "Main waiting..." << std::endl;
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(3);
|
||||
#else
|
||||
Sleep(3000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
if (!haveOwnAddress)
|
||||
{
|
||||
|
@ -48,7 +48,13 @@ int main()
|
||||
|
||||
dht.publishKey(key, value, ttl);
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(10);
|
||||
#else
|
||||
Sleep(10000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
std::list<std::string> values;
|
||||
dht.searchKey(key, values);
|
||||
|
@ -29,15 +29,17 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
const std::string openDHT_Client = "Retroshare V0.4";
|
||||
const std::string openDHT_Agent = "RS-HTTP-V0.4";
|
||||
|
||||
#define MAX_DHT_PEER_FAILS 5
|
||||
#define MAX_DHT_TOTAL_FAILS 5
|
||||
#define MAX_DHT_ATTEMPTS 5
|
||||
#define MAX_DHT_PEER_FAILS 2 /* then discard */
|
||||
#define MAX_DHT_TOTAL_FAILS 10 /* in a row -> think we're not connected! */
|
||||
#define MAX_DHT_ATTEMPTS 10 /* attempts per search/publish */
|
||||
#define MIN_DHT_SERVERS 5
|
||||
|
||||
#define OPENDHT_DEBUG 1
|
||||
@ -174,6 +176,16 @@ bool OpenDHTClient::getServer(std::string &host, uint16_t &port, struct sockaddr
|
||||
/* randomly choose one */
|
||||
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 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)
|
||||
{
|
||||
#ifdef OPENDHT_DEBUG
|
||||
std::cerr << "OpenDHTClient::openDHT_searchKey() key: 0x" << RsUtil::BinToHex(key);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* create request */
|
||||
std::string getmsg = createOpenDHT_get(key, 1024, openDHT_Client);
|
||||
std::string response;
|
||||
@ -510,7 +527,13 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* now wait for the response */
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
int recvsize = 51200; /* 50kb */
|
||||
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 << " Recvd Chunk:" << size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
idx += size;
|
||||
}
|
||||
|
||||
@ -531,12 +553,16 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
|
||||
free(inbuf);
|
||||
|
||||
/* 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 << response;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "HTTP response *******************" << std::endl;
|
||||
|
||||
close(sockfd);
|
||||
unix_close(sockfd);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -607,7 +633,13 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* now wait for the response */
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
int recvsize = 51200; /* 50kb */
|
||||
char *inbuf = (char *) malloc(recvsize);
|
||||
@ -617,7 +649,6 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
||||
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
|
||||
std::cerr << " Recvd Chunk:" << size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
idx += size;
|
||||
}
|
||||
|
||||
@ -633,7 +664,7 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "HTTP response *******************" << std::endl;
|
||||
|
||||
close(sockfd);
|
||||
unix_close(sockfd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ extern "C" void* doDhtPublish(void* p)
|
||||
|
||||
delete data;
|
||||
pthread_exit(NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +73,8 @@ extern "C" void* doDhtSearch(void* p)
|
||||
if ((!data) || (!data->mgr) || (!data->client))
|
||||
{
|
||||
pthread_exit(NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* search it! */
|
||||
@ -88,6 +92,8 @@ extern "C" void* doDhtSearch(void* p)
|
||||
|
||||
delete data;
|
||||
pthread_exit(NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,9 +31,11 @@ RSOBJ = $(BASE_OBJ) $(LOOP_OBJ) \
|
||||
$(UDP_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
|
||||
|
@ -302,7 +302,13 @@ int main()
|
||||
dhtTester.start();
|
||||
|
||||
/* wait for a little before switching on */
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||
dhtTester.setDhtOn(true);
|
||||
@ -310,7 +316,13 @@ int main()
|
||||
/* wait loop */
|
||||
while(1)
|
||||
{
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
connMgr.tick();
|
||||
pqipg->tick();
|
||||
|
@ -3,6 +3,8 @@
|
||||
/***** Test for the new DHT system *****/
|
||||
|
||||
|
||||
#include "pqi/pqinetwork.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "util/rsprint.h"
|
||||
@ -218,7 +220,13 @@ int main()
|
||||
dhtTester.start();
|
||||
|
||||
/* wait for a little before switching on */
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
std::cerr << "Switching on DhtTester()" << std::endl;
|
||||
dhtTester.setDhtOn(true);
|
||||
@ -234,7 +242,14 @@ int main()
|
||||
while(1)
|
||||
{
|
||||
std::cerr << "Main waiting..." << std::endl;
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(3);
|
||||
#else
|
||||
Sleep(3000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
|
||||
/* handle async search */
|
||||
frmMtx.lock(); /* LOCK TEST FRAMEWORK MUTEX */
|
||||
|
@ -29,8 +29,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "util/rsnet.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "util/rsnet.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -457,8 +457,14 @@ void p3DhtMgr::run()
|
||||
break; /* speed up config modifications */
|
||||
}
|
||||
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
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 */
|
||||
struct sockaddr_in laddr;
|
||||
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)
|
||||
// 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;
|
||||
if (inet_aton(inet_name, &addr))
|
||||
|
@ -28,6 +28,7 @@
|
||||
#ifndef MRK_PQI_NETWORKING_HEADER
|
||||
#define MRK_PQI_NETWORKING_HEADER
|
||||
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
|
||||
@ -47,20 +48,21 @@
|
||||
/* This defines the platform to be WinXP or later...
|
||||
* 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 <ws2tcpip.h>
|
||||
typedef int socklen_t;
|
||||
typedef unsigned long in_addr_t;
|
||||
//typedef unsigned long in_addr_t;
|
||||
|
||||
// Some Network functions that are missing from windows.
|
||||
|
||||
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);
|
||||
|
||||
extern int errno; /* Define extern errno, to duplicate unix behaviour */
|
||||
|
@ -26,11 +26,12 @@
|
||||
|
||||
|
||||
|
||||
#include "util/rsnet.h"
|
||||
|
||||
#include "pqi/pqissl.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
|
||||
#include "util/rsnet.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
@ -34,7 +34,12 @@ LIBRS = $(LIBDIR)/libretroshare.a
|
||||
|
||||
# Unix: Linux/Cygwin
|
||||
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
|
||||
INCLUDE += -I $(SSL_DIR)/include
|
||||
@ -59,6 +64,16 @@ endif
|
||||
|
||||
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.
|
||||
#########################################################################
|
||||
@ -69,7 +84,7 @@ WININC += -mno-cygwin -mwindows -fno-exceptions
|
||||
WININC += -DWINDOWS_SYS
|
||||
|
||||
WINLIB = -lws2_32 -luuid -lole32 -liphlpapi
|
||||
WINLIB += -lcrypt32
|
||||
WINLIB += -lcrypt32 -lwinmm
|
||||
|
||||
CFLAGS += -I$(PTHREADS_DIR) $(WININC)
|
||||
CFLAGS += -I$(ZLIB_DIR)
|
||||
@ -83,11 +98,7 @@ LIBS += -lssl -lcrypto
|
||||
LIBS += -L$(KADC_DIR) -lKadC
|
||||
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
||||
LIBS += -L$(ZLIB_DIR) -lz
|
||||
|
||||
RSLIBS += $(LIBS)
|
||||
RSLIBS += -L$(PTHREADS_DIR) -lpthreadGC2d
|
||||
|
||||
RSLIBS += $(WINLIB)
|
||||
LIBS += -L$(PTHREADS_DIR) -lpthreadGC2d
|
||||
LIBS += $(WINLIB)
|
||||
|
||||
RSCFLAGS += $(WININC)
|
||||
|
@ -4,9 +4,9 @@
|
||||
###########################################################################
|
||||
#Define OS.
|
||||
#
|
||||
OS = Linux
|
||||
#OS = Linux
|
||||
#OS = MacOSX
|
||||
#OS = Cygwin
|
||||
OS = Cygwin
|
||||
#OS = Win # MinGw.
|
||||
###########################################################################
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "util/rsnet.h"
|
||||
|
@ -29,10 +29,10 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "util/utest.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "services/p3gameservice.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/* global variable for GUI */
|
||||
RsGameLauncher *rsGameLauncher = NULL;
|
||||
@ -131,13 +132,27 @@ std::string generateRandomGameId()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
out << std::setw(8) << std::setfill('0');
|
||||
uint32_t rint = random();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "serialiser/rsrankitems.h"
|
||||
#include "services/p3ranking.h"
|
||||
#include <iomanip>
|
||||
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
@ -823,13 +824,26 @@ std::string generateRandomLinkId()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
out << std::setw(8) << std::setfill('0');
|
||||
uint32_t rint = random();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,12 @@ RSOBJ += tcppacket.o tcpstream.o tou.o $(BIOOBJ)
|
||||
EXECS = librs udpsock_test udpsort_test udp_server
|
||||
#test_tou pair_tou reset_tou internal_tou largefile_tou
|
||||
|
||||
TESTOBJ = udpsock_test.o udpsort_test.o udp_server.o test_tou.o
|
||||
TESTOBJ += pair_tou.o reset_tou.o largefile_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
|
||||
#internal_tou.o
|
||||
|
||||
TESTS = udpsock_test udpsort_test udp_server test_tou
|
||||
TESTS += pair_tou reset_tou largefile_tou
|
||||
#TESTS = udpsock_test udpsort_test udp_server test_tou
|
||||
#TESTS += pair_tou reset_tou largefile_tou
|
||||
#internal_tou
|
||||
|
||||
all: librs tests
|
||||
|
@ -28,6 +28,11 @@
|
||||
#ifndef 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 */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -58,32 +63,6 @@ extern "C" {
|
||||
* 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 */
|
||||
int tounet_errno(); /* for internal networking errors */
|
||||
|
@ -20,7 +20,7 @@ TESTS = upnptest
|
||||
all: librs tests
|
||||
|
||||
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
|
||||
|
@ -10,8 +10,8 @@ extern "C" {
|
||||
#endif
|
||||
/* This stuff is actually C */
|
||||
|
||||
#include "upnp/upnputil.h"
|
||||
#include "upnp/upnphandler.h"
|
||||
#include "upnp/upnputil.h"
|
||||
|
||||
class uPnPConfigData
|
||||
{
|
||||
|
@ -139,8 +139,12 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
|
||||
else
|
||||
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,
|
||||
eport, iport, iaddr, 0, leaseDuration, proto);
|
||||
eport, iport, iaddr, 0, proto);
|
||||
if(r==0)
|
||||
{
|
||||
printf("AddPortMapping(%s, %s, %s) failed\n", eport, iport, iaddr);
|
||||
|
@ -26,6 +26,12 @@
|
||||
#include "util/rsnet.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)
|
||||
{
|
||||
|
@ -45,9 +45,11 @@
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#include <stdio.h> /* for ssize_t */
|
||||
typedef uint32_t socklen_t;
|
||||
//typedef uint32_t socklen_t;
|
||||
typedef uint32_t in_addr_t;
|
||||
|
||||
int inet_aton(const char *name, struct in_addr *addr);
|
||||
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
######################################################################
|
||||
# Automatically generated by qmake (2.00a) Fr 18. Aug 22:48:56 2006
|
||||
######################################################################
|
||||
OBJECTS_DIR = temp/obj
|
||||
RCC_DIR = temp/qrc
|
||||
UI_DIR = temp/ui
|
||||
MOC_DIR = temp/moc
|
||||
#######################################################################
|
||||
#OBJECTS_DIR = temp/obj
|
||||
#RCC_DIR = temp/qrc
|
||||
#UI_DIR = temp/ui
|
||||
#MOC_DIR = temp/moc
|
||||
|
||||
CONFIG += qt release
|
||||
QT += network xml
|
||||
TEMPLATE = app
|
||||
@ -313,8 +314,9 @@ win32 {
|
||||
|
||||
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
|
||||
CONFIG += qt release"
|
||||
LIBS += -L"../../../../lib" -lretroshare -lssl -lcrypto -lpthreadGC2d -lKadC -lminiupnpc -lz
|
||||
LIBS += -lqcheckers -lsmplayer
|
||||
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32-cygwin -gdi32
|
||||
LIBS += -lole32
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user