/*
 * Lookup or enter a new address in arptab.
 */
static struct llinfo_arp *
arplookup(addr, create, proxy)
        u_long addr;
        int create, proxy;
{
        register struct rtentry *rt;
        static struct sockaddr_inarp sin = {sizeof(sin), AF_INET };
        const char *why = 0;

        sin.sin_addr.s_addr = addr;
        sin.sin_other = proxy ? SIN_PROXY : 0;
        rt = rtalloc1((struct sockaddr *)&sin, create, 0UL);
        if (rt == 0)
                return (0);
        rt->rt_refcnt--;

        if (rt->rt_flags & RTF_GATEWAY) /* XXX

How can we be sure that rt won't be freeed by
any other kernel thread now ??

 XXX */
                why = "host is not on local network";
        else if ((rt->rt_flags & RTF_LLINFO) == 0)
                why = "could not allocate llinfo";
        else if (rt->rt_gateway->sa_family != AF_LINK)
                why = "gateway route is not ours";

        if (why && create) {
                log(LOG_DEBUG, "arplookup %s failed: %s\n",
                    inet_ntoa(sin.sin_addr), why);
                return 0;
        } else if (why) {
                return 0;
        }
        return ((struct llinfo_arp *)rt->rt_llinfo);
}

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to