1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Protocol implementation for RakNet.
//! this module contains all of the necessary packets to communicate with RakNet servers.
//!
//! ## Example
//! Please note this example is not a copy-paste example, but rather a snippet of code
//! that shows how to use the [`protocol`] module.
//!
//! ```rust ignore
//! use rakrs::protocol::packet::RakPacket;
//! use binary_util::BinaryIo;
//!
//! fn decode_packet(packet: &[u8]) {
//! let packet = RakPacket::read_from_slice(packet).unwrap();
//!
//! match packet {
//! RakPacket::Offline(packet) => match packet {
//! OfflinePacket::UnconnectedPing(packet) => {
//! println!("Received a ping packet! {:?}", packet);
//! },
//! _ => {}
//! },
//! _ => {}
//! }
//! };
//! ```
/// This is an internal module that contains the logic to implement the Ack system within
/// RakNet.
pub
/// This is an internal module that contains the logic to implement the frame system within
/// RakNet. This is also called the "Datagram" or "Encapsulated" packet in different implementations.
///
/// You can find the original implementation from RakNet [here](https://github.com/facebookarchive/RakNet/blob/1a169895a900c9fc4841c556e16514182b75faf8/Source/ReliabilityLayer.cpp#L110-L231)
// pub(crate) mod frame;
/// This is the constant added to all offline packets to identify them as RakNet packets.
pub
/// This module contains the MCPE specific packets that are used within RakNet, this is guarded
/// under the `mcpe` feature.
///
/// To enable this feature, add the following to your `Cargo.toml`:
/// ```toml
/// [dependencies]
/// rak-rs = { version = "0.1.0", features = [ "mcpe" ] }
/// ```
pub use *;
/// The maximum amount of fragments that can be sent within a single frame.
/// This constant is used to prevent a client from sending too many fragments,
/// or from bad actors from sending too many fragments.
pub const MAX_FRAGS: u32 = 1024;
/// The maximum amount of channels that can be used on a single connection.
/// This is a raknet limitation, and is not configurable.
pub const MAX_ORD_CHANS: u8 = 32;
/// IP Header + UDP Header + RakNet Header + RakNet Frame Packet Header (MAX)
pub const RAKNET_HEADER_FRAME_OVERHEAD: u16 = 20 + 8 + 8 + 4 + 20;
/// IP Header + UDP Header + RakNet Header
pub const RAKNET_HEADER_OVERHEAD: u16 = 20 + 8 + 8;
/// The maximum possible amount of bytes that can be sent within a single frame.
pub const MTU_MAX: u16 = 2400;
/// The minimum possible amount of bytes that can be sent within a single frame.
pub const MTU_MIN: u16 = 400;