Compare commits

..

No commits in common. "953ee402cba52518f57105ae9c3c630d8a421f00" and "1f667d8a7cff4355cd23ebebeb4d7179e3498eb8" have entirely different histories.

7 changed files with 10 additions and 296 deletions

View File

@ -137,7 +137,6 @@ manpages = [
'sd_bus_add_fallback_vtable'],
''],
['sd_bus_attach_event', '3', ['sd_bus_detach_event', 'sd_bus_get_event'], ''],
['sd_bus_call', '3', ['sd_bus_call_async'], ''],
['sd_bus_call_method', '3', ['sd_bus_call_method_async'], ''],
['sd_bus_close', '3', ['sd_bus_flush'], ''],
['sd_bus_creds_get_pid',

View File

@ -43,8 +43,6 @@
<literallayout><citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_add_object_vtable</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_method_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -1,186 +0,0 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_call"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_call</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_call</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_call</refname>
<refname>sd_bus_call_async</refname>
<refpurpose>Invoke a D-Bus method call</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_call</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>uint64_t <parameter>usec</parameter></paramdef>
<paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>reply</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_call_async</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>sd_bus_message_handler_t <parameter>callback</parameter></paramdef>
<paramdef>void *<parameter>userdata</parameter></paramdef>
<paramdef>uint64_t <parameter>usec</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_call()</function> takes a complete bus message object and calls the
corresponding D-Bus method. The response is stored in <parameter>reply</parameter>.
<parameter>usec</parameter> indicates the timeout in microseconds. If
<parameter>ret_error</parameter> is not <constant>NULL</constant> and
<function>sd_bus_call()</function> returns an error, <parameter>ret_error</parameter> is
initialized to an instance of <structname>sd_bus_error</structname> describing the error.</para>
<para><function>sd_bus_call_async()</function> is like <function>sd_bus_call()</function> but
works asynchronously. The <parameter>callback</parameter> shall reference a function to call
when the event source is triggered. The <parameter>userdata</parameter> pointer will be passed
to the callback function, and may be chosen freely by the caller. If <parameter>slot</parameter>
is not <constant>NULL</constant> and <function>sd_bus_call_async()</function> succeeds,
<parameter>slot</parameter> is set to a slot object which can be used to cancel the method call
at a later time using
<citerefentry><refentrytitle>sd_bus_slot_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
If <parameter>slot</parameter> is <constant>NULL</constant>, the lifetime of the method call is
bound to the lifetime of the bus object itself, and it cannot be cancelled independently. See
<citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for details. The <parameter>callback</parameter> function is called when the response arrives
and receives the response, <parameter>userdata</parameter> and a
<structname>sd_bus_error</structname> object as its arguments. The
<structname>sd_bus_error</structname> object is unused here and should be ignored. If
<parameter>callback</parameter> returns a non-negative integer when called, a debug message is
logged along with details about the response.</para>
<para>To determine whether the method call succeeded, use
<citerefentry><refentrytitle>sd_bus_message_is_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
on the reply object returned by <function>sd_bus_call()</function> or passed to the callback of
<function>sd_bus_call_async()</function>.</para>
<para>If <parameter>usec</parameter> is zero, the timeout set using
<citerefentry><refentrytitle>sd_bus_set_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>
is used. If no method call timeout was set, the timeout is read from the
<varname>$SYSTEMD_BUS_TIMEOUT</varname> environment variable. If this environment variable is
unset or does not contain a valid timeout, the implementation falls back to a predefined method
call timeout of 25 seconds. Note that <varname>$SYSTEMD_BUS_TIMEOUT</varname> is read once and
cached so callers should not rely on being able to change the default method call timeout at
runtime by changing the value of <varname>$SYSTEMD_BUS_TIMEOUT</varname>. Instead, call
<function>sd_bus_set_method_call_timeout()</function> to change the default method call timeout.
</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, these functions return a non-negative integer. On failure, they return a
negative errno-style error code.</para>
<refsect2 id='errors'>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The input parameter <parameter>m</parameter> is <constant>NULL</constant>.
</para></listitem>
<listitem><para>The input parameter <parameter>m</parameter> is not a D-Bus method call.
To create a new D-Bus method call, use
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para></listitem>
<listitem><para>The input parameter <parameter>m</parameter> has the
<constant>BUS_MESSAGE_NO_REPLY_EXPECTED</constant> flag set.</para></listitem>
<listitem><para>The input parameter <parameter>error</parameter> is
non-<constant>NULL</constant> but was not set to <constant>SD_BUS_ERROR_NULL</constant>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus connection was allocated in a parent process and is being reused
in a child process after <function>fork()</function>.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOTCONN</constant></term>
<listitem><para>The bus parameter <parameter>bus</parameter> is <constant>NULL</constant>
or the bus is not connected.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECONNRESET</constant></term>
<listitem><para>The client was disconnected while waiting for the response.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ETIMEDOUT</constant></term>
<listitem><para>A response was not received within the given timeout.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ELOOP</constant></term>
<listitem><para>The message <parameter>m</parameter> is addressed to its own client.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_method_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -20,8 +20,7 @@
<refname>sd_bus_call_method</refname>
<refname>sd_bus_call_method_async</refname>
<refpurpose>Initialize a bus message object and invoke the corresponding D-Bus method call
</refpurpose>
<refpurpose>Invoke a D-Bus method call</refpurpose>
</refnamediv>
<refsynopsisdiv>
@ -60,15 +59,15 @@
<refsect1>
<title>Description</title>
<para><function>sd_bus_call_method()</function> is a convenience function for initializing a
bus message object and calling the corresponding D-Bus method. It combines the
<para><function>sd_bus_call_method()</function> is a convenience function for calling a D-Bus
method. It combines the
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>
functions into a single function call.</para>
<para><function>sd_bus_call_method_async()</function> is a convenience function for initializing
a bus message object and calling the corresponding D-Bus method asynchronously. It combines the
<para><function>sd_bus_call_method_async()</function> is a convenience function for calling a
D-Bus method asynchronously. It combines the
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>
@ -78,7 +77,7 @@
<refsect1>
<title>Return Value</title>
<para>On success, these functions return a non-negative integer. On failure, they return a
<para>On success, these functions returns a non-negative integer. On failure, they return a
negative errno-style error code.</para>
<refsect2 id='errors'>

View File

@ -84,7 +84,7 @@
<refsect1>
<title>Return Value</title>
<para>On success, these functions return a non-negative integer. On failure, they return a
<para>On success, these functions returns a non-negative integer. On failure, they return a
negative errno-style error code.</para>
<refsect2 id='errors'>
@ -163,9 +163,8 @@
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_path_encode</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -63,7 +63,7 @@
pointers to appropriate types (a pointer to <type>int8_t</type> for a <literal>y</literal> in
the type string, a pointer to <type>int32_t</type> for an <literal>i</literal>, a pointer to
<type>const char*</type> for an <literal>s</literal>, ...) which are set based on the values in
the message. As an exception, in case of array and variant types, the first argument is an
the message. As an exception, in case or array and variant types, the first argument is an
"input" argument that further specifies how the message should be read. See the table below for
a complete list of allowed arguments and their types. Note that, if the basic type is a pointer
(e.g., <type>const char *</type> in the case of a string), the argument is a pointer to a

View File

@ -154,10 +154,6 @@ typedef struct LinkInfo {
uint16_t vlan_id;
/* tunnel info */
uint8_t ttl;
uint8_t tos;
uint16_t tunnel_port;
uint32_t vni;
union in_addr_union local;
union in_addr_union remote;
@ -181,7 +177,6 @@ typedef struct LinkInfo {
bool has_bitrates:1;
bool has_ethtool_link_info:1;
bool has_wlan_link_info:1;
bool has_tunnel_ipv4:1;
bool needs_freeing:1;
} LinkInfo;
@ -258,30 +253,6 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
else if (STR_IN_SET(received_kind, "ipip", "sit")) {
(void) sd_netlink_message_read_in_addr(m, IFLA_IPTUN_LOCAL, &info->local.in);
(void) sd_netlink_message_read_in_addr(m, IFLA_IPTUN_REMOTE, &info->remote.in);
} else if (streq(received_kind, "geneve")) {
(void) sd_netlink_message_read_u32(m, IFLA_GENEVE_ID, &info->vni);
r = sd_netlink_message_read_in_addr(m, IFLA_GENEVE_REMOTE, &info->remote.in);
if (r >= 0)
info->has_tunnel_ipv4 = true;
else
(void) sd_netlink_message_read_in6_addr(m, IFLA_GENEVE_REMOTE6, &info->remote.in6);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_TTL, &info->ttl);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_TOS, &info->tos);
(void) sd_netlink_message_read_u16(m, IFLA_GENEVE_PORT, &info->tunnel_port);
} else if (STR_IN_SET(received_kind, "gre", "gretap", "erspan")) {
(void) sd_netlink_message_read_in_addr(m, IFLA_GRE_LOCAL, &info->local.in);
(void) sd_netlink_message_read_in_addr(m, IFLA_GRE_REMOTE, &info->remote.in);
} else if (STR_IN_SET(received_kind, "ip6gre", "ip6gretap", "ip6erspan")) {
(void) sd_netlink_message_read_in6_addr(m, IFLA_GRE_LOCAL, &info->local.in6);
(void) sd_netlink_message_read_in6_addr(m, IFLA_GRE_REMOTE, &info->remote.in6);
} else if (streq(received_kind, "vti")) {
(void) sd_netlink_message_read_in_addr(m, IFLA_VTI_LOCAL, &info->local.in);
(void) sd_netlink_message_read_in_addr(m, IFLA_VTI_REMOTE, &info->remote.in);
} else if (streq(received_kind, "vti6")) {
(void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_LOCAL, &info->local.in6);
(void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_REMOTE, &info->remote.in6);
}
strncpy(info->netdev_kind, received_kind, IFNAMSIZ);
@ -1488,7 +1459,7 @@ static int link_status_one(
TABLE_UINT16, info->vlan_id);
if (r < 0)
return table_log_add_error(r);
} else if (STRPTR_IN_SET(info->netdev_kind, "ipip", "sit", "gre", "gretap", "erspan", "vti")) {
} else if (STRPTR_IN_SET(info->netdev_kind, "ipip", "sit")) {
if (!in_addr_is_null(AF_INET, &info->local)) {
r = table_add_many(table,
TABLE_EMPTY,
@ -1506,72 +1477,6 @@ static int link_status_one(
if (r < 0)
return table_log_add_error(r);
}
} else if (STRPTR_IN_SET(info->netdev_kind, "ip6gre", "ip6gretap", "ip6erspan", "vti6")) {
if (!in_addr_is_null(AF_INET6, &info->local)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Local:",
TABLE_IN6_ADDR, &info->local);
if (r < 0)
return table_log_add_error(r);
}
if (!in_addr_is_null(AF_INET6, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
TABLE_IN6_ADDR, &info->remote);
if (r < 0)
return table_log_add_error(r);
}
} else if (streq_ptr(info->netdev_kind, "geneve")) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "VNI:",
TABLE_UINT32, info->vni);
if (r < 0)
return table_log_add_error(r);
if (info->has_tunnel_ipv4 && !in_addr_is_null(AF_INET, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
TABLE_IN_ADDR, &info->remote);
if (r < 0)
return table_log_add_error(r);
} else if (!in_addr_is_null(AF_INET6, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
TABLE_IN6_ADDR, &info->remote);
if (r < 0)
return table_log_add_error(r);
}
if (info->ttl > 0) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "TTL:",
TABLE_UINT8, info->ttl);
if (r < 0)
return table_log_add_error(r);
}
if (info->tos > 0) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "TOS:",
TABLE_UINT8, info->tos);
if (r < 0)
return table_log_add_error(r);
}
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Port:",
TABLE_UINT16, info->tunnel_port);
if (r < 0)
return table_log_add_error(r);
}
if (info->has_wlan_link_info) {