memcpy(&gateway.s_addr, p, 4);
p += 4;
- /* A host route is normally set by having the
+ /* An on-link host route is normally set by having the
* gateway match the destination or assigned address */
if (gateway.s_addr == dest.s_addr ||
(gateway.s_addr == bootp->yiaddr ||
{
gateway.s_addr = INADDR_ANY;
netmask.s_addr = INADDR_BROADCAST;
- rt->rt_flags = RTF_HOST;
}
+ if (netmask.s_addr == INADDR_BROADCAST)
+ rt->rt_flags = RTF_HOST;
sa_in_init(&rt->rt_dest, &dest);
sa_in_init(&rt->rt_netmask, &netmask);
sa_in_init(&rt->rt_gateway, &gateway);
- /* If CIDR is 32 then it's a host route. */
- if (cidr == 32)
- rt->rt_flags = RTF_HOST;
-
TAILQ_INSERT_TAIL(routes, rt, rt_next);
n++;
}
if ((rt = rt_new(ifp)) == NULL)
return -1;
- /* A host route is normally set by having the
+ /* A on-link host route is normally set by having the
* gateway match the destination or assigned address */
if (gateway.s_addr == dest.s_addr ||
(gateway.s_addr == bootp->yiaddr ||
{
gateway.s_addr = INADDR_ANY;
netmask.s_addr = INADDR_BROADCAST;
- rt->rt_flags = RTF_HOST;
} else
netmask.s_addr = route_netmask(dest.s_addr);
+ if (netmask.s_addr == INADDR_BROADCAST)
+ rt->rt_flags = RTF_HOST;
+
sa_in_init(&rt->rt_dest, &dest);
sa_in_init(&rt->rt_netmask, &netmask);
sa_in_init(&rt->rt_gateway, &gateway);
+
TAILQ_INSERT_TAIL(routes, rt, rt_next);
n++;
}