summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c15
-rw-r--r--src/systemd/sd-rtnl.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 9043c675ac..d611207dea 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -290,6 +290,21 @@ int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, unsigned char *family) {
return 0;
}
+int sd_rtnl_message_addr_get_prefixlen(sd_rtnl_message *m, unsigned char *prefixlen) {
+ struct ifaddrmsg *ifa;
+
+ assert_return(m, -EINVAL);
+ assert_return(m->hdr, -EINVAL);
+ assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
+ assert_return(prefixlen, -EINVAL);
+
+ ifa = NLMSG_DATA(m->hdr);
+
+ *prefixlen = ifa->ifa_prefixlen;
+
+ return 0;
+}
+
int sd_rtnl_message_addr_get_scope(sd_rtnl_message *m, unsigned char *scope) {
struct ifaddrmsg *ifa;
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index 93f5ab9b6c..9059ed4ddf 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -86,6 +86,7 @@ int sd_rtnl_message_addr_set_prefixlen(sd_rtnl_message *m, unsigned char prefixl
int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope);
int sd_rtnl_message_addr_set_flags(sd_rtnl_message *m, unsigned char flags);
int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, unsigned char *family);
+int sd_rtnl_message_addr_get_prefixlen(sd_rtnl_message *m, unsigned char *prefixlen);
int sd_rtnl_message_addr_get_scope(sd_rtnl_message *m, unsigned char *scope);
int sd_rtnl_message_addr_get_flags(sd_rtnl_message *m, unsigned char *flags);
int sd_rtnl_message_addr_get_ifindex(sd_rtnl_message *m, int *ifindex);