summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-24 13:10:12 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-10-15 01:57:19 +0900
commit31e78d1042a39709e54215a511a8d5f47b23a72b (patch)
tree044b99e5074aa57c5b500389ea617011c737972e
parent2be081ffd6228a0c0f9321c9ce722348c2ef4abd (diff)
downloadsystemd-31e78d1042a39709e54215a511a8d5f47b23a72b.tar.gz
sd-netlink: introduce sd_genl_message_get_family()
-rw-r--r--src/libsystemd/sd-netlink/generic-netlink.c16
-rw-r--r--src/systemd/sd-netlink.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd/sd-netlink/generic-netlink.c b/src/libsystemd/sd-netlink/generic-netlink.c
index cfd9b4973d..58dda0323d 100644
--- a/src/libsystemd/sd-netlink/generic-netlink.c
+++ b/src/libsystemd/sd-netlink/generic-netlink.c
@@ -158,3 +158,19 @@ int nlmsg_type_to_genl_family(sd_netlink *nl, uint16_t type, sd_genl_family *ret
return 0;
}
+
+int sd_genl_message_get_family(sd_netlink *nl, sd_netlink_message *m, sd_genl_family *family) {
+ uint16_t type;
+ int r;
+
+ assert_return(m, -EINVAL);
+ assert_return(nl, -EINVAL);
+ assert_return(nl->protocol == NETLINK_GENERIC, -EINVAL);
+ assert_return(family, -EINVAL);
+
+ r = sd_netlink_message_get_type(m, &type);
+ if (r < 0)
+ return r;
+
+ return nlmsg_type_to_genl_family(nl, type, family);
+}
diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h
index 283c2dd35b..43a15a98c0 100644
--- a/src/systemd/sd-netlink.h
+++ b/src/systemd/sd-netlink.h
@@ -204,6 +204,7 @@ int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, unsigne
/* genl */
int sd_genl_socket_open(sd_netlink **nl);
int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_netlink_message **m);
+int sd_genl_message_get_family(sd_netlink *nl, sd_netlink_message *m, sd_genl_family *family);
/* slot */
sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *nl);