From: Lennart Poettering Date: Fri, 22 Sep 2023 20:35:18 +0000 (+0200) Subject: varlink: add introspection data for the org.varlink.service and io.systemd interfaces X-Git-Tag: v255-rc1~305^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f946d4c9eca403a503f49465ea48a95562fbc3a6;p=thirdparty%2Fsystemd.git varlink: add introspection data for the org.varlink.service and io.systemd interfaces The official org.varlink.service interface definition, as per: https://varlink.org/Service And the io.systemd service where we carry some super generic errors our Varlink implementation generates. --- diff --git a/src/shared/meson.build b/src/shared/meson.build index da32e1435d6..429789b0452 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -167,6 +167,8 @@ shared_sources = files( 'userdb.c', 'varlink.c', 'varlink-idl.c', + 'varlink-io.systemd.c', + 'varlink-org.varlink.service.c', 'verb-log-control.c', 'verbs.c', 'vlan-util.c', diff --git a/src/shared/varlink-io.systemd.c b/src/shared/varlink-io.systemd.c new file mode 100644 index 00000000000..cdfe9ac263e --- /dev/null +++ b/src/shared/varlink-io.systemd.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "varlink-io.systemd.h" + +/* These are local errors that never cross the wire, and are our own invention */ +static VARLINK_DEFINE_ERROR(Disconnected); +static VARLINK_DEFINE_ERROR(TimedOut); +static VARLINK_DEFINE_ERROR(Protocol); + +/* This one we invented, and use for generically propagating system errors (errno) to clients */ +static VARLINK_DEFINE_ERROR( + System, + VARLINK_DEFINE_FIELD(errno, VARLINK_INT, 0)); + +VARLINK_DEFINE_INTERFACE( + io_systemd, + "io.systemd", + &vl_error_Disconnected, + &vl_error_TimedOut, + &vl_error_Protocol, + &vl_error_System); diff --git a/src/shared/varlink-io.systemd.h b/src/shared/varlink-io.systemd.h new file mode 100644 index 00000000000..6c17c6c4c71 --- /dev/null +++ b/src/shared/varlink-io.systemd.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "varlink-idl.h" + +extern const VarlinkInterface vl_interface_io_systemd; diff --git a/src/shared/varlink-org.varlink.service.c b/src/shared/varlink-org.varlink.service.c new file mode 100644 index 00000000000..52ba99dd2bd --- /dev/null +++ b/src/shared/varlink-org.varlink.service.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "varlink-org.varlink.service.h" + +static VARLINK_DEFINE_METHOD( + GetInfo, + VARLINK_DEFINE_OUTPUT(vendor, VARLINK_STRING, 0), + VARLINK_DEFINE_OUTPUT(product, VARLINK_STRING, 0), + VARLINK_DEFINE_OUTPUT(version, VARLINK_STRING, 0), + VARLINK_DEFINE_OUTPUT(url, VARLINK_STRING, 0), + VARLINK_DEFINE_OUTPUT(interfaces, VARLINK_STRING, VARLINK_ARRAY)); + +static VARLINK_DEFINE_METHOD( + GetInterfaceDescription, + VARLINK_DEFINE_OUTPUT(interface, VARLINK_STRING, 0)); + +static VARLINK_DEFINE_ERROR( + InterfaceNotFound, + VARLINK_DEFINE_FIELD(interface, VARLINK_STRING, 0)); + +static VARLINK_DEFINE_ERROR( + MethodNotFound, + VARLINK_DEFINE_FIELD(method, VARLINK_STRING, 0)); + +static VARLINK_DEFINE_ERROR( + MethodNotImplemented, + VARLINK_DEFINE_FIELD(method, VARLINK_STRING, 0)); + +static VARLINK_DEFINE_ERROR( + InvalidParameter, + VARLINK_DEFINE_FIELD(parameter, VARLINK_STRING, 0)); + +static VARLINK_DEFINE_ERROR(PermissionDenied); + +/* As per https://varlink.org/Service */ +VARLINK_DEFINE_INTERFACE( + org_varlink_service, + "org.varlink.service", + &vl_method_GetInfo, + &vl_method_GetInterfaceDescription, + &vl_error_InterfaceNotFound, + &vl_error_MethodNotFound, + &vl_error_MethodNotImplemented, + &vl_error_InvalidParameter, + &vl_error_PermissionDenied); diff --git a/src/shared/varlink-org.varlink.service.h b/src/shared/varlink-org.varlink.service.h new file mode 100644 index 00000000000..75c55e6e825 --- /dev/null +++ b/src/shared/varlink-org.varlink.service.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "varlink-idl.h" + +extern const VarlinkInterface vl_interface_org_varlink_service; diff --git a/src/shared/varlink.h b/src/shared/varlink.h index 457332eecc3..da7265312d9 100644 --- a/src/shared/varlink.h +++ b/src/shared/varlink.h @@ -187,6 +187,8 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkServer *, varlink_server_unref); #define VARLINK_ERROR_DISCONNECTED "io.systemd.Disconnected" #define VARLINK_ERROR_TIMEOUT "io.systemd.TimedOut" #define VARLINK_ERROR_PROTOCOL "io.systemd.Protocol" + +/* This one we invented, and use for generically propagating system errors (errno) to clients */ #define VARLINK_ERROR_SYSTEM "io.systemd.System" /* These are errors defined in the Varlink spec */