2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1983, 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 /* walk the tree of routes with this for output
40 struct sockaddr_in to;
45 struct interface *ifp; /* usually output interface */
47 char metric; /* adjust metrics by interface */
51 #define WS_ST_FLASH 0x001 /* send only changed routes */
52 #define WS_ST_RIP2_ALL 0x002 /* send full featured RIPv2 */
53 #define WS_ST_AG 0x004 /* ok to aggregate subnets */
54 #define WS_ST_SUPER_AG 0x008 /* ok to aggregate networks */
55 #define WS_ST_QUERY 0x010 /* responding to a query */
56 #define WS_ST_TO_ON_NET 0x020 /* sending onto one of our nets */
57 #define WS_ST_DEFAULT 0x040 /* faking a default */
60 /* A buffer for what can be heard by both RIPv1 and RIPv2 listeners */
62 static union pkt_buf ripv12_buf;
64 /* Another for only RIPv2 listeners */
65 static struct ws_buf v2buf;
66 static union pkt_buf rip_v2_buf;
73 ripv12_buf.rip.rip_cmd = RIPCMD_RESPONSE;
74 v12buf.buf = &ripv12_buf.rip;
75 v12buf.base = &v12buf.buf->rip_nets[0];
77 rip_v2_buf.rip.rip_cmd = RIPCMD_RESPONSE;
78 rip_v2_buf.rip.rip_vers = RIPv2;
79 v2buf.buf = &rip_v2_buf.rip;
80 v2buf.base = &v2buf.buf->rip_nets[0];
84 /* Send the contents of the global buffer via the non-multicast socket
86 int /* <0 on failure */
87 output(enum output_type type,
88 struct sockaddr_in *dst, /* send to here */
89 struct interface *ifp,
91 int size) /* this many bytes */
93 struct sockaddr_in osin;
102 if (osin.sin_port == 0)
103 osin.sin_port = htons(RIP_PORT);
105 if (osin.sin_len == 0)
106 osin.sin_len = sizeof(osin);
114 msg = "Answer Query";
116 soc = ifp->int_rip_sock;
121 soc = ifp->int_rip_sock;
122 flags = MSG_DONTROUTE;
125 if (ifp->int_if_flags & IFF_POINTOPOINT) {
130 flags = MSG_DONTROUTE;
133 if ((ifp->int_if_flags & (IFF_POINTOPOINT|IFF_MULTICAST)) ==
135 msg = "Send pt-to-pt";
136 } else if (ifp->int_state & IS_DUP) {
137 trace_act("abort multicast output via %s"
138 " with duplicate address",
143 if (rip_sock_mcast != ifp) {
144 struct ip_mreqn mreqn;
146 memset(&mreqn, 0, sizeof(struct ip_mreqn));
147 mreqn.imr_ifindex = ifp->int_index;
148 if (0 > setsockopt(rip_sock,
154 LOGERR("setsockopt(rip_sock, "
160 rip_sock_mcast = ifp;
162 osin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP);
166 case NO_OUT_MULTICAST:
175 trace_rip(msg, "to", &osin, ifp, buf, size);
177 res = sendto(soc, buf, size, flags,
178 (struct sockaddr *)&osin, sizeof(osin));
180 && (ifp == NULL || !(ifp->int_state & IS_BROKE))) {
182 msglog("%s sendto(%s%s%s.%d): %s", msg,
183 ifp != NULL ? ifp->int_name : "",
184 ifp != NULL ? ", " : "",
185 inet_ntoa(osin.sin_addr),
186 ntohs(osin.sin_port),
195 /* Find the first key for a packet to send.
196 * Try for a key that is eligible and has not expired, but settle for
197 * the last key if they have all expired.
198 * If no key is ready yet, give up.
201 find_auth(struct interface *ifp)
203 struct auth *ap, *res;
212 for (i = 0; i < MAX_AUTH_KEYS; i++, ap++) {
213 /* stop looking after the last key */
214 if (ap->type == RIP_AUTH_NONE)
217 /* ignore keys that are not ready yet */
218 if ((u_long)ap->start > (u_long)clk.tv_sec)
221 if ((u_long)ap->end < (u_long)clk.tv_sec) {
222 /* note best expired password as a fall-back */
223 if (res == NULL || (u_long)ap->end > (u_long)res->end)
228 /* note key with the best future */
229 if (res == NULL || (u_long)res->end < (u_long)ap->end)
237 clr_ws_buf(struct ws_buf *wb,
242 wb->lim = wb->base + NETS_LEN;
244 memset(wb->n, 0, NETS_LEN*sizeof(*wb->n));
246 /* (start to) install authentication if appropriate
251 na = (struct netauth*)wb->n;
252 if (ap->type == RIP_AUTH_PW) {
253 na->a_family = RIP_AF_AUTH;
254 na->a_type = RIP_AUTH_PW;
255 memcpy(na->au.au_pw, ap->key, sizeof(na->au.au_pw));
258 } else if (ap->type == RIP_AUTH_MD5) {
259 na->a_family = RIP_AF_AUTH;
260 na->a_type = RIP_AUTH_MD5;
261 na->au.a_md5.md5_keyid = ap->keyid;
262 na->au.a_md5.md5_auth_len = RIP_AUTH_MD5_KEY_LEN;
263 na->au.a_md5.md5_seqno = htonl(clk.tv_sec);
265 wb->lim--; /* make room for trailer */
271 end_md5_auth(struct ws_buf *wb,
274 struct netauth *na, *na2;
279 na = (struct netauth*)wb->base;
280 na2 = (struct netauth*)wb->n;
281 len = (char *)na2-(char *)wb->buf;
282 na2->a_family = RIP_AF_AUTH;
283 na2->a_type = htons(1);
284 na->au.a_md5.md5_pkt_len = htons(len);
286 MD5Update(&md5_ctx, (u_char *)wb->buf, len + RIP_AUTH_MD5_HASH_XTRA);
287 MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_KEY_LEN);
288 MD5Final(na2->au.au_pw, &md5_ctx);
296 supply_write(struct ws_buf *wb)
298 /* Output multicast only if legal.
299 * If we would multicast and it would be illegal, then discard the
303 case NO_OUT_MULTICAST:
304 trace_pkt("skip multicast to %s because impossible",
305 naddr_ntoa(ws.to.sin_addr.s_addr));
310 if (ws.a != NULL && ws.a->type == RIP_AUTH_MD5)
311 end_md5_auth(wb,ws.a);
312 if (output(wb->type, &ws.to, ws.ifp, wb->buf,
313 ((char *)wb->n - (char*)wb->buf)) < 0
324 /* put an entry into the packet
327 supply_out(struct ag_info *ag)
330 naddr mask, v1_mask, dst_h, ddst_h = 0;
334 /* Skip this route if doing a flash update and it and the routes
335 * it aggregates have not changed recently.
337 if (ag->ag_seqno < update_seqno
338 && (ws.state & WS_ST_FLASH))
341 dst_h = ag->ag_dst_h;
343 v1_mask = ripv1_mask_host(htonl(dst_h),
344 (ws.state & WS_ST_TO_ON_NET) ? ws.ifp : 0);
347 /* If we are sending RIPv2 packets that cannot (or must not) be
348 * heard by RIPv1 listeners, do not worry about sub- or supernets.
349 * Subnets (from other networks) can only be sent via multicast.
350 * A pair of subnet routes might have been promoted so that they
351 * are legal to send by RIPv1.
352 * If RIPv1 is off, use the multicast buffer.
354 if ((ws.state & WS_ST_RIP2_ALL)
355 || ((ag->ag_state & AGS_RIPV2) && v1_mask != mask)) {
356 /* use the RIPv2-only buffer */
360 /* use the RIPv1-or-RIPv2 buffer */
363 /* Convert supernet route into corresponding set of network
364 * routes for RIPv1, but leave non-contiguous netmasks
368 && mask + (mask & -mask) == 0) {
369 ddst_h = v1_mask & -v1_mask;
370 i = (v1_mask & ~mask)/ddst_h;
372 if (i > ws.gen_limit) {
373 /* Punt if we would have to generate an
374 * unreasonable number of routes.
377 trace_misc("sending %s-->%s as 1"
378 " instead of %d routes",
379 addrname(htonl(dst_h), mask,
381 naddr_ntoa(ws.to.sin_addr
394 wb->n->n_family = RIP_AF_INET;
395 wb->n->n_dst = htonl(dst_h);
396 /* If the route is from router-discovery or we are
397 * shutting down, admit only a bad metric.
399 wb->n->n_metric = ((stopint || ag->ag_metric < 1)
402 wb->n->n_metric = htonl(wb->n->n_metric);
403 /* Any non-zero bits in the supposedly unused RIPv1 fields
404 * cause the old `routed` to ignore the route.
405 * That means the mask and so forth cannot be sent
406 * in the hybrid RIPv1/RIPv2 mode.
408 if (ws.state & WS_ST_RIP2_ALL) {
410 && ((ws.state & WS_ST_QUERY)
411 || (ag->ag_nhop != ws.ifp->int_addr
412 && on_net(ag->ag_nhop,
415 wb->n->n_nhop = ag->ag_nhop;
416 wb->n->n_mask = htonl(mask);
417 wb->n->n_tag = ag->ag_tag;
421 if (++wb->n >= wb->lim)
427 /* supply one route from the table
431 walk_supply(struct radix_node *rn,
432 struct walkarg *argp UNUSED)
434 #define RT ((struct rt_entry *)rn)
438 struct rt_spare *rts;
442 /* Do not advertise external remote interfaces or passive interfaces.
444 if ((RT->rt_state & RS_IF)
446 && (RT->rt_ifp->int_state & IS_PASSIVE)
447 && !(RT->rt_state & RS_MHOME))
450 /* If being quiet about our ability to forward, then
451 * do not say anything unless responding to a query,
452 * except about our main interface.
454 if (!supplier && !(ws.state & WS_ST_QUERY)
455 && !(RT->rt_state & RS_MHOME))
460 /* do not collide with the fake default route */
461 if (dst == RIP_DEFAULT
462 && (ws.state & WS_ST_DEFAULT))
465 if (RT->rt_state & RS_NET_SYN) {
466 if (RT->rt_state & RS_NET_INT) {
467 /* Do not send manual synthetic network routes
470 if (on_net(ws.to.sin_addr.s_addr,
471 ntohl(dst), RT->rt_mask))
475 /* Do not send automatic synthetic network routes
476 * if they are not needed because no RIPv1 listeners
479 if (ws.state & WS_ST_RIP2_ALL)
482 /* Do not send automatic synthetic network routes to
485 if (on_net(ws.to.sin_addr.s_addr,
486 ntohl(dst), RT->rt_mask))
492 /* Advertise the next hop if this is not a route for one
493 * of our interfaces and the next hop is on the same
494 * network as the target.
495 * The final determination is made by supply_out().
497 if (!(RT->rt_state & RS_IF)
498 && RT->rt_gate != myaddr
499 && RT->rt_gate != loopaddr)
505 metric = RT->rt_metric;
508 if (RT->rt_state & RS_MHOME) {
509 /* retain host route of multi-homed servers */
512 } else if (RT_ISHOST(RT)) {
513 /* We should always suppress (into existing network routes)
514 * the host routes for the local end of our point-to-point
516 * If we are suppressing host routes in general, then do so.
517 * Avoid advertising host routes onto their own network,
518 * where they should be handled by proxy-ARP.
520 if ((RT->rt_state & RS_LOCAL)
522 || on_net(dst, ws.to_net, ws.to_mask))
525 /* Aggregate stray host routes into network routes if allowed.
526 * We cannot aggregate host routes into small network routes
527 * without confusing RIPv1 listeners into thinking the
528 * network routes are host routes.
530 if ((ws.state & WS_ST_AG) && (ws.state & WS_ST_RIP2_ALL))
531 ags |= AGS_AGGREGATE;
534 /* Always suppress network routes into other, existing
539 /* Generate supernets if allowed.
540 * If we can be heard by RIPv1 systems, we will
541 * later convert back to ordinary nets.
542 * This unifies dealing with received supernets.
544 if ((ws.state & WS_ST_AG)
545 && ((RT->rt_state & RS_SUBNET)
546 || (ws.state & WS_ST_SUPER_AG)))
547 ags |= AGS_AGGREGATE;
550 /* Do not send RIPv1 advertisements of subnets to other
551 * networks. If possible, multicast them by RIPv2.
553 if ((RT->rt_state & RS_SUBNET)
554 && !(ws.state & WS_ST_RIP2_ALL)
555 && !on_net(dst, ws.to_std_net, ws.to_std_mask))
556 ags |= AGS_RIPV2 | AGS_AGGREGATE;
559 /* Do not send a route back to where it came from, except in
560 * response to a query. This is "split-horizon". That means not
561 * advertising back to the same network and so via the same interface.
563 * We want to suppress routes that might have been fragmented
564 * from this route by a RIPv1 router and sent back to us, and so we
565 * cannot forget this route here. Let the split-horizon route
566 * suppress the fragmented routes and then itself be forgotten.
568 * Include the routes for both ends of point-to-point interfaces
569 * among those suppressed by split-horizon, since the other side
570 * should knows them as well as we do.
572 * Notice spare routes with the same metric that we are about to
573 * advertise, to split the horizon on redundant, inactive paths.
575 * Do not suppress advertisements of interface-related addresses on
576 * non-point-to-point interfaces. This ensures that we have something
577 * to say every 30 seconds to help detect broken Ethernets or
578 * other interfaces where one packet every 30 seconds costs nothing.
581 && !(ws.state & WS_ST_QUERY)
582 && (ws.state & WS_ST_TO_ON_NET)
583 && (!(RT->rt_state & RS_IF)
584 || ws.ifp->int_if_flags & IFF_POINTOPOINT)) {
585 for (rts = RT->rt_spares, i = NUM_SPARES; i != 0; i--, rts++) {
586 if (rts->rts_metric > metric
587 || rts->rts_ifp != ws.ifp)
590 /* If we do not mark the route with AGS_SPLIT_HZ here,
591 * it will be poisoned-reverse, or advertised back
592 * toward its source with an infinite metric.
593 * If we have recently advertised the route with a
594 * better metric than we now have, then we should
595 * poison-reverse the route before suppressing it for
598 * In almost all cases, if there is no spare for the
599 * route then it is either old and dead or a brand
600 * new route. If it is brand new, there is no need
601 * for poison-reverse. If it is old and dead, it
602 * 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_SUPPRESS;
610 metric = HOPCNT_INFINITY;
615 /* Keep track of the best metric with which the
616 * route has been advertised recently.
618 if (RT->rt_poison_metric >= metric
619 || RT->rt_poison_time < now_expire) {
620 RT->rt_poison_time = now.tv_sec;
621 RT->rt_poison_metric = metric;
624 /* Adjust the outgoing metric by the cost of the link.
625 * Avoid aggregation when a route is counting to infinity.
627 pref = RT->rt_poison_metric + ws.metric;
630 /* Do not advertise stable routes that will be ignored,
631 * unless we are answering a query.
632 * If the route recently was advertised with a metric that
633 * would have been less than infinity through this interface,
634 * we need to continue to advertise it in order to poison it.
636 if (metric >= HOPCNT_INFINITY) {
637 if (!(ws.state & WS_ST_QUERY)
638 && (pref >= HOPCNT_INFINITY
639 || RT->rt_poison_time < now_garbage))
642 metric = HOPCNT_INFINITY;
645 ag_check(dst, RT->rt_mask, 0, nhop, metric, pref,
646 RT->rt_seqno, RT->rt_tag, ags, supply_out);
652 /* Supply dst with the contents of the routing tables.
653 * If this won't fit in one packet, chop it up into several.
656 supply(struct sockaddr_in *dst,
657 struct interface *ifp, /* output interface */
658 enum output_type type,
659 int flash, /* 1=flash update */
660 int vers, /* RIP version */
661 int passwd_ok) /* OK to include cleartext password */
670 ws.to_std_mask = std_mask(ws.to.sin_addr.s_addr);
671 ws.to_std_net = ntohl(ws.to.sin_addr.s_addr) & ws.to_std_mask;
674 ws.to_mask = ifp->int_mask;
675 ws.to_net = ifp->int_net;
676 if (on_net(ws.to.sin_addr.s_addr, ws.to_net, ws.to_mask))
677 ws.state |= WS_ST_TO_ON_NET;
680 ws.to_mask = ripv1_mask_net(ws.to.sin_addr.s_addr, 0);
681 ws.to_net = ntohl(ws.to.sin_addr.s_addr) & ws.to_mask;
682 rt = rtfind(dst->sin_addr.s_addr);
689 ws.state |= WS_ST_FLASH;
691 if ((ws.ifp = ifp) == NULL) {
694 /* Adjust the advertised metric by the outgoing interface
697 ws.metric = ifp->int_metric + 1 + ifp->int_adj_outmetric;
700 ripv12_buf.rip.rip_vers = vers;
704 if (ifp != NULL && ifp->int_if_flags & IFF_MULTICAST)
705 v2buf.type = OUT_MULTICAST;
707 v2buf.type = NO_OUT_MULTICAST;
708 v12buf.type = OUT_BROADCAST;
712 ws.state |= WS_ST_QUERY;
716 v2buf.type = (vers == RIPv2) ? type : NO_OUT_RIPV2;
720 case NO_OUT_MULTICAST:
722 break; /* no output */
726 /* full RIPv2 only if cannot be heard by RIPv1 listeners */
727 if (type != OUT_BROADCAST)
728 ws.state |= WS_ST_RIP2_ALL;
729 if ((ws.state & WS_ST_QUERY)
730 || !(ws.state & WS_ST_TO_ON_NET)) {
731 ws.state |= (WS_ST_AG | WS_ST_SUPER_AG);
732 } else if (ifp == NULL || !(ifp->int_state & IS_NO_AG)) {
733 ws.state |= WS_ST_AG;
734 if (type != OUT_BROADCAST
736 || !(ifp->int_state & IS_NO_SUPER_AG)))
737 ws.state |= WS_ST_SUPER_AG;
741 ws.a = (vers == RIPv2) ? find_auth(ifp) : 0;
742 if (!passwd_ok && ws.a != NULL && ws.a->type == RIP_AUTH_PW)
744 clr_ws_buf(&v12buf,ws.a);
745 clr_ws_buf(&v2buf,ws.a);
747 /* Fake a default route if asked and if there is not already
748 * a better, real default route.
750 if (supplier && ifp && (def_metric = ifp->int_d_metric) != 0) {
751 if ((rt = rtget(RIP_DEFAULT, 0)) == NULL
752 || rt->rt_metric+ws.metric >= def_metric) {
753 ws.state |= WS_ST_DEFAULT;
754 ag_check(0, 0, 0, 0, def_metric, def_metric,
755 0, 0, 0, supply_out);
757 def_metric = rt->rt_metric+ws.metric;
760 /* If both RIPv2 and the poor-man's router discovery
761 * kludge are on, arrange to advertise an extra
762 * default route via RIPv1.
764 if ((ws.state & WS_ST_RIP2_ALL)
765 && (ifp->int_state & IS_PM_RDISC)) {
766 ripv12_buf.rip.rip_vers = RIPv1;
767 v12buf.n->n_family = RIP_AF_INET;
768 v12buf.n->n_dst = htonl(RIP_DEFAULT);
769 v12buf.n->n_metric = htonl(def_metric);
774 (void)rn_walktree(rhead, walk_supply, 0);
775 ag_flush(0,0,supply_out);
777 /* Flush the packet buffers, provided they are not empty and
778 * do not contain only the password.
780 if (v12buf.n != v12buf.base
781 && (v12buf.n > v12buf.base+1
782 || v12buf.base->n_family != RIP_AF_AUTH))
783 supply_write(&v12buf);
784 if (v2buf.n != v2buf.base
785 && (v2buf.n > v2buf.base+1
786 || v2buf.base->n_family != RIP_AF_AUTH))
787 supply_write(&v2buf);
789 /* If we sent nothing and this is an answer to a query, send
793 && (ws.state & WS_ST_QUERY))
794 supply_write(&v12buf);
798 /* send all of the routing table or just do a flash update
804 static struct sockaddr_in dst = {sizeof(dst), AF_INET, 0, {0}, {0}};
806 static struct sockaddr_in dst = {AF_INET};
808 struct interface *ifp;
809 enum output_type type;
811 struct timeval rtime;
815 intvl_random(&rtime, MIN_WAITTIME, MAX_WAITTIME);
817 timevaladd(&no_flash, &now);
822 trace_act("send %s and inhibit dynamic updates for %.3f sec",
823 flash ? "dynamic update" : "all routes",
824 rtime.tv_sec + ((float)rtime.tv_usec)/1000000.0);
826 LIST_FOREACH(ifp, &ifnet, int_list) {
827 /* Skip interfaces not doing RIP.
828 * Do try broken interfaces to see if they have healed.
830 if (IS_RIP_OUT_OFF(ifp->int_state))
833 /* skip turned off interfaces */
834 if (!iff_up(ifp->int_if_flags))
837 vers = (ifp->int_state & IS_NO_RIPV1_OUT) ? RIPv2 : RIPv1;
839 if (ifp->int_if_flags & IFF_BROADCAST) {
840 /* ordinary, hardware interface */
841 dst.sin_addr.s_addr = ifp->int_brdaddr;
844 && !(ifp->int_state & IS_NO_RIP_MCAST)) {
845 type = OUT_MULTICAST;
847 type = OUT_BROADCAST;
850 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
851 /* point-to-point hardware interface */
852 dst.sin_addr.s_addr = ifp->int_dstaddr;
854 ifp->int_if_flags & IFF_MULTICAST &&
855 !(ifp->int_state & IS_NO_RIP_MCAST)) {
856 type = OUT_MULTICAST;
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, 0, {0}, {0}};
888 static struct sockaddr_in dst = {AF_INET};
890 struct interface *ifp;
892 enum output_type type;
898 memset(&buf, 0, sizeof(buf));
900 LIST_FOREACH(ifp, &ifnet, int_list) {
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_up(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 /* Send a RIPv1 query only if allowed and if we will
921 * listen to RIPv1 routers.
923 if ((ifp->int_state & IS_NO_RIPV1_OUT)
924 || (ifp->int_state & IS_NO_RIPV1_IN)) {
925 buf.rip_vers = RIPv2;
927 buf.rip_vers = RIPv1;
930 if (ifp->int_if_flags & IFF_BROADCAST) {
931 /* ordinary, hardware interface */
932 dst.sin_addr.s_addr = ifp->int_brdaddr;
934 /* Broadcast RIPv1 queries and RIPv2 queries
935 * when the hardware cannot multicast.
937 if (buf.rip_vers == RIPv2
938 && (ifp->int_if_flags & IFF_MULTICAST)
939 && !(ifp->int_state & IS_NO_RIP_MCAST)) {
940 type = OUT_MULTICAST;
942 type = OUT_BROADCAST;
945 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
946 /* point-to-point hardware interface */
947 dst.sin_addr.s_addr = ifp->int_dstaddr;
950 } else if (ifp->int_state & IS_REMOTE) {
951 /* remote interface */
952 dst.sin_addr.s_addr = ifp->int_addr;
956 /* ATM, HIPPI, etc. */
960 ifp->int_query_time = now.tv_sec+SUPPLY_INTERVAL;
961 if (output(type, &dst, ifp, &buf, sizeof(buf)) < 0)