Skip to content

Commit

Permalink
test: Remove the hello packet
Browse files Browse the repository at this point in the history
The hello message isn't used on QEMU [1] or SPDM-Utils [2], so let's remove it
here as we don't need it and it breaks compability with other emulators.

1: https://github.com/qemu/qemu/blob/029e13a8a56a2931e7c24c0db52ae7256b932cb0/docs/specs/spdm.rst#L42
2: https://github.com/westerndigitalcorporation/spdm-utils

Signed-off-by: Alistair Francis <[email protected]>
  • Loading branch information
alistair23 committed Jul 26, 2024
1 parent ba86f84 commit 0f9b183
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 78 deletions.
1 change: 0 additions & 1 deletion test/spdm-emu/src/spdm_emu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub const SOCKET_TRANSPORT_TYPE_PCI_DOE: u32 = 0x02;
pub const SOCKET_SPDM_COMMAND_NORMAL: u32 = 0x0001;
pub const SOCKET_SPDM_COMMAND_STOP: u32 = 0xFFFE;
pub const SOCKET_SPDM_COMMAND_UNKOWN: u32 = 0xFFFF;
pub const SOCKET_SPDM_COMMAND_TEST: u32 = 0xDEAD;

#[derive(Debug, Copy, Clone, Default)]
pub struct SpdmSocketHeader {
Expand Down
43 changes: 0 additions & 43 deletions test/spdm-requester-emu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,6 @@ extern crate alloc;
use alloc::sync::Arc;
use core::ops::DerefMut;

#[maybe_async::maybe_async]
async fn send_receive_hello(
stream: Arc<Mutex<TcpStream>>,
transport_encap: Arc<Mutex<dyn common::SpdmTransportEncap + Send + Sync>>,
transport_type: u32,
) {
println!("send test");
let mut payload = [0u8; 1024];

let mut transport_encap = transport_encap.lock();
let transport_encap = transport_encap.deref_mut();
let used = transport_encap
.encap(
Arc::new(b"Client Hello!\0"),
Arc::new(Mutex::new(&mut payload[..])),
false,
)
.await
.unwrap();

let _buffer_size = spdm_emu::spdm_emu::send_message(
stream.clone(),
transport_type,
SOCKET_SPDM_COMMAND_TEST,
&payload[0..used],
);
let mut buffer = [0u8; config::RECEIVER_BUFFER_SIZE];
let (_transport_type, _command, _payload) =
spdm_emu::spdm_emu::receive_message(stream, &mut buffer[..], ST1)
.await
.unwrap();
}

#[maybe_async::maybe_async]
async fn send_receive_stop(
stream: Arc<Mutex<TcpStream>>,
Expand Down Expand Up @@ -1535,16 +1502,6 @@ fn emu_main_inner() {
SOCKET_TRANSPORT_TYPE_MCTP
};

#[cfg(not(feature = "is_sync"))]
block_on(Box::pin(send_receive_hello(
socket.clone(),
transport_encap.clone(),
transport_type,
)));

#[cfg(feature = "is_sync")]
send_receive_hello(socket.clone(), transport_encap.clone(), transport_type);

let socket_io_transport = SocketIoTransport::new(socket.clone());
let socket_io_transport: Arc<Mutex<dyn SpdmDeviceIo + Send + Sync>> =
Arc::new(Mutex::new(socket_io_transport));
Expand Down
34 changes: 0 additions & 34 deletions test/spdm-responder-emu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ async fn process_socket_message(
);

match socket_header.command.to_be() {
SOCKET_SPDM_COMMAND_TEST => {
send_hello(stream.clone(), transport_encap.clone(), res.0).await;
true
}
SOCKET_SPDM_COMMAND_STOP => {
send_stop(stream.clone(), transport_encap.clone(), res.0).await;
false
Expand Down Expand Up @@ -394,36 +390,6 @@ async fn handle_message(
}
}

#[maybe_async::maybe_async]
pub async fn send_hello(
stream: Arc<Mutex<TcpStream>>,
transport_encap: Arc<Mutex<dyn SpdmTransportEncap + Send + Sync>>,
tranport_type: u32,
) {
println!("get hello");

let mut payload = [0u8; 1024];

let mut transport_encap = transport_encap.lock();
let transport_encap = transport_encap.deref_mut();

let used = transport_encap
.encap(
Arc::new(b"Server Hello!\0"),
Arc::new(Mutex::new(&mut payload[..])),
false,
)
.await
.unwrap();

let _buffer_size = spdm_emu::spdm_emu::send_message(
stream,
tranport_type,
spdm_emu::spdm_emu::SOCKET_SPDM_COMMAND_TEST,
&payload[..used],
);
}

#[maybe_async::maybe_async]
pub async fn send_unknown(
stream: Arc<Mutex<TcpStream>>,
Expand Down

0 comments on commit 0f9b183

Please sign in to comment.