Skip to content

Commit 0853244

Browse files
bjorn3davidv1992
authored andcommitted
Use the correct sequence number in UnimplementedMsg
1 parent 4e21613 commit 0853244

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/proto.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl<R: AsyncReadExt + Unpin> DecryptingReader<R> {
221221
value: packet,
222222
next,
223223
} = Packet::decode(
224+
packet_number,
224225
&self.decrypted_buf
225226
[self.unread_start..self.unread_start + 4 + packet_length.inner as usize],
226227
)?;
@@ -252,6 +253,7 @@ impl<R: AsyncReadExt + Unpin> DecryptingReader<R> {
252253
value: packet,
253254
next,
254255
} = Packet::decode(
256+
packet_number,
255257
&self.buf[self.unread_start..self.unread_start + 4 + packet_length.inner as usize],
256258
)?;
257259
assert!(next.is_empty());
@@ -343,7 +345,8 @@ impl<W: AsyncWriteExt + Unpin> EncryptingWriter<W> {
343345
}
344346

345347
pub struct Packet<'a> {
346-
pub payload: &'a [u8],
348+
pub(crate) number: u32,
349+
pub(crate) payload: &'a [u8],
347350
}
348351

349352
impl<'a> Packet<'a> {
@@ -356,7 +359,7 @@ impl<'a> Packet<'a> {
356359
}
357360

358361
impl<'a> Packet<'a> {
359-
fn decode(bytes: &'a [u8]) -> Result<Decoded<'a, Self>, Error> {
362+
fn decode(number: u32, bytes: &'a [u8]) -> Result<Decoded<'a, Self>, Error> {
360363
let Decoded {
361364
value: packet_length,
362365
next,
@@ -391,7 +394,7 @@ impl<'a> Packet<'a> {
391394
// No MAC support yet
392395

393396
Ok(Decoded {
394-
value: Self { payload },
397+
value: Self { number, payload },
395398
next,
396399
})
397400
}

src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl<
153153
value: MessageType::Unknown(v),
154154
..
155155
}) => {
156+
let sequence_no = packet.number;
156157
let mut handled = false;
157158
for service in self.services.iter_mut() {
158159
if service.packet_types().contains(&v) {
@@ -162,10 +163,9 @@ impl<
162163
}
163164
}
164165
if !handled {
165-
// FIXME: send proper packet sequence number
166166
if let Err(e) = self
167167
.connection
168-
.send_packet(&UnimplementedMsg { sequence_no: 0 })
168+
.send_packet(&UnimplementedMsg { sequence_no })
169169
.await
170170
{
171171
debug!("Error sending packet: {e}");

0 commit comments

Comments
 (0)