diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-08 12:37:05 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-08 17:43:39 +0100 |
commit | 4af7b60d428765c2d2c66c46f416f6dae55e9ddb (patch) | |
tree | ed1f20a91b4c4c5a87d73fbba4eb2f9c875ec65c /src/libsystemd/sd-rtnl/test-rtnl.c | |
parent | 02f500532e4823584aae43cbe762914b4a0c0254 (diff) |
sd-rtnl: extend type system to allow address-family to decide the union members
So far we only supported selecting them by sibling attributes.
(This stuff is all a bit crazy, but there seems to be no other way...)
Diffstat (limited to 'src/libsystemd/sd-rtnl/test-rtnl.c')
-rw-r--r-- | src/libsystemd/sd-rtnl/test-rtnl.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c index ed60b3cb45..02f7a8e38a 100644 --- a/src/libsystemd/sd-rtnl/test-rtnl.c +++ b/src/libsystemd/sd-rtnl/test-rtnl.c @@ -31,8 +31,26 @@ #include "missing.h" #include "rtnl-internal.h" +static void test_message_link_bridge(sd_rtnl *rtnl) { + _cleanup_rtnl_message_unref_ sd_rtnl_message *message = NULL; + uint32_t cost; + + assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_NEWLINK, 1) >= 0); + assert_se(sd_rtnl_message_link_set_family(message, PF_BRIDGE) >= 0); + assert_se(sd_rtnl_message_open_container(message, IFLA_PROTINFO) >= 0); + assert_se(sd_rtnl_message_append_u32(message, IFLA_BRPORT_COST, 10) >= 0); + assert_se(sd_rtnl_message_close_container(message) >= 0); + + assert_se(sd_rtnl_message_rewind(message) >= 0); + + assert_se(sd_rtnl_message_enter_container(message, IFLA_PROTINFO) >= 0); + assert_se(sd_rtnl_message_read_u32(message, IFLA_BRPORT_COST, &cost) >= 0); + assert_se(cost == 10); + assert_se(sd_rtnl_message_exit_container(message) >= 0); +} + static void test_link_configure(sd_rtnl *rtnl, int ifindex) { - _cleanup_rtnl_message_unref_ sd_rtnl_message *message; + _cleanup_rtnl_message_unref_ sd_rtnl_message *message = NULL; const char *mac = "98:fe:94:3f:c6:18", *name = "test"; char buffer[ETHER_ADDR_TO_STRING_MAX]; unsigned int mtu = 1450, mtu_out; @@ -394,6 +412,8 @@ int main(void) { test_get_addresses(rtnl); + test_message_link_bridge(rtnl); + assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0); assert_se(m); |