]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: add introspection data for the org.varlink.service and io.systemd interfaces
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Sep 2023 20:35:18 +0000 (22:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Oct 2023 09:49:38 +0000 (11:49 +0200)
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.

src/shared/meson.build
src/shared/varlink-io.systemd.c [new file with mode: 0644]
src/shared/varlink-io.systemd.h [new file with mode: 0644]
src/shared/varlink-org.varlink.service.c [new file with mode: 0644]
src/shared/varlink-org.varlink.service.h [new file with mode: 0644]
src/shared/varlink.h

index da32e1435d6c8edf6fd92fc41f986d2b88fe39ff..429789b045292ea30f04720557137b29e53dfaa4 100644 (file)
@@ -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 (file)
index 0000000..cdfe9ac
--- /dev/null
@@ -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 (file)
index 0000000..6c17c6c
--- /dev/null
@@ -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 (file)
index 0000000..52ba99d
--- /dev/null
@@ -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 (file)
index 0000000..75c55e6
--- /dev/null
@@ -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;
index 457332eecc30184c1d6d6fcc8031004f4e358a43..da7265312d9f1fa9e124fa704e3c5b6eb8395cae 100644 (file)
@@ -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 */