99
1010#include "sd-radv.h"
1111
12- #include "macro.h"
1312#include "alloc-util.h"
1413#include "dns-domain.h"
1514#include "ether-addr-util.h"
1615#include "event-util.h"
1716#include "fd-util.h"
1817#include "icmp6-util.h"
1918#include "in-addr-util.h"
19+ #include "io-util.h"
20+ #include "macro.h"
2021#include "radv-internal.h"
22+ #include "random-util.h"
2123#include "socket-util.h"
2224#include "string-util.h"
2325#include "strv.h"
2426#include "util.h"
25- #include "random-util.h"
2627
2728_public_ int sd_radv_new (sd_radv * * ret ) {
2829 _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
159160 adv .nd_ra_curhoplimit = ra -> hop_limit ;
160161 adv .nd_ra_flags_reserved = ra -> flags ;
161162 adv .nd_ra_router_lifetime = htobe16 (router_lifetime );
162- iov [msg .msg_iovlen ].iov_base = & adv ;
163- iov [msg .msg_iovlen ].iov_len = sizeof (adv );
164- msg .msg_iovlen ++ ;
163+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (& adv , sizeof (adv ));
165164
166165 /* MAC address is optional, either because the link does not use L2
167166 addresses or load sharing is desired. See RFC 4861, Section 4.2 */
168167 if (!ether_addr_is_null (& ra -> mac_addr )) {
169168 opt_mac .slladdr = ra -> mac_addr ;
170- iov [msg .msg_iovlen ].iov_base = & opt_mac ;
171- iov [msg .msg_iovlen ].iov_len = sizeof (opt_mac );
172- msg .msg_iovlen ++ ;
169+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (& opt_mac , sizeof (opt_mac ));
173170 }
174171
175172 if (ra -> mtu ) {
176173 opt_mtu .nd_opt_mtu_mtu = htobe32 (ra -> mtu );
177- iov [msg .msg_iovlen ].iov_base = & opt_mtu ;
178- iov [msg .msg_iovlen ].iov_len = sizeof (opt_mtu );
179- msg .msg_iovlen ++ ;
174+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (& opt_mtu , sizeof (opt_mtu ));
180175 }
181176
182177 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
192187 else
193188 p -> opt .preferred_lifetime = htobe32 ((p -> preferred_until - time_now ) / USEC_PER_SEC );
194189 }
195- iov [msg .msg_iovlen ].iov_base = & p -> opt ;
196- iov [msg .msg_iovlen ].iov_len = sizeof (p -> opt );
197- msg .msg_iovlen ++ ;
190+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (& p -> opt , sizeof (p -> opt ));
198191 }
199192
200- if (ra -> rdnss ) {
201- iov [msg .msg_iovlen ].iov_base = ra -> rdnss ;
202- iov [msg .msg_iovlen ].iov_len = ra -> rdnss -> length * 8 ;
203- msg .msg_iovlen ++ ;
204- }
193+ if (ra -> rdnss )
194+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (ra -> rdnss , ra -> rdnss -> length * 8 );
205195
206- if (ra -> dnssl ) {
207- iov [msg .msg_iovlen ].iov_base = ra -> dnssl ;
208- iov [msg .msg_iovlen ].iov_len = ra -> dnssl -> length * 8 ;
209- msg .msg_iovlen ++ ;
210- }
196+ if (ra -> dnssl )
197+ iov [msg .msg_iovlen ++ ] = IOVEC_MAKE (ra -> dnssl , ra -> dnssl -> length * 8 );
211198
212199 if (sendmsg (ra -> fd , & msg , 0 ) < 0 )
213200 return - errno ;
0 commit comments