[raknet] Implement RakPeer::GetMTUSize()

This commit is contained in:
RD42 2024-04-14 19:05:41 +08:00
parent 6c038f5fb6
commit 98dc42b0d7
5 changed files with 66 additions and 5 deletions

40
raknet/MTUSize.h Normal file
View File

@ -0,0 +1,40 @@
/// \file
/// \brief \b [Internal] Defines the default maximum transfer unit.
///
/// This file is part of RakNet Copyright 2003 Kevin Jenkins.
///
/// Usage of RakNet is subject to the appropriate license agreement.
/// Creative Commons Licensees are subject to the
/// license found at
/// http://creativecommons.org/licenses/by-nc/2.5/
/// Single application licensees are subject to the license found at
/// http://www.rakkarsoft.com/SingleApplicationLicense.html
/// Custom license users are subject to the terms therein.
/// GPL license users are subject to the GNU General Public
/// License as published by the Free
/// Software Foundation; either version 2 of the License, or (at your
/// option) any later version.
#ifndef DEFAULT_MTU_SIZE
/// The MTU size to use if RakPeer::SetMTUSize() is not called.
/// \remarks I think many people forget to call RakPeer::SetMTUSize() so I'm setting this to 1500 by default for efficiency.
/// \li \em 17914 16 Mbit/Sec Token Ring
/// \li \em 4464 4 Mbits/Sec Token Ring
/// \li \em 4352 FDDI
/// \li \em 1500. The largest Ethernet packet size \b recommended. This is the typical setting for non-PPPoE, non-VPN connections. The default value for NETGEAR routers, adapters and switches.
/// \li \em 1492. The size PPPoE prefers.
/// \li \em 1472. Maximum size to use for pinging. (Bigger packets are fragmented.)
/// \li \em 1468. The size DHCP prefers.
/// \li \em 1460. Usable by AOL if you don't have large email attachments, etc.
/// \li \em 1430. The size VPN and PPTP prefer.
/// \li \em 1400. Maximum size for AOL DSL.
/// \li \em 576. Typical value to connect to dial-up ISPs.
#ifdef _COMPATIBILITY_1
#define DEFAULT_MTU_SIZE 1264
#else
#define DEFAULT_MTU_SIZE 576
#endif
#endif

View File

@ -7,6 +7,7 @@
RakPeer::RakPeer()
{
MTUSize = DEFAULT_MTU_SIZE;
maximumIncomingConnections = 0;
maximumNumberOfPeers = 0;
endThreads = true;
@ -350,9 +351,16 @@ void RakPeer::vftable_A8()
// TODO: RakPeer::vftable_A8() (saco W: 10038860) (server W: 450360 L: 8070050) (bot W: 4042A0 L: 807514E)
}
void RakPeer::vftable_AC()
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Description:
// Returns the current MTU size
//
// Returns:
// The MTU sized specified in SetMTUSize
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int RakPeer::GetMTUSize( void ) const
{
// TODO: RakPeer::vftable_AC() (saco W: 100388B0) (server W: 4503B0 L: 806DD50) (bot W: 4042F0 L: 807519E)
return MTUSize;
}
void RakPeer::vftable_B0()

View File

@ -5,6 +5,7 @@
#include "Export.h"
#include "RakPeerInterface.h"
#include "ReliabilityLayer.h"
#include "RPCNode.h"
#include "RPCMap.h"
@ -122,7 +123,11 @@ public:
void vftable_A0();
void vftable_A4();
void vftable_A8();
void vftable_AC();
/// Returns the current MTU size
/// \return The current MTU size
int GetMTUSize( void ) const;
void vftable_B0();
void vftable_B4();
void vftable_B8();
@ -169,8 +174,11 @@ protected:
char incomingPassword[256];
unsigned char incomingPasswordLength;
RPCMap rpcMap; // Can't use StrPtrHash because runtime insertions will screw up the indices
char _gap334[1230];
RPCMap rpcMap; // Can't use StrPtrHash because runtime insertions will screw up the indices
int MTUSize;
bool trackFrequencyTable;
};
#endif

View File

@ -119,7 +119,11 @@ public:
virtual void vftable_A0()=0;
virtual void vftable_A4()=0;
virtual void vftable_A8()=0;
virtual void vftable_AC()=0;
/// Returns the current MTU size
/// \return The current MTU size
virtual int GetMTUSize( void ) const=0;
virtual void vftable_B0()=0;
virtual void vftable_B4()=0;
virtual void vftable_B8()=0;

View File

@ -4,6 +4,7 @@
#define __RELIABILITY_LAYER_H
#include "SocketLayer.h"
#include "MTUSize.h"
class ReliabilityLayer
{