{"id":18368685,"url":"https://github.com/openbmc/libmctp","last_synced_at":"2025-06-28T18:10:55.699Z","repository":{"id":46177137,"uuid":"176275480","full_name":"openbmc/libmctp","owner":"openbmc","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-03T00:15:35.000Z","size":1642,"stargazers_count":41,"open_issues_count":7,"forks_count":32,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-03T14:43:39.093Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openbmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-18T12:06:48.000Z","updated_at":"2025-06-03T00:15:39.000Z","dependencies_parsed_at":"2023-10-05T06:55:29.305Z","dependency_job_id":"b83061a8-11d4-4271-87e2-d535999fd624","html_url":"https://github.com/openbmc/libmctp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/openbmc/libmctp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Flibmctp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Flibmctp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Flibmctp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Flibmctp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openbmc","download_url":"https://codeload.github.com/openbmc/libmctp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Flibmctp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262474089,"owners_count":23316912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:26:58.329Z","updated_at":"2025-06-28T18:10:55.657Z","avatar_url":"https://github.com/openbmc.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libmctp: Implementation of MCTP (DTMF DSP0236)\n\nThis library is intended to be a portable implementation of the Management\nComponent Transport Protocol (MCTP), as defined by DMTF standard \"DSP0236\", plus\ntransport binding specifications.\n\n## Target usage\n\n`libmctp` is a library that implements a straightforward MCTP stack. It will be\nuseful in a two main scenarios:\n\n- where you are implementing MCTP in an embedded device; or\n- where you have Linux system:\n  - with no kernel MCTP support,\n  - need a single application implementing all of the MCTP stack; and\n  - you are providing your own hardware drivers for MCTP transports.\n\nNotably, if you are implementing an MCTP application on Linux, you _almost\ncertainly_ want to use the in-kernel MCTP support, which gives you a standard\nsockets-based interface to transmit and receive MCTP messages. When using the\nLinux kernel MCTP support, you do not need to use `libmctp` at all, and can use\nthe sockets directly. `libmctp` does not provide functions to interact with the\nkernel MCTP sockets.\n\nThere is an overview and example code for the in-kernel support in the [MCTP\nkernel docs][kernel-mctp], and a general guide in an [introduction to MCTP on\nLinux][mctp-linux-intro] document.\n\n[kernel-mctp]: https://docs.kernel.org/networking/mctp.html\n[mctp-linux-intro]:\n  https://codeconstruct.com.au/docs/mctp-on-linux-introduction/\n\n## Contact\n\n- Email: See [OWNERS](OWNERS). Please also Cc \u003copenbmc@lists.ozlabs.org\u003e\n- Discord: #mctp on \u003chttps://discord.gg/69Km47zH98\u003e\n- IRC: #openbmc on Freenode\n\n## API/ABI Stability\n\nThe APIs and ABI of libmctp are not yet stablised as we continue to explore ways\nto present the MCTP protocol to firmware and applications. Please bear with us!\n\nWhen we approach a complete implementation of DSP0236 we will consider the\nsuitability of the API/ABI for stabilisation.\n\nIn the mean time, we'd like your feedback on the library's suitability for your\nenvironment.\n\n## Core API\n\nTo initialise the MCTP stack with a single hardware bus:\n\n- `mctp = mctp_init()`: Initialise the MCTP core\n- `binding = mctp_\u003cbinding\u003e_init()`: Initialise a hardware binding\n- `mctp_register_bus(mctp, binding, eid)`: Register the hardware binding with\n  the core, using a predefined EID\n\nThen, register a function call to be invoked when a message is received:\n\n- `mctp_set_rx_all(mctp, function)`: Provide a callback to be invoked when a\n  MCTP message is received\n\nOr transmit a message:\n\n- `mctp_message_tx(mctp, message, len)`: Transmit a MCTP message\n\nThe binding may require you to notify it to receive packets. For example, for\nthe serial binding, the `mctp_serial_read()` function should be invoked when the\nfile-descriptor for the serial device has data available.\n\n### Bridging\n\nlibmctp implements basic support for bridging between two hardware bindings. In\nthis mode, bindings may have different MTUs, so packets are reassembled into\ntheir messages, then the messages are re-packetised for the outgoing binding.\n\nFor bridging between two endpoints, use the `mctp_bridge_busses()` function:\n\n- `mctp = mctp_init()`: Initialise the MCTP core\n- `b1 = mctp_\u003cbinding\u003e_init(); b2 = mctp_\u003cbinding\u003e_init()`: Initialise two\n  hardware bindings\n- `mctp_bridge_busses(mctp, b1, b2)`: Setup bridge\n\nNote that no EIDs are defined here; the bridge does not deliver any messages to\na local rx callback, and messages are bridged as-is.\n\n## Binding API\n\nHardware bindings provide a method for libmctp to send and receive packets\nto/from hardware. A binding defines a hardware specific structure\n(`struct mctp_binding_\u003cname\u003e`), which wraps the generic binding\n(`struct mctp_binding`):\n\n    struct mctp_binding_foo {\n        struct mctp_binding binding;\n        /* hardware-specific members here... */\n    };\n\nThe binding code then provides a method (`_init`) to allocate and initialise the\nbinding; this may be of any prototype (calling code will know what arguments to\npass):\n\n    struct mctp_binding_foo *mctp_binding_foo_init(void);\n\nor maybe the `foo` binding needs a path argument:\n\n    struct mctp_binding_foo *mctp_binding_foo_init(const char *path);\n\nThe binding then needs to provide a function (`_core`) to convert the\nhardware-specific struct to the libmctp generic core struct\n\n    struct mctp_binding *mctp_binding_foo_core(struct mctp_binding_foo *b);\n\n(Implementations of this will usually be fairly consistent, just returning\n`b-\u003ebinding`). Callers can then use that generic pointer to register the binding\nwith the core:\n\n    struct mctp_binding *binding = mctp_binding_foo_core(foo);\n    mctp_register_bus(mctp, binding, 8);\n\n## Integration\n\nThe libmctp code is intended to be integrated into other codebases by two\nmethods:\n\n1. as a simple library (`libmctp.{a,so}`) which can be compiled separately and\n   linked into the containing project\n\n2. as a set of sources to be included into the containing project (either\n   imported, or as a git subtree/submodule)\n\nFor (1), you can use the top-level makefile to produce `libmctp.a`.\n\nFor (2), the `Makefile.inc` file provides the minimum set of dependencies to\neither build libmctp.a, or just the actual object files (`LIBMCTP_OBS`), which\nyou can include into your existing make definitions. You'll want to set\n`LIBMTCP_DIR` to refer to the subdirectory that contains that makefile, so we\ncan set the correct paths to sources.\n\n## Environment configuration\n\nThis library is intended to be portable to be used in a range of environments,\nbut the main targets are:\n\n- Linux userspace, typically for BMC use-cases\n- Low-level firmware environments\n\nFor the latter, we need to support customisation of the functions that libmctp\nuses (for example, POSIX file IO is not available).\n\nIn order to support these, we have a few compile-time definitions:\n\n- `MCTP_HAVE_FILEIO`: define if POSIX file io is available, allowing the serial\n  hardware binding to access char devices for IO.\n\n- `MCTP_HAVE_SYSLOG`: allow logging to syslog, through the `vsyslog` call.\n\n- `MCTP_DEFAULT_ALLOC`: set default allocator functions (malloc, free, realloc),\n  so that applications do not have to provide their own.\n\n## TODO\n\n- Partial packet queue transmit\n- Control messages\n- Message- and packet-buffer pools and preallocation\n- C++ API\n- Non-file-based serial binding\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Flibmctp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenbmc%2Flibmctp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Flibmctp/lists"}