Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
NAT Class Reference

#include <NAT.h>

Public Member Functions

 NAT ()
 
virtual ~NAT ()
 
NATStateType update ()
 
void attachSlotList (GameSlot **slotList, Int localSlot, UnsignedInt localIP)
 
void establishConnectionPaths ()
 
Int getSlotPort (Int slot)
 
TransportgetTransport ()
 return the newly created Transport layer that has all the connections and whatnot.
 
void processGlobalMessage (Int slotNum, const char *options)
 

Protected Member Functions

NATConnectionState connectionUpdate ()
 the update function for the connections.
 
void sendMangledSourcePort ()
 starts the process to get the next mangled source port.
 
void processManglerResponse (UnsignedShort mangledPort)
 
Bool allConnectionsDoneThisRound ()
 
Bool allConnectionsDone ()
 
void generatePortNumbers (GameSlot **slotList, Int localSlot)
 generate all of the slots' port numbers to be used.
 
void doThisConnectionRound ()
 compute who will connect with who for this round.
 
void setConnectionState (Int nodeNumber, NATConnectionState state)
 central point for changing a connection's state.
 
void sendAProbe (UnsignedInt ip, UnsignedShort port, Int fromNode)
 send a "PROBE" packet to this IP and port.
 
void notifyTargetOfProbe (GameSlot *targetSlot)
 
void notifyUsersOfConnectionDone (Int nodeIndex)
 
void notifyUsersOfConnectionFailed (Int nodeIndex)
 
void sendMangledPortNumberToTarget (UnsignedShort mangledPort, GameSlot *targetSlot)
 
void probed (Int nodeNumber)
 
void gotMangledPort (Int nodeNumber, UnsignedShort mangledPort)
 
void gotInternalAddress (Int nodeNumber, UnsignedInt address)
 
void connectionComplete (Int slotIndex)
 
void connectionFailed (Int slotIndex)
 

Protected Attributes

Transportm_transport
 
GameSlot ** m_slotList
 
NATStateType m_NATState
 
Int m_localNodeNumber
 The node number of the local player.
 
Int m_targetNodeNumber
 The node number of the player we are connecting to this round.
 
UnsignedInt m_localIP
 The IP of the local computer.
 
UnsignedInt m_numNodes
 The number of players we have to connect together.
 
UnsignedInt m_connectionRound
 The "round" of connections we are currently on.
 
Int m_numRetries
 
Int m_maxNumRetriesAllowed
 
UnsignedShort m_packetID
 
UnsignedShort m_spareSocketPort
 
time_t m_manglerRetryTime
 
Int m_manglerRetries
 
UnsignedShort m_previousSourcePort
 
Bool m_beenProbed
 have I been notified that I've been probed this round?
 
UnsignedInt m_manglerAddress
 
time_t m_timeTillNextSend
 The number of milliseconds till we send to the other guy's port again.
 
NATConnectionState m_connectionStates [MAX_SLOTS]
 connection states for this round for all the nodes.
 
ConnectionNodeType m_connectionNodes [MAX_SLOTS]
 info regarding the nodes that are being connected.
 
UnsignedShort m_sourcePorts [MAX_SLOTS]
 the source ports that the other players communicate to us on.
 
Bool m_myConnections [MAX_SLOTS]
 keeps track of all the nodes I've connected to. For keepalive.
 
time_t m_nextKeepaliveTime
 the next time we will send out our keepalive packets.
 
Int m_connectionPairIndex
 
UnsignedShort m_startingPortNumber
 
time_t m_nextPortSendTime
 Last time we sent our mangled port number to our target this round.
 
time_t m_timeoutTime
 the time at which we will time out waiting for the other player's port number.
 
time_t m_roundTimeout
 the time at which we will time out this connection round.
 

Static Protected Attributes

static Int m_connectionPairs [MAX_SLOTS-1][MAX_SLOTS-1][MAX_SLOTS]
 
static Int m_timeBetweenRetries = 500
 
static time_t m_manglerRetryTimeInterval = 300
 
static Int m_maxAllowedManglerRetries = 25
 
static time_t m_keepaliveInterval = 15000
 
static time_t m_timeToWaitForPort = 15000
 
static time_t m_timeForRoundTimeout = 15000
 

Detailed Description

Definition at line 66 of file NAT.h.

Constructor & Destructor Documentation

◆ NAT()

NAT::NAT ( )

Definition at line 150 of file NAT.cpp.

◆ ~NAT()

NAT::~NAT ( )
virtual

Definition at line 178 of file NAT.cpp.

Member Function Documentation

◆ allConnectionsDone()

Bool NAT::allConnectionsDone ( )
protected

Definition at line 916 of file NAT.cpp.

