diff --git a/docs/mctpd.md b/docs/mctpd.md index c67cfb6..f936e3b 100644 --- a/docs/mctpd.md +++ b/docs/mctpd.md @@ -47,10 +47,14 @@ interface: ``` NAME TYPE SIGNATURE RESULT/VALUE FLAGS au.com.CodeConstruct.MCTP.Interface1 interface - - - +.EIDs property ay 1 8 const .Role property s "BusOwner" emits-change writable ``` -The D-Bus interface includes the `Role` property which reports BMC roles +The D-Bus interface includes the `EIDs` property which reports BMC local EIDs +in the link. + +The D-Bus interface also includes the `Role` property which reports BMC roles in the link. The possible value of `Role` are: * `BusOwner`: this link is the owner of the attached bus, @@ -72,6 +76,7 @@ represents the bus-owner side of a transport. ``` NAME TYPE SIGNATURE RESULT/VALUE FLAGS au.com.CodeConstruct.MCTP.Interface1 interface - - - +.EIDs property ay 1 8 const .Role property s "BusOwner" emits-change writable au.com.codeconstruct.MCTP.BusOwner1 interface - - - .AssignEndpoint method ay yisb - diff --git a/src/mctp-netlink.c b/src/mctp-netlink.c index 6304dde..e84b2cf 100644 --- a/src/mctp-netlink.c +++ b/src/mctp-netlink.c @@ -979,6 +979,28 @@ void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname) return NULL; } +mctp_eid_t *mctp_nl_get_link_local_eids_byname(const mctp_nl *nl, + const char *ifname, size_t *ret_num) +{ + mctp_eid_t *ret; + *ret_num = 0; + size_t i; + + for (i = 0; i < nl->linkmap_count; i++) { + struct linkmap_entry *entry = &nl->linkmap[i]; + if (!strcmp(entry->ifname, ifname)) + { + ret = malloc(entry->num_local); + if (!ret) + return NULL; + memcpy(ret, entry->local_eids, entry->num_local); + *ret_num = entry->num_local; + } + } + + return ret; +} + bool mctp_nl_up_byindex(const mctp_nl *nl, int index) { struct linkmap_entry *entry = entry_byindex(nl, index); diff --git a/src/mctp-netlink.h b/src/mctp-netlink.h index 26450a4..881197b 100644 --- a/src/mctp-netlink.h +++ b/src/mctp-netlink.h @@ -90,6 +90,9 @@ int mctp_nl_set_link_userdata(mctp_nl *nl, int ifindex, void *userdata); void *mctp_nl_get_link_userdata(const mctp_nl *nl, int ifindex); /* Returns NULL if the link does not exist */ void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname); +/* Returns local EIDs*/ +mctp_eid_t *mctp_nl_get_link_local_eids_byname(const mctp_nl *nl, + const char *ifname, size_t *ret_num); /* MCTP route helper */ int mctp_nl_route_add(struct mctp_nl *nl, uint8_t eid, const char* ifname, diff --git a/src/mctpd.c b/src/mctpd.c index 9a6edb3..9a5cc08 100644 --- a/src/mctpd.c +++ b/src/mctpd.c @@ -2975,6 +2975,8 @@ static int bus_link_get_prop(sd_bus *bus, char *link_name = NULL; link_userdata *lmUserData = NULL; int rc = 0; + mctp_eid_t *eids; + size_t num; if (!is_interfaces_path(path)) { sd_bus_error_setf(berr, SD_BUS_ERROR_INVALID_ARGS, @@ -2998,6 +3000,10 @@ static int bus_link_get_prop(sd_bus *bus, if (lmUserData->published && strcmp(property, "Role") == 0) { rc = sd_bus_message_append(reply, "s", roles[lmUserData->role].dbus_val); + } else if (strcmp(property, "EIDs") == 0) { + eids = mctp_nl_get_link_local_eids_byname(ctx->nl, link_name, &num); + rc = sd_bus_message_append_array(reply, 'y', eids, num); + free(eids); } else { sd_bus_error_setf(berr, SD_BUS_ERROR_INVALID_ARGS, "Unknown property."); @@ -3162,6 +3168,11 @@ static const sd_bus_vtable bus_endpoint_link_vtable[] = { bus_link_set_prop, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), + SD_BUS_PROPERTY("EIDs", + "ay", + bus_link_get_prop, + 0, + SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_VTABLE_END };