Relaxed network grace + fixed annoying warnings

This commit is contained in:
mathusummut
2018-06-23 22:04:15 +02:00
parent 2e9623c8da
commit 3b14f3eb02
13 changed files with 294 additions and 288 deletions

View File

@@ -371,7 +371,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>

View File

@@ -308,7 +308,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>

View File

@@ -298,7 +298,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>

View File

@@ -256,7 +256,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>

View File

@@ -374,7 +374,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>

View File

@@ -308,7 +308,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>

View File

@@ -298,7 +298,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>

View File

@@ -256,7 +256,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4996;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>

View File

@@ -561,6 +561,8 @@ namespace
throw throw
megaglest_runtime_error(szBuf); megaglest_runtime_error(szBuf);
} }
/*if (unit->getProgress2() != NULL)
return result;*/
const UnitType * const UnitType *
unitType = unit->getType(); unitType = unit->getType();
if (unitType == NULL) { if (unitType == NULL) {
@@ -659,6 +661,8 @@ namespace
throw throw
megaglest_runtime_error(szBuf); megaglest_runtime_error(szBuf);
} }
/*if (unit->getProgress2() != NULL)
return result;*/
const UnitType * const UnitType *
unitType = unit->getType(); unitType = unit->getType();
if (unitType == NULL) { if (unitType == NULL) {
@@ -746,6 +750,8 @@ namespace
throw throw
megaglest_runtime_error(szBuf); megaglest_runtime_error(szBuf);
} }
/*if (unit->getProgress2() != NULL)
return result;*/
const UnitType * const UnitType *
unitType = unit->getType(); unitType = unit->getType();
if (unitType == NULL) { if (unitType == NULL) {
@@ -832,6 +838,8 @@ namespace
throw throw
megaglest_runtime_error(szBuf); megaglest_runtime_error(szBuf);
} }
/*if (unit->getProgress2() != NULL)
return result;*/
const UnitType * const UnitType *
unitType = unit->getType(); unitType = unit->getType();
if (unitType == NULL) { if (unitType == NULL) {

View File

@@ -50,7 +50,6 @@ using namespace Shared::Map;
namespace Glest { namespace Glest {
namespace Game { namespace Game {
double maxFrameCountLagAllowed = 30; double maxFrameCountLagAllowed = 30;
double maxClientLagTimeAllowed = 25; double maxClientLagTimeAllowed = 25;
double maxFrameCountLagAllowedEver = 30; double maxFrameCountLagAllowedEver = 30;
@@ -59,10 +58,10 @@ namespace Glest {
double warnFrameCountLagPercent = 0.50; double warnFrameCountLagPercent = 0.50;
double LAG_CHECK_GRACE_PERIOD = 15; double LAG_CHECK_GRACE_PERIOD = 15;
double LAG_CHECK_INTERVAL_PERIOD = 4; double LAG_CHECK_INTERVAL_PERIOD = 4;
int GRACE_LAG_CTR_LIMIT = 5; int GRACE_LAG_CTR_LIMIT = 10;
const int MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE_MILLISECONDS = 15000; const int MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE_MILLISECONDS = 15000;
const int MAX_CLIENT_PAUSE_FOR_LAG_COUNT = 3; const int MAX_CLIENT_PAUSE_FOR_LAG_COUNT = 5;
const int MAX_SLOT_THREAD_WAIT_TIME_MILLISECONDS = 1500; const int MAX_SLOT_THREAD_WAIT_TIME_MILLISECONDS = 1500;
const int MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS = 30; const int MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS = 30;
@@ -800,8 +799,8 @@ namespace Glest {
} }
} }
if ((gameSettings.getNetworkPauseGameForLaggedClients() == false || if (gameSettings.getNetworkPauseGameForLaggedClients() == false ||
((maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver) || (((maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver) ||
(maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver)) && (maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver)) &&
connectionSlot->getGraceLagCtr() > GRACE_LAG_CTR_LIMIT)) { connectionSlot->getGraceLagCtr() > GRACE_LAG_CTR_LIMIT)) {

View File

@@ -143,7 +143,7 @@ int testxmlparser(const char * xml, int size) {
return r; return r;
} }
int main(int argc, char * * argv) { /*int main(int argc, char * * argv) {
int r; int r;
(void) argc; (void) argv; (void) argc; (void) argv;
@@ -151,5 +151,5 @@ int main(int argc, char * * argv) {
if (r) if (r)
printf("minixml validation test failed\n"); printf("minixml validation test failed\n");
return r; return r;
} }*/

View File

@@ -488,274 +488,273 @@ RemovePinhole(struct UPNPUrls * urls,
/* sample upnp client program */ /* sample upnp client program */
int main(int argc, char ** argv) { //int main(int argc, char ** argv) {
char command = 0; // char command = 0;
char ** commandargv = 0; // char ** commandargv = 0;
int commandargc = 0; // int commandargc = 0;
struct UPNPDev * devlist = 0; // struct UPNPDev * devlist = 0;
char lanaddr[64]; /* my ip address on the LAN */ // char lanaddr[64]; /* my ip address on the LAN */
int i; // int i;
const char * rootdescurl = 0; // const char * rootdescurl = 0;
const char * multicastif = 0; // const char * multicastif = 0;
const char * minissdpdpath = 0; // const char * minissdpdpath = 0;
int localport = UPNP_LOCAL_PORT_ANY; // int localport = UPNP_LOCAL_PORT_ANY;
int retcode = 0; // int retcode = 0;
int error = 0; // int error = 0;
int ipv6 = 0; // int ipv6 = 0;
unsigned char ttl = 2; /* defaulting to 2 */ // unsigned char ttl = 2; /* defaulting to 2 */
const char * description = 0; // const char * description = 0;
//
#ifdef _WIN32 //#ifdef _WIN32
WSADATA wsaData; // WSADATA wsaData;
int nResult = WSAStartup(MAKEWORD(2, 2), &wsaData); // int nResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (nResult != NO_ERROR) { // if (nResult != NO_ERROR) {
fprintf(stderr, "WSAStartup() failed.\n"); // fprintf(stderr, "WSAStartup() failed.\n");
return -1; // return -1;
} // }
#endif //#endif
printf("upnpc : miniupnpc library test client, version %s.\n", MINIUPNPC_VERSION_STRING); // printf("upnpc : miniupnpc library test client, version %s.\n", MINIUPNPC_VERSION_STRING);
printf(" (c) 2005-2015 Thomas Bernard.\n"); // printf(" (c) 2005-2015 Thomas Bernard.\n");
printf("Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/\n" // printf("Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/\n"
"for more information.\n"); // "for more information.\n");
/* command line processing */ // /* command line processing */
for (i = 1; i < argc; i++) { // for (i = 1; i < argc; i++) {
if (0 == strcmp(argv[i], "--help") || 0 == strcmp(argv[i], "-h")) { // if (0 == strcmp(argv[i], "--help") || 0 == strcmp(argv[i], "-h")) {
command = 0; // command = 0;
break; // break;
} // }
if (argv[i][0] == '-') { // if (argv[i][0] == '-') {
if (argv[i][1] == 'u') // if (argv[i][1] == 'u')
rootdescurl = argv[++i]; // rootdescurl = argv[++i];
else if (argv[i][1] == 'm') // else if (argv[i][1] == 'm')
multicastif = argv[++i]; // multicastif = argv[++i];
else if (argv[i][1] == 'z') { // else if (argv[i][1] == 'z') {
char junk; // char junk;
if (sscanf(argv[++i], "%d%c", &localport, &junk) != 1 || // if (sscanf(argv[++i], "%d%c", &localport, &junk) != 1 ||
localport < 0 || localport>65535 || // localport < 0 || localport>65535 ||
(localport > 1 && localport < 1024)) { // (localport > 1 && localport < 1024)) {
fprintf(stderr, "Invalid localport '%s'\n", argv[i]); // fprintf(stderr, "Invalid localport '%s'\n", argv[i]);
localport = UPNP_LOCAL_PORT_ANY; // localport = UPNP_LOCAL_PORT_ANY;
break; // break;
} // }
} else if (argv[i][1] == 'p') // } else if (argv[i][1] == 'p')
minissdpdpath = argv[++i]; // minissdpdpath = argv[++i];
else if (argv[i][1] == '6') // else if (argv[i][1] == '6')
ipv6 = 1; // ipv6 = 1;
else if (argv[i][1] == 'e') // else if (argv[i][1] == 'e')
description = argv[++i]; // description = argv[++i];
else if (argv[i][1] == 't') // else if (argv[i][1] == 't')
ttl = (unsigned char) atoi(argv[++i]); // ttl = (unsigned char) atoi(argv[++i]);
else { // else {
command = argv[i][1]; // command = argv[i][1];
i++; // i++;
commandargv = argv + i; // commandargv = argv + i;
commandargc = argc - i; // commandargc = argc - i;
break; // break;
} // }
} else { // } else {
fprintf(stderr, "option '%s' invalid\n", argv[i]); // fprintf(stderr, "option '%s' invalid\n", argv[i]);
} // }
} // }
//
if (!command // if (!command
|| (command == 'a' && commandargc < 4) // || (command == 'a' && commandargc < 4)
|| (command == 'd' && argc < 2) // || (command == 'd' && argc < 2)
|| (command == 'r' && argc < 2) // || (command == 'r' && argc < 2)
|| (command == 'A' && commandargc < 6) // || (command == 'A' && commandargc < 6)
|| (command == 'U' && commandargc < 2) // || (command == 'U' && commandargc < 2)
|| (command == 'D' && commandargc < 1)) { // || (command == 'D' && commandargc < 1)) {
fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration]\n\t\tAdd port redirection\n", argv[0]); // fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration]\n\t\tAdd port redirection\n", argv[0]);
fprintf(stderr, " \t%s [options] -d external_port protocol <remote host>\n\t\tDelete port redirection\n", argv[0]); // fprintf(stderr, " \t%s [options] -d external_port protocol <remote host>\n\t\tDelete port redirection\n", argv[0]);
fprintf(stderr, " \t%s [options] -s\n\t\tGet Connection status\n", argv[0]); // fprintf(stderr, " \t%s [options] -s\n\t\tGet Connection status\n", argv[0]);
fprintf(stderr, " \t%s [options] -l\n\t\tList redirections\n", argv[0]); // fprintf(stderr, " \t%s [options] -l\n\t\tList redirections\n", argv[0]);
fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -N external_port_start external_port_end protocol [manage]\n\t\tDelete range of port redirections (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -N external_port_start external_port_end protocol [manage]\n\t\tDelete range of port redirections (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -r port1 [external_port1] protocol1 [port2 [external_port2] protocol2] [...]\n\t\tAdd all redirections to the current host\n", argv[0]); // fprintf(stderr, " \t%s [options] -r port1 [external_port1] protocol1 [port2 [external_port2] protocol2] [...]\n\t\tAdd all redirections to the current host\n", argv[0]);
fprintf(stderr, " \t%s [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time\n\t\tAdd Pinhole (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time\n\t\tAdd Pinhole (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -U uniqueID new_lease_time\n\t\tUpdate Pinhole (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -U uniqueID new_lease_time\n\t\tUpdate Pinhole (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -C uniqueID\n\t\tCheck if Pinhole is Working (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -C uniqueID\n\t\tCheck if Pinhole is Working (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -K uniqueID\n\t\tGet Number of packets going through the rule (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -K uniqueID\n\t\tGet Number of packets going through the rule (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -D uniqueID\n\t\tDelete Pinhole (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -D uniqueID\n\t\tDelete Pinhole (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -S\n\t\tGet Firewall status (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -S\n\t\tGet Firewall status (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -G remote_ip remote_port internal_ip internal_port protocol\n\t\tGet Outbound Pinhole Timeout (for IGD:2 only)\n", argv[0]); // fprintf(stderr, " \t%s [options] -G remote_ip remote_port internal_ip internal_port protocol\n\t\tGet Outbound Pinhole Timeout (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -P\n\t\tGet Presentation url\n", argv[0]); // fprintf(stderr, " \t%s [options] -P\n\t\tGet Presentation url\n", argv[0]);
fprintf(stderr, "\nprotocol is UDP or TCP\n"); // fprintf(stderr, "\nprotocol is UDP or TCP\n");
fprintf(stderr, "Options:\n"); // fprintf(stderr, "Options:\n");
fprintf(stderr, " -e description : set description for port mapping.\n"); // fprintf(stderr, " -e description : set description for port mapping.\n");
fprintf(stderr, " -6 : use ip v6 instead of ip v4.\n"); // fprintf(stderr, " -6 : use ip v6 instead of ip v4.\n");
fprintf(stderr, " -u url : bypass discovery process by providing the XML root description url.\n"); // fprintf(stderr, " -u url : bypass discovery process by providing the XML root description url.\n");
fprintf(stderr, " -m address/interface : provide ip address (ip v4) or interface name (ip v4 or v6) to use for sending SSDP multicast packets.\n"); // fprintf(stderr, " -m address/interface : provide ip address (ip v4) or interface name (ip v4 or v6) to use for sending SSDP multicast packets.\n");
fprintf(stderr, " -z localport : SSDP packets local (source) port (1024-65535).\n"); // fprintf(stderr, " -z localport : SSDP packets local (source) port (1024-65535).\n");
fprintf(stderr, " -p path : use this path for MiniSSDPd socket.\n"); // fprintf(stderr, " -p path : use this path for MiniSSDPd socket.\n");
fprintf(stderr, " -t ttl : set multicast TTL. Default value is 2.\n"); // fprintf(stderr, " -t ttl : set multicast TTL. Default value is 2.\n");
return 1; // return 1;
} // }
//
if (rootdescurl // if (rootdescurl
|| (devlist = upnpDiscover(2000, multicastif, minissdpdpath, // || (devlist = upnpDiscover(2000, multicastif, minissdpdpath,
localport, ipv6, ttl, &error))) { // localport, ipv6, ttl, &error))) {
struct UPNPDev * device; // struct UPNPDev * device;
struct UPNPUrls urls; // struct UPNPUrls urls;
struct IGDdatas data; // struct IGDdatas data;
if (devlist) { // if (devlist) {
printf("List of UPNP devices found on the network :\n"); // printf("List of UPNP devices found on the network :\n");
for (device = devlist; device; device = device->pNext) { // for (device = devlist; device; device = device->pNext) {
printf(" desc: %s\n st: %s\n\n", // printf(" desc: %s\n st: %s\n\n",
device->descURL, device->st); // device->descURL, device->st);
} // }
} else if (!rootdescurl) { // } else if (!rootdescurl) {
printf("upnpDiscover() error code=%d\n", error); // printf("upnpDiscover() error code=%d\n", error);
} // }
i = 1; // i = 1;
if ((rootdescurl && UPNP_GetIGDFromUrl(rootdescurl, &urls, &data, lanaddr, sizeof(lanaddr))) // if ((rootdescurl && UPNP_GetIGDFromUrl(rootdescurl, &urls, &data, lanaddr, sizeof(lanaddr)))
|| (i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)))) { // || (i = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)))) {
switch (i) { // switch (i) {
case 1: // case 1:
printf("Found valid IGD : %s\n", urls.controlURL); // printf("Found valid IGD : %s\n", urls.controlURL);
break; // break;
case 2: // case 2:
printf("Found a (not connected?) IGD : %s\n", urls.controlURL); // printf("Found a (not connected?) IGD : %s\n", urls.controlURL);
printf("Trying to continue anyway\n"); // printf("Trying to continue anyway\n");
break; // break;
case 3: // case 3:
printf("UPnP device found. Is it an IGD ? : %s\n", urls.controlURL); // printf("UPnP device found. Is it an IGD ? : %s\n", urls.controlURL);
printf("Trying to continue anyway\n"); // printf("Trying to continue anyway\n");
break; // break;
default: // default:
printf("Found device (igd ?) : %s\n", urls.controlURL); // printf("Found device (igd ?) : %s\n", urls.controlURL);
printf("Trying to continue anyway\n"); // printf("Trying to continue anyway\n");
} // }
printf("Local LAN ip address : %s\n", lanaddr); // printf("Local LAN ip address : %s\n", lanaddr);
#if 0 //#if 0
printf("getting \"%s\"\n", urls.ipcondescURL); // printf("getting \"%s\"\n", urls.ipcondescURL);
descXML = miniwget(urls.ipcondescURL, &descXMLsize); // descXML = miniwget(urls.ipcondescURL, &descXMLsize);
if (descXML) { // if (descXML) {
/*fwrite(descXML, 1, descXMLsize, stdout);*/ // /*fwrite(descXML, 1, descXMLsize, stdout);*/
free(descXML); descXML = NULL; // free(descXML); descXML = NULL;
} // }
#endif //#endif
//
switch (command) { // switch (command) {
case 'l': // case 'l':
DisplayInfos(&urls, &data); // DisplayInfos(&urls, &data);
ListRedirections(&urls, &data); // ListRedirections(&urls, &data);
break; // break;
case 'L': // case 'L':
NewListRedirections(&urls, &data); // NewListRedirections(&urls, &data);
break; // break;
case 'a': // case 'a':
SetRedirectAndTest(&urls, &data, // SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1], // commandargv[0], commandargv[1],
commandargv[2], commandargv[3], // commandargv[2], commandargv[3],
(commandargc > 4) ? commandargv[4] : "0", // (commandargc > 4) ? commandargv[4] : "0",
description, 0); // description, 0);
break; // break;
case 'd': // case 'd':
RemoveRedirect(&urls, &data, commandargv[0], commandargv[1], // RemoveRedirect(&urls, &data, commandargv[0], commandargv[1],
commandargc > 2 ? commandargv[2] : NULL); // commandargc > 2 ? commandargv[2] : NULL);
break; // break;
case 'n': /* aNy */ // case 'n': /* aNy */
SetRedirectAndTest(&urls, &data, // SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1], // commandargv[0], commandargv[1],
commandargv[2], commandargv[3], // commandargv[2], commandargv[3],
(commandargc > 4) ? commandargv[4] : "0", // (commandargc > 4) ? commandargv[4] : "0",
description, 1); // description, 1);
break; // break;
case 'N': // case 'N':
if (commandargc < 3) // if (commandargc < 3)
fprintf(stderr, "too few arguments\n"); // fprintf(stderr, "too few arguments\n");
//
RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2], // RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2],
commandargc > 3 ? commandargv[3] : NULL); // commandargc > 3 ? commandargv[3] : NULL);
break; // break;
case 's': // case 's':
GetConnectionStatus(&urls, &data); // GetConnectionStatus(&urls, &data);
break; // break;
case 'r': // case 'r':
i = 0; // i = 0;
while (i < commandargc) { // while (i < commandargc) {
if (!is_int(commandargv[i])) { // if (!is_int(commandargv[i])) {
/* 1st parameter not an integer : error */ // /* 1st parameter not an integer : error */
fprintf(stderr, "command -r : %s is not an port number\n", commandargv[i]); // fprintf(stderr, "command -r : %s is not an port number\n", commandargv[i]);
retcode = 1; // retcode = 1;
break; // break;
} else if (is_int(commandargv[i + 1])) { // } else if (is_int(commandargv[i + 1])) {
/* 2nd parameter is an integer : <port> <external_port> <protocol> */ // /* 2nd parameter is an integer : <port> <external_port> <protocol> */
SetRedirectAndTest(&urls, &data, // SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i], // lanaddr, commandargv[i],
commandargv[i + 1], commandargv[i + 2], "0", // commandargv[i + 1], commandargv[i + 2], "0",
description, 0); // description, 0);
i += 3; /* 3 parameters parsed */ // i += 3; /* 3 parameters parsed */
} else { // } else {
/* 2nd parameter not an integer : <port> <protocol> */ // /* 2nd parameter not an integer : <port> <protocol> */
SetRedirectAndTest(&urls, &data, // SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i], // lanaddr, commandargv[i],
commandargv[i], commandargv[i + 1], "0", // commandargv[i], commandargv[i + 1], "0",
description, 0); // description, 0);
i += 2; /* 2 parameters parsed */ // i += 2; /* 2 parameters parsed */
} // }
} // }
break; // break;
case 'A': // case 'A':
SetPinholeAndTest(&urls, &data, // SetPinholeAndTest(&urls, &data,
commandargv[0], commandargv[1], // commandargv[0], commandargv[1],
commandargv[2], commandargv[3], // commandargv[2], commandargv[3],
commandargv[4], commandargv[5]); // commandargv[4], commandargv[5]);
break; // break;
case 'U': // case 'U':
GetPinholeAndUpdate(&urls, &data, // GetPinholeAndUpdate(&urls, &data,
commandargv[0], commandargv[1]); // commandargv[0], commandargv[1]);
break; // break;
case 'C': // case 'C':
for (i = 0; i < commandargc; i++) { // for (i = 0; i < commandargc; i++) {
CheckPinhole(&urls, &data, commandargv[i]); // CheckPinhole(&urls, &data, commandargv[i]);
} // }
break; // break;
case 'K': // case 'K':
for (i = 0; i < commandargc; i++) { // for (i = 0; i < commandargc; i++) {
GetPinholePackets(&urls, &data, commandargv[i]); // GetPinholePackets(&urls, &data, commandargv[i]);
} // }
break; // break;
case 'D': // case 'D':
for (i = 0; i < commandargc; i++) { // for (i = 0; i < commandargc; i++) {
RemovePinhole(&urls, &data, commandargv[i]); // RemovePinhole(&urls, &data, commandargv[i]);
} // }
break; // break;
case 'S': // case 'S':
GetFirewallStatus(&urls, &data); // GetFirewallStatus(&urls, &data);
break; // break;
case 'G': // case 'G':
GetPinholeOutboundTimeout(&urls, &data, // GetPinholeOutboundTimeout(&urls, &data,
commandargv[0], commandargv[1], // commandargv[0], commandargv[1],
commandargv[2], commandargv[3], // commandargv[2], commandargv[3],
commandargv[4]); // commandargv[4]);
break; // break;
case 'P': // case 'P':
printf("Presentation URL found:\n"); // printf("Presentation URL found:\n");
printf(" %s\n", data.presentationurl); // printf(" %s\n", data.presentationurl);
break; // break;
default: // default:
fprintf(stderr, "Unknown switch -%c\n", command); // fprintf(stderr, "Unknown switch -%c\n", command);
retcode = 1; // retcode = 1;
} // }
//
FreeUPNPUrls(&urls); // FreeUPNPUrls(&urls);
} else { // } else {
fprintf(stderr, "No valid UPNP Internet Gateway Device found.\n"); // fprintf(stderr, "No valid UPNP Internet Gateway Device found.\n");
retcode = 1; // retcode = 1;
} // }
freeUPNPDevlist(devlist); devlist = 0; // freeUPNPDevlist(devlist); devlist = 0;
} else { // } else {
fprintf(stderr, "No IGD UPnP Device found on the network !\n"); // fprintf(stderr, "No IGD UPnP Device found on the network !\n");
retcode = 1; // retcode = 1;
} // }
#ifdef _WIN32 //#ifdef _WIN32
nResult = WSACleanup(); // nResult = WSACleanup();
if (nResult != NO_ERROR) { // if (nResult != NO_ERROR) {
fprintf(stderr, "WSACleanup() failed.\n"); // fprintf(stderr, "WSACleanup() failed.\n");
} // }
#endif /* _WIN32 */ //#endif /* _WIN32 */
return retcode; // return retcode;
} //}

View File

@@ -159,11 +159,11 @@ namespace Shared {
if (Thread::threadList.empty() == false) { if (Thread::threadList.empty() == false) {
std::vector<Thread *>::iterator iterFind = std::find(Thread::threadList.begin(), Thread::threadList.end(), this); std::vector<Thread *>::iterator iterFind = std::find(Thread::threadList.begin(), Thread::threadList.end(), this);
if (iterFind == Thread::threadList.end()) { if (iterFind == Thread::threadList.end()) {
if (this != cleanupThread.get()) { /*if (this != cleanupThread.get()) {
char szBuf[8096] = ""; char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] iterFind == Thread::threadList.end() Thread::threadList.size() = %ld", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, Thread::threadList.size()); snprintf(szBuf, 8095, "In [%s::%s Line: %d] iterFind == Thread::threadList.end() Thread::threadList.size() = %ld", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, Thread::threadList.size());
throw megaglest_runtime_error(szBuf); throw megaglest_runtime_error(szBuf);
} }*/
} else { } else {
Thread::threadList.erase(iterFind); Thread::threadList.erase(iterFind);
} }