◆ allConnectionsDoneThisRound()

Bool NAT::allConnectionsDoneThisRound ( )
protected

Definition at line 949 of file NAT.cpp.

◆ attachSlotList()

void NAT::attachSlotList ( GameSlot ** slotList,
Int localSlot,
UnsignedInt localIP )

Definition at line 617 of file NAT.cpp.

◆ connectionComplete()

void NAT::connectionComplete ( Int slotIndex)
protected

Definition at line 960 of file NAT.cpp.

◆ connectionFailed()

void NAT::connectionFailed ( Int slotIndex)
protected

Definition at line 964 of file NAT.cpp.

◆ connectionUpdate()

NATConnectionState NAT::connectionUpdate ( )
protected

the update function for the connections.

Definition at line 300 of file NAT.cpp.

◆ doThisConnectionRound()

void NAT::doThisConnectionRound ( )
protected

compute who will connect with who for this round.

Definition at line 657 of file NAT.cpp.

◆ establishConnectionPaths()

void NAT::establishConnectionPaths ( )

Definition at line 463 of file NAT.cpp.

◆ generatePortNumbers()

void NAT::generatePortNumbers ( GameSlot ** slotList,
Int localSlot )
protected

generate all of the slots' port numbers to be used.

Definition at line 638 of file NAT.cpp.

◆ getSlotPort()

Int NAT::getSlotPort ( Int slot)

Definition at line 630 of file NAT.cpp.

◆ getTransport()

Transport * NAT::getTransport ( )

return the newly created Transport layer that has all the connections and whatnot.

Definition at line 650 of file NAT.cpp.

◆ gotInternalAddress()

void NAT::gotInternalAddress ( Int nodeNumber,
UnsignedInt address )
protected

Definition at line 1051 of file NAT.cpp.

◆ gotMangledPort()

void NAT::gotMangledPort ( Int nodeNumber,
UnsignedShort mangledPort )
protected

Definition at line 1004 of file NAT.cpp.

◆ notifyTargetOfProbe()

void NAT::notifyTargetOfProbe ( GameSlot * targetSlot)
protected

Definition at line 1077 of file NAT.cpp.

◆ notifyUsersOfConnectionDone()

void NAT::notifyUsersOfConnectionDone ( Int nodeIndex)
protected

Definition at line 1092 of file NAT.cpp.

◆ notifyUsersOfConnectionFailed()

void NAT::notifyUsersOfConnectionFailed ( Int nodeIndex)
protected

Definition at line 1134 of file NAT.cpp.

◆ probed()

void NAT::probed ( Int nodeNumber)
protected

Definition at line 968 of file NAT.cpp.

◆ processGlobalMessage()

void NAT::processGlobalMessage ( Int slotNum,
const char * options )

Definition at line 1201 of file NAT.cpp.

◆ processManglerResponse()

void NAT::processManglerResponse ( UnsignedShort mangledPort)
protected

Definition at line 848 of file NAT.cpp.

◆ sendAProbe()

void NAT::sendAProbe ( UnsignedInt ip,
UnsignedShort port,
Int fromNode )
protected

send a "PROBE" packet to this IP and port.

Definition at line 726 of file NAT.cpp.

◆ sendMangledPortNumberToTarget()

void NAT::sendMangledPortNumberToTarget ( UnsignedShort mangledPort,
GameSlot * targetSlot )
protected

Definition at line 1185 of file NAT.cpp.

◆ sendMangledSourcePort()

void NAT::sendMangledSourcePort ( )
protected

starts the process to get the next mangled source port.

Definition at line 738 of file NAT.cpp.

◆ setConnectionState()

void NAT::setConnectionState ( Int nodeNumber,
NATConnectionState state )
protected

central point for changing a connection's state.

Definition at line 1286 of file NAT.cpp.

◆ update()

NATStateType NAT::update ( )

Definition at line 189 of file NAT.cpp.

Member Data Documentation

◆ m_beenProbed

Bool NAT::m_beenProbed
protected

have I been notified that I've been probed this round?

Definition at line 124 of file NAT.h.

◆ m_connectionNodes

ConnectionNodeType NAT::m_connectionNodes[MAX_SLOTS]
protected

info regarding the nodes that are being connected.

Definition at line 131 of file NAT.h.

◆ m_connectionPairIndex

Int NAT::m_connectionPairIndex
protected

Definition at line 139 of file NAT.h.

◆ m_connectionPairs

Int NAT::m_connectionPairs
staticprotected

Definition at line 67 of file NAT.h.

◆ m_connectionRound

UnsignedInt NAT::m_connectionRound
protected

The "round" of connections we are currently on.

Definition at line 113 of file NAT.h.

◆ m_connectionStates

