diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-21 15:55:57 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-22 18:01:45 +0100 |
commit | 5a72317435a39f23520b42731e53bd13d20f489e (patch) | |
tree | 482f11a74e177478689550b46fdd948b27f6e845 /src/network/networkd-address.c | |
parent | 52433f6b65eccd1c54606dde999610640f3458ac (diff) |
sd-rtnl: simplify sd_rtnl_message_addr_new()
Split out into sd_rtnl_message_addr_set_{prefixlen,flags,scope}().
Diffstat (limited to 'src/network/networkd-address.c')
-rw-r--r-- | src/network/networkd-address.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 7d06cf8877..3f787948f9 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -101,14 +101,19 @@ int address_drop(Address *address, Link *link, assert(link->manager); assert(link->manager->rtnl); - r = sd_rtnl_message_addr_new(RTM_DELADDR, link->ifindex, - address->family, address->prefixlen, 0, 0, &req); + r = sd_rtnl_message_addr_new(RTM_DELADDR, link->ifindex, address->family, &req); if (r < 0) { log_error("Could not allocate RTM_DELADDR message: %s", strerror(-r)); return r; } + r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); + if (r < 0) { + log_error("Could not set prefixlen: %s", strerror(-r)); + return r; + } + if (address->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); else if (address->family == AF_INET6) @@ -141,14 +146,31 @@ int address_configure(Address *address, Link *link, assert(link->manager->rtnl); r = sd_rtnl_message_addr_new(RTM_NEWADDR, link->ifindex, - address->family, address->prefixlen, - IFA_F_PERMANENT, RT_SCOPE_UNIVERSE, &req); + address->family, &req); if (r < 0) { log_error("Could not allocate RTM_NEWADDR message: %s", strerror(-r)); return r; } + r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); + if (r < 0) { + log_error("Could not set prefixlen: %s", strerror(-r)); + return r; + } + + r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT); + if (r < 0) { + log_error("Could not set flags: %s", strerror(-r)); + return r; + } + + r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_UNIVERSE); + if (r < 0) { + log_error("Could not set scope: %s", strerror(-r)); + return r; + } + if (address->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); else if (address->family == AF_INET6) |