| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
|
| 5 |
#include "basic-forward.h" |
| 6 |
#include "stdio-util.h" |
| 7 |
|
| 8 |
char* sysctl_normalize(char *s); |
| 9 |
int sysctl_read(const char *property, char **ret); |
| 10 |
int sysctl_write_full(const char *property, const char *value, Hashmap **shadow); |
| 11 |
int sysctl_writef(const char *property, const char *format, ...) _printf_(2, 3); |
| 12 |
static inline int sysctl_write(const char *property, const char *value) { |
| 13 |
return sysctl_write_full(property, value, NULL); |
| 14 |
} |
| 15 |
|
| 16 |
int sysctl_read_ip_property(int af, const char *ifname, const char *property, char **ret); |
| 17 |
int sysctl_read_ip_property_int(int af, const char *ifname, const char *property, int *ret); |
| 18 |
int sysctl_read_ip_property_uint32(int af, const char *ifname, const char *property, uint32_t *ret); |
| 19 |
int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow); |
| 20 |
int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow); |
| 21 |
|
| 22 |
int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow); |
| 23 |
int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow); |
| 24 |
|
| 25 |
#define DEFINE_SYSCTL_WRITE_IP_PROPERTY(name, type, format) \ |
| 26 |
static inline int sysctl_write_ip_property_##name(int af, const char *ifname, const char *property, type value, Hashmap **shadow) { \ |
| 27 |
char buf[DECIMAL_STR_MAX(type)]; \ |
| 28 |
xsprintf(buf, format, value); \ |
| 29 |
return sysctl_write_ip_property(af, ifname, property, buf, shadow); \ |
| 30 |
} |
| 31 |
|
| 32 |
DEFINE_SYSCTL_WRITE_IP_PROPERTY(int, int, "%i"); |
| 33 |
DEFINE_SYSCTL_WRITE_IP_PROPERTY(uint32, uint32_t, "%" PRIu32); |