Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conf/mctpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ mode = "bus-owner"
[mctp]
message_timeout_ms = 30

# Delay between each Get Routing Table message.
routing_table_polling_interval_ms = 1000

# Specify a UUID: not generally required - mctpd will query the system UUID
# where available.
# uuid = "21f0f554-7f7c-4211-9ca1-6d0f000ea9e7"
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ toml_dep = declare_dependency(
executable('mctp',
sources: ['src/mctp.c'] + netlink_sources + util_sources + ops_sources,
install: true,
c_args: ['-DHAVE_LIBSYSTEMD=0'],
)

mctp_test = executable('test-mctp',
sources: ['src/mctp.c'] + netlink_sources + util_sources + test_ops_sources,
include_directories: include_directories('src'),
c_args: ['-DHAVE_LIBSYSTEMD=0'],
)

executable('mctp-req',
Expand Down Expand Up @@ -92,6 +94,7 @@ if libsystemd.found()
dependencies: [libsystemd, toml_dep],
install: true,
install_dir: get_option('sbindir'),
c_args: ['-DHAVE_LIBSYSTEMD=1'],
)

mctpd_test = executable('test-mctpd',
Expand All @@ -100,6 +103,7 @@ if libsystemd.found()
] + test_ops_sources + netlink_sources + util_sources,
include_directories: include_directories('src'),
dependencies: [libsystemd, toml_dep],
c_args: ['-DHAVE_LIBSYSTEMD=1'],
)
endif

Expand Down
8 changes: 8 additions & 0 deletions src/mctp-control-spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,11 @@ enum mctp_phys_binding {
MCTP_PHYS_BINDING_UCIE = 0x09,
MCTP_PHYS_BINDING_VENDOR = 0xFF,
};

#define MCTP_GET_ROUTING_TABLE_MSG_PHYSICAL_ADDRESS(entryh) \
((void *)((char *)(entryh) + sizeof(struct get_routing_table_entry)))
#define MCTP_GET_ROUTING_TABLE_MSG_NEXT(entryh) \
((struct get_routing_table_entry \
*)((char *)(entryh) + \
sizeof(struct get_routing_table_entry) + \
(entryh)->phys_address_size))
9 changes: 9 additions & 0 deletions src/mctp-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#include <unistd.h>
#include <linux/netlink.h>
#if HAVE_LIBSYSTEMD
#include <systemd/sd-event.h>
#endif
#include <err.h>

#include "mctp.h"
Expand Down Expand Up @@ -74,6 +77,12 @@ const struct mctp_ops mctp_ops = {
.recvfrom = mctp_op_recvfrom,
.close = mctp_op_close,
},
#if HAVE_LIBSYSTEMD
.sd_event = {
.add_time_relative = sd_event_add_time_relative,
.source_set_time_relative = sd_event_source_set_time_relative,
},
#endif
.bug_warn = mctp_bug_warn,
};

Expand Down
15 changes: 15 additions & 0 deletions src/mctp-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
#pragma once

#include <stdint.h>
#include <sys/socket.h>
#include <stdarg.h>

Expand All @@ -24,9 +25,23 @@ struct socket_ops {
int (*close)(int sd);
};

struct sd_event;
struct sd_event_source;
struct sd_event_ops {
int (*add_time_relative)(struct sd_event *e,
struct sd_event_source **ret, clockid_t clock,
uint64_t usec, uint64_t accuracy,
int (*callback)(struct sd_event_source *s,
uint64_t usec, void *userdata),
void *userdata);
int (*source_set_time_relative)(struct sd_event_source *s,
uint64_t usec);
};

struct mctp_ops {
struct socket_ops mctp;
struct socket_ops nl;
struct sd_event_ops sd_event;
void (*bug_warn)(const char *fmt, va_list args);
};

Expand Down
Loading