sbin/routed/rdisc.c
/* age discovered routes and find the best one
 */
age discovered routes and find the best one
age discovered routes and find the best one
void
rdisc_age(naddr bad_gate)
{
	time_t sec;
	struct dr *drp;
	if (supplier) {
		if (cur_drp != NULL)
			rdisc_sort();
		rdisc_adv();
		return;
	}
	if (bad_gate != 0) {
		for (drp = drs; drp < &drs[MAX_ADS]; drp++) {
			if (drp->dr_ts == 0)
				continue;
			if (drp->dr_gate == bad_gate) {
				sec = (now.tv_sec - drp->dr_life
				       + SUPPLY_INTERVAL);
				if (drp->dr_ts > sec) {
					trace_act("age 0.0.0.0 --> %s via %s",
						  naddr_ntoa(drp->dr_gate),
						  drp->dr_ifp->int_name);
					drp->dr_ts = sec;
				}
				break;
			}
		}
	}
	rdisc_sol();
	rdisc_sort();
	if (rip_sock < 0 && bad_gate == 0)
		age(0);
}
void rdisc_age ( naddr bad_gate ) { time_t sec ; struct dr * drp ; if ( supplier ) { if ( cur_drp != NULL ) rdisc_sort ( ) ; rdisc_adv ( ) ; return ; } if ( bad_gate != 0 ) { for ( drp = drs ; drp < & drs [ MAX_ADS ] ; drp ++ ) { if ( drp -> dr_ts == 0 ) continue ; if ( drp -> dr_gate == bad_gate ) { sec = ( now . tv_sec - drp -> dr_life + SUPPLY_INTERVAL ) ; if ( drp -> dr_ts > sec ) { trace_act ( " " , naddr_ntoa ( drp -> dr_gate ) , drp -> dr_ifp -> int_name ) ; drp -> dr_ts = sec ; } break ; } } } rdisc_sol ( ) ; rdisc_sort ( ) ; if ( rip_sock < 0 && bad_gate == 0 ) age ( 0 ) ; }
age discovered routes and find the best one
age discovered routes and find the best one
/* If only advertising, then do only that. */ /* If switching from client to server, get rid of old
		 * default routes.
		 */ /* If we are being told about a bad router,
	 * then age the discovered default route, and if there is
	 * no alternative, solicit a replacement.
	 */ /* Look for the bad discovered default route.
		 * Age it and note its interface.
		 */ /* When we find the bad router, then age the route
			 * to at most SUPPLY_INTERVAL.
			 * This is contrary to RFC 1256, but defends against
			 * black holes.
			 */ /* Delete old redirected routes to keep the kernel table small,
	 * and to prevent black holes.  Check that the kernel table
	 * matches the daemon table (i.e. has the default route).
	 * But only if RIP is not running and we are not dealing with
	 * a bad gateway, since otherwise age() will be called.
	 */