Preprocessor Directives¶
MafiaNet provides numerous preprocessor directives to customize builds for different platforms, features, and optimization levels.
Configuration File¶
Primary configuration is in RakNetDefinesOverrides.h. Create this file to
override defaults from RakNetDefines.h.
// RakNetDefinesOverrides.h
#ifndef RAKNET_DEFINES_OVERRIDES_H
#define RAKNET_DEFINES_OVERRIDES_H
// Your custom defines here
#define RAKNET_SUPPORT_IPV6 1
#define USE_SLIDING_WINDOW_CONGESTION_CONTROL 1
#endif
Core Feature Toggles¶
Network Features:
// IPv6 support (default: 0)
#define RAKNET_SUPPORT_IPV6 1
// Secure connections with encryption
#define _RAKNET_SECURE_CONNECTIONS 1
// Enable statistics tracking
#define _RAKNET_STAT_COLLECTION 1
Component Toggles:
// File operations (FileListTransfer, etc.)
#define _RAKNET_SUPPORT_FileOperations 1
// TCP wrapper support
#define _RAKNET_SUPPORT_PacketizedTCP 1
// Thread support
#define _RAKNET_SUPPORT_THREADS 1
Performance Options¶
// Congestion control algorithm
#define USE_SLIDING_WINDOW_CONGESTION_CONTROL 1
// Ceiling on the negotiated per-connection MTU, and the size of every datagram
// buffer in the library (default: 1400). Lowering it is safe; raising it is
// only safe if every peer agrees, since it sizes those buffers.
#define MAXIMUM_MTU_SIZE 1400
// Packet pool sizes
#define RAKNET_MESSAGE_HANDLER_LIST_SIZE 32
// Send buffer size
#define RAKNET_SEND_BUFFER_SIZE 8192
// Largest session-handshake payload accepted, in bytes (default: 65536).
// Enforced on send and receive; an oversized inbound payload closes the connection.
// This is also the per-connection memory a remote peer can force, so lower it if a
// deployment does not need large payloads. See advanced/session-handshake-security.
#define MAXIMUM_SESSION_CONFIG_SIZE 65536
Debug Options¶
// Enable memory tracking
#define RAKNET_MEMORY_TRACKING 1
// Verbose debug output
#define _DEBUG 1
// Assert on errors
#define _RAKNET_DEBUG_ASSERT 1
// Log packet details
#define _RAKNET_PACKET_LOGGER 1
Platform-Specific¶
// Windows-specific
#ifdef _WIN32
#define RAKNET_WINDOWS 1
#endif
// Unix/Linux
#ifdef __linux__
#define RAKNET_LINUX 1
#endif
// macOS
#ifdef __APPLE__
#define RAKNET_APPLE 1
#endif
CMake Options¶
CMake build options (passed via -D):
MAFIANET_BUILD_SHARED- Build shared libraryMAFIANET_BUILD_STATIC- Build static libraryMAFIANET_BUILD_SAMPLES- Build sample applicationsMAFIANET_BUILD_TESTS- Build test suite
Batched Datagram I/O¶
The batched recvmmsg/sendmmsg paths are selected by a plain platform check.
There is no macro and no build option for them – nothing in the build system
configures batching, and consumer code should not try to:
#if defined(__linux__)
RNS2SendResult SendBatch( RNS2_SendParameters *sends, unsigned count,
const char *file, unsigned int line );
#endif
The guard is needed even inside RNS2_Linux because that is the non-Windows
socket class, so it also compiles on macOS and the BSDs, where
sendmmsg/recvmmsg do not exist. Those platforms inherit the portable
Send()-loop implementation of RakNetSocket2::SendBatch.
See Also¶
Custom Memory Management - Memory configuration
IPv6 Support - IPv6 setup
Congestion Control - Bandwidth tuning