47 class HuffmanEncodingTree;
48 class PluginInterface2;
83 StartupResult Startup(
unsigned int maxConnections,
SocketDescriptor *socketDescriptors,
unsigned socketDescriptorCount,
int threadPriority=-99999 );
94 bool InitializeSecurity(
const char *publicKey,
const char *privateKey,
bool bRequireClientKey =
false );
98 void DisableSecurity(
void );
105 void AddToSecurityExceptionList(
const char *ip);
109 void RemoveFromSecurityExceptionList(
const char *ip);
114 bool IsInSecurityExceptionList(
const char *ip);
123 void SetMaximumIncomingConnections(
unsigned short numberAllowed );
127 unsigned int GetMaximumIncomingConnections(
void )
const;
131 unsigned short NumberOfConnections(
void)
const;
139 void SetIncomingPassword(
const char* passwordData,
int passwordDataLength );
144 void GetIncomingPassword(
char* passwordData,
int *passwordDataLength );
167 ConnectionAttemptResult Connect(
const char* host,
unsigned short remotePort,
const char *passwordData,
int passwordDataLength,
PublicKey *publicKey=0,
unsigned connectionSocketIndex=0,
unsigned sendConnectionAttemptCount=6,
unsigned timeBetweenSendConnectionAttemptsMS=1000,
SLNet::TimeMS timeoutTime=0 );
180 virtual ConnectionAttemptResult ConnectWithSocket(
const char* host,
unsigned short remotePort,
const char *passwordData,
int passwordDataLength,
RakNetSocket2* socket,
PublicKey *publicKey=0,
unsigned sendConnectionAttemptCount=6,
unsigned timeBetweenSendConnectionAttemptsMS=1000,
SLNet::TimeMS timeoutTime=0);
194 void Shutdown(
unsigned int blockDuration,
unsigned char orderingChannel=0,
PacketPriority disconnectionNotificationPriority=
LOW_PRIORITY );
198 bool IsActive(
void )
const;
203 bool GetConnectionList(
SystemAddress *remoteSystems,
unsigned short *numberOfSystems )
const;
208 virtual uint32_t GetNextSendReceipt(
void);
213 virtual uint32_t IncrementNextSendReceipt(
void);
235 void SendLoopback(
const char *data,
const int length );
283 void DeallocatePacket(
Packet *packet );
287 unsigned int GetMaximumNumberOfPeers(
void )
const;
313 int GetIndexFromSystemAddress(
const SystemAddress systemAddress )
const;
320 SystemAddress GetSystemAddressFromIndex(
unsigned int index );
325 RakNetGUID GetGUIDFromIndex(
unsigned int index );
337 void AddToBanList(
const char *IP,
SLNet::TimeMS milliseconds=0 );
341 void RemoveFromBanList(
const char *IP );
344 void ClearBanList(
void );
349 bool IsBanned(
const char *IP );
354 void SetLimitIPConnectionFrequency(
bool b);
370 bool Ping(
const char* host,
unsigned short remotePort,
bool onlyReplyOnAcceptingConnections,
unsigned connectionSocketIndex=0 );
380 int GetLastPing(
const AddressOrGUID systemIdentifier )
const;
385 int GetLowestPing(
const AddressOrGUID systemIdentifier )
const;
391 void SetOccasionalPing(
bool doPing );
405 void SetOfflinePingResponse(
const char *data,
const unsigned int length );
411 void GetOfflinePingResponse(
char **data,
unsigned int *length );
424 void SetInternalID(
SystemAddress systemAddress,
int index=0);
455 bool GetClientPublicKeyFromSystemAddress(
const SystemAddress input,
char *client_public_key )
const;
478 unsigned GetNumberOfAddresses(
void );
483 const char* GetLocalIP(
unsigned int index );
489 bool IsLocalIP(
const char *ip );
494 void AllowConnectionResponseIPMigration(
bool allow );
505 bool AdvertiseSystem(
const char *host,
unsigned short remotePort,
const char *data,
int dataLength,
unsigned connectionSocketIndex=0 );
512 void SetSplitMessageProgressInterval(
int interval);
516 int GetSplitMessageProgressInterval(
void)
const;
531 void SendTTL(
const char* host,
unsigned short remotePort,
int ttl,
unsigned connectionSocketIndex=0 );
550 void PushBackPacket(
Packet *packet,
bool pushAtHead );
562 Packet* AllocatePacket(
unsigned dataSize);
583 virtual void SetUserUpdateThread(
void (*_userUpdateThreadPtr)(
RakPeerInterface *,
void *),
void *_userUpdateThreadData);
589 virtual void SetIncomingDatagramEventHandler(
bool (*_incomingDatagramEventHandler)(
RNS2RecvStruct *) );
600 virtual void ApplyNetworkSimulator(
float packetloss,
unsigned short minExtraPing,
unsigned short extraPingVariance);
606 virtual void SetPerConnectionOutgoingBandwidthLimit(
unsigned maxBitsPerSecond );
610 virtual bool IsNetworkSimulatorActive(
void );
632 virtual unsigned int GetReceiveBufferSize(
void);
645 bool RunUpdateCycle(
BitStream &updateBitStream );
654 bool SendOutOfBand(
const char *host,
unsigned short remotePort,
const char *data,
BitSize_t dataLength,
unsigned connectionSocketIndex=0 );
689 #if LIBCAT_SECURITY==1
691 char answer[cat::EasyHandshake::ANSWER_BYTES];
695 char client_public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
698 enum ConnectMode {NO_ACTION, DISCONNECT_ASAP, DISCONNECT_ASAP_SILENTLY, DISCONNECT_ON_NO_ACK, REQUESTED_CONNECTION, HANDLING_CONNECTION_REQUEST,
UNVERIFIED_SENDER, CONNECTED} connectMode;
714 int GetIndexFromSystemAddress(
const SystemAddress systemAddress,
bool calledFromNetworkThread )
const;
715 int GetIndexFromGuid(
const RakNetGUID guid );
719 ConnectionAttemptResult SendConnectionRequest(
const char* host,
unsigned short remotePort,
const char *passwordData,
int passwordDataLength,
PublicKey *publicKey,
unsigned connectionSocketIndex,
unsigned int extraData,
unsigned sendConnectionAttemptCount,
unsigned timeBetweenSendConnectionAttemptsMS,
SLNet::TimeMS timeoutTime,
RakNetSocket2* socket );
720 ConnectionAttemptResult SendConnectionRequest(
const char* host,
unsigned short remotePort,
const char *passwordData,
int passwordDataLength,
PublicKey *publicKey,
unsigned connectionSocketIndex,
unsigned int extraData,
unsigned sendConnectionAttemptCount,
unsigned timeBetweenSendConnectionAttemptsMS,
SLNet::TimeMS timeoutTime );
724 RemoteSystemStruct *GetRemoteSystemFromSystemAddress(
const SystemAddress systemAddress,
bool calledFromNetworkThread,
bool onlyActive )
const;
726 void ValidateRemoteSystemLookup(
void)
const;
727 RemoteSystemStruct *GetRemoteSystemFromGUID(
const RakNetGUID guid,
bool onlyActive )
const;
732 void NotifyAndFlagForShutdown(
const SystemAddress systemAddress,
bool performImmediate,
unsigned char orderingChannel,
PacketPriority disconnectionNotificationPriority );
734 unsigned int GetNumberOfRemoteInitiatedConnections(
void )
const;
743 RemoteSystemStruct * AssignSystemAddressToRemoteSystemList(
const SystemAddress systemAddress, RemoteSystemStruct::ConnectMode connectionMode,
RakNetSocket2* incomingRakNetSocket,
bool *thisIPConnectedRecently,
SystemAddress bindingAddress,
int incomingMTU,
RakNetGUID guid,
bool useSecurity );
747 void ShiftIncomingTimestamp(
unsigned char *data,
const SystemAddress &systemAddress )
const;
753 bool IsLoopbackAddress(
const AddressOrGUID &systemIdentifier,
bool matchPort)
const;
775 char incomingPassword[256];
791 unsigned int RemoteSystemLookupHashIndex(
const SystemAddress &sa)
const;
792 void ReferenceRemoteSystem(
const SystemAddress &sa,
unsigned int remoteSystemListIndex);
795 unsigned int GetRemoteSystemIndex(
const SystemAddress &sa)
const;
796 void ClearRemoteSystemLookup(
void);
799 void AddToActiveSystemList(
unsigned int remoteSystemListIndex);
811 NUMBER_OF_RAKPEER_MUTEXES
843 char outgoingPassword[256];
852 enum {CONNECT=1, } actionToTake;
854 #if LIBCAT_SECURITY==1
855 char handshakeChallenge[cat::EasyHandshake::CHALLENGE_BYTES];
856 cat::ClientEasyHandshake *client_handshake;
857 char remote_public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
862 #if LIBCAT_SECURITY==1
863 bool GenerateConnectionRequestChallenge(RequestedConnectionStruct *rcs,
PublicKey *publicKey);
895 enum {
BCS_SEND, BCS_CLOSE_CONNECTION, BCS_GET_SOCKET, BCS_CHANGE_SYSTEM_ADDRESS, BCS_DO_NOTHING} command;
911 virtual void DeallocRNS2RecvStruct(
RNS2RecvStruct *s,
const char *file,
unsigned int line);
912 virtual RNS2RecvStruct *AllocRNS2RecvStruct(
const char *file,
unsigned int line);
913 void SetupBufferedPackets(
void);
927 bool AllowIncomingConnections(
void)
const;
931 void CloseConnectionInternal(
const AddressOrGUID& systemIdentifier,
bool sendDisconnectionNotification,
bool performImmediate,
unsigned char orderingChannel,
PacketPriority disconnectionNotificationPriority );
936 void ClearBufferedCommands(
void);
937 void ClearBufferedPackets(
void);
938 void ClearSocketQueryOutput(
void);
939 void ClearRequestedConnectionList(
void);
941 unsigned int GenerateSeedFromGuid(
void);
951 void DerefAllSockets(
void);
952 unsigned int GetRakNetSocketFromUserConnectionSocketIndex(
unsigned int userIndex)
const;
961 void GenerateGUID(
void);
962 unsigned int GetSystemIndexFromGuid(
const RakNetGUID input )
const;
970 unsigned short _minExtraPing, _extraPingVariance;
1003 Packet *AllocPacket(
unsigned dataSize,
const char *file,
unsigned int line);
1004 Packet *AllocPacket(
unsigned dataSize,
unsigned char *data,
const char *file,
unsigned int line);
1011 void ResetSendReceipt(
void);
1015 #if LIBCAT_SECURITY==1
1017 bool _using_security, _require_client_public_key;
1018 char my_public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
1019 cat::ServerEasyHandshake *_server_handshake;
1020 cat::CookieJar *_cookie_jar;
1030 void FillIPList(
void);