mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #23868 from keszybz/lib-resplit-2
Export sd-netlink and clean up exported interfaces a bit
This commit is contained in:
commit
3bdb60055e
@ -9,8 +9,8 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
## Code Map
|
||||
|
||||
This section will attempt to provide a high-level overview of the various
|
||||
components of the systemd repository.
|
||||
This document provides a high-level overview of the various components of the
|
||||
systemd repository.
|
||||
|
||||
## Source Code
|
||||
|
||||
@ -21,30 +21,60 @@ names are self-explanatory.
|
||||
|
||||
### Shared Code
|
||||
|
||||
You might wonder what kind of common code belongs in `src/shared/` and what
|
||||
belongs in `src/basic/`. The split is like this: anything that is used to
|
||||
implement the public shared objects we provide (`sd-bus`, `sd-login`,
|
||||
`sd-id128`, `nss-systemd`, `nss-mymachines`, `nss-resolve`, `nss-myhostname`,
|
||||
`pam_systemd`), must be located in `src/basic` (those objects are not allowed
|
||||
to link to `libsystemd-shared.so`). Conversely, anything which is shared
|
||||
between multiple components and does not need to be in `src/basic/`, should be
|
||||
in `src/shared/`.
|
||||
The code that is shared between components is split into a few directories,
|
||||
each with a different purpose:
|
||||
|
||||
- `src/basic/` and `src/fundamental/` — those directories contain code
|
||||
primitives that are used by all other code. `src/fundamental/` is stricter,
|
||||
because it used for EFI and user-space code, while `src/basic/` is only used
|
||||
for user-space code. The code in `src/fundamental/` cannot depend on any
|
||||
other code in the tree, and `src/basic/` can depend only on itself and
|
||||
`src/fundamental/`. For user-space, a static library is built from this code
|
||||
and linked statically in various places.
|
||||
|
||||
- `src/libsystemd/` implements the `libsystemd.so` shared library (also
|
||||
available as static `libsystemd.a`). This code may use anything in
|
||||
`src/basic/` or `src/fundamental/`.
|
||||
|
||||
- `src/shared/` provides various utilities and code shared between other
|
||||
components that is exposed as the `libsystemd-shared-<nnn>.so` shared library.
|
||||
|
||||
The other subdirectories implement individual components. They may depend only
|
||||
on `src/fundamental/` + `src/basic/`, or also on `src/libsystemd/`, or also on
|
||||
`src/shared/`.
|
||||
|
||||
You might wonder what kind of code belongs where. In general, the rule is that
|
||||
code should linked as few times as possible, ideally only once. Thus code that
|
||||
is used by "higher-level" components (e.g. our binaries which are linked to
|
||||
`libsystemd-shared-<nnn>.so`), would go to a subdirectory specific to that
|
||||
component if it is only used there. If the code is to be shared between
|
||||
components, it'd go to `src/shared/`. Shared code that that is used by multiple
|
||||
components that do not link to `libsystemd-shared-<nnn>.so` may live either in
|
||||
`src/libsystemd/`, `src/basic/`, or `src/fundamental/`. Any code that is used
|
||||
only for EFI goes under `src/boot/efi/`, and `src/fundamental/` if is shared
|
||||
with non-EFI compoenents.
|
||||
|
||||
To summarize:
|
||||
|
||||
`src/fundamental/`
|
||||
- may be used by all code in the tree
|
||||
- may not use any code outside of `src/fundamental/`
|
||||
|
||||
`src/basic/`
|
||||
- may be used by all code in the tree
|
||||
- may not use any code outside of `src/basic/`
|
||||
- may not use any code outside of `src/fundamental/` and `src/basic/`
|
||||
|
||||
`src/libsystemd/`
|
||||
- may be used by all code in the tree, except for code in `src/basic/`
|
||||
- may not use any code outside of `src/basic/`, `src/libsystemd/`
|
||||
- may be used by all code in the tree that links to `libsystem.so`
|
||||
- may not use any code outside of `src/fundamental/`, `src/basic/`, and
|
||||
`src/libsystemd/`
|
||||
|
||||
`src/shared/`
|
||||
- may be used by all code in the tree, except for code in `src/basic/`,
|
||||
`src/libsystemd/`, `src/nss-*`, `src/login/pam_systemd.*`, and files under
|
||||
`src/journal/` that end up in `libjournal-client.a` convenience library.
|
||||
- may not use any code outside of `src/basic/`, `src/libsystemd/`, `src/shared/`
|
||||
- may not use any code outside of `src/fundamental/`, `src/basic/`,
|
||||
`src/libsystemd/`, `src/shared/`
|
||||
|
||||
### PID 1
|
||||
|
||||
|
@ -137,6 +137,7 @@ manpages = [
|
||||
'sd_id128_in_setv',
|
||||
'sd_id128_is_allf',
|
||||
'sd_id128_is_null',
|
||||
'sd_id128_string_equal',
|
||||
'sd_id128_t'],
|
||||
''],
|
||||
['sd-journal', '3', [], ''],
|
||||
@ -267,7 +268,8 @@ manpages = [
|
||||
'sd_bus_error_set_errno',
|
||||
'sd_bus_error_set_errnof',
|
||||
'sd_bus_error_set_errnofv',
|
||||
'sd_bus_error_setf'],
|
||||
'sd_bus_error_setf',
|
||||
'sd_bus_error_setfv'],
|
||||
''],
|
||||
['sd_bus_error_add_map',
|
||||
'3',
|
||||
@ -359,7 +361,7 @@ manpages = [
|
||||
''],
|
||||
['sd_bus_message_read_array', '3', [], ''],
|
||||
['sd_bus_message_read_basic', '3', [], ''],
|
||||
['sd_bus_message_read_strv', '3', [], ''],
|
||||
['sd_bus_message_read_strv', '3', ['sd_bus_message_read_strv_extend'], ''],
|
||||
['sd_bus_message_rewind', '3', [], ''],
|
||||
['sd_bus_message_seal', '3', [], ''],
|
||||
['sd_bus_message_sensitive', '3', [], ''],
|
||||
@ -646,7 +648,10 @@ manpages = [
|
||||
'3',
|
||||
['SD_HWDB_FOREACH_PROPERTY', 'sd_hwdb_enumerate', 'sd_hwdb_seek'],
|
||||
''],
|
||||
['sd_hwdb_new', '3', ['sd_hwdb_ref', 'sd_hwdb_unref'], ''],
|
||||
['sd_hwdb_new',
|
||||
'3',
|
||||
['sd_hwdb_new_from_path', 'sd_hwdb_ref', 'sd_hwdb_unref'],
|
||||
''],
|
||||
['sd_id128_get_machine',
|
||||
'3',
|
||||
['sd_id128_get_boot',
|
||||
|
164
man/sd-id128.xml
164
man/sd-id128.xml
@ -28,6 +28,7 @@
|
||||
<refname>SD_ID128_NULL</refname>
|
||||
<refname>SD_ID128_UUID_FORMAT_STR</refname>
|
||||
<refname>sd_id128_equal</refname>
|
||||
<refname>sd_id128_string_equal</refname>
|
||||
<refname>sd_id128_in_set</refname>
|
||||
<refname>sd_id128_in_set_sentinel</refname>
|
||||
<refname>sd_id128_in_setv</refname>
|
||||
@ -40,6 +41,75 @@
|
||||
<refsynopsisdiv>
|
||||
<funcsynopsis>
|
||||
<funcsynopsisinfo>#include <systemd/sd-id128.h></funcsynopsisinfo>
|
||||
|
||||
<para>
|
||||
<constant>SD_ID128_ALLF</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_NULL</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_CONST_STR(<replaceable>id</replaceable>)</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_FORMAT_STR</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_FORMAT_VAL(<replaceable>id</replaceable>)</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_MAKE(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_MAKE_STR(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_MAKE_UUID_STR(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
|
||||
</para>
|
||||
<para>
|
||||
<constant>SD_ID128_UUID_FORMAT_STR</constant>
|
||||
</para>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_equal</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>a</parameter></paramdef>
|
||||
<paramdef>sd_id128_t <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_string_equal</function></funcdef>
|
||||
<paramdef>const char *<parameter>a</parameter></paramdef>
|
||||
<paramdef>sd_id128_t <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_is_null</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_is_allf</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_in_setv</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
||||
<paramdef>va_list <parameter>ap</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_in_set_sentinel</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
||||
<paramdef>…</paramdef>
|
||||
<paramdef><constant>SD_ID128_NULL</constant></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_id128_in_set</function></funcdef>
|
||||
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
|
||||
<paramdef>…</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@ -51,20 +121,13 @@
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para><filename>sd-id128.h</filename> provides APIs to process and generate 128-bit ID values. The
|
||||
128-bit ID values processed and generated by these APIs are a generalization of OSF UUIDs as defined by
|
||||
<ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink> but use a simpler string format. These
|
||||
functions impose no structure on the used IDs, much unlike OSF UUIDs or Microsoft GUIDs, but are mostly
|
||||
compatible with those types of IDs.
|
||||
<para><filename>sd-id128.h</filename> provides APIs to generate, convert, and compare 128-bit ID values.
|
||||
The 128-bit ID values processed and generated by these APIs are a generalization of OSF UUIDs as defined
|
||||
by <ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink> but use a simpler string format.
|
||||
These functions impose no structure on the used IDs, much unlike OSF UUIDs or Microsoft GUIDs, but are
|
||||
mostly compatible with those types of IDs.
|
||||
</para>
|
||||
|
||||
<para>See
|
||||
<citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
and
|
||||
<citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
for more information about the implemented functions.</para>
|
||||
|
||||
<para>A 128-bit ID is implemented as the following
|
||||
union type:</para>
|
||||
|
||||
@ -73,30 +136,28 @@
|
||||
uint64_t qwords[2];
|
||||
} sd_id128_t;</programlisting>
|
||||
|
||||
<para>This union type allows accessing the 128-bit ID as 16
|
||||
separate bytes or two 64-bit words. It is generally safer to
|
||||
access the ID components by their 8-bit array to avoid endianness
|
||||
issues. This union is intended to be passed call-by-value (as
|
||||
opposed to call-by-reference) and may be directly manipulated by
|
||||
<para>This union type allows accessing the 128-bit ID as 16 separate bytes or two 64-bit words. It is
|
||||
generally safer to access the ID components by their 8-bit array to avoid endianness issues. This union
|
||||
is intended to be passed by value (as opposed to pass-by-reference) and may be directly manipulated by
|
||||
clients.</para>
|
||||
|
||||
<para>A couple of macros are defined to denote and decode 128-bit
|
||||
IDs:</para>
|
||||
|
||||
<para><function>SD_ID128_MAKE()</function> may be used to denote a
|
||||
constant 128-bit ID in source code. A commonly used idiom is to
|
||||
assign a name to a 128-bit ID using this macro:</para>
|
||||
<para><function>SD_ID128_MAKE()</function> is used to write a constant ID in source code. A commonly used
|
||||
idiom is to assign a name to an ID using this macro:</para>
|
||||
|
||||
<programlisting>#define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)</programlisting>
|
||||
|
||||
<para><constant>SD_ID128_NULL</constant> may be used to refer to the 128-bit ID consisting of only
|
||||
<constant>NUL</constant> bytes (i.e. all bits off).</para>
|
||||
<para><constant>SD_ID128_NULL</constant> defines an ID consisting of only <constant>NUL</constant> bytes
|
||||
(i.e. all bits off).</para>
|
||||
|
||||
<para><constant>SD_ID128_ALLF</constant> may be used to refer to the 128-bit ID consisting of only
|
||||
<constant>0xFF</constant> bytes (i.e. all bits on).</para>
|
||||
<para><constant>SD_ID128_ALLF</constant> defines an ID consisting of only <constant>0xFF</constant> bytes
|
||||
(i.e. all bits on).</para>
|
||||
|
||||
<para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but creates a
|
||||
<type>const char*</type> expression that can be conveniently used in message formats and such:</para>
|
||||
<para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but
|
||||
creates a <type>const char*</type> expression that can be conveniently used in message formats and
|
||||
such:</para>
|
||||
|
||||
<programlisting>#include <stdio.h>
|
||||
#define SD_MESSAGE_COREDUMP_STR SD_ID128_MAKE_STR(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)
|
||||
@ -105,18 +166,16 @@ int main(int argc, char **argv) {
|
||||
puts("Match for coredumps: MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR);
|
||||
}</programlisting>
|
||||
|
||||
<para><function>SD_ID128_CONST_STR()</function> may be used to
|
||||
convert constant 128-bit IDs into constant strings for output. The
|
||||
following example code will output the string
|
||||
"fc2e22bc6ee647b6b90729ab34a250b1":</para>
|
||||
<para><function>SD_ID128_CONST_STR()</function> converts constant IDs into constant strings for
|
||||
output. The following example code will output the string "fc2e22bc6ee647b6b90729ab34a250b1":</para>
|
||||
<programlisting>int main(int argc, char *argv[]) {
|
||||
puts("Match for coredumps: %s", SD_ID128_CONST_STR(SD_MESSAGE_COREDUMP));
|
||||
}</programlisting>
|
||||
|
||||
<para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> may
|
||||
be used to format a 128-bit ID in a
|
||||
<citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
format string, as shown in the following example:</para>
|
||||
<para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> is used to
|
||||
format an ID in a <citerefentry
|
||||
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
|
||||
string, as shown in the following example:</para>
|
||||
|
||||
<programlisting>int main(int argc, char *argv[]) {
|
||||
sd_id128_t id;
|
||||
@ -136,7 +195,7 @@ int main(int argc, char **argv) {
|
||||
best to avoid UUIDs of other variants, in order to avoid unnecessary ambiguities. All 128-bit IDs
|
||||
generated by the sd-id128 APIs strictly conform to Variant 1 Version 4 UUIDs, as per RFC 4122.</para>
|
||||
|
||||
<para>Use <function>sd_id128_equal()</function> to compare two 128-bit IDs:</para>
|
||||
<para><function>sd_id128_equal()</function> compares two 128-bit IDs:</para>
|
||||
|
||||
<programlisting>int main(int argc, char *argv[]) {
|
||||
sd_id128_t a, b, c;
|
||||
@ -148,18 +207,26 @@ int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}</programlisting>
|
||||
|
||||
<para>Use <function>sd_id128_is_null()</function> to check if an 128-bit ID consists of only
|
||||
<constant>NUL</constant> bytes:</para>
|
||||
<para><function>sd_id128_string_equal()</function> is similar to <function>sd_id128_equal()</function>,
|
||||
but the first ID is formatted as <type>const char*</type>. The same restrictions apply as to the first
|
||||
argument of <function>sd_id128_from_string()</function>.</para>
|
||||
|
||||
<para><function>sd_id128_is_null()</function> checks if an ID consists of only <constant>NUL</constant>
|
||||
bytes:</para>
|
||||
|
||||
<programlisting>assert(sd_id128_is_null(SD_ID128_NULL));</programlisting>
|
||||
|
||||
<para>Similarly, use <function>sd_id128_is_allf()</function> to check if an 128-bit ID consists of only
|
||||
<para>Similarly, <function>sd_id128_is_allf()</function> checks if an ID consists of only
|
||||
<constant>0xFF</constant> bytes (all bits on):</para>
|
||||
|
||||
<programlisting>assert(sd_id128_is_allf(SD_ID128_ALLF));</programlisting>
|
||||
|
||||
<para>For convenience, <function>sd_id128_in_set()</function> takes a list of IDs and
|
||||
returns true if any are equal to the first argument:</para>
|
||||
<para><function>sd_id128_in_set_sentinel()</function> takes a list of IDs and returns true if the first
|
||||
argument is equal to any of the subsequent arguments. The argument list is terminated by an
|
||||
<constant>SD_ID128_NULL</constant> sentinel, which must be present.</para>
|
||||
|
||||
<para><function>sd_id128_in_set()</function> is a convenience function that takes a list of IDs and
|
||||
returns true if the first argument is equal to any of the subsequent arguments:</para>
|
||||
|
||||
<programlisting>int main(int argc, char *argv[]) {
|
||||
sd_id12_t a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
|
||||
@ -175,18 +242,25 @@ int main(int argc, char **argv) {
|
||||
</programlisting>
|
||||
|
||||
<para><function>sd_id128_in_set()</function> is defined as a macro over
|
||||
<function>sd_id128_in_set_sentinel()</function>, adding the <constant>SD_ID128_NULL</constant>
|
||||
sentinel. Since <function>sd_id128_in_set_sentinel()</function> uses <constant>SD_ID128_NULL</constant>
|
||||
as the sentinel, <constant>SD_ID128_NULL</constant> cannot be otherwise placed in the argument list.
|
||||
</para>
|
||||
<function>sd_id128_in_set_sentinel()</function>, adding the <constant>SD_ID128_NULL</constant> sentinel
|
||||
automatically. Since <function>sd_id128_in_set_sentinel()</function> uses
|
||||
<constant>SD_ID128_NULL</constant> as the sentinel, <constant>SD_ID128_NULL</constant> cannot be
|
||||
otherwise placed in the argument list.</para>
|
||||
|
||||
<para><function>sd_id128_in_setv()</function> is similar to
|
||||
<function>sd_id128_in_set_sentinel()</function>, but takes a <structname>struct varargs</structname>
|
||||
argument.</para>
|
||||
|
||||
<para>Note that new, randomized IDs may be generated with
|
||||
<para>New randomized IDs may be generated with
|
||||
<citerefentry><refentrytitle>systemd-id128</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
|
||||
<command>new</command> command.</para>
|
||||
|
||||
<para>See
|
||||
<citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
and
|
||||
<citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
for information about other implemented functions.</para>
|
||||
</refsect1>
|
||||
|
||||
<xi:include href="libsystemd-pkgconfig.xml" />
|
||||
|
@ -22,6 +22,7 @@
|
||||
<refname>sd_bus_error_free</refname>
|
||||
<refname>sd_bus_error_set</refname>
|
||||
<refname>sd_bus_error_setf</refname>
|
||||
<refname>sd_bus_error_setfv</refname>
|
||||
<refname>sd_bus_error_set_const</refname>
|
||||
<refname>sd_bus_error_set_errno</refname>
|
||||
<refname>sd_bus_error_set_errnof</refname>
|
||||
@ -74,6 +75,14 @@
|
||||
<paramdef>…</paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_bus_error_setfv</function></funcdef>
|
||||
<paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
|
||||
<paramdef>const char *<parameter>name</parameter></paramdef>
|
||||
<paramdef>const char *<parameter>format</parameter></paramdef>
|
||||
<paramdef>va_list <parameter>ap</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_bus_error_set_const</function></funcdef>
|
||||
<paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
|
||||
@ -196,11 +205,15 @@
|
||||
which case an <constant>SD_BUS_ERROR_NO_MEMORY</constant> error will be set instead and
|
||||
<constant>-ENOMEM</constant> returned. </para>
|
||||
|
||||
<para><function>sd_bus_error_setf()</function> is similar to
|
||||
<function>sd_bus_error_set()</function>, but takes a <citerefentry
|
||||
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
format string and corresponding arguments to generate the
|
||||
<structfield>message</structfield> field.</para>
|
||||
<para><function>sd_bus_error_setf()</function> and <function>sd_bus_error_setfv()</function> are similar
|
||||
to <function>sd_bus_error_set()</function>, but take a <citerefentry
|
||||
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
|
||||
string and corresponding arguments to generate the <structfield>message</structfield> field.
|
||||
<function>sd_bus_error_setf()</function> uses variadic arguments, and
|
||||
<function>sd_bus_error_setfv()</function> accepts the arguments as a
|
||||
<citerefentry
|
||||
project='man-pages'><refentrytitle>va_arg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
parameter list.</para>
|
||||
|
||||
<para><function>sd_bus_error_set_const()</function> is similar to
|
||||
<function>sd_bus_error_set()</function>, but the string parameters are not copied internally, and must
|
||||
@ -223,17 +236,15 @@
|
||||
due to lack of memory, in which case an <constant>SD_BUS_ERROR_NO_MEMORY</constant> error is set instead,
|
||||
and <constant>-ENOMEM</constant> is returned.</para>
|
||||
|
||||
<para><function>sd_bus_error_set_errnof()</function> is similar to
|
||||
<function>sd_bus_error_set_errno()</function>, but in addition to
|
||||
<parameter>error</parameter>, takes a <citerefentry
|
||||
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
format string and corresponding arguments. The
|
||||
<structfield>message</structfield> field will be generated from
|
||||
<parameter>format</parameter> and the arguments.</para>
|
||||
|
||||
<para><function>sd_bus_error_set_errnofv()</function> is similar to
|
||||
<function>sd_bus_error_set_errnof()</function>, but takes the
|
||||
format string parameters as <citerefentry
|
||||
<para><function>sd_bus_error_set_errnof()</function> and <function>sd_bus_error_set_errnof()</function>
|
||||
are similar to <function>sd_bus_error_set_errno()</function>, but in addition to
|
||||
<parameter>error</parameter>, take a <citerefentry
|
||||
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
|
||||
string and corresponding arguments. The <structfield>message</structfield> field will be generated from
|
||||
<parameter>format</parameter> and the arguments.
|
||||
<function>sd_bus_error_set_errnof()</function> uses variadic arguments, and
|
||||
<function>sd_bus_error_set_errnofv()</function> accepts the arguments as a
|
||||
<citerefentry
|
||||
project='man-pages'><refentrytitle>va_arg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
parameter list.</para>
|
||||
|
||||
|
@ -44,9 +44,10 @@
|
||||
<title>Description</title>
|
||||
|
||||
<para>The <function>sd_bus_message_dump()</function> function writes a textual representation of the
|
||||
message <parameter>m</parameter> to the stream <parameter>f</parameter>. This function is intended to be
|
||||
used for debugging purposes, and the output is neither stable nor designed to be machine readable.
|
||||
</para>
|
||||
message <parameter>m</parameter> to the stream <parameter>f</parameter>. If <parameter>f</parameter> is
|
||||
<constant>NULL</constant>, standard output (<constant>stdio</constant>) will be used. This function is
|
||||
intended to be used for debugging purposes, and the output is neither stable nor designed to be machine
|
||||
readable.</para>
|
||||
|
||||
<para>The <parameter>flags</parameter> parameter may be used to modify the output. With
|
||||
<constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>, a header that specifies the message type and flags
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
<refnamediv>
|
||||
<refname>sd_bus_message_read_strv</refname>
|
||||
<refname>sd_bus_message_read_strv_extend</refname>
|
||||
|
||||
<refpurpose>Access an array of strings in a message</refpurpose>
|
||||
</refnamediv>
|
||||
@ -30,26 +31,39 @@
|
||||
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
||||
<paramdef>char ***<parameter>l</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_bus_message_read_strv_extend</function></funcdef>
|
||||
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
||||
<paramdef>char ***<parameter>l</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para><function>sd_bus_message_read_strv()</function> gives access to an array of string-like items in
|
||||
<para><function>sd_bus_message_read_strv()</function> reads an array of string-like items from the
|
||||
message <parameter>m</parameter>. The "read pointer" in the message must be right before an array of
|
||||
strings (D-Bus type <literal>as</literal>), object paths (D-Bus type <literal>ao</literal>), or
|
||||
signatures (D-Bus type <literal>ag</literal>). On success, a pointer to a
|
||||
<constant>NULL</constant>-terminated array of strings is returned in the output parameter
|
||||
<constant>NULL</constant>-terminated array of strings (strv) is returned in the output parameter
|
||||
<parameter>l</parameter>. Note that ownership of this array is transferred to the caller. Hence, the
|
||||
caller is responsible for freeing this array and its contents.</para>
|
||||
|
||||
<para><function>sd_bus_message_read_strv_extend()</function> is similar, but the second parameter is an
|
||||
input-output parameter. If <parameter>*l</parameter> is <constant>NULL</constant>, if behaves identically
|
||||
to <function>sd_bus_message_read_strv()</function>. Otherwise, <parameter>*l</parameter> must point to a
|
||||
strv, which will be reallocated and extended with additional strings. This function is particularly
|
||||
useful when combining multiple lists of strings in a message or messages into a single array of strings.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Return Value</title>
|
||||
|
||||
<para>On success, <function>sd_bus_message_read_strv()</function> returns a non-negative integer. On
|
||||
failure, it returns a negative errno-style error code.</para>
|
||||
<para>On success, these functions return a non-negative integer. On failure, they return a negative
|
||||
errno-style error code.</para>
|
||||
|
||||
<refsect2>
|
||||
<title>Errors</title>
|
||||
|
@ -53,28 +53,29 @@
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para><function>sd_event_source_set_enabled()</function> may be
|
||||
used to enable or disable the event source object specified as
|
||||
<parameter>source</parameter>. The <parameter>enabled</parameter>
|
||||
parameter takes one of <constant>SD_EVENT_ON</constant> (to
|
||||
enable), <constant>SD_EVENT_OFF</constant> (to disable) or
|
||||
<constant>SD_EVENT_ONESHOT</constant>. If invoked with
|
||||
<constant>SD_EVENT_ONESHOT</constant> the event source will be
|
||||
enabled but automatically reset to
|
||||
<constant>SD_EVENT_OFF</constant> after the event source was
|
||||
dispatched once.</para>
|
||||
<para><function>sd_event_source_set_enabled()</function> may be used to enable or disable the event
|
||||
source object specified as <parameter>source</parameter>. The <parameter>enabled</parameter> parameter
|
||||
takes one of <constant>SD_EVENT_ON</constant> (to enable), <constant>SD_EVENT_OFF</constant> (to disable)
|
||||
or <constant>SD_EVENT_ONESHOT</constant>. If invoked with <constant>SD_EVENT_ONESHOT</constant> the event
|
||||
source will be enabled but automatically reset to <constant>SD_EVENT_OFF</constant> after one dispatch.
|
||||
For <constant>SD_EVENT_OFF</constant>, the event source <parameter>source</parameter> may be
|
||||
<constant>NULL</constant>, in which case the function does nothing. Otherwise,
|
||||
<parameter>source</parameter> must be a valid pointer to an <structname>sd_event_source</structname>
|
||||
object.</para>
|
||||
|
||||
<para>Event sources that are disabled will not result in event
|
||||
loop wakeups and will not be dispatched, until they are enabled
|
||||
again.</para>
|
||||
|
||||
<para><function>sd_event_source_get_enabled()</function> may be
|
||||
used to query whether the event source object
|
||||
<parameter>source</parameter> is currently enabled or not. It
|
||||
returns the enablement state (one of <constant>SD_EVENT_ON</constant>,
|
||||
<constant>SD_EVENT_OFF</constant>, <constant>SD_EVENT_ONESHOT</constant>)
|
||||
in <parameter>enabled</parameter>, if it is not <constant>NULL</constant>.
|
||||
It also returns true if the event source is not disabled.</para>
|
||||
<para><function>sd_event_source_get_enabled()</function> may be used to query whether the event source
|
||||
object <parameter>source</parameter> is currently enabled or not. If both the
|
||||
<parameter>source</parameter> and the output parameter <parameter>enabled</parameter> are
|
||||
<constant>NULL</constant>, this function returns false. Otherwise, <parameter>source</parameter> must be
|
||||
a valid pointer to an <structname>sd_event_source</structname> object. If the output parameter
|
||||
<parameter>enabled</parameter> is not <constant>NULL</constant>, it is set to the enablement state (one
|
||||
of <constant>SD_EVENT_ON</constant>, <constant>SD_EVENT_OFF</constant>,
|
||||
<constant>SD_EVENT_ONESHOT</constant>). The function also returns true if the event source is not
|
||||
disabled.</para>
|
||||
|
||||
<para>Event source objects are enabled when they are first created
|
||||
with calls such as
|
||||
|
@ -1928,7 +1928,6 @@ alias_target('devel', libsystemd_pc, libudev_pc)
|
||||
|
||||
libsystemd = shared_library(
|
||||
'systemd',
|
||||
disable_mempool_c,
|
||||
version : libsystemd_version,
|
||||
include_directories : libsystemd_includes,
|
||||
link_args : ['-shared',
|
||||
@ -1953,7 +1952,6 @@ install_libsystemd_static = static_library(
|
||||
basic_gcrypt_sources,
|
||||
basic_compress_sources,
|
||||
fundamental_sources,
|
||||
disable_mempool_c,
|
||||
include_directories : libsystemd_includes,
|
||||
build_by_default : static_libsystemd != 'false',
|
||||
install : static_libsystemd != 'false',
|
||||
@ -1975,7 +1973,6 @@ install_libsystemd_static = static_library(
|
||||
|
||||
libudev = shared_library(
|
||||
'udev',
|
||||
disable_mempool_c,
|
||||
version : libudev_version,
|
||||
include_directories : includes,
|
||||
link_args : ['-shared',
|
||||
@ -1997,7 +1994,6 @@ install_libudev_static = static_library(
|
||||
shared_sources,
|
||||
libsystemd_sources,
|
||||
libudev_sources,
|
||||
disable_mempool_c,
|
||||
include_directories : includes,
|
||||
build_by_default : static_libudev != 'false',
|
||||
install : static_libudev != 'false',
|
||||
@ -2118,7 +2114,6 @@ subdir('test')
|
||||
test_dlopen = executable(
|
||||
'test-dlopen',
|
||||
test_dlopen_c,
|
||||
disable_mempool_c,
|
||||
include_directories : includes,
|
||||
link_with : [libbasic],
|
||||
dependencies : [libdl],
|
||||
@ -2148,7 +2143,6 @@ foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
|
||||
nss = shared_library(
|
||||
'nss_' + module,
|
||||
sources,
|
||||
disable_mempool_c,
|
||||
version : '2',
|
||||
include_directories : incs,
|
||||
# Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
|
||||
|
@ -771,16 +771,15 @@ static void shared_hash_key_initialize(void) {
|
||||
static struct HashmapBase* hashmap_base_new(const struct hash_ops *hash_ops, enum HashmapType type HASHMAP_DEBUG_PARAMS) {
|
||||
HashmapBase *h;
|
||||
const struct hashmap_type_info *hi = &hashmap_type_info[type];
|
||||
bool up;
|
||||
|
||||
up = mempool_enabled();
|
||||
bool use_pool = mempool_enabled && mempool_enabled();
|
||||
|
||||
h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
|
||||
h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
h->type = type;
|
||||
h->from_pool = up;
|
||||
h->from_pool = use_pool;
|
||||
h->hash_ops = hash_ops ?: &trivial_hash_ops;
|
||||
|
||||
if (type == HASHMAP_TYPE_ORDERED) {
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "env-util.h"
|
||||
#include "macro.h"
|
||||
#include "memory-util.h"
|
||||
#include "mempool.h"
|
||||
#include "process-util.h"
|
||||
#include "util.h"
|
||||
|
||||
struct pool {
|
||||
struct pool *next;
|
||||
@ -73,20 +70,6 @@ void mempool_free_tile(struct mempool *mp, void *p) {
|
||||
mp->freelist = p;
|
||||
}
|
||||
|
||||
bool mempool_enabled(void) {
|
||||
static int b = -1;
|
||||
|
||||
if (!is_main_thread())
|
||||
return false;
|
||||
|
||||
if (!mempool_use_allowed)
|
||||
b = false;
|
||||
if (b < 0)
|
||||
b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
#if VALGRIND
|
||||
void mempool_drop(struct mempool *mp) {
|
||||
struct pool *p = mp->first_pool;
|
||||
|
@ -23,8 +23,7 @@ static struct mempool pool_name = { \
|
||||
.at_least = alloc_at_least, \
|
||||
}
|
||||
|
||||
extern const bool mempool_use_allowed;
|
||||
bool mempool_enabled(void);
|
||||
__attribute__((weak)) bool mempool_enabled(void);
|
||||
|
||||
#if VALGRIND
|
||||
void mempool_drop(struct mempool *mp);
|
||||
|
@ -129,7 +129,7 @@ static inline int fd_inc_sndbuf(int fd, size_t n) {
|
||||
return fd_set_sndbuf(fd, n, true);
|
||||
}
|
||||
int fd_set_rcvbuf(int fd, size_t n, bool increase);
|
||||
static inline int fd_inc_rcvbuf(int fd, size_t n) {
|
||||
static inline int fd_increase_rxbuf(int fd, size_t n) {
|
||||
return fd_set_rcvbuf(fd, n, true);
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ static int manager_setup_notify(Manager *m) {
|
||||
if (fd < 0)
|
||||
return log_error_errno(errno, "Failed to allocate notification socket: %m");
|
||||
|
||||
fd_inc_rcvbuf(fd, NOTIFY_RCVBUF_SIZE);
|
||||
fd_increase_rxbuf(fd, NOTIFY_RCVBUF_SIZE);
|
||||
|
||||
m->notify_socket = path_join(m->prefix[EXEC_DIRECTORY_RUNTIME], "systemd/notify");
|
||||
if (!m->notify_socket)
|
||||
@ -1093,7 +1093,7 @@ static int manager_setup_cgroups_agent(Manager *m) {
|
||||
if (fd < 0)
|
||||
return log_error_errno(errno, "Failed to allocate cgroups agent socket: %m");
|
||||
|
||||
fd_inc_rcvbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE);
|
||||
fd_increase_rxbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE);
|
||||
|
||||
(void) sockaddr_un_unlink(&sa.un);
|
||||
|
||||
@ -1157,7 +1157,7 @@ static int manager_setup_user_lookup_fd(Manager *m) {
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, m->user_lookup_fds) < 0)
|
||||
return log_error_errno(errno, "Failed to allocate user lookup socket: %m");
|
||||
|
||||
(void) fd_inc_rcvbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE);
|
||||
(void) fd_increase_rxbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE);
|
||||
}
|
||||
|
||||
if (!m->user_lookup_event_source) {
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <sys/quota.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-error.h"
|
||||
@ -1239,7 +1241,7 @@ static int manager_add_device(Manager *m, sd_device *d) {
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to acquire ID_PART_ENTRY_TYPE device property, ignoring: %m");
|
||||
if (id128_equal_string(parttype, GPT_USER_HOME) <= 0) {
|
||||
if (sd_id128_string_equal(parttype, GPT_USER_HOME) <= 0) {
|
||||
log_debug("Found partition (%s) we don't care about, ignoring.", sysfs);
|
||||
return 0;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "sd-daemon.h"
|
||||
#include "sd-device.h"
|
||||
#include "sd-event.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "blkid-util.h"
|
||||
#include "blockdev-util.h"
|
||||
@ -34,7 +35,6 @@
|
||||
#include "home-util.h"
|
||||
#include "homework-luks.h"
|
||||
#include "homework-mount.h"
|
||||
#include "id128-util.h"
|
||||
#include "io-util.h"
|
||||
#include "keyring-util.h"
|
||||
#include "memory-util.h"
|
||||
@ -704,7 +704,7 @@ static int luks_validate(
|
||||
if (!pp)
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
if (id128_equal_string(blkid_partition_get_type_string(pp), GPT_USER_HOME) <= 0)
|
||||
if (sd_id128_string_equal(blkid_partition_get_type_string(pp), GPT_USER_HOME) <= 0)
|
||||
continue;
|
||||
|
||||
if (!streq_ptr(blkid_partition_get_name(pp), label))
|
||||
|
@ -375,12 +375,9 @@ ManagedJournalFile* managed_journal_file_close(ManagedJournalFile *f) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (f->file->post_change_timer) {
|
||||
if (sd_event_source_get_enabled(f->file->post_change_timer, NULL) > 0)
|
||||
journal_file_post_change(f->file);
|
||||
|
||||
sd_event_source_disable_unref(f->file->post_change_timer);
|
||||
}
|
||||
|
||||
managed_journal_file_set_offline(f, true);
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "mempool.h"
|
||||
|
||||
const bool mempool_use_allowed = false;
|
@ -781,5 +781,165 @@ global:
|
||||
|
||||
LIBSYSTEMD_252 {
|
||||
global:
|
||||
sd_bus_message_read_strv_extend;
|
||||
sd_bus_error_setfv;
|
||||
|
||||
sd_id128_string_equal;
|
||||
|
||||
sd_hwdb_new_from_path;
|
||||
|
||||
sd_netlink_new_from_fd;
|
||||
sd_netlink_open;
|
||||
sd_netlink_open_fd;
|
||||
sd_netlink_increase_rxbuf;
|
||||
sd_netlink_ref;
|
||||
sd_netlink_unref;
|
||||
sd_netlink_send;
|
||||
sd_netlink_call_async;
|
||||
sd_netlink_call;
|
||||
sd_netlink_read;
|
||||
sd_netlink_get_events;
|
||||
sd_netlink_get_timeout;
|
||||
sd_netlink_process;
|
||||
sd_netlink_wait;
|
||||
sd_netlink_add_match;
|
||||
sd_netlink_attach_event;
|
||||
sd_netlink_detach_event;
|
||||
sd_netlink_attach_filter;
|
||||
sd_netlink_message_append_string;
|
||||
sd_netlink_message_append_strv;
|
||||
sd_netlink_message_append_flag;
|
||||
sd_netlink_message_append_u8;
|
||||
sd_netlink_message_append_u16;
|
||||
sd_netlink_message_append_u32;
|
||||
sd_netlink_message_append_u64;
|
||||
sd_netlink_message_append_s8;
|
||||
sd_netlink_message_append_s16;
|
||||
sd_netlink_message_append_s32;
|
||||
sd_netlink_message_append_s64;
|
||||
sd_netlink_message_append_data;
|
||||
sd_netlink_message_append_in_addr;
|
||||
sd_netlink_message_append_in6_addr;
|
||||
sd_netlink_message_append_sockaddr_in;
|
||||
sd_netlink_message_append_sockaddr_in6;
|
||||
sd_netlink_message_append_ether_addr;
|
||||
sd_netlink_message_append_cache_info;
|
||||
sd_netlink_message_open_container;
|
||||
sd_netlink_message_open_container_union;
|
||||
sd_netlink_message_close_container;
|
||||
sd_netlink_message_read;
|
||||
sd_netlink_message_read_data;
|
||||
sd_netlink_message_read_data_suffix0;
|
||||
sd_netlink_message_read_string_strdup;
|
||||
sd_netlink_message_read_string;
|
||||
sd_netlink_message_read_strv;
|
||||
sd_netlink_message_read_u8;
|
||||
sd_netlink_message_read_u16;
|
||||
sd_netlink_message_read_u32;
|
||||
sd_netlink_message_read_ether_addr;
|
||||
sd_netlink_message_read_cache_info;
|
||||
sd_netlink_message_read_in_addr;
|
||||
sd_netlink_message_read_in6_addr;
|
||||
sd_netlink_message_has_flag;
|
||||
sd_netlink_message_enter_container;
|
||||
sd_netlink_message_enter_array;
|
||||
sd_netlink_message_exit_container;
|
||||
sd_netlink_message_open_array;
|
||||
sd_netlink_message_cancel_array;
|
||||
sd_netlink_message_rewind;
|
||||
sd_netlink_message_next;
|
||||
sd_netlink_message_ref;
|
||||
sd_netlink_message_unref;
|
||||
sd_netlink_message_request_dump;
|
||||
sd_netlink_message_is_error;
|
||||
sd_netlink_message_get_errno;
|
||||
sd_netlink_message_get_type;
|
||||
sd_netlink_message_set_flags;
|
||||
sd_netlink_message_is_broadcast;
|
||||
sd_netlink_message_get_max_attribute;
|
||||
sd_netlink_slot_ref;
|
||||
sd_netlink_slot_unref;
|
||||
sd_netlink_slot_get_netlink;
|
||||
sd_netlink_slot_get_userdata;
|
||||
sd_netlink_slot_set_userdata;
|
||||
sd_netlink_slot_get_destroy_callback;
|
||||
sd_netlink_slot_set_destroy_callback;
|
||||
sd_netlink_slot_get_floating;
|
||||
sd_netlink_slot_set_floating;
|
||||
sd_netlink_slot_get_description;
|
||||
sd_netlink_slot_set_description;
|
||||
|
||||
sd_rtnl_message_get_family;
|
||||
sd_rtnl_message_new_addr;
|
||||
sd_rtnl_message_new_addr_update;
|
||||
sd_rtnl_message_addr_set_prefixlen;
|
||||
sd_rtnl_message_addr_set_scope;
|
||||
sd_rtnl_message_addr_set_flags;
|
||||
sd_rtnl_message_addr_get_family;
|
||||
sd_rtnl_message_addr_get_prefixlen;
|
||||
sd_rtnl_message_addr_get_scope;
|
||||
sd_rtnl_message_addr_get_flags;
|
||||
sd_rtnl_message_addr_get_ifindex;
|
||||
sd_rtnl_message_new_link;
|
||||
sd_rtnl_message_link_set_flags;
|
||||
sd_rtnl_message_link_set_type;
|
||||
sd_rtnl_message_link_set_family;
|
||||
sd_rtnl_message_link_get_ifindex;
|
||||
sd_rtnl_message_link_get_flags;
|
||||
sd_rtnl_message_link_get_type;
|
||||
sd_rtnl_message_new_route;
|
||||
sd_rtnl_message_route_set_dst_prefixlen;
|
||||
sd_rtnl_message_route_set_src_prefixlen;
|
||||
sd_rtnl_message_route_set_scope;
|
||||
sd_rtnl_message_route_set_flags;
|
||||
sd_rtnl_message_route_set_table;
|
||||
sd_rtnl_message_route_set_type;
|
||||
sd_rtnl_message_route_get_flags;
|
||||
sd_rtnl_message_route_get_family;
|
||||
sd_rtnl_message_route_get_protocol;
|
||||
sd_rtnl_message_route_get_scope;
|
||||
sd_rtnl_message_route_get_tos;
|
||||
sd_rtnl_message_route_get_table;
|
||||
sd_rtnl_message_route_get_dst_prefixlen;
|
||||
sd_rtnl_message_route_get_src_prefixlen;
|
||||
sd_rtnl_message_route_get_type;
|
||||
sd_rtnl_message_new_nexthop;
|
||||
sd_rtnl_message_nexthop_set_flags;
|
||||
sd_rtnl_message_nexthop_get_flags;
|
||||
sd_rtnl_message_nexthop_get_family;
|
||||
sd_rtnl_message_nexthop_get_protocol;
|
||||
sd_rtnl_message_new_neigh;
|
||||
sd_rtnl_message_neigh_set_flags;
|
||||
sd_rtnl_message_neigh_set_state;
|
||||
sd_rtnl_message_neigh_get_family;
|
||||
sd_rtnl_message_neigh_get_ifindex;
|
||||
sd_rtnl_message_neigh_get_state;
|
||||
sd_rtnl_message_neigh_get_flags;
|
||||
sd_rtnl_message_new_addrlabel;
|
||||
sd_rtnl_message_addrlabel_set_prefixlen;
|
||||
sd_rtnl_message_addrlabel_get_prefixlen;
|
||||
sd_rtnl_message_new_routing_policy_rule;
|
||||
sd_rtnl_message_routing_policy_rule_set_tos;
|
||||
sd_rtnl_message_routing_policy_rule_get_tos;
|
||||
sd_rtnl_message_routing_policy_rule_set_table;
|
||||
sd_rtnl_message_routing_policy_rule_get_table;
|
||||
sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen;
|
||||
sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen;
|
||||
sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen;
|
||||
sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen;
|
||||
sd_rtnl_message_routing_policy_rule_set_fib_type;
|
||||
sd_rtnl_message_routing_policy_rule_get_fib_type;
|
||||
sd_rtnl_message_routing_policy_rule_set_flags;
|
||||
sd_rtnl_message_routing_policy_rule_get_flags;
|
||||
sd_rtnl_message_new_traffic_control;
|
||||
sd_rtnl_message_traffic_control_get_ifindex;
|
||||
sd_rtnl_message_traffic_control_get_handle;
|
||||
sd_rtnl_message_traffic_control_get_parent;
|
||||
sd_rtnl_message_new_mdb;
|
||||
|
||||
sd_genl_socket_open;
|
||||
sd_genl_message_new;
|
||||
sd_genl_message_get_family_name;
|
||||
sd_genl_message_get_command;
|
||||
sd_genl_add_match;
|
||||
} LIBSYSTEMD_251;
|
||||
|
@ -155,10 +155,8 @@ libsystemd_sources = files(
|
||||
'sd-path/sd-path.c',
|
||||
'sd-resolve/resolve-private.h',
|
||||
'sd-resolve/sd-resolve.c',
|
||||
'sd-utf8/sd-utf8.c',
|
||||
) + sd_journal_sources + id128_sources + sd_daemon_sources + sd_event_sources + sd_login_sources
|
||||
|
||||
disable_mempool_c = files('disable-mempool.c')
|
||||
|
||||
libsystemd_c_args = ['-fvisibility=default']
|
||||
|
||||
|
@ -270,7 +270,7 @@ _public_ int sd_bus_reply_method_errorfv(
|
||||
if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
|
||||
return 0;
|
||||
|
||||
bus_error_setfv(&error, name, format, ap);
|
||||
sd_bus_error_setfv(&error, name, format, ap);
|
||||
|
||||
return sd_bus_reply_method_error(call, &error);
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
|
||||
unsigned level = 1;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return((flags & ~_SD_BUS_MESSAGE_DUMP_KNOWN_FLAGS) == 0, -EINVAL);
|
||||
|
||||
if (!f)
|
||||
f = stdout;
|
||||
|
@ -237,7 +237,7 @@ _public_ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *mes
|
||||
return -r;
|
||||
}
|
||||
|
||||
int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) {
|
||||
_public_ int sd_bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) {
|
||||
int r;
|
||||
|
||||
if (!name)
|
||||
@ -277,7 +277,7 @@ _public_ int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *fo
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
r = bus_error_setfv(e, name, format, ap);
|
||||
r = sd_bus_error_setfv(e, name, format, ap);
|
||||
assert(!name || r < 0);
|
||||
va_end(ap);
|
||||
|
||||
|
@ -11,9 +11,6 @@ bool bus_error_is_dirty(sd_bus_error *e);
|
||||
|
||||
const char *bus_error_message(const sd_bus_error *e, int error);
|
||||
|
||||
int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) _printf_(3,0);
|
||||
int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_list ap) _printf_(3,0);
|
||||
|
||||
#define BUS_ERROR_OOM SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_NO_MEMORY, "Out of memory")
|
||||
#define BUS_ERROR_FAILED SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_FAILED, "Operation failed")
|
||||
|
||||
|
@ -674,7 +674,7 @@ _public_ int sd_bus_message_new_method_errorf(
|
||||
assert_return(m, -EINVAL);
|
||||
|
||||
va_start(ap, format);
|
||||
bus_error_setfv(&error, name, format, ap);
|
||||
sd_bus_error_setfv(&error, name, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return sd_bus_message_new_method_error(call, m, &error);
|
||||
@ -4256,7 +4256,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
|
||||
_public_ int sd_bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
|
||||
char type;
|
||||
const char *contents, *s;
|
||||
int r;
|
||||
@ -4299,7 +4299,7 @@ _public_ int sd_bus_message_read_strv(sd_bus_message *m, char ***l) {
|
||||
assert_return(m->sealed, -EPERM);
|
||||
assert_return(l, -EINVAL);
|
||||
|
||||
r = bus_message_read_strv_extend(m, &strv);
|
||||
r = sd_bus_message_read_strv_extend(m, &strv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
|
@ -159,7 +159,6 @@ static inline void* BUS_MESSAGE_FIELDS(sd_bus_message *m) {
|
||||
}
|
||||
|
||||
int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
|
||||
int bus_message_read_strv_extend(sd_bus_message *m, char ***l);
|
||||
|
||||
int bus_message_from_malloc(
|
||||
sd_bus *bus,
|
||||
|
@ -608,7 +608,7 @@ void bus_socket_setup(sd_bus *b) {
|
||||
assert(b);
|
||||
|
||||
/* Increase the buffers to 8 MB */
|
||||
(void) fd_inc_rcvbuf(b->input_fd, SNDBUF_SIZE);
|
||||
(void) fd_increase_rxbuf(b->input_fd, SNDBUF_SIZE);
|
||||
(void) fd_inc_sndbuf(b->output_fd, SNDBUF_SIZE);
|
||||
|
||||
b->message_version = 1;
|
||||
|
@ -190,7 +190,7 @@ _public_ int sd_is_special(int fd, const char *path) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int sd_is_socket_internal(int fd, int type, int listening) {
|
||||
static int is_socket_internal(int fd, int type, int listening) {
|
||||
struct stat st_fd;
|
||||
|
||||
assert_return(fd >= 0, -EBADF);
|
||||
@ -239,7 +239,7 @@ _public_ int sd_is_socket(int fd, int family, int type, int listening) {
|
||||
assert_return(fd >= 0, -EBADF);
|
||||
assert_return(family >= 0, -EINVAL);
|
||||
|
||||
r = sd_is_socket_internal(fd, type, listening);
|
||||
r = is_socket_internal(fd, type, listening);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
@ -267,7 +267,7 @@ _public_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint
|
||||
assert_return(fd >= 0, -EBADF);
|
||||
assert_return(IN_SET(family, 0, AF_INET, AF_INET6), -EINVAL);
|
||||
|
||||
r = sd_is_socket_internal(fd, type, listening);
|
||||
r = is_socket_internal(fd, type, listening);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
@ -307,7 +307,7 @@ _public_ int sd_is_socket_sockaddr(int fd, int type, const struct sockaddr* addr
|
||||
assert_return(addr_len >= sizeof(sa_family_t), -ENOBUFS);
|
||||
assert_return(IN_SET(addr->sa_family, AF_INET, AF_INET6), -EPFNOSUPPORT);
|
||||
|
||||
r = sd_is_socket_internal(fd, type, listening);
|
||||
r = is_socket_internal(fd, type, listening);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
@ -362,7 +362,7 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
|
||||
|
||||
assert_return(fd >= 0, -EBADF);
|
||||
|
||||
r = sd_is_socket_internal(fd, type, listening);
|
||||
r = is_socket_internal(fd, type, listening);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
|
@ -109,20 +109,6 @@ int event_reset_time_relative(
|
||||
return event_reset_time(e, s, clock, usec_add(usec_now, usec), accuracy, callback, userdata, priority, description, force_reset);
|
||||
}
|
||||
|
||||
int event_source_disable(sd_event_source *s) {
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
return sd_event_source_set_enabled(s, SD_EVENT_OFF);
|
||||
}
|
||||
|
||||
int event_source_is_enabled(sd_event_source *s) {
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
return sd_event_source_get_enabled(s, NULL);
|
||||
}
|
||||
|
||||
int event_add_time_change(sd_event *e, sd_event_source **ret, sd_event_io_handler_t callback, void *userdata) {
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
@ -27,7 +27,8 @@ int event_reset_time_relative(
|
||||
int64_t priority,
|
||||
const char *description,
|
||||
bool force_reset);
|
||||
int event_source_disable(sd_event_source *s);
|
||||
int event_source_is_enabled(sd_event_source *s);
|
||||
static inline int event_source_disable(sd_event_source *s) {
|
||||
return sd_event_source_set_enabled(s, SD_EVENT_OFF);
|
||||
}
|
||||
|
||||
int event_add_time_change(sd_event *e, sd_event_source **ret, sd_event_io_handler_t callback, void *userdata);
|
||||
|
@ -2413,6 +2413,10 @@ fail:
|
||||
}
|
||||
|
||||
_public_ int sd_event_source_get_enabled(sd_event_source *s, int *ret) {
|
||||
/* Quick mode: the event source doesn't exist and we only want to query boolean enablement state. */
|
||||
if (!s && !ret)
|
||||
return false;
|
||||
|
||||
assert_return(s, -EINVAL);
|
||||
assert_return(!event_pid_changed(s->event), -ECHILD);
|
||||
|
||||
@ -2590,8 +2594,13 @@ static int event_source_online(
|
||||
_public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
|
||||
int r;
|
||||
|
||||
assert_return(s, -EINVAL);
|
||||
assert_return(IN_SET(m, SD_EVENT_OFF, SD_EVENT_ON, SD_EVENT_ONESHOT), -EINVAL);
|
||||
|
||||
/* Quick mode: if the source doesn't exist, SD_EVENT_OFF is a noop. */
|
||||
if (m == SD_EVENT_OFF && !s)
|
||||
return 0;
|
||||
|
||||
assert_return(s, -EINVAL);
|
||||
assert_return(!event_pid_changed(s->event), -ECHILD);
|
||||
|
||||
/* If we are dead anyway, we are fine with turning off sources, but everything else needs to fail. */
|
||||
|
@ -206,19 +206,3 @@ int id128_get_product(sd_id128_t *ret) {
|
||||
*ret = uuid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int id128_equal_string(const char *s, sd_id128_t id) {
|
||||
sd_id128_t parsed;
|
||||
int r;
|
||||
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
/* Checks if the specified string matches a valid string representation of the specified 128 bit ID/uuid */
|
||||
|
||||
r = sd_id128_from_string(s, &parsed);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_id128_equal(parsed, id);
|
||||
}
|
||||
|
@ -34,5 +34,3 @@ extern const struct hash_ops id128_hash_ops;
|
||||
sd_id128_t id128_make_v4_uuid(sd_id128_t id);
|
||||
|
||||
int id128_get_product(sd_id128_t *ret);
|
||||
|
||||
int id128_equal_string(const char *s, sd_id128_t id);
|
||||
|
@ -101,6 +101,22 @@ _public_ int sd_id128_from_string(const char s[], sd_id128_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_public_ int sd_id128_string_equal(const char *s, sd_id128_t id) {
|
||||
sd_id128_t parsed;
|
||||
int r;
|
||||
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
/* Checks if the specified string matches a valid string representation of the specified 128 bit ID/uuid */
|
||||
|
||||
r = sd_id128_from_string(s, &parsed);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_id128_equal(parsed, id);
|
||||
}
|
||||
|
||||
_public_ int sd_id128_get_machine(sd_id128_t *ret) {
|
||||
static thread_local sd_id128_t saved_machine_id = {};
|
||||
int r;
|
||||
|
@ -365,7 +365,7 @@ int genl_get_type_system_and_header_size(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_genl_message_new(sd_netlink *nl, const char *family_name, uint8_t cmd, sd_netlink_message **ret) {
|
||||
_public_ int sd_genl_message_new(sd_netlink *nl, const char *family_name, uint8_t cmd, sd_netlink_message **ret) {
|
||||
const GenericNetlinkFamily *family;
|
||||
int r;
|
||||
|
||||
@ -381,7 +381,7 @@ int sd_genl_message_new(sd_netlink *nl, const char *family_name, uint8_t cmd, sd
|
||||
return genl_message_new(nl, family, cmd, ret);
|
||||
}
|
||||
|
||||
int sd_genl_message_get_family_name(sd_netlink *nl, sd_netlink_message *m, const char **ret) {
|
||||
_public_ int sd_genl_message_get_family_name(sd_netlink *nl, sd_netlink_message *m, const char **ret) {
|
||||
const GenericNetlinkFamily *family;
|
||||
uint16_t nlmsg_type;
|
||||
int r;
|
||||
@ -403,7 +403,7 @@ int sd_genl_message_get_family_name(sd_netlink *nl, sd_netlink_message *m, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_genl_message_get_command(sd_netlink *nl, sd_netlink_message *m, uint8_t *ret) {
|
||||
_public_ int sd_genl_message_get_command(sd_netlink *nl, sd_netlink_message *m, uint8_t *ret) {
|
||||
struct genlmsghdr *h;
|
||||
uint16_t nlmsg_type;
|
||||
size_t size;
|
||||
@ -448,7 +448,7 @@ static int genl_family_get_multicast_group_id_by_name(const GenericNetlinkFamily
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_genl_add_match(
|
||||
_public_ int sd_genl_add_match(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_slot **ret_slot,
|
||||
const char *family_name,
|
||||
@ -483,6 +483,6 @@ int sd_genl_add_match(
|
||||
callback, destroy_callback, userdata, description);
|
||||
}
|
||||
|
||||
int sd_genl_socket_open(sd_netlink **ret) {
|
||||
_public_ int sd_genl_socket_open(sd_netlink **ret) {
|
||||
return netlink_open_family(ret, NETLINK_GENERIC);
|
||||
}
|
||||
|
@ -138,7 +138,12 @@ int message_new_full(
|
||||
sd_netlink_message **ret);
|
||||
int message_new(sd_netlink *nl, sd_netlink_message **ret, uint16_t type);
|
||||
int message_new_synthetic_error(sd_netlink *nl, int error, uint32_t serial, sd_netlink_message **ret);
|
||||
uint32_t message_get_serial(sd_netlink_message *m);
|
||||
|
||||
static inline uint32_t message_get_serial(sd_netlink_message *m) {
|
||||
assert(m);
|
||||
return ASSERT_PTR(m->hdr)->nlmsg_seq;
|
||||
}
|
||||
|
||||
void message_seal(sd_netlink_message *m);
|
||||
|
||||
int netlink_open_family(sd_netlink **ret, int family);
|
||||
@ -146,12 +151,10 @@ bool netlink_pid_changed(sd_netlink *nl);
|
||||
int netlink_rqueue_make_room(sd_netlink *nl);
|
||||
int netlink_rqueue_partial_make_room(sd_netlink *nl);
|
||||
|
||||
int socket_open(int family);
|
||||
int socket_bind(sd_netlink *nl);
|
||||
int socket_broadcast_group_ref(sd_netlink *nl, unsigned group);
|
||||
int socket_broadcast_group_unref(sd_netlink *nl, unsigned group);
|
||||
int socket_write_message(sd_netlink *nl, sd_netlink_message *m);
|
||||
int socket_writev_message(sd_netlink *nl, sd_netlink_message **m, size_t msgcount);
|
||||
int socket_read_message(sd_netlink *nl);
|
||||
|
||||
int netlink_add_match_internal(
|
||||
@ -169,3 +172,30 @@ int netlink_add_match_internal(
|
||||
/* Make sure callbacks don't destroy the netlink connection */
|
||||
#define NETLINK_DONT_DESTROY(nl) \
|
||||
_cleanup_(sd_netlink_unrefp) _unused_ sd_netlink *_dont_destroy_##nl = sd_netlink_ref(nl)
|
||||
|
||||
/* nfnl */
|
||||
/* TODO: to be exported later */
|
||||
int sd_nfnl_socket_open(sd_netlink **ret);
|
||||
int sd_nfnl_message_batch_begin(sd_netlink *nfnl, sd_netlink_message **ret);
|
||||
int sd_nfnl_message_batch_end(sd_netlink *nfnl, sd_netlink_message **ret);
|
||||
int sd_nfnl_nft_message_del_table(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table);
|
||||
int sd_nfnl_nft_message_new_table(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table);
|
||||
int sd_nfnl_nft_message_new_basechain(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *chain,
|
||||
const char *type, uint8_t hook, int prio);
|
||||
int sd_nfnl_nft_message_new_rule(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *chain);
|
||||
int sd_nfnl_nft_message_new_set(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name,
|
||||
uint32_t setid, uint32_t klen);
|
||||
int sd_nfnl_nft_message_new_setelems_begin(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name);
|
||||
int sd_nfnl_nft_message_del_setelems_begin(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name);
|
||||
int sd_nfnl_nft_message_add_setelem(sd_netlink_message *m,
|
||||
uint32_t num,
|
||||
const void *key, uint32_t klen,
|
||||
const void *data, uint32_t dlen);
|
||||
int sd_nfnl_nft_message_add_setelem_end(sd_netlink_message *m);
|
||||
|
@ -277,7 +277,7 @@ int sd_nfnl_nft_message_del_setelems_begin(
|
||||
return r;
|
||||
}
|
||||
|
||||
static int sd_nfnl_add_data(sd_netlink_message *m, uint16_t attr, const void *data, uint32_t dlen) {
|
||||
static int add_data(sd_netlink_message *m, uint16_t attr, const void *data, uint32_t dlen) {
|
||||
int r;
|
||||
|
||||
r = sd_netlink_message_open_container(m, attr);
|
||||
@ -305,12 +305,12 @@ int sd_nfnl_nft_message_add_setelem(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_nfnl_add_data(m, NFTA_SET_ELEM_KEY, key, klen);
|
||||
r = add_data(m, NFTA_SET_ELEM_KEY, key, klen);
|
||||
if (r < 0)
|
||||
goto cancel;
|
||||
|
||||
if (data) {
|
||||
r = sd_nfnl_add_data(m, NFTA_SET_ELEM_DATA, data, dlen);
|
||||
r = add_data(m, NFTA_SET_ELEM_DATA, data, dlen);
|
||||
if (r < 0)
|
||||
goto cancel;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "socket-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
_public_ int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -35,7 +35,7 @@ int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
_public_ int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -53,7 +53,7 @@ int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
_public_ int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -67,7 +67,7 @@ int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags) {
|
||||
_public_ int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -81,7 +81,7 @@ int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
_public_ int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -96,7 +96,7 @@ int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table) {
|
||||
_public_ int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -110,7 +110,7 @@ int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family) {
|
||||
_public_ int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -125,7 +125,7 @@ int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_type(sd_netlink_message *m, unsigned char *type) {
|
||||
_public_ int sd_rtnl_message_route_get_type(sd_netlink_message *m, unsigned char *type) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -140,7 +140,7 @@ int sd_rtnl_message_route_get_type(sd_netlink_message *m, unsigned char *type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type) {
|
||||
_public_ int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -154,7 +154,7 @@ int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol) {
|
||||
_public_ int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -169,7 +169,7 @@ int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *pro
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope) {
|
||||
_public_ int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -184,7 +184,7 @@ int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
_public_ int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -199,7 +199,7 @@ int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table) {
|
||||
_public_ int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -214,7 +214,7 @@ int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len) {
|
||||
_public_ int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -229,7 +229,7 @@ int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len) {
|
||||
_public_ int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -244,7 +244,7 @@ int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
_public_ int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int rtm_family,
|
||||
unsigned char rtm_protocol) {
|
||||
struct rtmsg *rtm;
|
||||
@ -270,7 +270,7 @@ int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
_public_ int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int nh_family,
|
||||
unsigned char nh_protocol) {
|
||||
struct nhmsg *nhm;
|
||||
@ -308,7 +308,7 @@ int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
_public_ int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -321,7 +321,7 @@ int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
_public_ int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -335,7 +335,7 @@ int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, uint8_t *family) {
|
||||
_public_ int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, uint8_t *family) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -349,7 +349,7 @@ int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, uint8_t *family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *protocol) {
|
||||
_public_ int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *protocol) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -363,7 +363,7 @@ int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *protoco
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
_public_ int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -376,7 +376,7 @@ int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state) {
|
||||
_public_ int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -389,7 +389,7 @@ int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags) {
|
||||
_public_ int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -402,7 +402,7 @@ int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state) {
|
||||
_public_ int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -415,7 +415,7 @@ int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family) {
|
||||
_public_ int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -430,7 +430,7 @@ int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *index) {
|
||||
_public_ int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *index) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -445,7 +445,13 @@ int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_neigh(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int index, int ndm_family) {
|
||||
_public_ int sd_rtnl_message_new_neigh(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int index,
|
||||
int ndm_family) {
|
||||
|
||||
struct ndmsg *ndm;
|
||||
int r;
|
||||
|
||||
@ -472,7 +478,7 @@ int sd_rtnl_message_new_neigh(sd_netlink *rtnl, sd_netlink_message **ret, uint16
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change) {
|
||||
_public_ int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -488,7 +494,7 @@ int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsign
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type) {
|
||||
_public_ int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -502,7 +508,7 @@ int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family) {
|
||||
_public_ int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -516,7 +522,7 @@ int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
_public_ int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int index) {
|
||||
struct ifinfomsg *ifi;
|
||||
int r;
|
||||
@ -541,7 +547,7 @@ int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
_public_ int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -559,7 +565,7 @@ int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char pref
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags) {
|
||||
_public_ int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -573,7 +579,7 @@ int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
_public_ int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -587,7 +593,7 @@ int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family) {
|
||||
_public_ int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -602,7 +608,7 @@ int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen) {
|
||||
_public_ int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -617,7 +623,7 @@ int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *pre
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope) {
|
||||
_public_ int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -632,7 +638,7 @@ int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags) {
|
||||
_public_ int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -647,7 +653,7 @@ int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
_public_ int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -662,9 +668,13 @@ int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_addr(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int index,
|
||||
_public_ int sd_rtnl_message_new_addr(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int index,
|
||||
int family) {
|
||||
|
||||
struct ifaddrmsg *ifa;
|
||||
int r;
|
||||
|
||||
@ -687,8 +697,11 @@ int sd_rtnl_message_new_addr(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_addr_update(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
int index, int family) {
|
||||
_public_ int sd_rtnl_message_new_addr_update(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
int index,
|
||||
int family) {
|
||||
int r;
|
||||
|
||||
r = sd_rtnl_message_new_addr(rtnl, ret, RTM_NEWADDR, index, family);
|
||||
@ -700,7 +713,7 @@ int sd_rtnl_message_new_addr_update(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
_public_ int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -715,7 +728,7 @@ int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
_public_ int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -730,7 +743,7 @@ int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type) {
|
||||
_public_ int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -745,7 +758,7 @@ int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
_public_ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(family, -EINVAL);
|
||||
|
||||
@ -804,7 +817,13 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_addrlabel(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex, int ifal_family) {
|
||||
_public_ int sd_rtnl_message_new_addrlabel(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int ifindex,
|
||||
int ifal_family) {
|
||||
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
int r;
|
||||
|
||||
@ -826,7 +845,7 @@ int sd_rtnl_message_new_addrlabel(sd_netlink *rtnl, sd_netlink_message **ret, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
_public_ int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -843,7 +862,7 @@ int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen) {
|
||||
_public_ int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen) {
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -857,7 +876,12 @@ int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_routing_policy_rule(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifal_family) {
|
||||
_public_ int sd_rtnl_message_new_routing_policy_rule(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int ifal_family) {
|
||||
|
||||
struct fib_rule_hdr *frh;
|
||||
int r;
|
||||
|
||||
@ -877,7 +901,7 @@ int sd_rtnl_message_new_routing_policy_rule(sd_netlink *rtnl, sd_netlink_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t tos) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t tos) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -891,7 +915,7 @@ int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -905,7 +929,7 @@ int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t table) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t table) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -919,7 +943,7 @@ int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *table) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *table) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -933,7 +957,7 @@ int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_t flags) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_t flags) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -946,7 +970,7 @@ int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *flags) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *flags) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -959,7 +983,7 @@ int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint8_t type) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint8_t type) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -973,7 +997,7 @@ int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *type) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *type) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -987,7 +1011,7 @@ int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1001,7 +1025,7 @@ int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1015,7 +1039,7 @@ int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1029,7 +1053,7 @@ int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
_public_ int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1043,7 +1067,7 @@ int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_traffic_control(
|
||||
_public_ int sd_rtnl_message_new_traffic_control(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
@ -1072,7 +1096,7 @@ int sd_rtnl_message_new_traffic_control(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_traffic_control_get_ifindex(sd_netlink_message *m, int *ret) {
|
||||
_public_ int sd_rtnl_message_traffic_control_get_ifindex(sd_netlink_message *m, int *ret) {
|
||||
struct tcmsg *tcm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1086,7 +1110,7 @@ int sd_rtnl_message_traffic_control_get_ifindex(sd_netlink_message *m, int *ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_traffic_control_get_handle(sd_netlink_message *m, uint32_t *ret) {
|
||||
_public_ int sd_rtnl_message_traffic_control_get_handle(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct tcmsg *tcm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1100,7 +1124,7 @@ int sd_rtnl_message_traffic_control_get_handle(sd_netlink_message *m, uint32_t *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *ret) {
|
||||
_public_ int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct tcmsg *tcm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1114,7 +1138,12 @@ int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_mdb(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int mdb_ifindex) {
|
||||
_public_ int sd_rtnl_message_new_mdb(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int mdb_ifindex) {
|
||||
|
||||
struct br_port_msg *bpm;
|
||||
int r;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int message_new_synthetic_error(sd_netlink *nl, int error, uint32_t serial, sd_n
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
|
||||
_public_ int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(m->protocol != NETLINK_ROUTE ||
|
||||
@ -129,7 +129,7 @@ int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
|
||||
|
||||
DEFINE_TRIVIAL_REF_FUNC(sd_netlink_message, sd_netlink_message);
|
||||
|
||||
sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m) {
|
||||
_public_ sd_netlink_message* sd_netlink_message_unref(sd_netlink_message *m) {
|
||||
while (m && --m->n_ref == 0) {
|
||||
unsigned i;
|
||||
|
||||
@ -146,7 +146,7 @@ sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type) {
|
||||
_public_ int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(type != 0, -EINVAL);
|
||||
|
||||
@ -155,7 +155,7 @@ int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags) {
|
||||
_public_ int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(flags != 0, -EINVAL);
|
||||
|
||||
@ -164,7 +164,7 @@ int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_is_broadcast(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_is_broadcast(sd_netlink_message *m) {
|
||||
assert_return(m, -EINVAL);
|
||||
|
||||
return m->multicast_group != 0;
|
||||
@ -231,7 +231,7 @@ static int message_attribute_has_type(sd_netlink_message *m, size_t *out_size, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data) {
|
||||
_public_ int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data) {
|
||||
size_t length, size;
|
||||
int r;
|
||||
|
||||
@ -257,7 +257,7 @@ int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, char * const *data) {
|
||||
_public_ int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, char * const *data) {
|
||||
size_t length, size;
|
||||
int r;
|
||||
|
||||
@ -285,7 +285,7 @@ int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type) {
|
||||
_public_ int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type) {
|
||||
size_t size;
|
||||
int r;
|
||||
|
||||
@ -303,7 +303,7 @@ int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data) {
|
||||
_public_ int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -320,7 +320,7 @@ int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uin
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data) {
|
||||
_public_ int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -337,7 +337,7 @@ int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, uint32_t data) {
|
||||
_public_ int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, uint32_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -354,7 +354,7 @@ int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_u64(sd_netlink_message *m, unsigned short type, uint64_t data) {
|
||||
_public_ int sd_netlink_message_append_u64(sd_netlink_message *m, unsigned short type, uint64_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -371,7 +371,7 @@ int sd_netlink_message_append_u64(sd_netlink_message *m, unsigned short type, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_s8(sd_netlink_message *m, unsigned short type, int8_t data) {
|
||||
_public_ int sd_netlink_message_append_s8(sd_netlink_message *m, unsigned short type, int8_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -388,7 +388,7 @@ int sd_netlink_message_append_s8(sd_netlink_message *m, unsigned short type, int
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_s16(sd_netlink_message *m, unsigned short type, int16_t data) {
|
||||
_public_ int sd_netlink_message_append_s16(sd_netlink_message *m, unsigned short type, int16_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -405,7 +405,7 @@ int sd_netlink_message_append_s16(sd_netlink_message *m, unsigned short type, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_s32(sd_netlink_message *m, unsigned short type, int32_t data) {
|
||||
_public_ int sd_netlink_message_append_s32(sd_netlink_message *m, unsigned short type, int32_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -422,7 +422,7 @@ int sd_netlink_message_append_s32(sd_netlink_message *m, unsigned short type, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_s64(sd_netlink_message *m, unsigned short type, int64_t data) {
|
||||
_public_ int sd_netlink_message_append_s64(sd_netlink_message *m, unsigned short type, int64_t data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -439,7 +439,7 @@ int sd_netlink_message_append_s64(sd_netlink_message *m, unsigned short type, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_data(sd_netlink_message *m, unsigned short type, const void *data, size_t len) {
|
||||
_public_ int sd_netlink_message_append_data(sd_netlink_message *m, unsigned short type, const void *data, size_t len) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -471,11 +471,11 @@ int netlink_message_append_in_addr_union(sd_netlink_message *m, unsigned short t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data) {
|
||||
_public_ int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data) {
|
||||
return netlink_message_append_in_addr_union(m, type, AF_INET, (const union in_addr_union *) data);
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data) {
|
||||
_public_ int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data) {
|
||||
return netlink_message_append_in_addr_union(m, type, AF_INET6, (const union in_addr_union *) data);
|
||||
}
|
||||
|
||||
@ -498,15 +498,15 @@ int netlink_message_append_sockaddr_union(sd_netlink_message *m, unsigned short
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_sockaddr_in(sd_netlink_message *m, unsigned short type, const struct sockaddr_in *data) {
|
||||
_public_ int sd_netlink_message_append_sockaddr_in(sd_netlink_message *m, unsigned short type, const struct sockaddr_in *data) {
|
||||
return netlink_message_append_sockaddr_union(m, type, (const union sockaddr_union *) data);
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_sockaddr_in6(sd_netlink_message *m, unsigned short type, const struct sockaddr_in6 *data) {
|
||||
_public_ int sd_netlink_message_append_sockaddr_in6(sd_netlink_message *m, unsigned short type, const struct sockaddr_in6 *data) {
|
||||
return netlink_message_append_sockaddr_union(m, type, (const union sockaddr_union *) data);
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data) {
|
||||
_public_ int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -543,7 +543,7 @@ int netlink_message_append_hw_addr(sd_netlink_message *m, unsigned short type, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info) {
|
||||
_public_ int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -561,7 +561,7 @@ int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type) {
|
||||
_public_ int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type) {
|
||||
size_t size;
|
||||
int r;
|
||||
|
||||
@ -610,7 +610,7 @@ int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned short type, const char *key) {
|
||||
_public_ int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned short type, const char *key) {
|
||||
const NLTypeSystemUnion *type_system_union;
|
||||
int r;
|
||||
|
||||
@ -645,7 +645,7 @@ int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned shor
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_close_container(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_close_container(sd_netlink_message *m) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(!m->sealed, -EPERM);
|
||||
assert_return(m->n_containers > 0, -EINVAL);
|
||||
@ -657,7 +657,7 @@ int sd_netlink_message_close_container(sd_netlink_message *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_open_array(sd_netlink_message *m, uint16_t type) {
|
||||
_public_ int sd_netlink_message_open_array(sd_netlink_message *m, uint16_t type) {
|
||||
int r;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -675,7 +675,7 @@ int sd_netlink_message_open_array(sd_netlink_message *m, uint16_t type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_cancel_array(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_cancel_array(sd_netlink_message *m) {
|
||||
uint32_t rta_len;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -731,7 +731,7 @@ static int netlink_message_read_internal(
|
||||
return RTA_PAYLOAD(rta);
|
||||
}
|
||||
|
||||
int sd_netlink_message_read(sd_netlink_message *m, unsigned short type, size_t size, void *data) {
|
||||
_public_ int sd_netlink_message_read(sd_netlink_message *m, unsigned short type, size_t size, void *data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -741,16 +741,16 @@ int sd_netlink_message_read(sd_netlink_message *m, unsigned short type, size_t s
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if ((size_t) r < size)
|
||||
return -EIO;
|
||||
if ((size_t) r > size)
|
||||
return -ENOBUFS;
|
||||
|
||||
if (data)
|
||||
memcpy(data, attr_data, size);
|
||||
memcpy(data, attr_data, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_data(sd_netlink_message *m, unsigned short type, size_t *ret_size, void **ret_data) {
|
||||
_public_ int sd_netlink_message_read_data(sd_netlink_message *m, unsigned short type, size_t *ret_size, void **ret_data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -776,7 +776,7 @@ int sd_netlink_message_read_data(sd_netlink_message *m, unsigned short type, siz
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_data_suffix0(sd_netlink_message *m, unsigned short type, size_t *ret_size, void **ret_data) {
|
||||
_public_ int sd_netlink_message_read_data_suffix0(sd_netlink_message *m, unsigned short type, size_t *ret_size, void **ret_data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -802,7 +802,7 @@ int sd_netlink_message_read_data_suffix0(sd_netlink_message *m, unsigned short t
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_string_strdup(sd_netlink_message *m, unsigned short type, char **data) {
|
||||
_public_ int sd_netlink_message_read_string_strdup(sd_netlink_message *m, unsigned short type, char **data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -829,7 +829,7 @@ int sd_netlink_message_read_string_strdup(sd_netlink_message *m, unsigned short
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data) {
|
||||
_public_ int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -852,7 +852,7 @@ int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data) {
|
||||
_public_ int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -875,7 +875,7 @@ int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data) {
|
||||
_public_ int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data) {
|
||||
void *attr_data;
|
||||
bool net_byteorder;
|
||||
int r;
|
||||
@ -903,7 +903,7 @@ int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data) {
|
||||
_public_ int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data) {
|
||||
void *attr_data;
|
||||
bool net_byteorder;
|
||||
int r;
|
||||
@ -931,7 +931,7 @@ int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short type, struct ether_addr *data) {
|
||||
_public_ int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short type, struct ether_addr *data) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -979,7 +979,7 @@ int netlink_message_read_hw_addr(sd_netlink_message *m, unsigned short type, str
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short type, struct ifa_cacheinfo *info) {
|
||||
_public_ int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short type, struct ifa_cacheinfo *info) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -1026,7 +1026,7 @@ int netlink_message_read_in_addr_union(sd_netlink_message *m, unsigned short typ
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type, struct in_addr *data) {
|
||||
_public_ int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type, struct in_addr *data) {
|
||||
union in_addr_union u;
|
||||
int r;
|
||||
|
||||
@ -1037,7 +1037,7 @@ int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type,
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type, struct in6_addr *data) {
|
||||
_public_ int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type, struct in6_addr *data) {
|
||||
union in_addr_union u;
|
||||
int r;
|
||||
|
||||
@ -1048,7 +1048,7 @@ int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type,
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_has_flag(sd_netlink_message *m, unsigned short type) {
|
||||
_public_ int sd_netlink_message_has_flag(sd_netlink_message *m, unsigned short type) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -1069,7 +1069,7 @@ int sd_netlink_message_has_flag(sd_netlink_message *m, unsigned short type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container_type, unsigned short type_id, char ***ret) {
|
||||
_public_ int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container_type, unsigned short type_id, char ***ret) {
|
||||
_cleanup_strv_free_ char **s = NULL;
|
||||
const NLTypeSystem *type_system;
|
||||
const NLType *nl_type;
|
||||
@ -1166,7 +1166,7 @@ static int netlink_container_parse(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short type_id) {
|
||||
_public_ int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short type_id) {
|
||||
const NLType *nl_type;
|
||||
const NLTypeSystem *type_system;
|
||||
void *container;
|
||||
@ -1261,7 +1261,7 @@ int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short typ
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_enter_array(sd_netlink_message *m, unsigned short type_id) {
|
||||
_public_ int sd_netlink_message_enter_array(sd_netlink_message *m, unsigned short type_id) {
|
||||
void *container;
|
||||
size_t size;
|
||||
int r;
|
||||
@ -1290,7 +1290,7 @@ int sd_netlink_message_enter_array(sd_netlink_message *m, unsigned short type_id
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_exit_container(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_exit_container(sd_netlink_message *m) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->sealed, -EINVAL);
|
||||
assert_return(m->n_containers > 0, -EINVAL);
|
||||
@ -1304,7 +1304,7 @@ int sd_netlink_message_exit_container(sd_netlink_message *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_get_max_attribute(sd_netlink_message *m, uint16_t *ret) {
|
||||
_public_ int sd_netlink_message_get_max_attribute(sd_netlink_message *m, uint16_t *ret) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->sealed, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
@ -1313,21 +1313,14 @@ int sd_netlink_message_get_max_attribute(sd_netlink_message *m, uint16_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t message_get_serial(sd_netlink_message *m) {
|
||||
assert(m);
|
||||
assert(m->hdr);
|
||||
|
||||
return m->hdr->nlmsg_seq;
|
||||
}
|
||||
|
||||
int sd_netlink_message_is_error(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_is_error(sd_netlink_message *m) {
|
||||
assert_return(m, 0);
|
||||
assert_return(m->hdr, 0);
|
||||
|
||||
return m->hdr->nlmsg_type == NLMSG_ERROR;
|
||||
}
|
||||
|
||||
int sd_netlink_message_get_errno(sd_netlink_message *m) {
|
||||
_public_ int sd_netlink_message_get_errno(sd_netlink_message *m) {
|
||||
struct nlmsgerr *err;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1362,7 +1355,7 @@ static int netlink_message_parse_error(sd_netlink_message *m) {
|
||||
NLMSG_PAYLOAD(m->hdr, hlen));
|
||||
}
|
||||
|
||||
int sd_netlink_message_rewind(sd_netlink_message *m, sd_netlink *nl) {
|
||||
_public_ int sd_netlink_message_rewind(sd_netlink_message *m, sd_netlink *nl) {
|
||||
size_t size;
|
||||
int r;
|
||||
|
||||
|
@ -17,16 +17,6 @@
|
||||
#include "socket-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int socket_open(int family) {
|
||||
int fd;
|
||||
|
||||
fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, family);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
return fd_move_above_stdio(fd);
|
||||
}
|
||||
|
||||
static int broadcast_groups_get(sd_netlink *nl) {
|
||||
_cleanup_free_ uint32_t *groups = NULL;
|
||||
socklen_t len = 0, old_len;
|
||||
@ -192,32 +182,6 @@ int socket_write_message(sd_netlink *nl, sd_netlink_message *m) {
|
||||
return k;
|
||||
}
|
||||
|
||||
int socket_writev_message(sd_netlink *nl, sd_netlink_message **m, size_t msgcount) {
|
||||
_cleanup_free_ struct iovec *iovs = NULL;
|
||||
ssize_t k;
|
||||
|
||||
assert(nl);
|
||||
assert(m);
|
||||
assert(msgcount > 0);
|
||||
|
||||
iovs = new(struct iovec, msgcount);
|
||||
if (!iovs)
|
||||
return -ENOMEM;
|
||||
|
||||
for (size_t i = 0; i < msgcount; i++) {
|
||||
assert(m[i]->hdr);
|
||||
assert(m[i]->hdr->nlmsg_len > 0);
|
||||
|
||||
iovs[i] = IOVEC_MAKE(m[i]->hdr, m[i]->hdr->nlmsg_len);
|
||||
}
|
||||
|
||||
k = writev(nl->fd, iovs, msgcount);
|
||||
if (k < 0)
|
||||
return -errno;
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
static int socket_recv_message(int fd, struct iovec *iov, uint32_t *ret_mcast_group, bool peek) {
|
||||
union sockaddr_union sender;
|
||||
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct nl_pktinfo))) control;
|
||||
|
@ -2,11 +2,14 @@
|
||||
|
||||
#include "sd-netlink.h"
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "io-util.h"
|
||||
#include "memory-util.h"
|
||||
#include "netlink-internal.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "process-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
|
||||
@ -628,3 +631,121 @@ int rtattr_read_nexthop(const struct rtnexthop *rtnh, size_t size, int family, O
|
||||
*ret = TAKE_PTR(set);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool netlink_pid_changed(sd_netlink *nl) {
|
||||
/* We don't support people creating an nl connection and
|
||||
* keeping it around over a fork(). Let's complain. */
|
||||
return ASSERT_PTR(nl)->original_pid != getpid_cached();
|
||||
}
|
||||
|
||||
static int socket_open(int family) {
|
||||
int fd;
|
||||
|
||||
fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, family);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
return fd_move_above_stdio(fd);
|
||||
}
|
||||
|
||||
int netlink_open_family(sd_netlink **ret, int family) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int r;
|
||||
|
||||
fd = socket_open(family);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
r = sd_netlink_open_fd(ret, fd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
TAKE_FD(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void netlink_seal_message(sd_netlink *nl, sd_netlink_message *m) {
|
||||
uint32_t picked;
|
||||
|
||||
assert(nl);
|
||||
assert(!netlink_pid_changed(nl));
|
||||
assert(m);
|
||||
assert(m->hdr);
|
||||
|
||||
/* Avoid collisions with outstanding requests */
|
||||
do {
|
||||
picked = nl->serial;
|
||||
|
||||
/* Don't use seq == 0, as that is used for broadcasts, so we would get confused by replies to
|
||||
such messages */
|
||||
nl->serial = nl->serial == UINT32_MAX ? 1 : nl->serial + 1;
|
||||
|
||||
} while (hashmap_contains(nl->reply_callbacks, UINT32_TO_PTR(picked)));
|
||||
|
||||
m->hdr->nlmsg_seq = picked;
|
||||
message_seal(m);
|
||||
}
|
||||
|
||||
static int socket_writev_message(sd_netlink *nl, sd_netlink_message **m, size_t msgcount) {
|
||||
_cleanup_free_ struct iovec *iovs = NULL;
|
||||
ssize_t k;
|
||||
|
||||
assert(nl);
|
||||
assert(m);
|
||||
assert(msgcount > 0);
|
||||
|
||||
iovs = new(struct iovec, msgcount);
|
||||
if (!iovs)
|
||||
return -ENOMEM;
|
||||
|
||||
for (size_t i = 0; i < msgcount; i++) {
|
||||
assert(m[i]->hdr);
|
||||
assert(m[i]->hdr->nlmsg_len > 0);
|
||||
|
||||
iovs[i] = IOVEC_MAKE(m[i]->hdr, m[i]->hdr->nlmsg_len);
|
||||
}
|
||||
|
||||
k = writev(nl->fd, iovs, msgcount);
|
||||
if (k < 0)
|
||||
return -errno;
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
int sd_netlink_sendv(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_message **messages,
|
||||
size_t msgcount,
|
||||
uint32_t **ret_serial) {
|
||||
|
||||
_cleanup_free_ uint32_t *serials = NULL;
|
||||
int r;
|
||||
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
assert_return(messages, -EINVAL);
|
||||
assert_return(msgcount > 0, -EINVAL);
|
||||
|
||||
if (ret_serial) {
|
||||
serials = new(uint32_t, msgcount);
|
||||
if (!serials)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < msgcount; i++) {
|
||||
assert_return(!messages[i]->sealed, -EPERM);
|
||||
|
||||
netlink_seal_message(nl, messages[i]);
|
||||
if (serials)
|
||||
serials[i] = message_get_serial(messages[i]);
|
||||
}
|
||||
|
||||
r = socket_writev_message(nl, messages, msgcount);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret_serial)
|
||||
*ret_serial = TAKE_PTR(serials);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -142,3 +142,8 @@ void rtattr_append_attribute_internal(struct rtattr *rta, unsigned short type, c
|
||||
int rtattr_append_attribute(struct rtattr **rta, unsigned short type, const void *data, size_t data_length);
|
||||
|
||||
int rtattr_read_nexthop(const struct rtnexthop *rtnh, size_t size, int family, OrderedSet **ret);
|
||||
|
||||
void netlink_seal_message(sd_netlink *nl, sd_netlink_message *m);
|
||||
|
||||
/* TODO: to be exported later */
|
||||
int sd_netlink_sendv(sd_netlink *nl, sd_netlink_message **messages, size_t msgcnt, uint32_t **ret_serial);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "netlink-genl.h"
|
||||
#include "netlink-internal.h"
|
||||
#include "netlink-slot.h"
|
||||
#include "netlink-util.h"
|
||||
#include "process-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
@ -68,7 +69,7 @@ static int netlink_new(sd_netlink **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_new_from_fd(sd_netlink **ret, int fd) {
|
||||
_public_ int sd_netlink_new_from_fd(sd_netlink **ret, int fd) {
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *nl = NULL;
|
||||
socklen_t addrlen;
|
||||
int r;
|
||||
@ -93,7 +94,7 @@ int sd_netlink_new_from_fd(sd_netlink **ret, int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_open_fd(sd_netlink **ret, int fd) {
|
||||
_public_ int sd_netlink_open_fd(sd_netlink **ret, int fd) {
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *nl = NULL;
|
||||
int r, protocol;
|
||||
|
||||
@ -131,40 +132,15 @@ int sd_netlink_open_fd(sd_netlink **ret, int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int netlink_open_family(sd_netlink **ret, int family) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int r;
|
||||
|
||||
fd = socket_open(family);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
r = sd_netlink_open_fd(ret, fd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
TAKE_FD(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_open(sd_netlink **ret) {
|
||||
_public_ int sd_netlink_open(sd_netlink **ret) {
|
||||
return netlink_open_family(ret, NETLINK_ROUTE);
|
||||
}
|
||||
|
||||
bool netlink_pid_changed(sd_netlink *nl) {
|
||||
assert(nl);
|
||||
|
||||
/* We don't support people creating an nl connection and
|
||||
* keeping it around over a fork(). Let's complain. */
|
||||
|
||||
return nl->original_pid != getpid_cached();
|
||||
}
|
||||
|
||||
int sd_netlink_inc_rcvbuf(sd_netlink *nl, size_t size) {
|
||||
_public_ int sd_netlink_increase_rxbuf(sd_netlink *nl, size_t size) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
return fd_inc_rcvbuf(nl->fd, size);
|
||||
return fd_increase_rxbuf(nl->fd, size);
|
||||
}
|
||||
|
||||
static sd_netlink *netlink_free(sd_netlink *nl) {
|
||||
@ -204,29 +180,7 @@ static sd_netlink *netlink_free(sd_netlink *nl) {
|
||||
|
||||
DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_netlink, sd_netlink, netlink_free);
|
||||
|
||||
static void netlink_seal_message(sd_netlink *nl, sd_netlink_message *m) {
|
||||
uint32_t picked;
|
||||
|
||||
assert(nl);
|
||||
assert(!netlink_pid_changed(nl));
|
||||
assert(m);
|
||||
assert(m->hdr);
|
||||
|
||||
/* Avoid collisions with outstanding requests */
|
||||
do {
|
||||
picked = nl->serial;
|
||||
|
||||
/* Don't use seq == 0, as that is used for broadcasts, so we would get confused by replies to
|
||||
such messages */
|
||||
nl->serial = nl->serial == UINT32_MAX ? 1 : nl->serial + 1;
|
||||
|
||||
} while (hashmap_contains(nl->reply_callbacks, UINT32_TO_PTR(picked)));
|
||||
|
||||
m->hdr->nlmsg_seq = picked;
|
||||
message_seal(m);
|
||||
}
|
||||
|
||||
int sd_netlink_send(
|
||||
_public_ int sd_netlink_send(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_message *message,
|
||||
uint32_t *serial) {
|
||||
@ -250,44 +204,6 @@ int sd_netlink_send(
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_netlink_sendv(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_message **messages,
|
||||
size_t msgcount,
|
||||
uint32_t **ret_serial) {
|
||||
|
||||
_cleanup_free_ uint32_t *serials = NULL;
|
||||
int r;
|
||||
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
assert_return(messages, -EINVAL);
|
||||
assert_return(msgcount > 0, -EINVAL);
|
||||
|
||||
if (ret_serial) {
|
||||
serials = new(uint32_t, msgcount);
|
||||
if (!serials)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < msgcount; i++) {
|
||||
assert_return(!messages[i]->sealed, -EPERM);
|
||||
|
||||
netlink_seal_message(nl, messages[i]);
|
||||
if (serials)
|
||||
serials[i] = message_get_serial(messages[i]);
|
||||
}
|
||||
|
||||
r = socket_writev_message(nl, messages, msgcount);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret_serial)
|
||||
*ret_serial = TAKE_PTR(serials);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int netlink_rqueue_make_room(sd_netlink *nl) {
|
||||
assert(nl);
|
||||
|
||||
@ -594,7 +510,7 @@ static int timeout_compare(const void *a, const void *b) {
|
||||
return CMP(x->timeout, y->timeout);
|
||||
}
|
||||
|
||||
int sd_netlink_call_async(
|
||||
_public_ int sd_netlink_call_async(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_slot **ret_slot,
|
||||
sd_netlink_message *m,
|
||||
@ -659,7 +575,7 @@ int sd_netlink_call_async(
|
||||
return k;
|
||||
}
|
||||
|
||||
int sd_netlink_read(
|
||||
_public_ int sd_netlink_read(
|
||||
sd_netlink *nl,
|
||||
uint32_t serial,
|
||||
uint64_t usec,
|
||||
@ -736,7 +652,7 @@ int sd_netlink_read(
|
||||
}
|
||||
}
|
||||
|
||||
int sd_netlink_call(
|
||||
_public_ int sd_netlink_call(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_message *message,
|
||||
uint64_t usec,
|
||||
@ -756,14 +672,14 @@ int sd_netlink_call(
|
||||
return sd_netlink_read(nl, serial, usec, ret);
|
||||
}
|
||||
|
||||
int sd_netlink_get_events(sd_netlink *nl) {
|
||||
_public_ int sd_netlink_get_events(sd_netlink *nl) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
return nl->rqueue_size == 0 ? POLLIN : 0;
|
||||
}
|
||||
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
|
||||
_public_ int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
|
||||
struct reply_callback *c;
|
||||
|
||||
assert_return(nl, -EINVAL);
|
||||
@ -846,7 +762,7 @@ static int prepare_callback(sd_event_source *s, void *userdata) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_netlink_attach_event(sd_netlink *nl, sd_event *event, int64_t priority) {
|
||||
_public_ int sd_netlink_attach_event(sd_netlink *nl, sd_event *event, int64_t priority) {
|
||||
int r;
|
||||
|
||||
assert_return(nl, -EINVAL);
|
||||
@ -898,7 +814,7 @@ fail:
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_detach_event(sd_netlink *nl) {
|
||||
_public_ int sd_netlink_detach_event(sd_netlink *nl) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(nl->event, -ENXIO);
|
||||
|
||||
@ -961,7 +877,7 @@ int netlink_add_match_internal(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_add_match(
|
||||
_public_ int sd_netlink_add_match(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_slot **ret_slot,
|
||||
uint16_t type,
|
||||
@ -1031,7 +947,7 @@ int sd_netlink_add_match(
|
||||
destroy_callback, userdata, description);
|
||||
}
|
||||
|
||||
int sd_netlink_attach_filter(sd_netlink *nl, size_t len, struct sock_filter *filter) {
|
||||
_public_ int sd_netlink_attach_filter(sd_netlink *nl, size_t len, struct sock_filter *filter) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(len == 0 || filter, -EINVAL);
|
||||
|
||||
|
@ -506,9 +506,9 @@ _public_ int sd_resolve_new(sd_resolve **ret) {
|
||||
resolve->fds[i] = fd_move_above_stdio(resolve->fds[i]);
|
||||
|
||||
(void) fd_inc_sndbuf(resolve->fds[REQUEST_SEND_FD], QUERIES_MAX * BUFSIZE);
|
||||
(void) fd_inc_rcvbuf(resolve->fds[REQUEST_RECV_FD], QUERIES_MAX * BUFSIZE);
|
||||
(void) fd_increase_rxbuf(resolve->fds[REQUEST_RECV_FD], QUERIES_MAX * BUFSIZE);
|
||||
(void) fd_inc_sndbuf(resolve->fds[RESPONSE_SEND_FD], QUERIES_MAX * BUFSIZE);
|
||||
(void) fd_inc_rcvbuf(resolve->fds[RESPONSE_RECV_FD], QUERIES_MAX * BUFSIZE);
|
||||
(void) fd_increase_rxbuf(resolve->fds[RESPONSE_RECV_FD], QUERIES_MAX * BUFSIZE);
|
||||
|
||||
(void) fd_nonblock(resolve->fds[RESPONSE_RECV_FD], true);
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-utf8.h"
|
||||
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
|
||||
_public_ const char *sd_utf8_is_valid(const char *s) {
|
||||
assert_return(s, NULL);
|
||||
|
||||
return utf8_is_valid(s);
|
||||
}
|
||||
|
||||
_public_ const char *sd_ascii_is_valid(const char *s) {
|
||||
assert_return(s, NULL);
|
||||
|
||||
return ascii_is_valid(s);
|
||||
}
|
@ -405,7 +405,7 @@ static int peer_resolve_endpoint(WireguardPeer *peer) {
|
||||
/* Not necessary to resolve the endpoint. */
|
||||
return 0;
|
||||
|
||||
if (event_source_is_enabled(peer->resolve_retry_event_source) > 0)
|
||||
if (sd_event_source_get_enabled(peer->resolve_retry_event_source, NULL) > 0)
|
||||
/* Timer event source is enabled. The endpoint will be resolved later. */
|
||||
return 0;
|
||||
|
||||
|
@ -692,7 +692,7 @@ static void acquire_wlan_link_info(LinkInfo *link) {
|
||||
return;
|
||||
}
|
||||
|
||||
(void) sd_netlink_inc_rcvbuf(genl, RCVBUF_SIZE);
|
||||
(void) sd_netlink_increase_rxbuf(genl, RCVBUF_SIZE);
|
||||
|
||||
r = wifi_get_interface(genl, link->ifindex, &link->wlan_iftype, &link->ssid);
|
||||
if (r < 0)
|
||||
|
@ -226,7 +226,7 @@ static int manager_connect_genl(Manager *m) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_netlink_inc_rcvbuf(m->genl, RCVBUF_SIZE);
|
||||
r = sd_netlink_increase_rxbuf(m->genl, RCVBUF_SIZE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to increase receive buffer size for general netlink socket, ignoring: %m");
|
||||
|
||||
@ -298,7 +298,7 @@ static int manager_connect_rtnl(Manager *m) {
|
||||
* case systemd sets the receive buffer size for us, and the value in the .socket unit
|
||||
* should take full effect. */
|
||||
if (fd < 0) {
|
||||
r = sd_netlink_inc_rcvbuf(m->rtnl, RCVBUF_SIZE);
|
||||
r = sd_netlink_increase_rxbuf(m->rtnl, RCVBUF_SIZE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to increase receive buffer size for rtnl socket, ignoring: %m");
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ int bus_map_strv_sort(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus
|
||||
char ***p = userdata;
|
||||
int r;
|
||||
|
||||
r = bus_message_read_strv_extend(m, &l);
|
||||
r = sd_bus_message_read_strv_extend(m, &l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -75,7 +75,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, unsigne
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
char ***p = userdata;
|
||||
|
||||
r = bus_message_read_strv_extend(m, &l);
|
||||
r = sd_bus_message_read_strv_extend(m, &l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -1,5 +1,19 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "mempool.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
const bool mempool_use_allowed = true;
|
||||
#include "env-util.h"
|
||||
#include "mempool.h"
|
||||
#include "process-util.h"
|
||||
|
||||
bool mempool_enabled(void) {
|
||||
static int cache = -1;
|
||||
|
||||
if (!is_main_thread())
|
||||
return false;
|
||||
|
||||
if (cache < 0)
|
||||
cache = getenv_bool("SYSTEMD_MEMPOOL") != 0;
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#include "sd-device.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "blkid-util.h"
|
||||
@ -13,7 +14,6 @@
|
||||
#include "errno-util.h"
|
||||
#include "find-esp.h"
|
||||
#include "gpt.h"
|
||||
#include "id128-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "stat-util.h"
|
||||
@ -85,7 +85,7 @@ static int verify_esp_blkid(
|
||||
r = blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, NULL);
|
||||
if (r != 0)
|
||||
return log_error_errno(errno ?: EIO, "Failed to probe partition type UUID of \"%s\": %m", node);
|
||||
if (id128_equal_string(v, GPT_ESP) <= 0)
|
||||
if (sd_id128_string_equal(v, GPT_ESP) <= 0)
|
||||
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
|
||||
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
|
||||
"File system \"%s\" has wrong type for an EFI System Partition (ESP).", node);
|
||||
@ -178,7 +178,7 @@ static int verify_esp_udev(
|
||||
r = sd_device_get_property_value(d, "ID_PART_ENTRY_TYPE", &v);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get device property: %m");
|
||||
if (id128_equal_string(v, GPT_ESP) <= 0)
|
||||
if (sd_id128_string_equal(v, GPT_ESP) <= 0)
|
||||
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
|
||||
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
|
||||
"File system \"%s\" has wrong type for an EFI System Partition (ESP).", node);
|
||||
@ -510,7 +510,7 @@ static int verify_xbootldr_blkid(
|
||||
r = blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, NULL);
|
||||
if (r != 0)
|
||||
return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "%s: Failed to probe PART_ENTRY_TYPE: %m", node);
|
||||
if (id128_equal_string(v, GPT_XBOOTLDR) <= 0)
|
||||
if (sd_id128_string_equal(v, GPT_XBOOTLDR) <= 0)
|
||||
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
|
||||
searching ? SYNTHETIC_ERRNO(EADDRNOTAVAIL) : SYNTHETIC_ERRNO(ENODEV),
|
||||
"%s: Partitition has wrong PART_ENTRY_TYPE=%s for XBOOTLDR partition.", node, v);
|
||||
@ -576,7 +576,7 @@ static int verify_xbootldr_udev(
|
||||
if (r < 0)
|
||||
return log_device_error_errno(d, r, "Failed to query ID_PART_ENTRY_TYPE: %m");
|
||||
|
||||
r = id128_equal_string(v, GPT_XBOOTLDR);
|
||||
r = sd_id128_string_equal(v, GPT_XBOOTLDR);
|
||||
if (r < 0)
|
||||
return log_device_error_errno(d, r, "Failed to parse ID_PART_ENTRY_TYPE=%s: %m", v);
|
||||
if (r == 0)
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "firewall-util-private.h"
|
||||
#include "in-addr-util.h"
|
||||
#include "macro.h"
|
||||
#include "netlink-internal.h"
|
||||
#include "netlink-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "time-util.h"
|
||||
|
||||
|
@ -12,6 +12,7 @@ _systemd_headers = [
|
||||
'sd-journal.h',
|
||||
'sd-login.h',
|
||||
'sd-messages.h',
|
||||
'sd-netlink.h',
|
||||
'sd-path.h',
|
||||
]
|
||||
|
||||
@ -32,11 +33,9 @@ _not_installed_headers = [
|
||||
'sd-lldp-tx.h',
|
||||
'sd-lldp.h',
|
||||
'sd-ndisc.h',
|
||||
'sd-netlink.h',
|
||||
'sd-network.h',
|
||||
'sd-radv.h',
|
||||
'sd-resolve.h',
|
||||
'sd-utf8.h',
|
||||
]
|
||||
|
||||
install_headers(
|
||||
|
@ -102,7 +102,8 @@ __extension__ enum {
|
||||
|
||||
__extension__ enum {
|
||||
SD_BUS_MESSAGE_DUMP_WITH_HEADER = 1ULL << 0,
|
||||
SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1
|
||||
SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1,
|
||||
_SD_BUS_MESSAGE_DUMP_KNOWN_FLAGS = SD_BUS_MESSAGE_DUMP_WITH_HEADER | SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY
|
||||
};
|
||||
|
||||
/* Callbacks */
|
||||
@ -330,6 +331,7 @@ int sd_bus_message_readv(sd_bus_message *m, const char *types, va_list ap);
|
||||
int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
|
||||
int sd_bus_message_read_array(sd_bus_message *m, char type, const void **ptr, size_t *size);
|
||||
int sd_bus_message_read_strv(sd_bus_message *m, char ***l); /* free the result! */
|
||||
int sd_bus_message_read_strv_extend(sd_bus_message *m, char ***l);
|
||||
int sd_bus_message_skip(sd_bus_message *m, const char *types);
|
||||
int sd_bus_message_enter_container(sd_bus_message *m, char type, const char *contents);
|
||||
int sd_bus_message_exit_container(sd_bus_message *m);
|
||||
@ -445,6 +447,8 @@ int sd_bus_creds_get_description(sd_bus_creds *c, const char **name);
|
||||
void sd_bus_error_free(sd_bus_error *e);
|
||||
int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message);
|
||||
int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *format, ...) _sd_printf_(3, 4);
|
||||
int sd_bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) _sd_printf_(3,0);
|
||||
|
||||
int sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message);
|
||||
int sd_bus_error_set_errno(sd_bus_error *e, int error);
|
||||
int sd_bus_error_set_errnof(sd_bus_error *e, int error, const char *format, ...) _sd_printf_(3, 4);
|
||||
|
@ -119,6 +119,8 @@ _sd_pure_ static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
|
||||
return memcmp(&a, &b, 16) == 0;
|
||||
}
|
||||
|
||||
int sd_id128_string_equal(const char *s, sd_id128_t id);
|
||||
|
||||
_sd_pure_ static __inline__ int sd_id128_is_null(sd_id128_t a) {
|
||||
return a.qwords[0] == 0 && a.qwords[1] == 0;
|
||||
}
|
||||
|
@ -43,13 +43,12 @@ typedef _sd_destroy_t sd_netlink_destroy_t;
|
||||
int sd_netlink_new_from_fd(sd_netlink **nl, int fd);
|
||||
int sd_netlink_open(sd_netlink **nl);
|
||||
int sd_netlink_open_fd(sd_netlink **nl, int fd);
|
||||
int sd_netlink_inc_rcvbuf(sd_netlink *nl, const size_t size);
|
||||
int sd_netlink_increase_rxbuf(sd_netlink *nl, const size_t size);
|
||||
|
||||
sd_netlink *sd_netlink_ref(sd_netlink *nl);
|
||||
sd_netlink *sd_netlink_unref(sd_netlink *nl);
|
||||
|
||||
int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial);
|
||||
int sd_netlink_sendv(sd_netlink *nl, sd_netlink_message **messages, size_t msgcnt, uint32_t **ret_serial);
|
||||
int sd_netlink_call_async(sd_netlink *nl, sd_netlink_slot **ret_slot, sd_netlink_message *message,
|
||||
sd_netlink_message_handler_t callback, sd_netlink_destroy_t destoy_callback,
|
||||
void *userdata, uint64_t usec, const char *description);
|
||||
@ -210,32 +209,6 @@ int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *
|
||||
|
||||
int sd_rtnl_message_new_mdb(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int mdb_ifindex);
|
||||
|
||||
/* nfnl */
|
||||
int sd_nfnl_socket_open(sd_netlink **ret);
|
||||
int sd_nfnl_message_batch_begin(sd_netlink *nfnl, sd_netlink_message **ret);
|
||||
int sd_nfnl_message_batch_end(sd_netlink *nfnl, sd_netlink_message **ret);
|
||||
int sd_nfnl_nft_message_del_table(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table);
|
||||
int sd_nfnl_nft_message_new_table(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table);
|
||||
int sd_nfnl_nft_message_new_basechain(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *chain,
|
||||
const char *type, uint8_t hook, int prio);
|
||||
int sd_nfnl_nft_message_new_rule(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *chain);
|
||||
int sd_nfnl_nft_message_new_set(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name,
|
||||
uint32_t setid, uint32_t klen);
|
||||
int sd_nfnl_nft_message_new_setelems_begin(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name);
|
||||
int sd_nfnl_nft_message_del_setelems_begin(sd_netlink *nfnl, sd_netlink_message **ret,
|
||||
int family, const char *table, const char *set_name);
|
||||
int sd_nfnl_nft_message_add_setelem(sd_netlink_message *m,
|
||||
uint32_t num,
|
||||
const void *key, uint32_t klen,
|
||||
const void *data, uint32_t dlen);
|
||||
int sd_nfnl_nft_message_add_setelem_end(sd_netlink_message *m);
|
||||
|
||||
/* genl */
|
||||
int sd_genl_socket_open(sd_netlink **ret);
|
||||
int sd_genl_message_new(sd_netlink *genl, const char *family_name, uint8_t cmd, sd_netlink_message **ret);
|
||||
|
@ -11,21 +11,26 @@ print('''
|
||||
/* We want to check deprecated symbols too, without complaining */
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
const void* symbols[] = {''')
|
||||
const struct {
|
||||
const char *name;
|
||||
const void *symbol;
|
||||
} symbols[] = {''')
|
||||
|
||||
count = 0
|
||||
for line in open(sys.argv[1]):
|
||||
match = re.search('^ +([a-zA-Z0-9_]+);', line)
|
||||
if match:
|
||||
s = match.group(1)
|
||||
if s == 'sd_bus_object_vtable_format':
|
||||
print(' &{},'.format(s))
|
||||
print(f' {{"{s}", &{s}}},')
|
||||
else:
|
||||
print(' {},'.format(s))
|
||||
print(f' {{"{s}", {s}}},')
|
||||
count += 1
|
||||
|
||||
print('''};
|
||||
print(f'''}};
|
||||
|
||||
int main(void) {
|
||||
for (size_t i = 0; i < sizeof(symbols)/sizeof(void*); i++)
|
||||
printf("%p\\n", symbols[i]);
|
||||
int main(void) {{
|
||||
for (size_t i = 0; i < {count}; i++)
|
||||
printf("%p: %s\\n", symbols[i].symbol, symbols[i].name);
|
||||
return 0;
|
||||
}''')
|
||||
}}''')
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "mempool.h"
|
||||
#include "process-util.h"
|
||||
#include "set.h"
|
||||
#include "tests.h"
|
||||
@ -15,6 +16,9 @@ static void* thread(void *p) {
|
||||
assert_se(*s);
|
||||
|
||||
assert_se(!is_main_thread());
|
||||
assert_se(mempool_enabled);
|
||||
assert_se(!mempool_enabled());
|
||||
|
||||
assert_se(set_size(*s) == NUM);
|
||||
*s = set_free(*s);
|
||||
|
||||
@ -29,7 +33,10 @@ static void test_one(const char *val) {
|
||||
|
||||
log_info("Testing with SYSTEMD_MEMPOOL=%s", val);
|
||||
assert_se(setenv("SYSTEMD_MEMPOOL", val, true) == 0);
|
||||
|
||||
assert_se(is_main_thread());
|
||||
assert_se(mempool_enabled); /* It is a weak symbol, but we expect it to be available */
|
||||
assert_se(!mempool_enabled());
|
||||
|
||||
assert_se(s = set_new(NULL));
|
||||
for (i = 0; i < NUM; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user