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