Add sanity check for return of sotoinpcb() and intotcpcb()
[unix-history] / sys / netinet / if_ether.c
CommitLineData
15637ed4
RG
1/*
2 * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
3 * 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 *
38e82238 33 * from: @(#)if_ether.c 7.13 (Berkeley) 10/31/90
4cf615e1 34 * $Id: if_ether.c,v 1.4 1993/11/25 01:34:57 wollman Exp $
15637ed4
RG
35 */
36
37/*
38 * Ethernet address resolution protocol.
39 * TODO:
40 * run at splnet (add ARP protocol intr.)
41 * link entries onto hash chains, keep free list
42 * add "inuse/lock" bit (or ref. count) along with valid bit
43 */
44
45#include "param.h"
46#include "systm.h"
47#include "malloc.h"
48#include "mbuf.h"
49#include "socket.h"
50#include "time.h"
51#include "kernel.h"
52#include "errno.h"
53#include "ioctl.h"
54#include "syslog.h"
55
56#include "../net/if.h"
57#include "in.h"
58#include "in_systm.h"
59#include "in_var.h"
60#include "ip.h"
61#include "if_ether.h"
62
4c45483e
GW
63static void in_arpinput(struct arpcom *, struct mbuf *);
64static void arptfree(struct arptab *);
65
15637ed4
RG
66#ifdef GATEWAY
67#define ARPTAB_BSIZ 16 /* bucket size */
68#define ARPTAB_NB 37 /* number of buckets */
69#else
70#define ARPTAB_BSIZ 9 /* bucket size */
71#define ARPTAB_NB 19 /* number of buckets */
72#endif
73#define ARPTAB_SIZE (ARPTAB_BSIZ * ARPTAB_NB)
74struct arptab arptab[ARPTAB_SIZE];
75int arptab_size = ARPTAB_SIZE; /* for arp command */
76
77/*
78 * ARP trailer negotiation. Trailer protocol is not IP specific,
79 * but ARP request/response use IP addresses.
80 */
81#define ETHERTYPE_IPTRAILERS ETHERTYPE_TRAIL
82
83#define ARPTAB_HASH(a) \
84 ((u_long)(a) % ARPTAB_NB)
85
86#define ARPTAB_LOOK(at,addr) { \
87 register n; \
88 at = &arptab[ARPTAB_HASH(addr) * ARPTAB_BSIZ]; \
89 for (n = 0 ; n < ARPTAB_BSIZ ; n++,at++) \
90 if (at->at_iaddr.s_addr == addr) \
91 break; \
92 if (n >= ARPTAB_BSIZ) \
93 at = 0; \
94}
95
96/* timer values */
97#define ARPT_AGE (60*1) /* aging timer, 1 min. */
98#define ARPT_KILLC 20 /* kill completed entry in 20 mins. */
99#define ARPT_KILLI 3 /* kill incomplete entry in 3 minutes */
100
101extern struct ifnet loif;
102
103/*
104 * Timeout routine. Age arp_tab entries once a minute.
105 */
4c45483e 106void
15637ed4
RG
107arptimer()
108{
109 register struct arptab *at;
110 register i;
111
112 timeout(arptimer, (caddr_t)0, ARPT_AGE * hz);
113 at = &arptab[0];
114 for (i = 0; i < ARPTAB_SIZE; i++, at++) {
115 if (at->at_flags == 0 || (at->at_flags & ATF_PERM))
116 continue;
117 if (++at->at_timer < ((at->at_flags&ATF_COM) ?
118 ARPT_KILLC : ARPT_KILLI))
119 continue;
120 /* timer has expired, clear entry */
121 arptfree(at);
122 }
123}
124
125/*
126 * Broadcast an ARP packet, asking who has addr on interface ac.
127 */
4c45483e 128void
15637ed4
RG
129arpwhohas(ac, addr)
130 register struct arpcom *ac;
131 struct in_addr *addr;
132{
133 register struct mbuf *m;
134 register struct ether_header *eh;
135 register struct ether_arp *ea;
136 struct sockaddr sa;
137
138 if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
139 return;
140 m->m_len = sizeof(*ea);
141 m->m_pkthdr.len = sizeof(*ea);
142 MH_ALIGN(m, sizeof(*ea));
143 ea = mtod(m, struct ether_arp *);
144 eh = (struct ether_header *)sa.sa_data;
145 bzero((caddr_t)ea, sizeof (*ea));
146 bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
147 sizeof(eh->ether_dhost));
148 eh->ether_type = ETHERTYPE_ARP; /* if_output will swap */
149 ea->arp_hrd = htons(ARPHRD_ETHER);
150 ea->arp_pro = htons(ETHERTYPE_IP);
151 ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
152 ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
153 ea->arp_op = htons(ARPOP_REQUEST);
154 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
155 sizeof(ea->arp_sha));
156 bcopy((caddr_t)&ac->ac_ipaddr, (caddr_t)ea->arp_spa,
157 sizeof(ea->arp_spa));
158 bcopy((caddr_t)addr, (caddr_t)ea->arp_tpa, sizeof(ea->arp_tpa));
159 sa.sa_family = AF_UNSPEC;
160 sa.sa_len = sizeof(sa);
161 (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
162}
163
164int useloopback = 1; /* use loopback interface for local traffic */
165
166/*
167 * Resolve an IP address into an ethernet address. If success,
168 * desten is filled in. If there is no entry in arptab,
169 * set one up and broadcast a request for the IP address.
170 * Hold onto this mbuf and resend it once the address
171 * is finally resolved. A return value of 1 indicates
172 * that desten has been filled in and the packet should be sent
173 * normally; a 0 return indicates that the packet has been
174 * taken over here, either now or for later transmission.
175 *
176 * We do some (conservative) locking here at splimp, since
177 * arptab is also altered from input interrupt service (ecintr/ilintr
178 * calls arpinput when ETHERTYPE_ARP packets come in).
179 */
4c45483e 180int
15637ed4
RG
181arpresolve(ac, m, destip, desten, usetrailers)
182 register struct arpcom *ac;
183 struct mbuf *m;
184 register struct in_addr *destip;
185 register u_char *desten;
186 int *usetrailers;
187{
188 register struct arptab *at;
189 struct sockaddr_in sin;
190 register struct in_ifaddr *ia;
191 u_long lna;
192 int s;
193
194 *usetrailers = 0;
195 if (m->m_flags & M_BCAST) { /* broadcast */
196 bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
197 sizeof(etherbroadcastaddr));
198 return (1);
199 }
4cf615e1
JH
200#ifdef MULTICAST
201 if (m->m_flags & M_MCAST) { /* multicast */
202 ETHER_MAP_IP_MULTICAST(destip, desten);
203 return(1);
204 }
205#endif
15637ed4
RG
206 lna = in_lnaof(*destip);
207 /* if for us, use software loopback driver if up */
208 for (ia = in_ifaddr; ia; ia = ia->ia_next)
209 if ((ia->ia_ifp == &ac->ac_if) &&
210 (destip->s_addr == ia->ia_addr.sin_addr.s_addr)) {
211 /*
212 * This test used to be
213 * if (loif.if_flags & IFF_UP)
214 * It allowed local traffic to be forced
215 * through the hardware by configuring the loopback down.
216 * However, it causes problems during network configuration
217 * for boards that can't receive packets they send.
218 * It is now necessary to clear "useloopback"
219 * to force traffic out to the hardware.
220 */
221 if (useloopback) {
222 sin.sin_family = AF_INET;
223 sin.sin_addr = *destip;
224 (void) looutput(&loif, m, (struct sockaddr *)&sin, 0);
225 /*
226 * The packet has already been sent and freed.
227 */
228 return (0);
229 } else {
230 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)desten,
231 sizeof(ac->ac_enaddr));
232 return (1);
233 }
234 }
235 s = splimp();
236 ARPTAB_LOOK(at, destip->s_addr);
237 if (at == 0) { /* not found */
238 if (ac->ac_if.if_flags & IFF_NOARP) {
239 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)desten, 3);
240 desten[3] = (lna >> 16) & 0x7f;
241 desten[4] = (lna >> 8) & 0xff;
242 desten[5] = lna & 0xff;
243 splx(s);
244 return (1);
245 } else {
246 at = arptnew(destip);
247 if (at == 0)
248 panic("arpresolve: no free entry");
249 at->at_hold = m;
250 arpwhohas(ac, destip);
251 splx(s);
252 return (0);
253 }
254 }
255 at->at_timer = 0; /* restart the timer */
256 if (at->at_flags & ATF_COM) { /* entry IS complete */
47110967
RG
257
258 *(int *) desten = *(int *) at->at_enaddr;
259 ((short *) desten)[2] = ((short *) at->at_enaddr)[2];
260
15637ed4
RG
261 if (at->at_flags & ATF_USETRAILERS)
262 *usetrailers = 1;
263 splx(s);
264 return (1);
265 }
266 /*
267 * There is an arptab entry, but no ethernet address
268 * response yet. Replace the held mbuf with this
269 * latest one.
270 */
271 if (at->at_hold)
272 m_freem(at->at_hold);
273 at->at_hold = m;
274 arpwhohas(ac, destip); /* ask again */
275 splx(s);
276 return (0);
277}
278
279/*
280 * Called from 10 Mb/s Ethernet interrupt handlers
281 * when ether packet type ETHERTYPE_ARP
282 * is received. Common length and type checks are done here,
283 * then the protocol-specific routine is called.
284 */
4c45483e 285void
15637ed4
RG
286arpinput(ac, m)
287 struct arpcom *ac;
288 struct mbuf *m;
289{
290 register struct arphdr *ar;
291
292 if (ac->ac_if.if_flags & IFF_NOARP)
293 goto out;
294 if (m->m_len < sizeof(struct arphdr))
295 goto out;
296 ar = mtod(m, struct arphdr *);
297 if (ntohs(ar->ar_hrd) != ARPHRD_ETHER)
298 goto out;
299 if (m->m_len < sizeof(struct arphdr) + 2 * ar->ar_hln + 2 * ar->ar_pln)
300 goto out;
301
302 switch (ntohs(ar->ar_pro)) {
303
304 case ETHERTYPE_IP:
305 case ETHERTYPE_IPTRAILERS:
306 in_arpinput(ac, m);
307 return;
308
309 default:
310 break;
311 }
312out:
313 m_freem(m);
314}
315
316/*
317 * ARP for Internet protocols on 10 Mb/s Ethernet.
318 * Algorithm is that given in RFC 826.
319 * In addition, a sanity check is performed on the sender
320 * protocol address, to catch impersonators.
321 * We also handle negotiations for use of trailer protocol:
322 * ARP replies for protocol type ETHERTYPE_TRAIL are sent
323 * along with IP replies if we want trailers sent to us,
324 * and also send them in response to IP replies.
325 * This allows either end to announce the desire to receive
326 * trailer packets.
327 * We reply to requests for ETHERTYPE_TRAIL protocol as well,
328 * but don't normally send requests.
329 */
4c45483e 330void
15637ed4
RG
331in_arpinput(ac, m)
332 register struct arpcom *ac;
333 struct mbuf *m;
334{
335 register struct ether_arp *ea;
336 struct ether_header *eh;
4c45483e 337 register struct arptab *at = 0; /* same as "merge" flag */
15637ed4
RG
338 register struct in_ifaddr *ia;
339 struct in_ifaddr *maybe_ia = 0;
340 struct mbuf *mcopy = 0;
341 struct sockaddr_in sin;
342 struct sockaddr sa;
343 struct in_addr isaddr, itaddr, myaddr;
344 int proto, op, s, completed = 0;
345
346 ea = mtod(m, struct ether_arp *);
347 proto = ntohs(ea->arp_pro);
348 op = ntohs(ea->arp_op);
349 bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
350 bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
351 for (ia = in_ifaddr; ia; ia = ia->ia_next)
352 if (ia->ia_ifp == &ac->ac_if) {
353 maybe_ia = ia;
354 if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) ||
355 (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr))
356 break;
357 }
358 if (maybe_ia == 0)
359 goto out;
360 myaddr = ia ? ia->ia_addr.sin_addr : maybe_ia->ia_addr.sin_addr;
361 if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)ac->ac_enaddr,
362 sizeof (ea->arp_sha)))
363 goto out; /* it's from me, ignore it. */
364 if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
365 sizeof (ea->arp_sha))) {
366 log(LOG_ERR,
367 "arp: ether address is broadcast for IP address %x!\n",
368 ntohl(isaddr.s_addr));
369 goto out;
370 }
371 if (isaddr.s_addr == myaddr.s_addr) {
372 log(LOG_ERR,
373 "duplicate IP address %x!! sent from ethernet address: %s\n",
374 ntohl(isaddr.s_addr), ether_sprintf(ea->arp_sha));
375 itaddr = myaddr;
376 if (op == ARPOP_REQUEST)
377 goto reply;
378 goto out;
379 }
380 s = splimp();
381 ARPTAB_LOOK(at, isaddr.s_addr);
382 if (at) {
383 bcopy((caddr_t)ea->arp_sha, (caddr_t)at->at_enaddr,
384 sizeof(ea->arp_sha));
385 if ((at->at_flags & ATF_COM) == 0)
386 completed = 1;
387 at->at_flags |= ATF_COM;
388 if (at->at_hold) {
389 sin.sin_family = AF_INET;
390 sin.sin_addr = isaddr;
391 (*ac->ac_if.if_output)(&ac->ac_if, at->at_hold,
392 (struct sockaddr *)&sin, (struct rtentry *)0);
393 at->at_hold = 0;
394 }
395 }
396 if (at == 0 && itaddr.s_addr == myaddr.s_addr) {
397 /* ensure we have a table entry */
398 if (at = arptnew(&isaddr)) {
399 bcopy((caddr_t)ea->arp_sha, (caddr_t)at->at_enaddr,
400 sizeof(ea->arp_sha));
401 completed = 1;
402 at->at_flags |= ATF_COM;
403 }
404 }
405 splx(s);
406reply:
407 switch (proto) {
408
409 case ETHERTYPE_IPTRAILERS:
410 /* partner says trailers are OK */
411 if (at)
412 at->at_flags |= ATF_USETRAILERS;
413 /*
414 * Reply to request iff we want trailers.
415 */
416 if (op != ARPOP_REQUEST || ac->ac_if.if_flags & IFF_NOTRAILERS)
417 goto out;
418 break;
419
420 case ETHERTYPE_IP:
421 /*
422 * Reply if this is an IP request,
423 * or if we want to send a trailer response.
424 * Send the latter only to the IP response
425 * that completes the current ARP entry.
426 */
427 if (op != ARPOP_REQUEST &&
428 (completed == 0 || ac->ac_if.if_flags & IFF_NOTRAILERS))
429 goto out;
430 }
431 if (itaddr.s_addr == myaddr.s_addr) {
432 /* I am the target */
433 bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
434 sizeof(ea->arp_sha));
435 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
436 sizeof(ea->arp_sha));
437 } else {
438 ARPTAB_LOOK(at, itaddr.s_addr);
439 if (at == NULL || (at->at_flags & ATF_PUBL) == 0)
440 goto out;
441 bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
442 sizeof(ea->arp_sha));
443 bcopy((caddr_t)at->at_enaddr, (caddr_t)ea->arp_sha,
444 sizeof(ea->arp_sha));
445 }
446
447 bcopy((caddr_t)ea->arp_spa, (caddr_t)ea->arp_tpa,
448 sizeof(ea->arp_spa));
449 bcopy((caddr_t)&itaddr, (caddr_t)ea->arp_spa,
450 sizeof(ea->arp_spa));
451 ea->arp_op = htons(ARPOP_REPLY);
452 /*
453 * If incoming packet was an IP reply,
454 * we are sending a reply for type IPTRAILERS.
455 * If we are sending a reply for type IP
456 * and we want to receive trailers,
457 * send a trailer reply as well.
458 */
459 if (op == ARPOP_REPLY)
460 ea->arp_pro = htons(ETHERTYPE_IPTRAILERS);
461 else if (proto == ETHERTYPE_IP &&
462 (ac->ac_if.if_flags & IFF_NOTRAILERS) == 0)
463 mcopy = m_copy(m, 0, (int)M_COPYALL);
464 eh = (struct ether_header *)sa.sa_data;
465 bcopy((caddr_t)ea->arp_tha, (caddr_t)eh->ether_dhost,
466 sizeof(eh->ether_dhost));
467 eh->ether_type = ETHERTYPE_ARP;
468 sa.sa_family = AF_UNSPEC;
469 sa.sa_len = sizeof(sa);
470 (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
471 if (mcopy) {
472 ea = mtod(mcopy, struct ether_arp *);
473 ea->arp_pro = htons(ETHERTYPE_IPTRAILERS);
474 (*ac->ac_if.if_output)(&ac->ac_if,
475 mcopy, &sa, (struct rtentry *)0);
476 }
477 return;
478out:
479 m_freem(m);
480 return;
481}
482
483/*
484 * Free an arptab entry.
485 */
4c45483e 486void
15637ed4
RG
487arptfree(at)
488 register struct arptab *at;
489{
490 int s = splimp();
491
492 if (at->at_hold)
493 m_freem(at->at_hold);
494 at->at_hold = 0;
495 at->at_timer = at->at_flags = 0;
496 at->at_iaddr.s_addr = 0;
497 splx(s);
498}
499
500/*
501 * Enter a new address in arptab, pushing out the oldest entry
502 * from the bucket if there is no room.
503 * This always succeeds since no bucket can be completely filled
504 * with permanent entries (except from arpioctl when testing whether
505 * another permanent entry will fit).
506 * MUST BE CALLED AT SPLIMP.
507 */
508struct arptab *
509arptnew(addr)
510 struct in_addr *addr;
511{
512 register n;
513 int oldest = -1;
514 register struct arptab *at, *ato = NULL;
515 static int first = 1;
516
517 if (first) {
518 first = 0;
519 timeout(arptimer, (caddr_t)0, hz);
520 }
521 at = &arptab[ARPTAB_HASH(addr->s_addr) * ARPTAB_BSIZ];
522 for (n = 0; n < ARPTAB_BSIZ; n++,at++) {
523 if (at->at_flags == 0)
524 goto out; /* found an empty entry */
525 if (at->at_flags & ATF_PERM)
526 continue;
527 if ((int) at->at_timer > oldest) {
528 oldest = at->at_timer;
529 ato = at;
530 }
531 }
532 if (ato == NULL)
533 return (NULL);
534 at = ato;
535 arptfree(at);
536out:
537 at->at_iaddr = *addr;
538 at->at_flags = ATF_INUSE;
539 return (at);
540}
541
4c45483e 542int
15637ed4
RG
543arpioctl(cmd, data)
544 int cmd;
545 caddr_t data;
546{
547 register struct arpreq *ar = (struct arpreq *)data;
548 register struct arptab *at;
549 register struct sockaddr_in *sin;
550 int s;
551
552 sin = (struct sockaddr_in *)&ar->arp_ha;
553#if defined(COMPAT_43) && BYTE_ORDER != BIG_ENDIAN
554 if (sin->sin_family == 0 && sin->sin_len < 16)
555 sin->sin_family = sin->sin_len;
556#endif
557 sin->sin_len = sizeof(ar->arp_ha);
558 sin = (struct sockaddr_in *)&ar->arp_pa;
559#if defined(COMPAT_43) && BYTE_ORDER != BIG_ENDIAN
560 if (sin->sin_family == 0 && sin->sin_len < 16)
561 sin->sin_family = sin->sin_len;
562#endif
563 sin->sin_len = sizeof(ar->arp_pa);
564 if (ar->arp_pa.sa_family != AF_INET ||
565 ar->arp_ha.sa_family != AF_UNSPEC)
566 return (EAFNOSUPPORT);
567 s = splimp();
568 ARPTAB_LOOK(at, sin->sin_addr.s_addr);
569 if (at == NULL) { /* not found */
570 if (cmd != SIOCSARP) {
571 splx(s);
572 return (ENXIO);
573 }
574 if (ifa_ifwithnet(&ar->arp_pa) == NULL) {
575 splx(s);
576 return (ENETUNREACH);
577 }
578 }
579 switch (cmd) {
580
581 case SIOCSARP: /* set entry */
582 if (at == NULL) {
583 at = arptnew(&sin->sin_addr);
584 if (at == NULL) {
585 splx(s);
586 return (EADDRNOTAVAIL);
587 }
588 if (ar->arp_flags & ATF_PERM) {
589 /* never make all entries in a bucket permanent */
590 register struct arptab *tat;
591
592 /* try to re-allocate */
593 tat = arptnew(&sin->sin_addr);
594 if (tat == NULL) {
595 arptfree(at);
596 splx(s);
597 return (EADDRNOTAVAIL);
598 }
599 arptfree(tat);
600 }
601 }
602 bcopy((caddr_t)ar->arp_ha.sa_data, (caddr_t)at->at_enaddr,
603 sizeof(at->at_enaddr));
604 at->at_flags = ATF_COM | ATF_INUSE |
605 (ar->arp_flags & (ATF_PERM|ATF_PUBL|ATF_USETRAILERS));
606 at->at_timer = 0;
607 break;
608
609 case SIOCDARP: /* delete entry */
610 arptfree(at);
611 break;
612
613 case SIOCGARP: /* get entry */
614 case OSIOCGARP:
615 bcopy((caddr_t)at->at_enaddr, (caddr_t)ar->arp_ha.sa_data,
616 sizeof(at->at_enaddr));
617#ifdef COMPAT_43
618 if (cmd == OSIOCGARP)
619 *(u_short *)&ar->arp_ha = ar->arp_ha.sa_family;
620#endif
621 ar->arp_flags = at->at_flags;
622 break;
623 }
624 splx(s);
625 return (0);
626}