NATConnectionState NAT::m_connectionStates[MAX_SLOTS]
protected

connection states for this round for all the nodes.

Definition at line 129 of file NAT.h.

◆ m_keepaliveInterval

time_t NAT::m_keepaliveInterval = 15000
staticprotected

Definition at line 154 of file NAT.h.

◆ m_localIP

UnsignedInt NAT::m_localIP
protected

The IP of the local computer.

Definition at line 111 of file NAT.h.

◆ m_localNodeNumber

Int NAT::m_localNodeNumber
protected

The node number of the local player.

Definition at line 109 of file NAT.h.

◆ m_manglerAddress

UnsignedInt NAT::m_manglerAddress
protected

Definition at line 126 of file NAT.h.

◆ m_manglerRetries

Int NAT::m_manglerRetries
protected

Definition at line 121 of file NAT.h.

◆ m_manglerRetryTime

time_t NAT::m_manglerRetryTime
protected

Definition at line 120 of file NAT.h.

◆ m_manglerRetryTimeInterval

time_t NAT::m_manglerRetryTimeInterval = 300
staticprotected

Definition at line 152 of file NAT.h.

◆ m_maxAllowedManglerRetries

Int NAT::m_maxAllowedManglerRetries = 25
staticprotected

Definition at line 153 of file NAT.h.

◆ m_maxNumRetriesAllowed

Int NAT::m_maxNumRetriesAllowed
protected

Definition at line 116 of file NAT.h.

◆ m_myConnections

Bool NAT::m_myConnections[MAX_SLOTS]
protected

keeps track of all the nodes I've connected to. For keepalive.

Definition at line 135 of file NAT.h.

◆ m_NATState

NATStateType NAT::m_NATState
protected

Definition at line 108 of file NAT.h.

◆ m_nextKeepaliveTime

time_t NAT::m_nextKeepaliveTime
protected

the next time we will send out our keepalive packets.

Definition at line 136 of file NAT.h.

◆ m_nextPortSendTime

time_t NAT::m_nextPortSendTime
protected

Last time we sent our mangled port number to our target this round.

Definition at line 146 of file NAT.h.

◆ m_numNodes

UnsignedInt NAT::m_numNodes
protected

The number of players we have to connect together.

Definition at line 112 of file NAT.h.

◆ m_numRetries

Int NAT::m_numRetries
protected

Definition at line 115 of file NAT.h.

◆ m_packetID

UnsignedShort NAT::m_packetID
protected

Definition at line 118 of file NAT.h.

◆ m_previousSourcePort

UnsignedShort NAT::m_previousSourcePort
protected

Definition at line 122 of file NAT.h.

◆ m_roundTimeout

time_t NAT::m_roundTimeout
protected

the time at which we will time out this connection round.

Definition at line 149 of file NAT.h.

◆ m_slotList

GameSlot** NAT::m_slotList
protected

Definition at line 107 of file NAT.h.

◆ m_sourcePorts

UnsignedShort NAT::m_sourcePorts[MAX_SLOTS]
protected

the source ports that the other players communicate to us on.

Definition at line 133 of file NAT.h.

◆ m_spareSocketPort

UnsignedShort NAT::m_spareSocketPort
protected

Definition at line 119 of file NAT.h.

◆ m_startingPortNumber

UnsignedShort NAT::m_startingPortNumber
protected

the starting port number for this game. The slots all get port numbers with their port numbers based on this number. this is done so that games that are played right after each other with the same players in the same slot order will not use the old source port allocation scheme in case their NAT hasn't timed out that connection.

Definition at line 141 of file NAT.h.

◆ m_targetNodeNumber

Int NAT::m_targetNodeNumber
protected

The node number of the player we are connecting to this round.

Definition at line 110 of file NAT.h.

◆ m_timeBetweenRetries

Int NAT::m_timeBetweenRetries = 500
staticprotected

Definition at line 151 of file NAT.h.

◆ m_timeForRoundTimeout

time_t NAT::m_timeForRoundTimeout = 15000
staticprotected

Definition at line 156 of file NAT.h.

◆ m_timeoutTime

time_t NAT::m_timeoutTime
protected

the time at which we will time out waiting for the other player's port number.

Definition at line 148 of file NAT.h.

◆ m_timeTillNextSend

time_t NAT::m_timeTillNextSend
protected

The number of milliseconds till we send to the other guy's port again.

Definition at line 128 of file NAT.h.

◆ m_timeToWaitForPort

time_t NAT::m_timeToWaitForPort = 15000
staticprotected

Definition at line 155 of file NAT.h.

◆ m_transport

Transport* NAT::m_transport
protected

Definition at line 106 of file NAT.h.


The documentation for this class was generated from the following files: