Compare commits

..

2 Commits

6 changed files with 156 additions and 8 deletions

View File

@ -137,6 +137,7 @@ manpages = [
'sd_bus_add_fallback_vtable'], 'sd_bus_add_fallback_vtable'],
''], ''],
['sd_bus_attach_event', '3', ['sd_bus_detach_event', 'sd_bus_get_event'], ''], ['sd_bus_attach_event', '3', ['sd_bus_detach_event', 'sd_bus_get_event'], ''],
['sd_bus_call_method', '3', ['sd_bus_call_method_async'], ''],
['sd_bus_close', '3', ['sd_bus_flush'], ''], ['sd_bus_close', '3', ['sd_bus_flush'], ''],
['sd_bus_creds_get_pid', ['sd_bus_creds_get_pid',
'3', '3',
@ -217,7 +218,10 @@ manpages = [
'3', '3',
['SD_BUS_ERROR_END', 'SD_BUS_ERROR_MAP', 'sd_bus_error_map'], ['SD_BUS_ERROR_END', 'SD_BUS_ERROR_MAP', 'sd_bus_error_map'],
''], ''],
['sd_bus_get_fd', '3', ['sd_bus_get_events', 'sd_bus_get_timeout'], ''], ['sd_bus_get_fd',
'3',
['sd_bus_get_events', 'sd_bus_get_timeout', 'sd_bus_set_fd'],
''],
['sd_bus_get_n_queued_read', '3', ['sd_bus_get_n_queued_write'], ''], ['sd_bus_get_n_queued_read', '3', ['sd_bus_get_n_queued_write'], ''],
['sd_bus_is_open', '3', ['sd_bus_is_ready'], ''], ['sd_bus_is_open', '3', ['sd_bus_is_ready'], ''],
['sd_bus_message_append', '3', ['sd_bus_message_appendv'], ''], ['sd_bus_message_append', '3', ['sd_bus_message_appendv'], ''],

View File

@ -43,6 +43,8 @@
<literallayout><citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <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_add_object_vtable</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_attach_event</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>, <citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

110
man/sd_bus_call_method.xml Normal file
View File

@ -0,0 +1,110 @@
<?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_method"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_call_method</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_call_method</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_call_method</refname>
<refname>sd_bus_call_method_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_method</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char *<parameter>destination</parameter></paramdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
<paramdef>const char *<parameter>interface</parameter></paramdef>
<paramdef>const char *<parameter>member</parameter></paramdef>
<paramdef>sd_bus_error *<parameter>ret_error</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>reply</parameter></paramdef>
<paramdef>const char *<parameter>types</parameter></paramdef>
<paramdef>...</paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_call_method_async</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>sd_bus_slot **<parameter>slot</parameter></paramdef>
<paramdef>const char *<parameter>destination</parameter></paramdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
<paramdef>const char *<parameter>interface</parameter></paramdef>
<paramdef>const char *<parameter>member</parameter></paramdef>
<paramdef>sd_bus_message_handler_t <parameter>callback</parameter></paramdef>
<paramdef>void *<parameter>userdata</parameter></paramdef>
<paramdef>const char *<parameter>types</parameter></paramdef>
<paramdef>...</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<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 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>
functions into a single function call.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, these functions returns a non-negative integer. On failure, they return a
negative errno-style error code.</para>
<refsect2 id='errors'>
<title>Errors</title>
<para>See the man pages of
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for a list of possible errors.</para>
</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_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</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>
</para>
</refsect1>
</refentry>

View File

@ -28,7 +28,7 @@
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo> <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype> <funcprototype>
<funcdef>int sd_bus_message_new_method_call</funcdef> <funcdef>int <function>sd_bus_message_new_method_call</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef> <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
<paramdef>const char *<parameter>destination</parameter></paramdef> <paramdef>const char *<parameter>destination</parameter></paramdef>
@ -38,7 +38,7 @@
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
<funcdef>int sd_bus_message_new_method_return</funcdef> <funcdef>int <function>sd_bus_message_new_method_return</function></funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef> <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef> <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
</funcprototype> </funcprototype>
@ -70,7 +70,11 @@
has only a single member with the given name and there is no ambiguity if the interface name is has only a single member with the given name and there is no ambiguity if the interface name is
omitted.</para> omitted.</para>
<para>The <function>sd_bus_message_new_method_call()</function> function creates a new bus <para>Note that this is a low level interface. See
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for a more convenient way of calling D-Bus methods.</para>
<para>The <function>sd_bus_message_new_method_return()</function> function creates a new bus
message object that is a reply to the method call <parameter>call</parameter> and returns it in message object that is a reply to the method call <parameter>call</parameter> and returns it in
the <parameter>m</parameter> output parameter. The <parameter>call</parameter> parameter must be the <parameter>m</parameter> output parameter. The <parameter>call</parameter> parameter must be
a method call message. The sender of <parameter>call</parameter> is used as the destination. a method call message. The sender of <parameter>call</parameter> is used as the destination.
@ -80,8 +84,8 @@
<refsect1> <refsect1>
<title>Return Value</title> <title>Return Value</title>
<para>This function returns 0 if the message object was successfully created, and a negative <para>On success, these functions returns a non-negative integer. On failure, they return a
errno-style error code otherwise.</para> negative errno-style error code.</para>
<refsect2 id='errors'> <refsect2 id='errors'>
<title>Errors</title> <title>Errors</title>
@ -160,6 +164,7 @@
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_path_encode</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> </para>
</refsect1> </refsect1>

View File

@ -30,14 +30,14 @@
<funcprototype> <funcprototype>
<funcdef>int <function>sd_bus_message_read</function></funcdef> <funcdef>int <function>sd_bus_message_read</function></funcdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef> <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>char char *<parameter>types</parameter></paramdef> <paramdef>const char *<parameter>types</parameter></paramdef>
<paramdef>...</paramdef> <paramdef>...</paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
<funcdef>int <function>sd_bus_message_readv</function></funcdef> <funcdef>int <function>sd_bus_message_readv</function></funcdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef> <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>char char *<parameter>types</parameter></paramdef> <paramdef>const char *<parameter>types</parameter></paramdef>
<paramdef>va_list <parameter>ap</parameter></paramdef> <paramdef>va_list <parameter>ap</parameter></paramdef>
</funcprototype> </funcprototype>
</funcsynopsis> </funcsynopsis>

View File

@ -7,6 +7,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <linux/if_tunnel.h>
#include "sd-bus.h" #include "sd-bus.h"
#include "sd-device.h" #include "sd-device.h"
@ -152,6 +153,10 @@ typedef struct LinkInfo {
/* vlan info */ /* vlan info */
uint16_t vlan_id; uint16_t vlan_id;
/* tunnel info */
union in_addr_union local;
union in_addr_union remote;
/* ethtool info */ /* ethtool info */
int autonegotiation; int autonegotiation;
uint64_t speed; uint64_t speed;
@ -245,6 +250,10 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
(void) sd_netlink_message_read_u16(m, IFLA_VXLAN_PORT, &info->vxlan_info.dest_port); (void) sd_netlink_message_read_u16(m, IFLA_VXLAN_PORT, &info->vxlan_info.dest_port);
} else if (streq(received_kind, "vlan")) } else if (streq(received_kind, "vlan"))
(void) sd_netlink_message_read_u16(m, IFLA_VLAN_ID, &info->vlan_id); (void) sd_netlink_message_read_u16(m, IFLA_VLAN_ID, &info->vlan_id);
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);
}
strncpy(info->netdev_kind, received_kind, IFNAMSIZ); strncpy(info->netdev_kind, received_kind, IFNAMSIZ);
@ -1450,6 +1459,24 @@ static int link_status_one(
TABLE_UINT16, info->vlan_id); TABLE_UINT16, info->vlan_id);
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
} 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,
TABLE_STRING, "Local:",
TABLE_IN_ADDR, &info->local);
if (r < 0)
return table_log_add_error(r);
}
if (!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);
}
} }
if (info->has_wlan_link_info) { if (info->has_wlan_link_info) {