if_ether.c revision 7090
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
20 *
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
31 * SUCH DAMAGE.
32 *
33 *	@(#)if_ether.c	8.1 (Berkeley) 6/10/93
34 * $Id: if_ether.c,v 1.12 1995/03/16 17:32:26 wollman Exp $
35 */
36
37/*
38 * Ethernet address resolution protocol.
39 * TODO:
40 *	add "inuse/lock" bit (or ref. count) along with valid bit
41 */
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/malloc.h>
46#include <sys/mbuf.h>
47#include <sys/socket.h>
48#include <sys/time.h>
49#include <sys/kernel.h>
50#include <sys/errno.h>
51#include <sys/ioctl.h>
52#include <sys/syslog.h>
53
54#include <net/if.h>
55#include <net/if_dl.h>
56#include <net/route.h>
57
58#include <netinet/in.h>
59#include <netinet/in_systm.h>
60#include <netinet/in_var.h>
61#include <netinet/ip.h>
62#include <netinet/if_ether.h>
63
64#define SIN(s) ((struct sockaddr_in *)s)
65#define SDL(s) ((struct sockaddr_dl *)s)
66#define SRP(s) ((struct sockaddr_inarp *)s)
67
68/*
69 * ARP trailer negotiation.  Trailer protocol is not IP specific,
70 * but ARP request/response use IP addresses.
71 */
72#define ETHERTYPE_IPTRAILERS ETHERTYPE_TRAIL
73
74
75/* timer values */
76int	arpt_prune = (5*60*1);	/* walk list every 5 minutes */
77int	arpt_keep = (20*60);	/* once resolved, good for 20 more minutes */
78int	arpt_down = 20;		/* once declared down, don't send for 20 secs */
79#define	rt_expire rt_rmx.rmx_expire
80
81static	void arprequest __P((struct arpcom *, u_long *, u_long *, u_char *));
82static	void arptfree __P((struct llinfo_arp *));
83static	void arptimer __P((void *));
84static	struct llinfo_arp *arplookup __P((u_long, int, int));
85static	void in_arpinput __P((struct mbuf *));
86
87struct	llinfo_arp llinfo_arp = {&llinfo_arp, &llinfo_arp};
88struct	ifqueue arpintrq = {0, 0, 0, 50};
89int	arp_inuse, arp_allocated, arp_intimer;
90int	arp_maxtries = 5;
91int	useloopback = 1;	/* use loopback interface for local traffic */
92int	arpinit_done = 0;
93
94#ifdef	ARP_PROXYALL
95int	arp_proxyall = 1;
96#endif
97
98/*
99 * Timeout routine.  Age arp_tab entries periodically.
100 */
101/* ARGSUSED */
102static void
103arptimer(ignored_arg)
104	void *ignored_arg;
105{
106	int s = splnet();
107	register struct llinfo_arp *la = llinfo_arp.la_next;
108
109	timeout(arptimer, (caddr_t)0, arpt_prune * hz);
110	while (la != &llinfo_arp) {
111		register struct rtentry *rt = la->la_rt;
112		la = la->la_next;
113		if (rt->rt_expire && rt->rt_expire <= time.tv_sec)
114			arptfree(la->la_prev); /* timer has expired, clear */
115	}
116	splx(s);
117}
118
119/*
120 * Parallel to llc_rtrequest.
121 */
122static void
123arp_rtrequest(req, rt, sa)
124	int req;
125	register struct rtentry *rt;
126	struct sockaddr *sa;
127{
128	register struct sockaddr *gate = rt->rt_gateway;
129	register struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo;
130	static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
131
132	if (!arpinit_done) {
133		arpinit_done = 1;
134		timeout(arptimer, (caddr_t)0, hz);
135	}
136	if (rt->rt_flags & RTF_GATEWAY)
137		return;
138	switch (req) {
139
140	case RTM_ADD:
141		/*
142		 * XXX: If this is a manually added route to interface
143		 * such as older version of routed or gated might provide,
144		 * restore cloning bit.
145		 */
146		if ((rt->rt_flags & RTF_HOST) == 0 &&
147		    SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
148			rt->rt_flags |= RTF_CLONING;
149#if 0
150		/*
151		 * Actually, all IP gateway routes should have the cloning
152		 * flag turned on.  We can't do this yet because the expiration
153		 * stuff isn't working yet.
154		 */
155		if (rt->rt_flags & RTF_GATEWAY) {
156			rt->rt_flags |= RTF_CLONING;
157		}
158#endif
159		if (rt->rt_flags & RTF_CLONING) {
160			/*
161			 * Case 1: This route should come from a route to iface.
162			 */
163			rt_setgate(rt, rt_key(rt),
164					(struct sockaddr *)&null_sdl);
165			gate = rt->rt_gateway;
166			SDL(gate)->sdl_type = rt->rt_ifp->if_type;
167			SDL(gate)->sdl_index = rt->rt_ifp->if_index;
168			rt->rt_expire = time.tv_sec;
169			break;
170		}
171		/* Announce a new entry if requested. */
172		if (rt->rt_flags & RTF_ANNOUNCE)
173			arprequest((struct arpcom *)rt->rt_ifp,
174			    &SIN(rt_key(rt))->sin_addr.s_addr,
175			    &SIN(rt_key(rt))->sin_addr.s_addr,
176			    (u_char *)LLADDR(SDL(gate)));
177		/*FALLTHROUGH*/
178	case RTM_RESOLVE:
179		if (gate->sa_family != AF_LINK ||
180		    gate->sa_len < sizeof(null_sdl)) {
181			log(LOG_DEBUG, "arp_rtrequest: bad gateway value\n");
182			break;
183		}
184		SDL(gate)->sdl_type = rt->rt_ifp->if_type;
185		SDL(gate)->sdl_index = rt->rt_ifp->if_index;
186		if (la != 0)
187			break; /* This happens on a route change */
188		/*
189		 * Case 2:  This route may come from cloning, or a manual route
190		 * add with a LL address.
191		 */
192		R_Malloc(la, struct llinfo_arp *, sizeof(*la));
193		rt->rt_llinfo = (caddr_t)la;
194		if (la == 0) {
195			log(LOG_DEBUG, "arp_rtrequest: malloc failed\n");
196			break;
197		}
198		arp_inuse++, arp_allocated++;
199		Bzero(la, sizeof(*la));
200		la->la_rt = rt;
201		rt->rt_flags |= RTF_LLINFO;
202		insque(la, &llinfo_arp);
203		if (SIN(rt_key(rt))->sin_addr.s_addr ==
204		    (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
205		    /*
206		     * This test used to be
207		     *	if (loif.if_flags & IFF_UP)
208		     * It allowed local traffic to be forced
209		     * through the hardware by configuring the loopback down.
210		     * However, it causes problems during network configuration
211		     * for boards that can't receive packets they send.
212		     * It is now necessary to clear "useloopback" and remove
213		     * the route to force traffic out to the hardware.
214		     */
215			rt->rt_expire = 0;
216			Bcopy(((struct arpcom *)rt->rt_ifp)->ac_enaddr,
217				LLADDR(SDL(gate)), SDL(gate)->sdl_alen = 6);
218			if (useloopback)
219				rt->rt_ifp = &loif;
220
221		}
222		break;
223
224	case RTM_DELETE:
225		if (la == 0)
226			break;
227		arp_inuse--;
228		remque(la);
229		rt->rt_llinfo = 0;
230		rt->rt_flags &= ~RTF_LLINFO;
231		if (la->la_hold)
232			m_freem(la->la_hold);
233		Free((caddr_t)la);
234	}
235}
236
237/*
238 * Broadcast an ARP packet, asking who has addr on interface ac.
239 */
240void
241arpwhohas(ac, addr)
242	register struct arpcom *ac;
243	register struct in_addr *addr;
244{
245	arprequest(ac, &ac->ac_ipaddr.s_addr, &addr->s_addr, ac->ac_enaddr);
246}
247
248/*
249 * Broadcast an ARP request. Caller specifies:
250 *	- arp header source ip address
251 *	- arp header target ip address
252 *	- arp header source ethernet address
253 */
254static void
255arprequest(ac, sip, tip, enaddr)
256	register struct arpcom *ac;
257	register u_long *sip, *tip;
258	register u_char *enaddr;
259{
260	register struct mbuf *m;
261	register struct ether_header *eh;
262	register struct ether_arp *ea;
263	struct sockaddr sa;
264
265	if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
266		return;
267	m->m_len = sizeof(*ea);
268	m->m_pkthdr.len = sizeof(*ea);
269	MH_ALIGN(m, sizeof(*ea));
270	ea = mtod(m, struct ether_arp *);
271	eh = (struct ether_header *)sa.sa_data;
272	bzero((caddr_t)ea, sizeof (*ea));
273	bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
274	    sizeof(eh->ether_dhost));
275	eh->ether_type = ETHERTYPE_ARP;		/* if_output will swap */
276	ea->arp_hrd = htons(ARPHRD_ETHER);
277	ea->arp_pro = htons(ETHERTYPE_IP);
278	ea->arp_hln = sizeof(ea->arp_sha);	/* hardware address length */
279	ea->arp_pln = sizeof(ea->arp_spa);	/* protocol address length */
280	ea->arp_op = htons(ARPOP_REQUEST);
281	bcopy((caddr_t)enaddr, (caddr_t)ea->arp_sha, sizeof(ea->arp_sha));
282	bcopy((caddr_t)sip, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
283	bcopy((caddr_t)tip, (caddr_t)ea->arp_tpa, sizeof(ea->arp_tpa));
284	sa.sa_family = AF_UNSPEC;
285	sa.sa_len = sizeof(sa);
286	(*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
287}
288
289/*
290 * Resolve an IP address into an ethernet address.  If success,
291 * desten is filled in.  If there is no entry in arptab,
292 * set one up and broadcast a request for the IP address.
293 * Hold onto this mbuf and resend it once the address
294 * is finally resolved.  A return value of 1 indicates
295 * that desten has been filled in and the packet should be sent
296 * normally; a 0 return indicates that the packet has been
297 * taken over here, either now or for later transmission.
298 */
299int
300arpresolve(ac, rt, m, dst, desten, rt0)
301	register struct arpcom *ac;
302	register struct rtentry *rt;
303	struct mbuf *m;
304	register struct sockaddr *dst;
305	register u_char *desten;
306	struct rtentry *rt0;
307{
308	register struct llinfo_arp *la;
309	struct sockaddr_dl *sdl;
310
311	if (m->m_flags & M_BCAST) {	/* broadcast */
312		bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
313		    sizeof(etherbroadcastaddr));
314		return (1);
315	}
316	if (m->m_flags & M_MCAST) {	/* multicast */
317		ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten);
318		return(1);
319	}
320	if (rt)
321		la = (struct llinfo_arp *)rt->rt_llinfo;
322	else {
323		la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0);
324		if (la)
325			rt = la->la_rt;
326	}
327	if (la == 0 || rt == 0) {
328		log(LOG_DEBUG, "arpresolve: can't allocate llinfo\n");
329		m_freem(m);
330		return (0);
331	}
332	sdl = SDL(rt->rt_gateway);
333	/*
334	 * Check the address family and length is valid, the address
335	 * is resolved; otherwise, try to resolve.
336	 */
337	if ((rt->rt_expire == 0 || rt->rt_expire > time.tv_sec) &&
338	    sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
339		bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
340		return 1;
341	}
342	/*
343	 * There is an arptab entry, but no ethernet address
344	 * response yet.  Replace the held mbuf with this
345	 * latest one.
346	 */
347	if (la->la_hold)
348		m_freem(la->la_hold);
349	la->la_hold = m;
350	if (rt->rt_expire) {
351		rt->rt_flags &= ~RTF_REJECT;
352		if (la->la_asked == 0 || rt->rt_expire != time.tv_sec) {
353			rt->rt_expire = time.tv_sec;
354			if (la->la_asked++ < arp_maxtries)
355				arpwhohas(ac, &(SIN(dst)->sin_addr));
356			else {
357				rt->rt_flags |= RTF_REJECT;
358				rt->rt_expire += arpt_down;
359				la->la_asked = 0;
360			}
361
362		}
363	}
364	return (0);
365}
366
367/*
368 * Common length and type checks are done here,
369 * then the protocol-specific routine is called.
370 */
371void
372arpintr()
373{
374	register struct mbuf *m;
375	register struct arphdr *ar;
376	int s;
377
378	while (arpintrq.ifq_head) {
379		s = splimp();
380		IF_DEQUEUE(&arpintrq, m);
381		splx(s);
382		if (m == 0 || (m->m_flags & M_PKTHDR) == 0)
383			panic("arpintr");
384		if (m->m_len >= sizeof(struct arphdr) &&
385		    (ar = mtod(m, struct arphdr *)) &&
386		    ntohs(ar->ar_hrd) == ARPHRD_ETHER &&
387		    m->m_len >=
388		      sizeof(struct arphdr) + 2 * ar->ar_hln + 2 * ar->ar_pln)
389
390			    switch (ntohs(ar->ar_pro)) {
391
392			    case ETHERTYPE_IP:
393			    case ETHERTYPE_IPTRAILERS:
394				    in_arpinput(m);
395				    continue;
396			    }
397		m_freem(m);
398	}
399}
400
401/*
402 * ARP for Internet protocols on 10 Mb/s Ethernet.
403 * Algorithm is that given in RFC 826.
404 * In addition, a sanity check is performed on the sender
405 * protocol address, to catch impersonators.
406 * We no longer handle negotiations for use of trailer protocol:
407 * Formerly, ARP replied for protocol type ETHERTYPE_TRAIL sent
408 * along with IP replies if we wanted trailers sent to us,
409 * and also sent them in response to IP replies.
410 * This allowed either end to announce the desire to receive
411 * trailer packets.
412 * We no longer reply to requests for ETHERTYPE_TRAIL protocol either,
413 * but formerly didn't normally send requests.
414 */
415static void
416in_arpinput(m)
417	struct mbuf *m;
418{
419	register struct ether_arp *ea;
420	register struct arpcom *ac = (struct arpcom *)m->m_pkthdr.rcvif;
421	struct ether_header *eh;
422	register struct llinfo_arp *la = 0;
423	register struct rtentry *rt;
424	struct in_ifaddr *ia, *maybe_ia = 0;
425	struct sockaddr_dl *sdl;
426	struct sockaddr sa;
427	struct in_addr isaddr, itaddr, myaddr;
428	int op;
429
430	ea = mtod(m, struct ether_arp *);
431	op = ntohs(ea->arp_op);
432	bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
433	bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
434	for (ia = in_ifaddr; ia; ia = ia->ia_next)
435		if (ia->ia_ifp == &ac->ac_if) {
436			maybe_ia = ia;
437			if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) ||
438			     (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr))
439				break;
440		}
441	if (maybe_ia == 0)
442		goto out;
443	myaddr = ia ? ia->ia_addr.sin_addr : maybe_ia->ia_addr.sin_addr;
444	if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)ac->ac_enaddr,
445	    sizeof (ea->arp_sha)))
446		goto out;	/* it's from me, ignore it. */
447	if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
448	    sizeof (ea->arp_sha))) {
449		log(LOG_ERR,
450		    "arp: ether address is broadcast for IP address %s!\n",
451		    inet_ntoa(isaddr));
452		goto out;
453	}
454	if (isaddr.s_addr == myaddr.s_addr) {
455		log(LOG_ERR,
456		   "duplicate IP address %s! sent from ethernet address: %s\n",
457		   inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
458		itaddr = myaddr;
459		goto reply;
460	}
461	la = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0);
462	if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) {
463		if (sdl->sdl_alen &&
464		    bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen))
465			log(LOG_INFO, "arp info overwritten for %s by %s\n",
466			    inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
467		bcopy((caddr_t)ea->arp_sha, LLADDR(sdl),
468			    sdl->sdl_alen = sizeof(ea->arp_sha));
469		if (rt->rt_expire)
470			rt->rt_expire = time.tv_sec + arpt_keep;
471		rt->rt_flags &= ~RTF_REJECT;
472		la->la_asked = 0;
473		if (la->la_hold) {
474			(*ac->ac_if.if_output)(&ac->ac_if, la->la_hold,
475				rt_key(rt), rt);
476			la->la_hold = 0;
477		}
478	}
479reply:
480	if (op != ARPOP_REQUEST) {
481	out:
482		m_freem(m);
483		return;
484	}
485	if (itaddr.s_addr == myaddr.s_addr) {
486		/* I am the target */
487		bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
488		    sizeof(ea->arp_sha));
489		bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
490		    sizeof(ea->arp_sha));
491	} else {
492		la = arplookup(itaddr.s_addr, 0, SIN_PROXY);
493		if (la == NULL) {
494#ifdef ARP_PROXYALL
495			struct sockaddr_in sin;
496
497			if(!arp_proxyall) goto out;
498
499			bzero(&sin, sizeof sin);
500			sin.sin_family = AF_INET;
501			sin.sin_len = sizeof sin;
502			sin.sin_addr = itaddr;
503
504			rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL);
505			if( !rt )
506				goto out;
507			/*
508			 * Don't send proxies for nodes on the same interface
509			 * as this one came out of, or we'll get into a fight
510			 * over who claims what Ether address.
511			 */
512			if(rt->rt_ifp == &ac->ac_if) {
513				rtfree(rt);
514				goto out;
515			}
516			bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
517			      sizeof(ea->arp_sha));
518			bcopy(ac->ac_enaddr, (caddr_t)ea->arp_sha,
519			      sizeof(ea->arp_sha));
520			rtfree(rt);
521#ifdef DEBUG_PROXY
522			printf("arp: proxying for %s\n",
523			       inet_ntoa(itaddr));
524#endif
525#else
526			goto out;
527#endif
528		} else {
529			rt = la->la_rt;
530			bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
531			      sizeof(ea->arp_sha));
532			sdl = SDL(rt->rt_gateway);
533			bcopy(LLADDR(sdl), (caddr_t)ea->arp_sha,
534			      sizeof(ea->arp_sha));
535		}
536	}
537
538	bcopy((caddr_t)ea->arp_spa, (caddr_t)ea->arp_tpa, sizeof(ea->arp_spa));
539	bcopy((caddr_t)&itaddr, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
540	ea->arp_op = htons(ARPOP_REPLY);
541	ea->arp_pro = htons(ETHERTYPE_IP); /* let's be sure! */
542	eh = (struct ether_header *)sa.sa_data;
543	bcopy((caddr_t)ea->arp_tha, (caddr_t)eh->ether_dhost,
544	    sizeof(eh->ether_dhost));
545	eh->ether_type = ETHERTYPE_ARP;
546	sa.sa_family = AF_UNSPEC;
547	sa.sa_len = sizeof(sa);
548	(*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
549	return;
550}
551
552/*
553 * Free an arp entry.
554 */
555static void
556arptfree(la)
557	register struct llinfo_arp *la;
558{
559	register struct rtentry *rt = la->la_rt;
560	register struct sockaddr_dl *sdl;
561	if (rt == 0)
562		panic("arptfree");
563	if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) &&
564	    sdl->sdl_family == AF_LINK) {
565		sdl->sdl_alen = 0;
566		la->la_asked = 0;
567		rt->rt_flags &= ~RTF_REJECT;
568		return;
569	}
570	rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt),
571			0, (struct rtentry **)0);
572}
573/*
574 * Lookup or enter a new address in arptab.
575 */
576static struct llinfo_arp *
577arplookup(addr, create, proxy)
578	u_long addr;
579	int create, proxy;
580{
581	register struct rtentry *rt;
582	static struct sockaddr_inarp sin = {sizeof(sin), AF_INET };
583	const char *why = 0;
584
585	sin.sin_addr.s_addr = addr;
586	sin.sin_other = proxy ? SIN_PROXY : 0;
587	rt = rtalloc1((struct sockaddr *)&sin, create, 0UL);
588	if (rt == 0)
589		return (0);
590	rt->rt_refcnt--;
591
592	if(rt->rt_flags & RTF_GATEWAY)
593		why = "host is not on local network";
594	else if((rt->rt_flags & RTF_LLINFO) == 0)
595		why = "could not allocate llinfo";
596	else if(rt->rt_gateway->sa_family != AF_LINK)
597		why = "gateway route is not ours";
598
599	if(why && create) {
600		log(LOG_DEBUG, "arplookup %s failed: %s\n",
601		    inet_ntoa(sin.sin_addr), why);
602		return 0;
603	} else if(why) {
604		return 0;
605	}
606	return ((struct llinfo_arp *)rt->rt_llinfo);
607}
608
609int
610arpioctl(cmd, data)
611	int cmd;
612	caddr_t data;
613{
614	return (EOPNOTSUPP);
615}
616
617void
618arp_ifinit(ac, ifa)
619	struct arpcom *ac;
620	struct ifaddr *ifa;
621{
622	ac->ac_ipaddr = IA_SIN(ifa)->sin_addr;
623	arpwhohas(ac, &ac->ac_ipaddr);
624	ifa->ifa_rtrequest = arp_rtrequest;
625	ifa->ifa_flags |= RTF_CLONING;
626}
627