feat(async): teach single_sequence_step() to keep unmatched PDUs

The caller can gather the unmatching/unexpected PDUs as necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2024-08-14 19:29:07 +04:00 committed by Benoît Cortier
parent 6f779406e6
commit e54fa5f4c8
5 changed files with 13 additions and 10 deletions

View file

@ -23,7 +23,7 @@ where
info!("Begin connection procedure");
while !connector.should_perform_security_upgrade() {
single_sequence_step(framed, connector, &mut buf).await?;
single_sequence_step(framed, connector, &mut buf, None).await?;
}
Ok(ShouldUpgrade)
@ -73,7 +73,7 @@ where
}
let result = loop {
single_sequence_step(framed, &mut connector, &mut buf).await?;
single_sequence_step(framed, &mut connector, &mut buf, None).await?;
if let ClientConnectorState::Connected { result } = connector.state {
break result;

View file

@ -230,12 +230,13 @@ pub async fn single_sequence_step<S>(
framed: &mut Framed<S>,
sequence: &mut dyn Sequence,
buf: &mut WriteBuf,
unmatched: Option<&mut Vec<Bytes>>,
) -> ConnectorResult<()>
where
S: FramedWrite + FramedRead,
{
buf.clear();
let written = single_sequence_step_read(framed, sequence, buf).await?;
let written = single_sequence_step_read(framed, sequence, buf, unmatched).await?;
single_sequence_step_write(framed, buf, written).await
}
@ -243,6 +244,7 @@ pub async fn single_sequence_step_read<S>(
framed: &mut Framed<S>,
sequence: &mut dyn Sequence,
buf: &mut WriteBuf,
unmatched: Option<&mut Vec<Bytes>>,
) -> ConnectorResult<Written>
where
S: FramedRead,
@ -257,7 +259,7 @@ where
);
let pdu = framed
.read_by_hint(next_pdu_hint, None)
.read_by_hint(next_pdu_hint, unmatched)
.await
.map_err(|e| ironrdp_connector::custom_err!("read frame by hint", e))?;