]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/sysctl-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 #include "stdio-util.h"
11 char *sysctl_normalize(char *s
);
12 int sysctl_read(const char *property
, char **value
);
13 int sysctl_write(const char *property
, const char *value
);
15 int sysctl_read_ip_property(int af
, const char *ifname
, const char *property
, char **ret
);
16 int sysctl_write_ip_property(int af
, const char *ifname
, const char *property
, const char *value
);
17 static inline int sysctl_write_ip_property_boolean(int af
, const char *ifname
, const char *property
, bool value
) {
18 return sysctl_write_ip_property(af
, ifname
, property
, one_zero(value
));
21 #define DEFINE_SYSCTL_WRITE_IP_PROPERTY(name, type, format) \
22 static inline int sysctl_write_ip_property_##name(int af, const char *ifname, const char *property, type value) { \
23 char buf[DECIMAL_STR_MAX(type)]; \
24 xsprintf(buf, format, value); \
25 return sysctl_write_ip_property(af, ifname, property, buf); \
28 DEFINE_SYSCTL_WRITE_IP_PROPERTY(int, int, "%i");
29 DEFINE_SYSCTL_WRITE_IP_PROPERTY(uint32
, uint32_t, "%" PRIu32
);