Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
RakNet::MessageFilter Class Reference

Assigns systems to FilterSets. Each FilterSet limits what kinds of messages are allowed. More...

#include <MessageFilter.h>

Inheritance diagram for RakNet::MessageFilter:

List of all members.

Public Member Functions

void DeleteFilterSet (int filterSetID)
unsigned GetFilterSetCount (void) const
int GetFilterSetIDByIndex (unsigned index)
unsigned GetSystemCount (int filterSetID) const
int GetSystemFilterSet (AddressOrGUID addressOrGUID)
 MessageFilter ()
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual PluginReceiveResult OnReceive (Packet *packet)
void SetActionOnDisallowedMessage (bool kickOnDisallowed, bool banOnDisallowed, RakNet::TimeMS banTimeMS, int filterSetID)
void SetAllowMessageID (bool allow, int messageIDStart, int messageIDEnd, int filterSetID)
void SetAllowRPC4 (bool allow, const char *uniqueID, int filterSetID)
void SetAutoAddNewConnectionsToFilter (int filterSetID)
void SetDisallowedMessageCallback (int filterSetID, void *userData, void(*invalidMessageCallback)(RakPeerInterface *peer, AddressOrGUID addressOrGUID, int filterSetID, void *userData, unsigned char messageID))
void SetFilterMaxTime (int allowedTimeMS, bool banOnExceed, RakNet::TimeMS banTimeMS, int filterSetID)
void SetSystemFilterSet (AddressOrGUID addressOrGUID, int filterSetID)
void SetTimeoutCallback (int filterSetID, void *userData, void(*invalidMessageCallback)(RakPeerInterface *peer, AddressOrGUID addressOrGUID, int filterSetID, void *userData))
virtual void Update (void)
 Update is called every time a packet is checked for .
virtual ~MessageFilter ()

Static Public Member Functions

static void DestroyInstance (MessageFilter *i)
static MessageFilterGetInstance (void)

Protected Member Functions

void Clear (void)
void DeallocateFilterSet (FilterSet *filterSet)
FilterSetGetFilterSetByID (int filterSetID)
void OnInvalidMessage (FilterSet *filterSet, AddressOrGUID systemAddress, unsigned char messageID)

Protected Attributes

int autoAddNewConnectionsToFilter
DataStructures::OrderedList
< int, FilterSet
*, FilterSetComp > 
filterList
DataStructures::Hash
< AddressOrGUID,
FilteredSystem,
2048, AddressOrGUID::ToInteger > 
systemList
RakNet::Time whenLastTimeoutCheck

Detailed Description

The MessageFilter plugin is used for security where you limit what systems can send what kind of messages.
You implicitly define FilterSets, and add allowed message IDs to these FilterSets.
You then add systems to these filters, such that those systems are limited to sending what the filters allows.
You can automatically assign systems to a filter.
You can automatically kick and possibly ban users that stay in a filter too long, or send the wrong message.
Each system is a member of either zero or one filters.
Add this plugin before any plugin you wish to filter (most likely just add this plugin before any other).

Definition at line 73 of file MessageFilter.h.


Constructor & Destructor Documentation

RakNet::MessageFilter::MessageFilter ( )
virtual RakNet::MessageFilter::~MessageFilter ( ) [virtual]

Member Function Documentation

void RakNet::MessageFilter::Clear ( void  ) [protected]
void RakNet::MessageFilter::DeallocateFilterSet ( FilterSet filterSet) [protected]
void RakNet::MessageFilter::DeleteFilterSet ( int  filterSetID)

Delete a FilterSet. All systems formerly subscribed to this filter are now unrestricted.

Parameters:
[in]filterSetIDThe ID of the filter set to delete.
static void RakNet::MessageFilter::DestroyInstance ( MessageFilter i) [static]
FilterSet* RakNet::MessageFilter::GetFilterSetByID ( int  filterSetID) [protected]
unsigned RakNet::MessageFilter::GetFilterSetCount ( void  ) const

Returns the total number of filter sets.

Returns:
The total number of filter sets.
int RakNet::MessageFilter::GetFilterSetIDByIndex ( unsigned  index)

Returns the ID of a filter set, by index

Parameters:
[in]Anindex between 0 and GetFilterSetCount()-1 inclusive
static MessageFilter* RakNet::MessageFilter::GetInstance ( void  ) [static]
unsigned RakNet::MessageFilter::GetSystemCount ( int  filterSetID) const

Returns the number of systems subscribed to a particular filter set Using anything other than -1 for filterSetID is slow, so you should store the returned value.

Parameters:
[in]filterSetIDThe filter set to limit to. Use -1 for none (just returns the total number of filter systems in that case).
int RakNet::MessageFilter::GetSystemFilterSet ( AddressOrGUID  addressOrGUID)

Get the filterSetID a system is using. Returns -1 for none.

Parameters:
[in]addressOrGUIDThe system we are referring to
virtual void RakNet::MessageFilter::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
) [virtual]

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters:
[in]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

void RakNet::MessageFilter::OnInvalidMessage ( FilterSet filterSet,
AddressOrGUID  systemAddress,
unsigned char  messageID 
) [protected]
virtual void RakNet::MessageFilter::OnNewConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
bool  isIncoming 
) [virtual]

