2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
35 static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
36 #elif defined(__NetBSD__)
37 static char rcsid[] = "$NetBSD$";
39 #ident "$Revision: 1.21 $"
47 /* walk the tree of routes with this for output
50 struct sockaddr_in to;
55 struct interface *ifp; /* usually output interface */
57 char metric; /* adjust metrics by interface */
61 #define WS_ST_FLASH 0x001 /* send only changed routes */
62 #define WS_ST_RIP2_ALL 0x002 /* send full featured RIPv2 */
63 #define WS_ST_AG 0x004 /* ok to aggregate subnets */
64 #define WS_ST_SUPER_AG 0x008 /* ok to aggregate networks */
65 #define WS_ST_SUB_AG 0x010 /* aggregate subnets in odd case */
66 #define WS_ST_QUERY 0x020 /* responding to a query */
67 #define WS_ST_TO_ON_NET 0x040 /* sending onto one of our nets */
68 #define WS_ST_DEFAULT 0x080 /* faking a default */
71 /* A buffer for what can be heard by both RIPv1 and RIPv2 listeners */
73 union pkt_buf ripv12_buf;
75 /* Another for only RIPv2 listeners */
77 union pkt_buf rip_v2_buf;
84 ripv12_buf.rip.rip_cmd = RIPCMD_RESPONSE;
85 v12buf.buf = &ripv12_buf.rip;
86 v12buf.base = &v12buf.buf->rip_nets[0];
88 rip_v2_buf.rip.rip_cmd = RIPCMD_RESPONSE;
89 rip_v2_buf.rip.rip_vers = RIPv2;
90 v2buf.buf = &rip_v2_buf.rip;
91 v2buf.base = &v2buf.buf->rip_nets[0];
95 /* Send the contents of the global buffer via the non-multicast socket
97 int /* <0 on failure */
98 output(enum output_type type,
99 struct sockaddr_in *dst, /* send to here */
100 struct interface *ifp,
102 int size) /* this many bytes */
104 struct sockaddr_in sin;
113 if (sin.sin_port == 0)
114 sin.sin_port = htons(RIP_PORT);
116 if (sin.sin_len == 0)
117 sin.sin_len = sizeof(sin);
125 msg = "Answer Query";
127 soc = ifp->int_rip_sock;
132 soc = ifp->int_rip_sock;
133 flags = MSG_DONTROUTE;
136 if (ifp->int_if_flags & IFF_POINTOPOINT) {
141 flags = MSG_DONTROUTE;
144 if (ifp->int_if_flags & IFF_POINTOPOINT) {
145 msg = "Send pt-to-pt";
146 } else if (ifp->int_state & IS_DUP) {
147 trace_act("abort multicast output via %s"
148 " with duplicate address",
153 if (rip_sock_mcast != ifp) {
155 /* Do not specifiy the primary interface
156 * explicitly if we have the multicast
157 * point-to-point kernel bug, since the
158 * kernel will do the wrong thing if the
159 * local address of a point-to-point link
160 * is the same as the address of an ordinary
163 if (ifp->int_addr == myaddr) {
167 tgt_mcast = ifp->int_addr;
168 if (0 > setsockopt(rip_sock,
169 IPPROTO_IP, IP_MULTICAST_IF,
171 sizeof(tgt_mcast))) {
173 LOGERR("setsockopt(rip_sock,"
179 rip_sock_mcast = ifp;
181 sin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP);
185 case NO_OUT_MULTICAST:
194 trace_rip(msg, "to", &sin, ifp, buf, size);
196 res = sendto(soc, buf, size, flags,
197 (struct sockaddr *)&sin, sizeof(sin));
199 && (ifp == 0 || !(ifp->int_state & IS_BROKE))) {
201 msglog("%s sendto(%s%s%s.%d): %s", msg,
202 ifp != 0 ? ifp->int_name : "",
203 ifp != 0 ? ", " : "",
204 inet_ntoa(sin.sin_addr),
214 /* Find the first key for a packet to send.
215 * Try for a key that is eligable and has not expired, but settle for
216 * the last key if they have all expired.
217 * If no key is ready yet, give up.
220 find_auth(struct interface *ifp)
222 struct auth *ap, *res;
231 for (i = 0; i < MAX_AUTH_KEYS; i++, ap++) {
232 /* stop looking after the last key */
233 if (ap->type == RIP_AUTH_NONE)
236 /* ignore keys that are not ready yet */
237 if ((u_long)ap->start > (u_long)clk.tv_sec)
240 if ((u_long)ap->end < (u_long)clk.tv_sec) {
241 /* note best expired password as a fall-back */
242 if (res == 0 || (u_long)ap->end > (u_long)res->end)
247 /* note key with the best future */
248 if (res == 0 || (u_long)res->end < (u_long)ap->end)
256 clr_ws_buf(struct ws_buf *wb,
261 wb->lim = wb->base + NETS_LEN;
263 bzero(wb->n, NETS_LEN*sizeof(*wb->n));
265 /* install authentication if appropriate
269 na = (struct netauth*)wb->n;
270 if (ap->type == RIP_AUTH_PW) {
271 na->a_family = RIP_AF_AUTH;
272 na->a_type = RIP_AUTH_PW;
273 bcopy(ap->key, na->au.au_pw, sizeof(na->au.au_pw));
276 } else if (ap->type == RIP_AUTH_MD5) {
277 na->a_family = RIP_AF_AUTH;
278 na->a_type = RIP_AUTH_MD5;
279 na->au.a_md5.md5_keyid = ap->keyid;
280 na->au.a_md5.md5_auth_len = RIP_AUTH_PW_LEN;
281 na->au.a_md5.md5_seqno = clk.tv_sec;
283 wb->lim--; /* make room for trailer */
289 end_md5_auth(struct ws_buf *wb,
292 struct netauth *na, *na2;
296 na = (struct netauth*)wb->base;
297 na2 = (struct netauth*)wb->n;
298 na2->a_family = RIP_AF_AUTH;
300 bcopy(ap->key, na2->au.au_pw, sizeof(na2->au.au_pw));
301 na->au.a_md5.md5_pkt_len = (char *)na2-(char *)(na+1);
303 MD5Update(&md5_ctx, (u_char *)na,
304 (char *)(na2+1) - (char *)na);
305 MD5Final(na2->au.au_pw, &md5_ctx);
313 supply_write(struct ws_buf *wb)
315 /* Output multicast only if legal.
316 * If we would multcast and it would be illegal, then discard the
320 case NO_OUT_MULTICAST:
321 trace_pkt("skip multicast to %s because impossible",
322 naddr_ntoa(ws.to.sin_addr.s_addr));
327 if (ws.a != 0 && ws.a->type == RIP_AUTH_MD5)
328 end_md5_auth(wb,ws.a);
329 if (output(wb->type, &ws.to, ws.ifp, wb->buf,
330 ((char *)wb->n - (char*)wb->buf)) < 0
341 /* put an entry into the packet
344 supply_out(struct ag_info *ag)
347 naddr mask, v1_mask, dst_h, ddst_h = 0;
351 /* Skip this route if doing a flash update and it and the routes
352 * it aggregates have not changed recently.
354 if (ag->ag_seqno < update_seqno
355 && (ws.state & WS_ST_FLASH))
358 /* Skip this route if required by split-horizon.
360 if (ag->ag_state & AGS_SPLIT_HZ)
363 dst_h = ag->ag_dst_h;
365 v1_mask = ripv1_mask_host(htonl(dst_h),
366 (ws.state & WS_ST_TO_ON_NET) ? ws.ifp : 0);
369 /* If we are sending RIPv2 packets that cannot (or must not) be
370 * heard by RIPv1 listeners, do not worry about sub- or supernets.
371 * Subnets (from other networks) can only be sent via multicast.
372 * A pair of subnet routes might have been promoted so that they
373 * are legal to send by RIPv1.
374 * If RIPv1 is off, use the multicast buffer.
376 if ((ws.state & WS_ST_RIP2_ALL)
377 || ((ag->ag_state & AGS_RIPV2) && v1_mask != mask)) {
378 /* use the RIPv2-only buffer */
382 /* use the RIPv1-or-RIPv2 buffer */
385 /* Convert supernet route into corresponding set of network
386 * routes for RIPv1, but leave non-contiguous netmasks
390 && mask + (mask & -mask) == 0) {
391 ddst_h = v1_mask & -v1_mask;
392 i = (v1_mask & ~mask)/ddst_h;
394 if (i > ws.gen_limit) {
395 /* Punt if we would have to generate an
396 * unreasonable number of routes.
399 msglog("sending %s to %s as 1 instead"
401 addrname(htonl(dst_h),mask,1),
402 naddr_ntoa(ws.to.sin_addr.s_addr),
415 wb->n->n_family = RIP_AF_INET;
416 wb->n->n_dst = htonl(dst_h);
417 /* If the route is from router-discovery or we are
418 * shutting down, admit only a bad metric.
420 wb->n->n_metric = ((stopint || ag->ag_metric < 1)
423 HTONL(wb->n->n_metric);
424 /* Any non-zero bits in the supposedly unused RIPv1 fields
425 * cause the old `routed` to ignore the route.
426 * That means the mask and so forth cannot be sent
427 * in the hybrid RIPv1/RIPv2 mode.
429 if (ws.state & WS_ST_RIP2_ALL) {
431 && ((ws.state & WS_ST_QUERY)
432 || (ag->ag_nhop != ws.ifp->int_addr
433 && on_net(ag->ag_nhop,
436 wb->n->n_nhop = ag->ag_nhop;
437 wb->n->n_mask = htonl(mask);
438 wb->n->n_tag = ag->ag_tag;
442 if (++wb->n >= wb->lim)
448 /* supply one route from the table
452 walk_supply(struct radix_node *rn,
455 #define RT ((struct rt_entry *)rn)
461 /* Do not advertise external remote interfaces or passive interfaces.
463 if ((RT->rt_state & RS_IF)
465 && (RT->rt_ifp->int_if_flags & IS_PASSIVE)
466 && !(RT->rt_state & RS_MHOME))
469 /* If being quiet about our ability to forward, then
470 * do not say anything unless responding to a query,
471 * except about our main interface.
473 if (!supplier && !(ws.state & WS_ST_QUERY)
474 && !(RT->rt_state & RS_MHOME))
479 /* do not collide with the fake default route */
480 if (dst == RIP_DEFAULT
481 && (ws.state & WS_ST_DEFAULT))
484 if (RT->rt_state & RS_NET_SYN) {
485 if (RT->rt_state & RS_NET_INT) {
486 /* Do not send manual synthetic network routes
489 if (on_net(ws.to.sin_addr.s_addr,
490 ntohl(dst), RT->rt_mask))
494 /* Do not send automatic synthetic network routes
495 * if they are not needed becaus no RIPv1 listeners
498 if (ws.state & WS_ST_RIP2_ALL)
501 /* Do not send automatic synthetic network routes to
504 if (on_net(ws.to.sin_addr.s_addr,
505 ntohl(dst), RT->rt_mask))
511 /* Advertise the next hop if this is not a route for one
512 * of our interfaces and the next hop is on the same
513 * network as the target.
515 if (!(RT->rt_state & RS_IF)
516 && RT->rt_gate != myaddr
517 && RT->rt_gate != loopaddr)
523 metric = RT->rt_metric;
526 if (RT->rt_state & RS_MHOME) {
527 /* retain host route of multi-homed servers */
530 } else if (RT_ISHOST(RT)) {
531 /* We should always aggregate the host routes
532 * for the local end of our point-to-point links.
533 * If we are suppressing host routes in general, then do so.
534 * Avoid advertising host routes onto their own network,
535 * where they should be handled by proxy-ARP.
537 if ((RT->rt_state & RS_LOCAL)
539 || (ws.state & WS_ST_SUPER_AG)
540 || on_net(dst, ws.to_net, ws.to_mask))
543 if (ws.state & WS_ST_SUPER_AG)
546 } else if (ws.state & WS_ST_AG) {
547 /* Aggregate network routes, if we are allowed.
551 /* Generate supernets if allowed.
552 * If we can be heard by RIPv1 systems, we will
553 * later convert back to ordinary nets.
554 * This unifies dealing with received supernets.
556 if ((RT->rt_state & RS_SUBNET)
557 || (ws.state & WS_ST_SUPER_AG))
562 /* Do not send RIPv1 advertisements of subnets to other
563 * networks. If possible, multicast them by RIPv2.
565 if ((RT->rt_state & RS_SUBNET)
566 && !(ws.state & WS_ST_RIP2_ALL)
567 && !on_net(dst, ws.to_std_net, ws.to_std_mask)) {
568 ags |= AGS_RIPV2 | AGS_PROMOTE;
569 if (ws.state & WS_ST_SUB_AG)
573 /* Do not send a route back to where it came from, except in
574 * response to a query. This is "split-horizon". That means not
575 * advertising back to the same network and so via the same interface.
577 * We want to suppress routes that might have been fragmented
578 * from this route by a RIPv1 router and sent back to us, and so we
579 * cannot forget this route here. Let the split-horizon route
580 * aggregate (suppress) the fragmented routes and then itself be
583 * Include the routes for both ends of point-to-point interfaces
584 * among those suppressed by split-horizon, since the other side
585 * should knows them as well as we do.
587 if (RT->rt_ifp == ws.ifp && ws.ifp != 0
588 && !(ws.state & WS_ST_QUERY)
589 && (ws.state & WS_ST_TO_ON_NET)
590 && (!(RT->rt_state & RS_IF)
591 || ws.ifp->int_if_flags & IFF_POINTOPOINT)) {
592 /* If we do not mark the route with AGS_SPLIT_HZ here,
593 * it will be poisoned-reverse, or advertised back toward
594 * its source with an infinite metric. If we have recently
595 * advertised the route with a better metric than we now
596 * have, then we should poison-reverse the route before
597 * suppressing it for split-horizon.
599 * In almost all cases, if there is no spare for the route
600 * then it is either old and dead or a brand new route.
601 * If it is brand new, there is no need for poison-reverse.
602 * If it is old and dead, it is already poisoned.
604 if (RT->rt_poison_time < now_expire
605 || RT->rt_poison_metric >= metric
606 || RT->rt_spares[1].rts_gate == 0) {
608 ags &= ~(AGS_PROMOTE | AGS_SUPPRESS);
610 metric = HOPCNT_INFINITY;
613 /* Adjust the outgoing metric by the cost of the link.
615 pref = metric + ws.metric;
616 if (pref < HOPCNT_INFINITY) {
617 /* Keep track of the best metric with which the
618 * route has been advertised recently.
620 if (RT->rt_poison_metric >= metric
621 || RT->rt_poison_time < now_expire) {
622 RT->rt_poison_time = now.tv_sec;
623 RT->rt_poison_metric = metric;
628 /* Do not advertise stable routes that will be ignored,
629 * unless we are answering a query.
630 * If the route recently was advertised with a metric that
631 * would have been less than infinity through this interface,
632 * we need to continue to advertise it in order to poison it.
634 pref = RT->rt_poison_metric + ws.metric;
635 if (!(ws.state & WS_ST_QUERY)
636 && (pref >= HOPCNT_INFINITY
637 || RT->rt_poison_time < now_garbage))
640 metric = HOPCNT_INFINITY;
643 ag_check(dst, RT->rt_mask, 0, nhop, metric, pref,
644 RT->rt_seqno, RT->rt_tag, ags, supply_out);
650 /* Supply dst with the contents of the routing tables.
651 * If this won't fit in one packet, chop it up into several.
654 supply(struct sockaddr_in *dst,
655 struct interface *ifp, /* output interface */
656 enum output_type type,
657 int flash, /* 1=flash update */
658 int vers, /* RIP version */
659 int passwd_ok) /* OK to include cleartext password */
669 ws.to_std_mask = std_mask(ws.to.sin_addr.s_addr);
670 ws.to_std_net = ntohl(ws.to.sin_addr.s_addr) & ws.to_std_mask;
673 ws.to_mask = ifp->int_mask;
674 ws.to_net = ifp->int_net;
675 if (on_net(ws.to.sin_addr.s_addr, ws.to_net, ws.to_mask))
676 ws.state |= WS_ST_TO_ON_NET;
679 ws.to_mask = ripv1_mask_net(ws.to.sin_addr.s_addr, 0);
680 ws.to_net = ntohl(ws.to.sin_addr.s_addr) & ws.to_mask;
681 rt = rtfind(dst->sin_addr.s_addr);
688 ws.state |= WS_ST_FLASH;
689 if (type == OUT_QUERY)
690 ws.state |= WS_ST_QUERY;
692 if ((ws.ifp = ifp) == 0) {
695 /* Adjust the advertised metric by the outgoing interface
698 ws.metric = ifp->int_metric+1;
701 ripv12_buf.rip.rip_vers = vers;
705 v2buf.type = ((ifp != 0 && (ifp->int_if_flags & IFF_MULTICAST))
708 v12buf.type = OUT_BROADCAST;
711 v2buf.type = ((ifp != 0 && (ifp->int_if_flags & IFF_MULTICAST))
714 v12buf.type = OUT_BROADCAST;
718 v2buf.type = (vers == RIPv2) ? type : NO_OUT_RIPV2;
728 /* full RIPv2 only if cannot be heard by RIPv1 listeners */
729 if (type != OUT_BROADCAST)
730 ws.state |= WS_ST_RIP2_ALL;
731 if (!(ws.state & WS_ST_TO_ON_NET)) {
732 ws.state |= (WS_ST_AG | WS_ST_SUPER_AG);
733 } else if (ifp == 0 || !(ifp->int_state & IS_NO_AG)) {
734 ws.state |= WS_ST_AG;
735 if (type != OUT_BROADCAST
736 && (ifp == 0 || !(ifp->int_state&IS_NO_SUPER_AG)))
737 ws.state |= WS_ST_SUPER_AG;
740 } else if (ifp == 0 || !(ifp->int_state & IS_NO_AG)) {
741 ws.state |= WS_ST_SUB_AG;
744 ws.a = (vers == RIPv2) ? find_auth(ifp) : 0;
745 if (!passwd_ok && ws.a != 0 && ws.a->type == RIP_AUTH_PW)
747 clr_ws_buf(&v12buf,ws.a);
748 clr_ws_buf(&v2buf,ws.a);
750 /* Fake a default route if asked and if there is not already
751 * a better, real default route.
753 if (supplier && (def_metric = ifp->int_d_metric) != 0) {
754 if (0 == (rt = rtget(RIP_DEFAULT, 0))
755 || rt->rt_metric+ws.metric >= def_metric) {
756 ws.state |= WS_ST_DEFAULT;
757 ag_check(0, 0, 0, 0, def_metric, def_metric,
758 0, 0, 0, supply_out);
760 def_metric = rt->rt_metric+ws.metric;
763 /* If both RIPv2 and the poor-man's router discovery
764 * kludge are on, arrange to advertise an extra
765 * default route via RIPv1.
767 if ((ws.state & WS_ST_RIP2_ALL)
768 && (ifp->int_state & IS_PM_RDISC)) {
769 ripv12_buf.rip.rip_vers = RIPv1;
770 v12buf.n->n_family = RIP_AF_INET;
771 v12buf.n->n_dst = htonl(RIP_DEFAULT);
772 v12buf.n->n_metric = htonl(def_metric);
777 (void)rn_walktree(rhead, walk_supply, 0);
778 ag_flush(0,0,supply_out);
780 /* Flush the packet buffers, provided they are not empty and
781 * do not contain only the password.
783 if (v12buf.n != v12buf.base
784 && (v12buf.n > v12buf.base+1
785 || v12buf.base->n_family != RIP_AF_AUTH))
786 supply_write(&v12buf);
787 if (v2buf.n != v2buf.base
788 && (v2buf.n > v2buf.base+1
789 || v2buf.base->n_family != RIP_AF_AUTH))
790 supply_write(&v2buf);
792 /* If we sent nothing and this is an answer to a query, send
796 && (ws.state & WS_ST_QUERY))
797 supply_write(&v12buf);
801 /* send all of the routing table or just do a flash update
807 static struct sockaddr_in dst = {sizeof(dst), AF_INET};
809 static struct sockaddr_in dst = {AF_INET};
811 struct interface *ifp;
812 enum output_type type;
814 struct timeval rtime;
818 intvl_random(&rtime, MIN_WAITTIME, MAX_WAITTIME);
820 timevaladd(&no_flash, &now);
825 trace_act("send %s and inhibit dynamic updates for %.3f sec",
826 flash ? "dynamic update" : "all routes",
827 rtime.tv_sec + ((float)rtime.tv_usec)/1000000.0);
829 for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
830 /* Skip interfaces not doing RIP.
831 * Do try broken interfaces to see if they have healed.
833 if (IS_RIP_OUT_OFF(ifp->int_state))
836 /* skip turned off interfaces */
837 if (!iff_alive(ifp->int_if_flags))
840 vers = (ifp->int_state & IS_NO_RIPV1_OUT) ? RIPv2 : RIPv1;
842 if (ifp->int_if_flags & IFF_BROADCAST) {
843 /* ordinary, hardware interface */
844 dst.sin_addr.s_addr = ifp->int_brdaddr;
846 /* If RIPv1 is not turned off, then broadcast so
847 * that RIPv1 listeners can hear.
850 && (ifp->int_state & IS_NO_RIPV1_OUT)) {
851 type = OUT_MULTICAST;
853 type = OUT_BROADCAST;
856 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
857 /* point-to-point hardware interface */
858 dst.sin_addr.s_addr = ifp->int_dstaddr;
861 } else if (ifp->int_state & IS_REMOTE) {
862 /* remote interface */
863 dst.sin_addr.s_addr = ifp->int_addr;
867 /* ATM, HIPPI, etc. */
871 supply(&dst, ifp, type, flash, vers, 1);
874 update_seqno++; /* all routes are up to date */
879 * Do it only once to an interface, and not even after the interface
880 * was broken and recovered.
886 static struct sockaddr_in dst = {sizeof(dst), AF_INET};
888 static struct sockaddr_in dst = {AF_INET};
890 struct interface *ifp;
892 enum output_type type;
898 bzero(&buf, sizeof(buf));
900 for (ifp = ifnet; ifp; ifp = ifp->int_next) {
901 /* Skip interfaces those already queried.
902 * Do not ask via interfaces through which we don't
903 * accept input. Do not ask via interfaces that cannot
905 * Do try broken interfaces to see if they have healed.
907 if (IS_RIP_IN_OFF(ifp->int_state)
908 || ifp->int_query_time != NEVER)
911 /* skip turned off interfaces */
912 if (!iff_alive(ifp->int_if_flags))
915 buf.rip_vers = (ifp->int_state&IS_NO_RIPV1_OUT) ? RIPv2:RIPv1;
916 buf.rip_cmd = RIPCMD_REQUEST;
917 buf.rip_nets[0].n_family = RIP_AF_UNSPEC;
918 buf.rip_nets[0].n_metric = htonl(HOPCNT_INFINITY);
920 if (ifp->int_if_flags & IFF_BROADCAST) {
921 /* ordinary, hardware interface */
922 dst.sin_addr.s_addr = ifp->int_brdaddr;
923 /* if RIPv1 is not turned off, then broadcast so
924 * that RIPv1 listeners can hear.
926 if (buf.rip_vers == RIPv2
927 && (ifp->int_state & IS_NO_RIPV1_OUT)) {
928 type = OUT_MULTICAST;
930 type = OUT_BROADCAST;
933 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
934 /* point-to-point hardware interface */
935 dst.sin_addr.s_addr = ifp->int_dstaddr;
938 } else if (ifp->int_state & IS_REMOTE) {
939 /* remote interface */
940 dst.sin_addr.s_addr = ifp->int_addr;
944 /* ATM, HIPPI, etc. */
948 ifp->int_query_time = now.tv_sec+SUPPLY_INTERVAL;
949 if (output(type, &dst, ifp, &buf, sizeof(buf)) < 0)