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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
//! Offline packets are packets that are sent before a connection is established.
//! In rak-rs, these packets consist of:
//! - [`UnconnectedPing`]
//! - [`UnconnectedPong`]
//! - [`OpenConnectRequest`]
//! - [`OpenConnectReply`]
//! - [`SessionInfoRequest`]
//! - [`SessionInfoReply`]
//! - [`IncompatibleProtocolVersion`]
//!
//! During this stage, the client and server are exchanging information about each other, such as
//! the server id, the client id, the mtu size, etc, to prepare for the connection handshake.
use SocketAddr;
use RakPacket;
pub use crateUnconnectedPong;
use crateMagic;
use crateRAKNET_HEADER_FRAME_OVERHEAD;
use crateregister_packets;
use ;
use ;
use BinaryIo;
/// This is an enum of all offline packets.
///
/// You can use this to read and write offline packets,
/// with the `binary_util` traits `Reader` and `Writer`.
register_packets!
/// Send to the other peer expecting a [`UnconnectedPong`] packet,
/// this is used to determine the latency between the client and the server,
/// and to determine if the server is online.
///
/// If the peer does not respond with a [`UnconnectedPong`] packet, the iniatior should
/// expect that the server is offline.
/// Sent in response to a [`UnconnectedPing`] packet.
/// This is used to determine the latency between the client and the server, and to determine
/// that the peer is online.
///
/// <style>
/// .warning-2 {
/// background: rgba(255,240,76,0.34) !important;
/// padding: 0.75em;
/// border-left: 2px solid #fce811;
/// font-family: "Source Serif 4", NanumBarunGothic, serif;
/// }
///
/// .warning-2 code {
/// background: rgba(211,201,88,0.64) !important;
/// }
///
/// .notice-2 {
/// background: rgba(88, 211, 255, 0.34) !important;
/// padding: 0.75em;
/// border-left: 2px solid #4c96ff;
/// font-family: "Source Serif 4", NanumBarunGothic, serif;
/// }
///
/// .notice-2 code {
/// background: rgba(88, 211, 255, 0.64) !important;
/// }
/// </style>
/// <div class="notice-2">
/// <strong> Note: </strong>
/// <p>
/// If the client is a Minecraft: Bedrock Edition client, this packet is not sent
/// and the
/// <a
/// href="/rak-rs/latest/protocol/mcpe/struct.UnconnectedPong.html"
/// title="struct rak_rs::protocol::mcpe::UnconnectedPing">
/// UnconnectedPong
/// </a>
/// from the <code>mcpe</code> module is sent instead.
/// </p>
/// </div>
///
/// [`UnconnectedPong`]: crate::protocol::packet::offline::UnconnectedPong
/// This packet is the equivelant of the `OpenConnectRequest` packet in RakNet.
///
/// This packet is sent by the peer to a server to request a connection.
/// It contains information about the client, such as the protocol version, and the mtu size.
/// The peer should expect a [`OpenConnectReply`] packet in response to this packet, if the
/// server accepts the connection. Otherwise, the peer should expect a [`IncompatibleProtocolVersion`]
/// packet to be sent to indicate that the server does not support the protocol version.
///
/// <style>
/// .warning-2 {
/// background: rgba(255,240,76,0.34) !important;
/// padding: 0.75em;
/// border-left: 2px solid #fce811;
/// font-family: "Source Serif 4", NanumBarunGothic, serif;
/// }
///
/// .warning-2 code {
/// background: rgba(211,201,88,0.64) !important;
/// }
///
/// .notice-2 {
/// background: rgba(88, 211, 255, 0.34) !important;
/// padding: 0.75em;
/// border-left: 2px solid #4c96ff;
/// font-family: "Source Serif 4", NanumBarunGothic, serif;
/// }
///
/// .notice-2 code {
/// background: rgba(88, 211, 255, 0.64) !important;
/// }
/// </style>
/// <div class="notice-2">
/// <strong> Note: </strong>
/// <p>
/// Internally this packet is padded by the given
/// <code>mtu_size</code> in the packet. This is done by appending null bytes
/// to the current buffer of the packet which is calculated by adding the difference
/// between the <code>mtu_size</code> and the current length.
/// </p>
/// </div>
// Open Connection Reply
/// This packet is sent in response to a [`OpenConnectRequest`] packet, and confirms
/// the information sent by the peer in the [`OpenConnectRequest`] packet.
///
/// This packet is the equivalent of the `Open Connect Reply 1` within the original RakNet implementation.
///
/// If the server chooses to deny the connection, it should send a [`IncompatibleProtocolVersion`]
/// or ignore the packet.
/// This packet is sent after receiving a [`OpenConnectReply`] packet, and confirms
/// that the peer wishes to proceed with the connection. The information within this packet
/// is primarily used to get the external address of the peer.
///
/// This packet is the equivalent of the `Open Connect Request 2` within the original RakNet implementation.
/// This packet is sent in response to a [`SessionInfoRequest`] packet, and confirms
/// all the information sent by the peer in the [`SessionInfoRequest`] packet. This packet
/// also specifies the external address of the peer, as well as whether or not
/// encryption at the RakNet level is enabled on the server.
///
/// This packet is the equivalent of the `Open Connect Reply 2` within the original RakNet implementation.
/// This packet is sent by the server to indicate that the server does not support the
/// protocol version of the client.