Called when we got a new connection

Parameters:
[in]systemAddressAddress of the new connection
[in]rakNetGuidThe guid of the specified system
[in]isIncomingIf true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::MessageFilter::OnReceive ( Packet packet) [virtual]

OnReceive is called for every packet.

Parameters:
[in]packetthe packet that is being returned to the user
Returns:
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

void RakNet::MessageFilter::SetActionOnDisallowedMessage ( bool  kickOnDisallowed,
bool  banOnDisallowed,
RakNet::TimeMS  banTimeMS,
int  filterSetID 
)

What action to take on a disallowed message. You can kick or not. You can add them to the ban list for some time By default no action is taken. The message is simply ignored. param[in] 0 for permanent ban, >0 for ban time in milliseconds.

Parameters:
[in]kickOnDisallowedkick the system that sent a disallowed message.
[in]banOnDisallowedban the system that sent a disallowed message. See banTimeMS for the ban duration
[in]banTimeMSPassed to the milliseconds parameter of RakPeer::AddToBanList.
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
void RakNet::MessageFilter::SetAllowMessageID ( bool  allow,
int  messageIDStart,
int  messageIDEnd,
int  filterSetID 
)

Allow a range of message IDs Always allowed by default: ID_CONNECTION_REQUEST_ACCEPTED through ID_DOWNLOAD_PROGRESS Usually you specify a range to make it easier to add new enumerations without having to constantly refer back to this function.

Parameters:
[in]allowTrue to allow this message ID, false to disallow. By default, all messageIDs except the noted types are disallowed. This includes messages from other plugins!
[in]messageIDStartThe first ID_* message to allow in the range. Inclusive.
[in]messageIDEndThe last ID_* message to allow in the range. Inclusive.
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
void RakNet::MessageFilter::SetAllowRPC4 ( bool  allow,
const char *  uniqueID,
int  filterSetID 
)

Allow a specific RPC4 call

Precondition:
MessageFilter must be attached before RPC4
Parameters:
[in]uniqueIDIdentifier passed to RegisterFunction()
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
void RakNet::MessageFilter::SetAutoAddNewConnectionsToFilter ( int  filterSetID)

Automatically add all new systems to a particular filter Defaults to -1

Parameters:
[in]filterSetIDWhich filter to add new systems to. <0 for do not add.
void RakNet::MessageFilter::SetDisallowedMessageCallback ( int  filterSetID,
void *  userData,
void(*)(RakPeerInterface *peer, AddressOrGUID addressOrGUID, int filterSetID, void *userData, unsigned char messageID)  invalidMessageCallback 
)

Set a user callback to be called on an invalid message for a particular filterSet

Parameters:
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
[in]userDataA pointer passed with the callback
[in]invalidMessageCallbackA pointer to a C function to be called back with the specified parameters.
void RakNet::MessageFilter::SetFilterMaxTime ( int  allowedTimeMS,
bool  banOnExceed,
RakNet::TimeMS  banTimeMS,
int  filterSetID 
)

Limit how long a connection can stay in a particular filterSetID. After this time, the connection is kicked and possibly banned. By default there is no limit to how long a connection can stay in a particular filter set.

Parameters:
[in]allowedTimeMSHow many milliseconds to allow a connection to stay in this filter set.
[in]banOnExceedTrue or false to ban the system, or not, when allowedTimeMS is exceeded
[in]banTimeMSPassed to the milliseconds parameter of RakPeer::AddToBanList.
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
void RakNet::MessageFilter::SetSystemFilterSet ( AddressOrGUID  addressOrGUID,
int  filterSetID 
)

Assign a system to a filter set. Systems are automatically added to filter sets (or not) based on SetAutoAddNewConnectionsToFilter() This function is used to change the filter set a system is using, to add it to a new filter set, or to remove it from all existin filter sets.

Parameters:
[in]addressOrGUIDThe system we are referring to
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings. If -1, the system will be removed from all filter sets.
void RakNet::MessageFilter::SetTimeoutCallback ( int  filterSetID,
void *  userData,
void(*)(RakPeerInterface *peer, AddressOrGUID addressOrGUID, int filterSetID, void *userData)  invalidMessageCallback 
)

Set a user callback to be called when a user is disconnected due to SetFilterMaxTime

Parameters:
[in]filterSetIDA user defined ID to represent a filter set. If no filter with this ID exists, one will be created with default settings.
[in]userDataA pointer passed with the callback
[in]invalidMessageCallbackA pointer to a C function to be called back with the specified parameters.
virtual void RakNet::MessageFilter::Update ( void  ) [virtual]

Reimplemented from RakNet::PluginInterface2.


Member Data Documentation

Definition at line 183 of file MessageFilter.h.

Definition at line 179 of file MessageFilter.h.

DataStructures::Hash<AddressOrGUID, FilteredSystem, 2048, AddressOrGUID::ToInteger> RakNet::MessageFilter::systemList [protected]

Definition at line 181 of file MessageFilter.h.

Definition at line 184 of file MessageFilter.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net