Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Core/GameEngine/Include/Common/OptionPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class OptionPreferences : public UserPreferences
Bool getScreenEdgeScrollEnabledInWindowedApp() const;
Bool getScreenEdgeScrollEnabledInFullscreenApp() const;
ScreenEdgeScrollMode getScreenEdgeScrollMode() const;
Bool getSendDelay();
Int getFirewallBehavior();
Short getFirewallPortAllocationDelta();
UnsignedShort getFirewallPortOverride();
Expand Down
20 changes: 0 additions & 20 deletions Core/GameEngine/Include/GameNetwork/FirewallHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ class FirewallHelperClass {
*/
FIREWALL_TYPE_SMART_MANGLING = 4,

/*
** This is a firewall that exhibits the bug as seen in the Netgear firewalls. A previously good
** source port mapping will change in response to unsolicited traffic from a known IP.
*/
FIREWALL_TYPE_NETGEAR_BUG = 8,

/*
** This firewall has a simple absolute offset port allocation scheme.
*/
Expand Down Expand Up @@ -225,20 +219,6 @@ class FirewallHelperClass {
return(TRUE);
};

Bool isNetgear(FirewallBehaviorType behavior) {
if ((behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
return(TRUE);
}
return(FALSE);
};

Bool isNetgear() {
if ((m_behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
return(TRUE);
}
return(FALSE);
};



private:
Expand Down
1 change: 0 additions & 1 deletion Core/GameEngine/Include/GameNetwork/NAT.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ enum NATStateType CPP_11(: Int) {
enum NATConnectionState CPP_11(: Int) {
NATCONNECTIONSTATE_NOSTATE,
NATCONNECTIONSTATE_WAITINGTOBEGIN,
// NATCONNECTIONSTATE_NETGEARDELAY,
NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE,
NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT,
NATCONNECTIONSTATE_WAITINGFORRESPONSE,
Expand Down
12 changes: 0 additions & 12 deletions Core/GameEngine/Source/Common/OptionPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,6 @@ Int OptionPreferences::getStaticGameDetail()
return TheGameLODManager->getStaticGameLODIndex(it->second);
}

Bool OptionPreferences::getSendDelay()
{
OptionPreferences::const_iterator it = find("SendDelay");
if (it == end())
return TheGlobalData->m_firewallSendDelay;

if (stricmp(it->second.str(), "yes") == 0) {
return TRUE;
}
return FALSE;
}

Int OptionPreferences::getFirewallBehavior()
{
OptionPreferences::const_iterator it = find("FirewallBehavior");
Expand Down
52 changes: 0 additions & 52 deletions Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,6 @@ Bool FirewallHelperClass::detectionBeginUpdate() {
m_behavior = FIREWALL_TYPE_SIMPLE;
DEBUG_LOG(("Source port %d specified by user", TheGlobalData->m_firewallPortOverride));

if (TheGlobalData->m_firewallSendDelay) {
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
addbehavior |= (UnsignedInt)m_behavior;
m_behavior = (FirewallBehaviorType) addbehavior;
DEBUG_LOG(("Netgear bug specified by command line or SendDelay flag"));
}
m_currentState = DETECTIONSTATE_DONE;
return TRUE;
}
Expand Down Expand Up @@ -714,20 +708,6 @@ Bool FirewallHelperClass::detectionBeginUpdate() {
// memcpy(&(m_manglers[i]), &mangler_addresses[i][0], 4);
}

DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Testing for Netgear bug"));

/*
** See if the user specified a netgear firewall - that will save us the trouble.
*/
if (TheGlobalData->m_firewallSendDelay) {
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
addbehavior |= (UnsignedInt)m_behavior;
m_behavior = (FirewallBehaviorType) addbehavior;
DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Netgear bug specified by command line or SendDelay flag"));
} else {
DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Netgear bug not specified"));
}

/*
** OK, we have our manglers.
**
Expand Down Expand Up @@ -1173,28 +1153,7 @@ Bool FirewallHelperClass::detectionTest4Stage2Update() {
Bool FirewallHelperClass::detectionTest5Update() {
/*
** We have done all the tests we *have* to. There's other info that it would be nice to know though.
**
** Test for the netgear bug behavior.
*/
#if (0)
// moved to before test 1. Moved because this flag could be specified for another firewall
// for testing purposes and never get this far because it has behavior that doesn't require
// all the tests to be performed.
// BGC 10/1/02
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Testing for Netgear bug"));

/*
** See if the user specified a netgear firewall - that will save us the trouble.
*/
if (TheGlobalData->m_firewallSendDelay) {
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
addbehavior |= (UnsignedInt)m_behavior;
m_behavior = (FirewallBehaviorType) addbehavior;
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Netgear bug specified by command line or SendDelay flag"));
} else {
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Netgear bug not specified"));
}
#endif // #if (0)

DEBUG_LOG_RAW(("FirewallHelperClass::detectionTest5Update - All done, behavior is: "));

Expand All @@ -1207,9 +1166,6 @@ Bool FirewallHelperClass::detectionTest5Update() {
if ((m_behavior & FIREWALL_TYPE_SMART_MANGLING) != 0) {
DEBUG_LOG_RAW((" FIREWALL_TYPE_SMART_MANGLING "));
}
if ((m_behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
DEBUG_LOG_RAW((" FIREWALL_TYPE_NETGEAR_BUG "));
}
if ((m_behavior & FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION) != 0) {
DEBUG_LOG_RAW((" FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION "));
}
Expand Down Expand Up @@ -1433,10 +1389,6 @@ Int FirewallHelperClass::getFirewallHardness(FirewallBehaviorType behavior)
hardness += 3;
}

if (((UnsignedInt)FIREWALL_TYPE_NETGEAR_BUG & fw) != 0) {
hardness += 10;
}

if (((UnsignedInt)FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION & fw) != 0) {
hardness += 1;
}
Expand Down Expand Up @@ -1486,10 +1438,6 @@ Int FirewallHelperClass::getFirewallRetries(FirewallBehaviorType behavior)
retries += 1;
}

if (((UnsignedInt)FIREWALL_TYPE_NETGEAR_BUG & fw) != 0) {
//retries += 10;
}

if (((UnsignedInt)FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION & fw) != 0) {
//retries += 1;
}
Expand Down
99 changes: 10 additions & 89 deletions Core/GameEngine/Source/GameNetwork/NAT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ NATConnectionState NAT::connectionUpdate() {
mangledPort = TheFirewallHelper->getManglerResponse(m_packetID);
}
if (mangledPort != 0) {
// we got a response. now we need to start probing (unless of course we have a netgear)
// we got a response. now we need to start probing
processManglerResponse(mangledPort);

// we know there is a firewall helper if we got here.
Expand Down Expand Up @@ -497,50 +497,7 @@ void NAT::establishConnectionPaths() {

m_previousSourcePort = 0;

// check for netgear bug behavior.
// as an aside, if there are more than 2 netgear bug firewall's in the game,
// it probably isn't going to work so well. stupid netgear.

// nodes with a netgear bug behavior need to be matched up first. This prevents
// the NAT table from being reset for connections to other nodes. This also happens
// to be the reason why I call them "nodes" rather than "slots" or "players" as the
// ordering has to be messed with to get the netgears to make love, not war.
DEBUG_LOG(("NAT::establishConnectionPaths - about to set up the node list"));
DEBUG_LOG(("NAT::establishConnectionPaths - doing the netgear stuff"));
UnsignedInt otherNetgearNum = -1;
for (i = 0; i < MAX_SLOTS; ++i) {
if ((m_slotList != nullptr) && (m_slotList[i] != nullptr)) {
if ((m_slotList[i]->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) {
if (otherNetgearNum == -1) {
// this is the start of a new pair, put it in as the first non -1 node connection pair thing.
Int nodeindex = 0;
while ((m_connectionPairs[m_connectionPairIndex][0][nodeindex] == -1) || (m_connectionNodes[nodeindex].m_slotIndex != -1)) {
++nodeindex;
}
m_connectionNodes[nodeindex].m_slotIndex = i;
m_connectionNodes[nodeindex].m_behavior = m_slotList[i]->getNATBehavior();
connectionAssigned[i] = TRUE;
otherNetgearNum = nodeindex;
DEBUG_LOG(("NAT::establishConnectionPaths - first netgear in pair. assigning node %d to slot %d (%ls)", nodeindex, i, m_slotList[i]->getName().str()));
} else {
// this is the second in the pair of netgears, pair this up with the other one
// for the first round.
Int nodeindex = 0;
while (m_connectionPairs[m_connectionPairIndex][0][nodeindex] != otherNetgearNum) {
++nodeindex;
}
m_connectionNodes[nodeindex].m_slotIndex = i;
m_connectionNodes[nodeindex].m_behavior = m_slotList[i]->getNATBehavior();
connectionAssigned[i] = TRUE;
otherNetgearNum = -1;
DEBUG_LOG(("NAT::establishConnectionPaths - second netgear in pair. assigning node %d to slot %d (%ls)", nodeindex, i, m_slotList[i]->getName().str()));
}
}
}
}

// fill in the rest of the nodes with the remaining slots.
DEBUG_LOG(("NAT::establishConnectionPaths - doing the non-Netgear nodes"));
for (i = 0; i < MAX_SLOTS; ++i) {
if (connectionAssigned[i] == TRUE) {
continue;
Expand Down Expand Up @@ -662,6 +619,7 @@ void NAT::doThisConnectionRound() {
if (i == m_localNodeNumber) {
m_targetNodeNumber = targetNodeNumber;
DEBUG_LOG(("NAT::doThisConnectionRound - Local node is connecting to node %d", m_targetNodeNumber));
#if defined(DEBUG_LOGGING)
UnsignedInt targetSlotIndex = m_connectionNodes[(m_connectionPairs[m_connectionPairIndex][m_connectionRound][i])].m_slotIndex;
GameSlot *targetSlot = m_slotList[targetSlotIndex];
GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex];
Expand All @@ -671,24 +629,13 @@ void NAT::doThisConnectionRound() {
DEBUG_LOG(("NAT::doThisConnectionRound - Target slot index = %d (%ls)", targetSlotIndex, m_slotList[targetSlotIndex]->getName().str()));
DEBUG_LOG(("NAT::doThisConnectionRound - Target slot has NAT behavior 0x%8X, local slot has NAT behavior 0x%8X", targetSlot->getNATBehavior(), localSlot->getNATBehavior()));

#if defined(DEBUG_LOGGING)
UnsignedInt targetIP = targetSlot->getIP();
UnsignedInt localIP = localSlot->getIP();
#endif

DEBUG_LOG(("NAT::doThisConnectionRound - Target slot has IP %d.%d.%d.%d Local slot has IP %d.%d.%d.%d",
PRINTF_IP_AS_4_INTS(targetIP),
PRINTF_IP_AS_4_INTS(localIP)));

if (((targetSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) == 0) &&
((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0)) {

// we have a netgear bug type behavior and the target does not, so we need them to send to us
// first to avoid having our NAT table reset.

DEBUG_LOG(("NAT::doThisConnectionRound - Local node has a netgear and the target node does not, need to delay our probe."));
m_timeTillNextSend = -1;
}
#endif

// figure out which port number I'm using for this connection
// this merely starts to talk to the mangler server, we have to keep calling
Expand Down Expand Up @@ -941,26 +888,6 @@ void NAT::probed(Int nodeNumber) {
if (m_beenProbed == FALSE) {
m_beenProbed = TRUE;
DEBUG_LOG(("NAT::probed - just got probed for the first time."));
if ((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) {
DEBUG_LOG(("NAT::probed - we have a NETGEAR and we were just probed for the first time"));
GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex];
DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::probed - targetSlot is null"));
if (targetSlot == nullptr) {
DEBUG_LOG(("NAT::probed - targetSlot is null, failed this connection"));
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED);
return;
}

if (targetSlot->getPort() == 0) {
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT);
DEBUG_LOG(("NAT::probed - still waiting for mangled port"));
} else {
DEBUG_LOG(("NAT::probed - sending a probe to %ls", targetSlot->getName().str()));
sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
notifyTargetOfProbe(targetSlot);
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
}
}
}
}

Expand Down Expand Up @@ -996,20 +923,15 @@ void NAT::gotMangledPort(Int nodeNumber, UnsignedShort mangledPort) {

targetSlot->setPort(mangledPort);
DEBUG_LOG(("NAT::gotMangledPort - got mangled port number %d from our target node (%ls)", mangledPort, targetSlot->getName().str()));
if (((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) == 0) || (m_beenProbed == TRUE) ||
(((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) && ((targetSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0))) {
#ifdef DEBUG_LOGGING
UnsignedInt ip = targetSlot->getIP();
UnsignedInt ip = targetSlot->getIP();
#endif
DEBUG_LOG(("NAT::gotMangledPort - don't have a netgear or we have already been probed, or both my target and I have a netgear, send a PROBE. Sending to %d.%d.%d.%d:%d",
PRINTF_IP_AS_4_INTS(ip), targetSlot->getPort()));
DEBUG_LOG(("NAT::gotMangledPort - send a PROBE. Sending to %d.%d.%d.%d:%d",
PRINTF_IP_AS_4_INTS(ip), targetSlot->getPort()));

sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
notifyTargetOfProbe(targetSlot);
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
} else {
DEBUG_LOG(("NAT::gotMangledPort - we are a netgear, not sending a PROBE yet."));
}
sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
notifyTargetOfProbe(targetSlot);
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
}

void NAT::gotInternalAddress(Int nodeNumber, UnsignedInt address) {
Expand Down Expand Up @@ -1171,8 +1093,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
DEBUG_LOG(("NAT::processGlobalMessage - got message from slot %d, message is \"%s\"", slotNum, ptr));
if (strncmp(ptr, "PROBED", strlen("PROBED")) == 0) {
// format: PROBED<node number>
// a probe has been sent at us, if we are waiting because of a netgear or something, we
// should start sending our own probes.
// a probe has been sent at us; notify probed node.
Int node = atoi(ptr + strlen("PROBED"));
if (node == m_targetNodeNumber) {
// make sure we're being probed by who we're supposed to be probed by.
Expand Down
1 change: 0 additions & 1 deletion Generals/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ class GlobalData : public SubsystemInterface

UnsignedInt m_defaultIP; ///< preferred IP address for LAN
UnsignedInt m_firewallBehavior; ///< Last detected firewall behavior
Bool m_firewallSendDelay; ///< Use send delay for firewall connection negotiations
UnsignedInt m_firewallPortOverride; ///< User-specified port to be used
Short m_firewallPortAllocationDelta; ///< the port allocation delta last detected.

Expand Down
2 changes: 0 additions & 2 deletions Generals/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ GlobalData::GlobalData()
// m_languageFilterPref = false;
m_languageFilterPref = true;
m_firewallBehavior = FirewallHelperClass::FIREWALL_TYPE_UNKNOWN;
m_firewallSendDelay = FALSE;
m_firewallPortOverride = 0;
m_firewallPortAllocationDelta = 0;
m_loadScreenDemo = FALSE;
Expand Down Expand Up @@ -1205,7 +1204,6 @@ void GlobalData::parseGameDataDefinition( INI* ini )
TheWritableGlobalData->m_drawScrollAnchor = optionPref.getDrawScrollAnchor();
TheWritableGlobalData->m_moveScrollAnchor = optionPref.getMoveScrollAnchor();
TheWritableGlobalData->m_defaultIP = optionPref.getLANIPAddress();
TheWritableGlobalData->m_firewallSendDelay = optionPref.getSendDelay();
TheWritableGlobalData->m_firewallBehavior = optionPref.getFirewallBehavior();
TheWritableGlobalData->m_firewallPortAllocationDelta = optionPref.getFirewallPortAllocationDelta();
TheWritableGlobalData->m_firewallPortOverride = optionPref.getFirewallPortOverride();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ void EstablishConnectionsMenu::setPlayerStatus(Int slot, NATConnectionState stat
DEBUG_ASSERTCRASH(control != nullptr, ("player status control for slot %d is null", slot));
return;
}
// if (state == NATCONNECTIONSTATE_NETGEARDELAY) {
// GadgetStaticTextSetText(control, TheGameText->fetch("GUI:NetgearDelay"));
if (state == NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE) {
GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingForManglerResponse"));
} else if (state == NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT) {
Expand Down
Loading
Loading