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
36 static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
38 static const char rcsid[] =
48 /* walk the tree of routes with this for output
51 struct sockaddr_in to;
56 struct interface *ifp; /* usually output interface */
58 char metric; /* adjust metrics by interface */
62 #define WS_ST_FLASH 0x001 /* send only changed routes */
63 #define WS_ST_RIP2_ALL 0x002 /* send full featured RIPv2 */
64 #define WS_ST_AG 0x004 /* ok to aggregate subnets */
65 #define WS_ST_SUPER_AG 0x008 /* ok to aggregate networks */
66 #define WS_ST_SUB_AG 0x010 /* aggregate subnets in odd case */
67 #define WS_ST_QUERY 0x020 /* responding to a query */
68 #define WS_ST_TO_ON_NET 0x040 /* sending onto one of our nets */
69 #define WS_ST_DEFAULT 0x080 /* faking a default */
72 /* A buffer for what can be heard by both RIPv1 and RIPv2 listeners */
74 union pkt_buf ripv12_buf;
76 /* Another for only RIPv2 listeners */
78 union pkt_buf rip_v2_buf;
85 ripv12_buf.rip.rip_cmd = RIPCMD_RESPONSE;
86 v12buf.buf = &ripv12_buf.rip;
87 v12buf.base = &v12buf.buf->rip_nets[0];
89 rip_v2_buf.rip.rip_cmd = RIPCMD_RESPONSE;
90 rip_v2_buf.rip.rip_vers = RIPv2;
91 v2buf.buf = &rip_v2_buf.rip;
92 v2buf.base = &v2buf.buf->rip_nets[0];
96 /* Send the contents of the global buffer via the non-multicast socket
98 int /* <0 on failure */
99 output(enum output_type type,
100 struct sockaddr_in *dst, /* send to here */
101 struct interface *ifp,
103 int size) /* this many bytes */
105 struct sockaddr_in sin;
114 if (sin.sin_port == 0)
115 sin.sin_port = htons(RIP_PORT);
117 if (sin.sin_len == 0)
118 sin.sin_len = sizeof(sin);
126 msg = "Answer Query";
128 soc = ifp->int_rip_sock;
133 soc = ifp->int_rip_sock;
134 flags = MSG_DONTROUTE;
137 if (ifp->int_if_flags & IFF_POINTOPOINT) {
142 flags = MSG_DONTROUTE;
145 if (ifp->int_if_flags & IFF_POINTOPOINT) {
146 msg = "Send pt-to-pt";
147 } else if (ifp->int_state & IS_DUP) {
148 trace_act("abort multicast output via %s"
149 " with duplicate address",
154 if (rip_sock_mcast != ifp) {
156 /* Do not specify the primary interface
157 * explicitly if we have the multicast
158 * point-to-point kernel bug, since the
159 * kernel will do the wrong thing if the
160 * local address of a point-to-point link
161 * is the same as the address of an ordinary
164 if (ifp->int_addr == myaddr) {
168 tgt_mcast = ifp->int_addr;
169 if (0 > setsockopt(rip_sock,
170 IPPROTO_IP, IP_MULTICAST_IF,
172 sizeof(tgt_mcast))) {
174 LOGERR("setsockopt(rip_sock,"
180 rip_sock_mcast = ifp;
182 sin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP);
186 case NO_OUT_MULTICAST:
195 trace_rip(msg, "to", &sin, ifp, buf, size);
197 res = sendto(soc, buf, size, flags,
198 (struct sockaddr *)&sin, sizeof(sin));
200 && (ifp == 0 || !(ifp->int_state & IS_BROKE))) {
202 msglog("%s sendto(%s%s%s.%d): %s", msg,
203 ifp != 0 ? ifp->int_name : "",
204 ifp != 0 ? ", " : "",
205 inet_ntoa(sin.sin_addr),
215 /* Find the first key for a packet to send.
216 * Try for a key that is eligible and has not expired, but settle for
217 * the last key if they have all expired.
218 * If no key is ready yet, give up.
221 find_auth(struct interface *ifp)
223 struct auth *ap, *res;
232 for (i = 0; i < MAX_AUTH_KEYS; i++, ap++) {
233 /* stop looking after the last key */
234 if (ap->type == RIP_AUTH_NONE)
237 /* ignore keys that are not ready yet */
238 if ((u_long)ap->start > (u_long)clk.tv_sec)
241 if ((u_long)ap->end < (u_long)clk.tv_sec) {
242 /* note best expired password as a fall-back */
243 if (res == 0 || (u_long)ap->end > (u_long)res->end)
248 /* note key with the best future */
249 if (res == 0 || (u_long)res->end < (u_long)ap->end)
257 clr_ws_buf(struct ws_buf *wb,
262 wb->lim = wb->base + NETS_LEN;
264 bzero(wb->n, NETS_LEN*sizeof(*wb->n));
266 /* install authentication if appropriate
270 na = (struct netauth*)wb->n;
271 if (ap->type == RIP_AUTH_PW) {
272 na->a_family = RIP_AF_AUTH;
273 na->a_type = RIP_AUTH_PW;
274 bcopy(ap->key, na->au.au_pw, sizeof(na->au.au_pw));
277 } else if (ap->type == RIP_AUTH_MD5) {
278 na->a_family = RIP_AF_AUTH;
279 na->a_type = RIP_AUTH_MD5;
280 na->au.a_md5.md5_keyid = ap->keyid;
281 na->au.a_md5.md5_auth_len = RIP_AUTH_PW_LEN;
282 na->au.a_md5.md5_seqno = clk.tv_sec;
284 wb->lim--; /* make room for trailer */
290 end_md5_auth(struct ws_buf *wb,
293 struct netauth *na, *na2;
297 na = (struct netauth*)wb->base;
298 na2 = (struct netauth*)wb->n;
299 na2->a_family = RIP_AF_AUTH;
301 bcopy(ap->key, na2->au.au_pw, sizeof(na2->au.au_pw));
302 na->au.a_md5.md5_pkt_len = (char *)na2-(char *)(na+1);
304 MD5Update(&md5_ctx, (u_char *)na,
305 (char *)(na2+1) - (char *)na);
306 MD5Final(na2->au.au_pw, &md5_ctx);
314 supply_write(struct ws_buf *wb)
316 /* Output multicast only if legal.
317 * If we would multicast and it would be illegal, then discard the
321 case NO_OUT_MULTICAST:
322 trace_pkt("skip multicast to %s because impossible",
323 naddr_ntoa(ws.to.sin_addr.s_addr));
328 if (ws.a != 0 && ws.a->type == RIP_AUTH_MD5)
329 end_md5_auth(wb,ws.a);
330 if (output(wb->type, &ws.to, ws.ifp, wb->buf,
331 ((char *)wb->n - (char*)wb->buf)) < 0
342 /* put an entry into the packet
345 supply_out(struct ag_info *ag)
348 naddr mask, v1_mask, dst_h, ddst_h = 0;
352 /* Skip this route if doing a flash update and it and the routes
353 * it aggregates have not changed recently.
355 if (ag->ag_seqno < update_seqno
356 && (ws.state & WS_ST_FLASH))
359 /* Skip this route if required by split-horizon.
361 if (ag->ag_state & AGS_SPLIT_HZ)
364 dst_h = ag->ag_dst_h;
366 v1_mask = ripv1_mask_host(htonl(dst_h),
367 (ws.state & WS_ST_TO_ON_NET) ? ws.ifp : 0);
370 /* If we are sending RIPv2 packets that cannot (or must not) be
371 * heard by RIPv1 listeners, do not worry about sub- or supernets.
372 * Subnets (from other networks) can only be sent via multicast.
373 * A pair of subnet routes might have been promoted so that they
374 * are legal to send by RIPv1.
375 * If RIPv1 is off, use the multicast buffer.
377 if ((ws.state & WS_ST_RIP2_ALL)
378 || ((ag->ag_state & AGS_RIPV2) && v1_mask != mask)) {
379 /* use the RIPv2-only buffer */
383 /* use the RIPv1-or-RIPv2 buffer */
386 /* Convert supernet route into corresponding set of network
387 * routes for RIPv1, but leave non-contiguous netmasks
391 && mask + (mask & -mask) == 0) {
392 ddst_h = v1_mask & -v1_mask;
393 i = (v1_mask & ~mask)/ddst_h;
395 if (i > ws.gen_limit) {
396 /* Punt if we would have to generate an
397 * unreasonable number of routes.
400 msglog("sending %s to %s as 1 instead"
402 addrname(htonl(dst_h),mask,1),
403 naddr_ntoa(ws.to.sin_addr.s_addr),
416 wb->n->n_family = RIP_AF_INET;
417 wb->n->n_dst = htonl(dst_h);
418 /* If the route is from router-discovery or we are
419 * shutting down, admit only a bad metric.
421 wb->n->n_metric = ((stopint || ag->ag_metric < 1)
424 HTONL(wb->n->n_metric);
425 /* Any non-zero bits in the supposedly unused RIPv1 fields
426 * cause the old `routed` to ignore the route.
427 * That means the mask and so forth cannot be sent
428 * in the hybrid RIPv1/RIPv2 mode.
430 if (ws.state & WS_ST_RIP2_ALL) {
432 && ((ws.state & WS_ST_QUERY)
433 || (ag->ag_nhop != ws.ifp->int_addr
434 && on_net(ag->ag_nhop,
437 wb->n->n_nhop = ag->ag_nhop;
438 wb->n->n_mask = htonl(mask);
439 wb->n->n_tag = ag->ag_tag;
443 if (++wb->n >= wb->lim)
449 /* supply one route from the table
453 walk_supply(struct radix_node *rn,
456 #define RT ((struct rt_entry *)rn)
462 /* Do not advertise external remote interfaces or passive interfaces.
464 if ((RT->rt_state & RS_IF)
466 && (RT->rt_ifp->int_if_flags & IS_PASSIVE)
467 && !(RT->rt_state & RS_MHOME))
470 /* If being quiet about our ability to forward, then
471 * do not say anything unless responding to a query,
472 * except about our main interface.
474 if (!supplier && !(ws.state & WS_ST_QUERY)
475 && !(RT->rt_state & RS_MHOME))
480 /* do not collide with the fake default route */
481 if (dst == RIP_DEFAULT
482 && (ws.state & WS_ST_DEFAULT))
485 if (RT->rt_state & RS_NET_SYN) {
486 if (RT->rt_state & RS_NET_INT) {
487 /* Do not send manual synthetic network routes
490 if (on_net(ws.to.sin_addr.s_addr,
491 ntohl(dst), RT->rt_mask))
495 /* Do not send automatic synthetic network routes
496 * if they are not needed because no RIPv1 listeners
499 if (ws.state & WS_ST_RIP2_ALL)
502 /* Do not send automatic synthetic network routes to
505 if (on_net(ws.to.sin_addr.s_addr,
506 ntohl(dst), RT->rt_mask))
512 /* Advertise the next hop if this is not a route for one
513 * of our interfaces and the next hop is on the same
514 * network as the target.
516 if (!(RT->rt_state & RS_IF)
517 && RT->rt_gate != myaddr
518 && RT->rt_gate != loopaddr)
524 metric = RT->rt_metric;
527 if (RT->rt_state & RS_MHOME) {
528 /* retain host route of multi-homed servers */
531 } else if (RT_ISHOST(RT)) {
532 /* We should always aggregate the host routes
533 * for the local end of our point-to-point links.
534 * If we are suppressing host routes in general, then do so.
535 * Avoid advertising host routes onto their own network,
536 * where they should be handled by proxy-ARP.
538 if ((RT->rt_state & RS_LOCAL)
540 || (ws.state & WS_ST_SUPER_AG)
541 || on_net(dst, ws.to_net, ws.to_mask))
544 if (ws.state & WS_ST_SUPER_AG)
547 } else if (ws.state & WS_ST_AG) {
548 /* Aggregate network routes, if we are allowed.
552 /* Generate supernets if allowed.
553 * If we can be heard by RIPv1 systems, we will
554 * later convert back to ordinary nets.
555 * This unifies dealing with received supernets.
557 if ((RT->rt_state & RS_SUBNET)
558 || (ws.state & WS_ST_SUPER_AG))
563 /* Do not send RIPv1 advertisements of subnets to other
564 * networks. If possible, multicast them by RIPv2.
566 if ((RT->rt_state & RS_SUBNET)
567 && !(ws.state & WS_ST_RIP2_ALL)
568 && !on_net(dst, ws.to_std_net, ws.to_std_mask)) {
569 ags |= AGS_RIPV2 | AGS_PROMOTE;
570 if (ws.state & WS_ST_SUB_AG)
574 /* Do not send a route back to where it came from, except in
575 * response to a query. This is "split-horizon". That means not
576 * advertising back to the same network and so via the same interface.
578 * We want to suppress routes that might have been fragmented
579 * from this route by a RIPv1 router and sent back to us, and so we
580 * cannot forget this route here. Let the split-horizon route
581 * aggregate (suppress) the fragmented routes and then itself be
584 * Include the routes for both ends of point-to-point interfaces
585 * among those suppressed by split-horizon, since the other side
586 * should knows them as well as we do.
588 if (RT->rt_ifp == ws.ifp && ws.ifp != 0
589 && !(ws.state & WS_ST_QUERY)
590 && (ws.state & WS_ST_TO_ON_NET)
591 && (!(RT->rt_state & RS_IF)
592 || ws.ifp->int_if_flags & IFF_POINTOPOINT)) {
593 /* If we do not mark the route with AGS_SPLIT_HZ here,
594 * it will be poisoned-reverse, or advertised back toward
595 * its source with an infinite metric. If we have recently
596 * advertised the route with a better metric than we now
597 * have, then we should poison-reverse the route before
598 * suppressing it for split-horizon.
600 * In almost all cases, if there is no spare for the route
601 * then it is either old and dead or a brand new route.
602 * If it is brand new, there is no need for poison-reverse.
603 * If it is old and dead, it is already poisoned.
605 if (RT->rt_poison_time < now_expire
606 || RT->rt_poison_metric >= metric
607 || RT->rt_spares[1].rts_gate == 0) {
609 ags &= ~(AGS_PROMOTE | AGS_SUPPRESS);
611 metric = HOPCNT_INFINITY;
614 /* Adjust the outgoing metric by the cost of the link.
616 pref = metric + ws.metric;
617 if (pref < HOPCNT_INFINITY) {
618 /* Keep track of the best metric with which the
619 * route has been advertised recently.
621 if (RT->rt_poison_metric >= metric
622 || RT->rt_poison_time < now_expire) {
623 RT->rt_poison_time = now.tv_sec;
624 RT->rt_poison_metric = metric;
629 /* Do not advertise stable routes that will be ignored,
630 * unless we are answering a query.
631 * If the route recently was advertised with a metric that
632 * would have been less than infinity through this interface,
633 * we need to continue to advertise it in order to poison it.
635 pref = RT->rt_poison_metric + ws.metric;
636 if (!(ws.state & WS_ST_QUERY)
637 && (pref >= HOPCNT_INFINITY
638 || RT->rt_poison_time < now_garbage))
641 metric = HOPCNT_INFINITY;
644 ag_check(dst, RT->rt_mask, 0, nhop, metric, pref,
645 RT->rt_seqno, RT->rt_tag, ags, supply_out);
651 /* Supply dst with the contents of the routing tables.
652 * If this won't fit in one packet, chop it up into several.
655 supply(struct sockaddr_in *dst,
656 struct interface *ifp, /* output interface */
657 enum output_type type,
658 int flash, /* 1=flash update */
659 int vers, /* RIP version */
660 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;
690 if (type == OUT_QUERY)
691 ws.state |= WS_ST_QUERY;
693 if ((ws.ifp = ifp) == 0) {
696 /* Adjust the advertised metric by the outgoing interface
699 ws.metric = ifp->int_metric+1;
702 ripv12_buf.rip.rip_vers = vers;
706 v2buf.type = ((ifp != 0 && (ifp->int_if_flags & IFF_MULTICAST))
709 v12buf.type = OUT_BROADCAST;
712 v2buf.type = ((ifp != 0 && (ifp->int_if_flags & IFF_MULTICAST))
715 v12buf.type = OUT_BROADCAST;
719 v2buf.type = (vers == RIPv2) ? type : NO_OUT_RIPV2;
729 /* full RIPv2 only if cannot be heard by RIPv1 listeners */
730 if (type != OUT_BROADCAST)
731 ws.state |= WS_ST_RIP2_ALL;
732 if (!(ws.state & WS_ST_TO_ON_NET)) {
733 ws.state |= (WS_ST_AG | WS_ST_SUPER_AG);
734 } else if (ifp == 0 || !(ifp->int_state & IS_NO_AG)) {
735 ws.state |= WS_ST_AG;
736 if (type != OUT_BROADCAST
737 && (ifp == 0 || !(ifp->int_state&IS_NO_SUPER_AG)))
738 ws.state |= WS_ST_SUPER_AG;
741 } else if (ifp == 0 || !(ifp->int_state & IS_NO_AG)) {
742 ws.state |= WS_ST_SUB_AG;
745 ws.a = (vers == RIPv2) ? find_auth(ifp) : 0;
746 if (!passwd_ok && ws.a != 0 && ws.a->type == RIP_AUTH_PW)
748 clr_ws_buf(&v12buf,ws.a);
749 clr_ws_buf(&v2buf,ws.a);
751 /* Fake a default route if asked and if there is not already
752 * a better, real default route.
754 if (supplier && (def_metric = ifp->int_d_metric) != 0) {
755 if (0 == (rt = rtget(RIP_DEFAULT, 0))
756 || rt->rt_metric+ws.metric >= def_metric) {
757 ws.state |= WS_ST_DEFAULT;
758 ag_check(0, 0, 0, 0, def_metric, def_metric,
759 0, 0, 0, supply_out);
761 def_metric = rt->rt_metric+ws.metric;
764 /* If both RIPv2 and the poor-man's router discovery
765 * kludge are on, arrange to advertise an extra
766 * default route via RIPv1.
768 if ((ws.state & WS_ST_RIP2_ALL)
769 && (ifp->int_state & IS_PM_RDISC)) {
770 ripv12_buf.rip.rip_vers = RIPv1;
771 v12buf.n->n_family = RIP_AF_INET;
772 v12buf.n->n_dst = htonl(RIP_DEFAULT);
773 v12buf.n->n_metric = htonl(def_metric);
778 (void)rn_walktree(rhead, walk_supply, 0);
779 ag_flush(0,0,supply_out);
781 /* Flush the packet buffers, provided they are not empty and
782 * do not contain only the password.
784 if (v12buf.n != v12buf.base
785 && (v12buf.n > v12buf.base+1
786 || v12buf.base->n_family != RIP_AF_AUTH))
787 supply_write(&v12buf);
788 if (v2buf.n != v2buf.base
789 && (v2buf.n > v2buf.base+1
790 || v2buf.base->n_family != RIP_AF_AUTH))
791 supply_write(&v2buf);
793 /* If we sent nothing and this is an answer to a query, send
797 && (ws.state & WS_ST_QUERY))
798 supply_write(&v12buf);
802 /* send all of the routing table or just do a flash update
808 static struct sockaddr_in dst = {sizeof(dst), AF_INET};
810 static struct sockaddr_in dst = {AF_INET};
812 struct interface *ifp;
813 enum output_type type;
815 struct timeval rtime;
819 intvl_random(&rtime, MIN_WAITTIME, MAX_WAITTIME);
821 timevaladd(&no_flash, &now);
826 trace_act("send %s and inhibit dynamic updates for %.3f sec",
827 flash ? "dynamic update" : "all routes",
828 rtime.tv_sec + ((float)rtime.tv_usec)/1000000.0);
830 for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
831 /* Skip interfaces not doing RIP.
832 * Do try broken interfaces to see if they have healed.
834 if (IS_RIP_OUT_OFF(ifp->int_state))
837 /* skip turned off interfaces */
838 if (!iff_alive(ifp->int_if_flags))
841 vers = (ifp->int_state & IS_NO_RIPV1_OUT) ? RIPv2 : RIPv1;
843 if (ifp->int_if_flags & IFF_BROADCAST) {
844 /* ordinary, hardware interface */
845 dst.sin_addr.s_addr = ifp->int_brdaddr;
847 /* If RIPv1 is not turned off, then broadcast so
848 * that RIPv1 listeners can hear.
851 && (ifp->int_state & IS_NO_RIPV1_OUT)) {
852 type = OUT_MULTICAST;
854 type = OUT_BROADCAST;
857 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
858 /* point-to-point hardware interface */
859 dst.sin_addr.s_addr = ifp->int_dstaddr;
862 } else if (ifp->int_state & IS_REMOTE) {
863 /* remote interface */
864 dst.sin_addr.s_addr = ifp->int_addr;
868 /* ATM, HIPPI, etc. */
872 supply(&dst, ifp, type, flash, vers, 1);
875 update_seqno++; /* all routes are up to date */
880 * Do it only once to an interface, and not even after the interface
881 * was broken and recovered.
887 static struct sockaddr_in dst = {sizeof(dst), AF_INET};
889 static struct sockaddr_in dst = {AF_INET};
891 struct interface *ifp;
893 enum output_type type;
899 bzero(&buf, sizeof(buf));
901 for (ifp = ifnet; ifp; ifp = ifp->int_next) {
902 /* Skip interfaces those already queried.
903 * Do not ask via interfaces through which we don't
904 * accept input. Do not ask via interfaces that cannot
906 * Do try broken interfaces to see if they have healed.
908 if (IS_RIP_IN_OFF(ifp->int_state)
909 || ifp->int_query_time != NEVER)
912 /* skip turned off interfaces */
913 if (!iff_alive(ifp->int_if_flags))
916 buf.rip_vers = (ifp->int_state&IS_NO_RIPV1_OUT) ? RIPv2:RIPv1;
917 buf.rip_cmd = RIPCMD_REQUEST;
918 buf.rip_nets[0].n_family = RIP_AF_UNSPEC;
919 buf.rip_nets[0].n_metric = htonl(HOPCNT_INFINITY);
921 if (ifp->int_if_flags & IFF_BROADCAST) {
922 /* ordinary, hardware interface */
923 dst.sin_addr.s_addr = ifp->int_brdaddr;
924 /* if RIPv1 is not turned off, then broadcast so
925 * that RIPv1 listeners can hear.
927 if (buf.rip_vers == RIPv2
928 && (ifp->int_state & IS_NO_RIPV1_OUT)) {
929 type = OUT_MULTICAST;
931 type = OUT_BROADCAST;
934 } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
935 /* point-to-point hardware interface */
936 dst.sin_addr.s_addr = ifp->int_dstaddr;
939 } else if (ifp->int_state & IS_REMOTE) {
940 /* remote interface */
941 dst.sin_addr.s_addr = ifp->int_addr;
945 /* ATM, HIPPI, etc. */
949 ifp->int_query_time = now.tv_sec+SUPPLY_INTERVAL;
950 if (output(type, &dst, ifp, &buf, sizeof(buf)) < 0)