- if (trace)
- printf(">>> time %d >>>\n", timeval);
-again:
- for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) {
- rt = rh->rt_forw;
- for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
-
- /*
- * If the host is indicated to be
- * "hidden" (i.e. it's one we got
- * from the initialization file),
- * don't time out it's entry.
- */
- if ((rt->rt_state & RTS_PASSIVE) == 0)
- rt->rt_timer += TIMER_RATE;
- log("", rt);
-
- /*
- * If the entry should be deleted
- * attempt to do so and reclaim space.
- */
- if (rt->rt_timer >= GARBAGE_TIME ||
- (rt->rt_state & RTS_DELRT)) {
- rt = rt->rt_back;
- rtdelete(rt->rt_forw);
- continue;
- }
-
- /*
- * If we haven't heard from the router
- * in a long time indicate the route is
- * hard to reach.
- */
- if (rt->rt_timer >= EXPIRE_TIME)
- rt->rt_metric = HOPCNT_INFINITY;
-
- /*
- * If a change or addition is to be made
- * and this isn't time to broadcast an
- * update, then broadcast the change.
- */
- if ((rt->rt_state & (RTS_CHGRT|RTS_ADDRT)) &&
- supplier &&
- (timeval + TIMER_RATE) % SUPPLY_INTERVAL)
- broadcast(rt);
-
- if (rt->rt_state & RTS_CHGRT) {
- struct rtentry oldroute;
-
- oldroute = rt->rt_rt;
- rt->rt_router = rt->rt_newrouter;
- if (ioctl(s, SIOCADDRT, (char *)&rt->rt_rt) < 0)
- perror("SIOCADDRT");
- if (ioctl(s, SIOCDELRT, (char *)&oldroute) < 0)
- perror("SIOCDELRT");
- rt->rt_state &= ~RTS_CHGRT;
- }
- if (rt->rt_state & RTS_ADDRT) {
- if (ioctl(s, SIOCADDRT, (char *)&rt->rt_rt) < 0)
- perror("SIOCADDRT");
- rt->rt_state &= ~RTS_ADDRT;
- }
- }
- }
- if (doinghost) {
- doinghost = 0;
- base = nethash;
- goto again;
- }
- timeval += TIMER_RATE;
- if (lookforinterfaces && (timeval % CHECK_INTERVAL) == 0)
- getinterfaces();
- if (supplier && (timeval % SUPPLY_INTERVAL) == 0)
- supplyall();
- if (trace)
- printf("<<< time %d <<<\n", timeval);
- alarm(TIMER_RATE);