#linux #sockets #component #protocols #endpoint #bind #mctp

mctp-linux

Management Component Transport Protocol (MCTP) Linux transport

1 unstable release

0.1.0 Jun 24, 2024

#553 in Unix APIs


Used in 2 crates

Apache-2.0

25KB
411 lines

Management Component Transport Protocol (MCTP) using Linux sockets

This crate provides an implementation of the mctp base crate, using Linux socket support for MCTP messsaging.

See https://codeconstruct.com.au/docs/mctp-on-linux-introduction/ for an overview on the kernel sockets support.

Using the standard sockets API, we implement the mctp::Endpoint trait, allowing upper layers to implement MCTP applications without needing further details of the sockets interface.


lib.rs:

Interface for the Linux socket-based MCTP support.

This crate provides some minimal wrappers around standard libc socket operations, using MCTP-specific addressing structures.

MctpSocket provides support for blocking socket operations sendto, recvfrom and bind.

use mctp_linux;

let sock = mctp_linux::MctpSocket::new()?;
let bind_addr = mctp_linux::MctpSockAddr::new(
    mctp::MCTP_ADDR_ANY.0,
    mctp_linux::MCTP_NET_ANY,
    1,
    0
);
sock.bind(&bind_addr)?;

let mut buf = [0; 64];
let (len, src) = sock.recvfrom(&mut buf)?;

MctpLinuxEp provides a thin wrapper that represents a remote endpoint, referenced by EID. It creates a single socket for communication with that endpoint. This is a convenience for simple consumers that perform single-endpoint communication; general MCTP requesters may want a different socket model.

Dependencies

~43KB