diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-26 21:52:36 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-27 10:12:27 +0100 |
commit | 5cfa2c3dc09ffed16e3ad249e893911e372d3ed0 (patch) | |
tree | 11a7f2aec6fba69fbdfdfdf51e189523d95ecc83 /src/libsystemd-network | |
parent | Merge pull request #10949 from yuwata/man-improve-unset (diff) | |
download | systemd-5cfa2c3dc09ffed16e3ad249e893911e372d3ed0.tar.xz systemd-5cfa2c3dc09ffed16e3ad249e893911e372d3ed0.zip |
tree-wide: use IOVEC_MAKE() at many places
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/icmp6-util.c | 6 | ||||
-rw-r--r-- | src/libsystemd-network/sd-radv.c | 35 |
2 files changed, 14 insertions, 27 deletions
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c index ecb517f7ec..e535b12cda 100644 --- a/src/libsystemd-network/icmp6-util.c +++ b/src/libsystemd-network/icmp6-util.c @@ -17,8 +17,9 @@ #include "fd-util.h" #include "icmp6-util.h" -#include "socket-util.h" #include "in-addr-util.h" +#include "io-util.h" +#include "socket-util.h" #define IN6ADDR_ALL_ROUTERS_MULTICAST_INIT \ { { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -169,8 +170,7 @@ int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst, struct cmsghdr *cmsg; ssize_t len; - iov.iov_base = buffer; - iov.iov_len = size; + iov = IOVEC_MAKE(buffer, size); len = recvmsg(fd, &msg, MSG_DONTWAIT); if (len < 0) diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 4df7f273ce..fe458bcaa6 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -9,7 +9,6 @@ #include "sd-radv.h" -#include "macro.h" #include "alloc-util.h" #include "dns-domain.h" #include "ether-addr-util.h" @@ -17,12 +16,14 @@ #include "fd-util.h" #include "icmp6-util.h" #include "in-addr-util.h" +#include "io-util.h" +#include "macro.h" #include "radv-internal.h" +#include "random-util.h" #include "socket-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "random-util.h" _public_ int sd_radv_new(sd_radv **ret) { _cleanup_(sd_radv_unrefp) sd_radv *ra = NULL; @@ -159,24 +160,18 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, uint32_t router_li adv.nd_ra_curhoplimit = ra->hop_limit; adv.nd_ra_flags_reserved = ra->flags; adv.nd_ra_router_lifetime = htobe16(router_lifetime); - iov[msg.msg_iovlen].iov_base = &adv; - iov[msg.msg_iovlen].iov_len = sizeof(adv); - msg.msg_iovlen++; + iov[msg.msg_iovlen++] = IOVEC_MAKE(&adv, sizeof(adv)); /* MAC address is optional, either because the link does not use L2 addresses or load sharing is desired. See RFC 4861, Section 4.2 */ if (!ether_addr_is_null(&ra->mac_addr)) { opt_mac.slladdr = ra->mac_addr; - iov[msg.msg_iovlen].iov_base = &opt_mac; - iov[msg.msg_iovlen].iov_len = sizeof(opt_mac); - msg.msg_iovlen++; + iov[msg.msg_iovlen++] = IOVEC_MAKE(&opt_mac, sizeof(opt_mac)); } if (ra->mtu) { opt_mtu.nd_opt_mtu_mtu = htobe32(ra->mtu); - iov[msg.msg_iovlen].iov_base = &opt_mtu; - iov[msg.msg_iovlen].iov_len = sizeof(opt_mtu); - msg.msg_iovlen++; + iov[msg.msg_iovlen++] = IOVEC_MAKE(&opt_mtu, sizeof(opt_mtu)); } LIST_FOREACH(prefix, p, ra->prefixes) { @@ -192,22 +187,14 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, uint32_t router_li else p->opt.preferred_lifetime = htobe32((p->preferred_until - time_now) / USEC_PER_SEC); } - iov[msg.msg_iovlen].iov_base = &p->opt; - iov[msg.msg_iovlen].iov_len = sizeof(p->opt); - msg.msg_iovlen++; + iov[msg.msg_iovlen++] = IOVEC_MAKE(&p->opt, sizeof(p->opt)); } - if (ra->rdnss) { - iov[msg.msg_iovlen].iov_base = ra->rdnss; - iov[msg.msg_iovlen].iov_len = ra->rdnss->length * 8; - msg.msg_iovlen++; - } + if (ra->rdnss) + iov[msg.msg_iovlen++] = IOVEC_MAKE(ra->rdnss, ra->rdnss->length * 8); - if (ra->dnssl) { - iov[msg.msg_iovlen].iov_base = ra->dnssl; - iov[msg.msg_iovlen].iov_len = ra->dnssl->length * 8; - msg.msg_iovlen++; - } + if (ra->dnssl) + iov[msg.msg_iovlen++] = IOVEC_MAKE(ra->dnssl, ra->dnssl->length * 8); if (sendmsg(ra->fd, &msg, 0) < 0) return -errno; |