mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
sysctl-util: introduce sysctl_read_ip_property_int() and _uint32()
Currently not used, but will be used later.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
@@ -193,3 +194,29 @@ int sysctl_read_ip_property(int af, const char *ifname, const char *property, ch
|
||||
|
||||
return sysctl_read(p, ret);
|
||||
}
|
||||
|
||||
int sysctl_read_ip_property_int(int af, const char *ifname, const char *property, int *ret) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = sysctl_read_ip_property(af, ifname, property, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return safe_atoi(s, ret);
|
||||
}
|
||||
|
||||
int sysctl_read_ip_property_uint32(int af, const char *ifname, const char *property, uint32_t *ret) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = sysctl_read_ip_property(af, ifname, property, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return safe_atou32(s, ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user