DMTF / spdm-emu

BSD 3-Clause "New" or "Revised" License
33 stars 45 forks source link

Connection error in SPDM_EMU when using SPDM over MCTP #312

Open amuthakrishnasamy opened 11 months ago

amuthakrishnasamy commented 11 months ago

Hi Jiewen,

I am creating requester and responder model using SPDM_EMU. Raspberry pi is used to simulate requester model and Riscv32 processor to used to simulate responder model. Requester and responder is connected thru I2C. However, for requester implementation in https://github.com/DMTF/spdm-emu/blob/main/spdm_emu/spdm_emu_common/spdm_emu.c SPDM_EMU, init_client function, I see the socket communication is happening thru TCP packet bool init_client(SOCKET *sock, uint16_t port) { SOCKET client_socket; struct sockaddr_in server_addr; int32_t ret_val;

ifdef _MSC_VER

WSADATA ws;
if (WSAStartup(MAKEWORD(2, 2), &ws) != 0) {
    printf("Init Windows socket Failed - %x\n", WSAGetLastError());
    return false;
}

endif

client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (client_socket == INVALID_SOCKET) {
    printf("Create socket Failed - %x\n",

ifdef _MSC_VER

           WSAGetLastError()

else

           errno

endif

           );
    return false;
}

I am getting connection error ( on requester side) due to there is no TCP connection between requester and responder. What would be the suggested implementation that I can use to make connection between requester and responder over MCTP transport layer and I2C/SMBUS.

Thanks AKrishnasamy

jyao1 commented 11 months ago

spdm-emu is just an emulation program running on Windows/Linux OS environment with TCP/IP.

If you want to use it MCTP, then it is NOT an emulation. It is a real platform environment. You need to write your own device layer function to send/receive function.

See https://github.com/DMTF/libspdm/blob/main/doc/user_guide.md#spdm-responder

0.5, implement required SPDM device IO functions - libspdm_device_send_message_func and libspdm_device_receive_message_func according to spdm_common_lib.

admiyo commented 11 months ago

If I run --trans MCTP it still does everything as tcp/ip.

MCTP supports a socket layer, so instead of listening on tcp, it should listen on an MCTP socket, like the echo listener here:

https://github.com/CodeConstruct/mctp/blob/main/src/mctp-echo.c

But all the socket calls are TCP/IP.

Is this a change in how it was intended to be used?

alistair23 commented 11 months ago

Another option is to use SPDM-Utils. Like spdm-emu it uses libspdm but is aimed at testing real devices instead of emulators.

SPDM-Utils can currently communicate with a SPDM device over PCIe DOE. We don't yet have MCTP support, but we are working on it. It should be pretty easy for you to extend SPDM-Utils to support MCTP as well