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
5 changes: 1 addition & 4 deletions Core/GameEngine/Include/Common/OptionPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ class OptionPreferences : public UserPreferences
Bool getScreenEdgeScrollEnabledInWindowedApp() const;
Bool getScreenEdgeScrollEnabledInFullscreenApp() const;
ScreenEdgeScrollMode getScreenEdgeScrollMode() const;
Int getFirewallBehavior();
Short getFirewallPortAllocationDelta();
UnsignedShort getFirewallPortOverride();
Bool getFirewallNeedToRefresh();

Bool usesSystemMapDir();
AsciiString getPreferred3DProvider();
AsciiString getSpeakerType();
Expand Down
38 changes: 14 additions & 24 deletions Core/GameEngine/Include/GameNetwork/FirewallHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ struct ManglerMessage {
static const Int MAX_NUM_MANGLERS = 4;
static const UnsignedShort MANGLER_PORT = 4321;

static const UnsignedInt BEHAVIOR_DETECTION_WAIT_TIME = 6000;

class FirewallHelperClass {

public:
Expand Down Expand Up @@ -171,20 +173,19 @@ class FirewallHelperClass {
FirewallHelperClass();
virtual ~FirewallHelperClass();
Bool detectFirewall();
UnsignedShort getRawFirewallBehavior() {return((UnsignedShort)m_behavior);}
Short getSourcePortAllocationDelta();
Int getFirewallHardness(FirewallBehaviorType behavior);
Int getFirewallRetries(FirewallBehaviorType behavior);
void detectFirewallBehavior();
UnsignedShort getRawFirewallBehavior() const {return((UnsignedShort)m_behavior);}
Short getSourcePortAllocationDelta() const;
Int getFirewallHardness(FirewallBehaviorType behavior) const;
Int getFirewallRetries(FirewallBehaviorType behavior) const;
void setSourcePortPoolStart(Int port) {m_sourcePortPool = port;};
Int getSourcePortPool() {return(m_sourcePortPool);};
void readFirewallBehavior();
Int getSourcePortPool() const {return(m_sourcePortPool);};
void reset();
Bool behaviorDetectionUpdate();

FirewallBehaviorType getFirewallBehavior();
void writeFirewallBehavior();
FirewallBehaviorType getFirewallBehavior() const;

void flagNeedToRefresh(Bool flag);
Bool isBehaviorDetectionComplete() const {return(m_currentState == DETECTIONSTATE_DONE);}

static void getManglerName(Int manglerIndex, Char *nameBuf);
Bool sendToManglerFromPort(UnsignedInt address, UnsignedShort port, UnsignedShort packetID, Bool blitzme = FALSE);
Expand All @@ -207,26 +208,23 @@ class FirewallHelperClass {
/*
** Behavior query functions.
*/
Bool isNAT() {
Bool isNAT() const {
if (m_behavior == FIREWALL_TYPE_UNKNOWN || (m_behavior & FIREWALL_TYPE_SIMPLE) != 0) {
return(FALSE);
}
return(TRUE);
};

Bool isNAT(FirewallBehaviorType behavior) {
Bool isNAT(FirewallBehaviorType behavior) const {
if (behavior == FIREWALL_TYPE_UNKNOWN || (behavior & FIREWALL_TYPE_SIMPLE) != 0) {
return(FALSE);
}
return(TRUE);
};



private:

Int getNATPortAllocationScheme(Int numPorts, UnsignedShort *originalPorts, UnsignedShort *mangledPorts, Bool &relativeDelta, Bool &looksGood);
void detectFirewallBehavior(/*Bool &canRecord*/);
Bool getReferencePort();

SpareSocketStruct * findSpareSocketByPort(UnsignedShort port);
Expand All @@ -239,21 +237,11 @@ class FirewallHelperClass {
*/
FirewallBehaviorType m_behavior;

/*
** How did the firewall behave the last time we ran the game.
*/
FirewallBehaviorType m_lastBehavior;

/*
** What is the delta in our firewalls NAT port allocation scheme.
*/
Int m_sourcePortAllocationDelta;

/*
** What was the delta the last time we ran?
*/
Int m_lastSourcePortAllocationDelta;

/*
** Source ports used only to discover port allocation patterns.
** Needs to be static so that previous communications with the manglers
Expand Down Expand Up @@ -281,9 +269,11 @@ class FirewallHelperClass {

Int m_numResponses;
Int m_currentTry;
UnsignedInt m_lastDetectionTime;
};



extern FirewallHelperClass *TheFirewallHelper;
FirewallHelperClass * createFirewallHelper();

53 changes: 0 additions & 53 deletions Core/GameEngine/Source/Common/OptionPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,59 +451,6 @@ Int OptionPreferences::getStaticGameDetail()
return TheGameLODManager->getStaticGameLODIndex(it->second);
}

Int OptionPreferences::getFirewallBehavior()
{
OptionPreferences::const_iterator it = find("FirewallBehavior");
if (it == end())
return TheGlobalData->m_firewallBehavior;

Int behavior = atoi(it->second.str());
if (behavior < 0)
{
behavior = 0;
}
return behavior;
}

Short OptionPreferences::getFirewallPortAllocationDelta()
{
OptionPreferences::const_iterator it = find("FirewallPortAllocationDelta");
if (it == end()) {
return TheGlobalData->m_firewallPortAllocationDelta;
}

Short delta = atoi(it->second.str());
return delta;
}

UnsignedShort OptionPreferences::getFirewallPortOverride()
{
OptionPreferences::const_iterator it = find("FirewallPortOverride");
if (it == end()) {
return TheGlobalData->m_firewallPortOverride;
}

Int portOverride = atoi(it->second.str());
if (portOverride < 0 || portOverride > 65535)
portOverride = 0;
return portOverride;
}

Bool OptionPreferences::getFirewallNeedToRefresh()
{
OptionPreferences::const_iterator it = find("FirewallNeedToRefresh");
if (it == end()) {
return FALSE;
}

Bool retval = FALSE;
AsciiString str = it->second;
if (str.compareNoCase("TRUE") == 0) {
retval = TRUE;
}
return retval;
}

AsciiString OptionPreferences::getPreferred3DProvider()
{
OptionPreferences::const_iterator it = find("3DAudioProvider");
Expand Down
Loading
Loading