chiark / gitweb /
sd-rtnl: add sd_rtnl_message_route_get_family
authorTom Gundersen <teg@jklm.no>
Mon, 1 Dec 2014 23:58:17 +0000 (00:58 +0100)
committerTom Gundersen <teg@jklm.no>
Mon, 1 Dec 2014 23:58:17 +0000 (00:58 +0100)
src/libsystemd/sd-rtnl/rtnl-message.c
src/systemd/sd-rtnl.h

index 44ad303..22ee4c5 100644 (file)
@@ -128,6 +128,21 @@ int sd_rtnl_message_route_set_scope(sd_rtnl_message *m, unsigned char scope) {
         return 0;
 }
 
+int sd_rtnl_message_route_get_family(sd_rtnl_message *m, int *family) {
+        struct rtmsg *rtm;
+
+        assert_return(m, -EINVAL);
+        assert_return(m->hdr, -EINVAL);
+        assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
+        assert_return(family, -EINVAL);
+
+        rtm = NLMSG_DATA(m->hdr);
+
+        *family = rtm->rtm_family;
+
+        return 0;
+}
+
 int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
                               uint16_t nlmsg_type, int rtm_family,
                               unsigned char rtm_protocol) {
index 95bdb1d..0d17b16 100644 (file)
@@ -101,6 +101,7 @@ int sd_rtnl_message_link_get_type(sd_rtnl_message *m, unsigned *type);
 
 int sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char prefixlen);
 int sd_rtnl_message_route_set_scope(sd_rtnl_message *m, unsigned char scope);
+int sd_rtnl_message_route_get_family(sd_rtnl_message *m, int *family);
 
 int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const char *data);
 int sd_rtnl_message_append_u8(sd_rtnl_message *m, unsigned short type, uint8_t data);