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.18 1995/06/27 20:36:34 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 #include <sys/queue.h> 54 55 #include <net/if.h> 56 #include <net/if_dl.h> 57 #include <net/route.h> 58 #include <net/netisr.h> 59 60 #include <netinet/in.h> 61 #include <netinet/in_systm.h> 62 #include <netinet/in_var.h> 63 #include <netinet/ip.h> 64 #include <netinet/if_ether.h> 65 66 #define SIN(s) ((struct sockaddr_in *)s) 67 #define SDL(s) ((struct sockaddr_dl *)s) 68 #define SRP(s) ((struct sockaddr_inarp *)s) 69 70 /* 71 * ARP trailer negotiation. Trailer protocol is not IP specific, 72 * but ARP request/response use IP addresses. 73 */ 74 #define ETHERTYPE_IPTRAILERS ETHERTYPE_TRAIL 75 76 77 /* timer values */ 78 int arpt_prune = (5*60*1); /* walk list every 5 minutes */ 79 int arpt_keep = (20*60); /* once resolved, good for 20 more minutes */ 80 int arpt_down = 20; /* once declared down, don't send for 20 secs */ 81 #define rt_expire rt_rmx.rmx_expire 82 83 struct llinfo_arp { 84 LIST_ENTRY(llinfo_arp) la_le; 85 struct rtentry *la_rt; 86 struct mbuf *la_hold; /* last packet until resolved/timeout */ 87 long la_asked; /* last time we QUERIED for this addr */ 88 #define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */ 89 }; 90 static LIST_HEAD(, llinfo_arp) llinfo_arp; 91 92 static void arprequest __P((struct arpcom *, u_long *, u_long *, u_char *)); 93 static void arptfree __P((struct llinfo_arp *)); 94 static void arptimer __P((void *)); 95 static struct llinfo_arp *arplookup __P((u_long, int, int)); 96 static void in_arpinput __P((struct mbuf *)); 97 static struct llinfo_arp *arptnew __P((struct in_addr *)); 98 99 struct ifqueue arpintrq = {0, 0, 0, 50}; 100 int arp_inuse, arp_allocated, arp_intimer; 101 int arp_maxtries = 5; 102 int useloopback = 1; /* use loopback interface for local traffic */ 103 int arpinit_done = 0; 104 105 #ifdef ARP_PROXYALL 106 int arp_proxyall = 1; 107 #endif 108 109 /* 110 * Timeout routine. Age arp_tab entries periodically. 111 */ 112 /* ARGSUSED */ 113 static void 114 arptimer(ignored_arg) 115 void *ignored_arg; 116 { 117 int s = splnet(); 118 register struct llinfo_arp *la = llinfo_arp.lh_first; 119 struct llinfo_arp *ola; 120 121 timeout(arptimer, (caddr_t)0, arpt_prune * hz); 122 while ((ola = la) != 0) { 123 register struct rtentry *rt = la->la_rt; 124 la = la->la_le.le_next; 125 if (rt->rt_expire && rt->rt_expire <= time.tv_sec) 126 arptfree(ola); /* timer has expired, clear */ 127 } 128 splx(s); 129 } 130 131 /* 132 * Parallel to llc_rtrequest. 133 */ 134 static void 135 arp_rtrequest(req, rt, sa) 136 int req; 137 register struct rtentry *rt; 138 struct sockaddr *sa; 139 { 140 register struct sockaddr *gate = rt->rt_gateway; 141 register struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo; 142 static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; 143 144 if (!arpinit_done) { 145 arpinit_done = 1; 146 LIST_INIT(&llinfo_arp); 147 timeout(arptimer, (caddr_t)0, hz); 148 } 149 if (rt->rt_flags & RTF_GATEWAY) 150 return; 151 switch (req) { 152 153 case RTM_ADD: 154 /* 155 * XXX: If this is a manually added route to interface 156 * such as older version of routed or gated might provide, 157 * restore cloning bit. 158 */ 159 if ((rt->rt_flags & RTF_HOST) == 0 && 160 SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff) 161 rt->rt_flags |= RTF_CLONING; 162 if (rt->rt_flags & RTF_CLONING) { 163 /* 164 * Case 1: This route should come from a route to iface. 165 */ 166 rt_setgate(rt, rt_key(rt), 167 (struct sockaddr *)&null_sdl); 168 gate = rt->rt_gateway; 169 SDL(gate)->sdl_type = rt->rt_ifp->if_type; 170 SDL(gate)->sdl_index = rt->rt_ifp->if_index; 171 rt->rt_expire = time.tv_sec; 172 break; 173 } 174 /* Announce a new entry if requested. */ 175 if (rt->rt_flags & RTF_ANNOUNCE) 176 arprequest((struct arpcom *)rt->rt_ifp, 177 &SIN(rt_key(rt))->sin_addr.s_addr, 178 &SIN(rt_key(rt))->sin_addr.s_addr, 179 (u_char *)LLADDR(SDL(gate))); 180 /*FALLTHROUGH*/ 181 case RTM_RESOLVE: 182 if (gate->sa_family != AF_LINK || 183 gate->sa_len < sizeof(null_sdl)) { 184 log(LOG_DEBUG, "arp_rtrequest: bad gateway value\n"); 185 break; 186 } 187 SDL(gate)->sdl_type = rt->rt_ifp->if_type; 188 SDL(gate)->sdl_index = rt->rt_ifp->if_index; 189 if (la != 0) 190 break; /* This happens on a route change */ 191 /* 192 * Case 2: This route may come from cloning, or a manual route 193 * add with a LL address. 194 */ 195 R_Malloc(la, struct llinfo_arp *, sizeof(*la)); 196 rt->rt_llinfo = (caddr_t)la; 197 if (la == 0) { 198 log(LOG_DEBUG, "arp_rtrequest: malloc failed\n"); 199 break; 200 } 201 arp_inuse++, arp_allocated++; 202 Bzero(la, sizeof(*la)); 203 la->la_rt = rt; 204 rt->rt_flags |= RTF_LLINFO; 205 LIST_INSERT_HEAD(&llinfo_arp, la, la_le); 206 if (SIN(rt_key(rt))->sin_addr.s_addr == 207 (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) { 208 /* 209 * This test used to be 210 * if (loif.if_flags & IFF_UP) 211 * It allowed local traffic to be forced 212 * through the hardware by configuring the loopback down. 213 * However, it causes problems during network configuration 214 * for boards that can't receive packets they send. 215 * It is now necessary to clear "useloopback" and remove 216 * the route to force traffic out to the hardware. 217 */ 218 rt->rt_expire = 0; 219 Bcopy(((struct arpcom *)rt->rt_ifp)->ac_enaddr, 220 LLADDR(SDL(gate)), SDL(gate)->sdl_alen = 6); 221 if (useloopback) 222 rt->rt_ifp = loif; 223 224 } 225 break; 226 227 case RTM_DELETE: 228 if (la == 0) 229 break; 230 arp_inuse--; 231 LIST_REMOVE(la, la_le); 232 rt->rt_llinfo = 0; 233 rt->rt_flags &= ~RTF_LLINFO; 234 if (la->la_hold) 235 m_freem(la->la_hold); 236 Free((caddr_t)la); 237 } 238 } 239 240 /* 241 * Broadcast an ARP packet, asking who has addr on interface ac. 242 */ 243 void 244 arpwhohas(ac, addr) 245 register struct arpcom *ac; 246 register struct in_addr *addr; 247 { 248 arprequest(ac, &ac->ac_ipaddr.s_addr, &addr->s_addr, ac->ac_enaddr); 249 } 250 251 /* 252 * Broadcast an ARP request. Caller specifies: 253 * - arp header source ip address 254 * - arp header target ip address 255 * - arp header source ethernet address 256 */ 257 static void 258 arprequest(ac, sip, tip, enaddr) 259 register struct arpcom *ac; 260 register u_long *sip, *tip; 261 register u_char *enaddr; 262 { 263 register struct mbuf *m; 264 register struct ether_header *eh; 265 register struct ether_arp *ea; 266 struct sockaddr sa; 267 268 if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) 269 return; 270 m->m_len = sizeof(*ea); 271 m->m_pkthdr.len = sizeof(*ea); 272 MH_ALIGN(m, sizeof(*ea)); 273 ea = mtod(m, struct ether_arp *); 274 eh = (struct ether_header *)sa.sa_data; 275 bzero((caddr_t)ea, sizeof (*ea)); 276 (void)memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost)); 277 eh->ether_type = ETHERTYPE_ARP; /* if_output will swap */ 278 ea->arp_hrd = htons(ARPHRD_ETHER); 279 ea->arp_pro = htons(ETHERTYPE_IP); 280 ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */ 281 ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */ 282 ea->arp_op = htons(ARPOP_REQUEST); 283 (void)memcpy(ea->arp_sha, enaddr, sizeof(ea->arp_sha)); 284 (void)memcpy(ea->arp_spa, sip, sizeof(ea->arp_spa)); 285 (void)memcpy(ea->arp_tpa, tip, sizeof(ea->arp_tpa)); 286 sa.sa_family = AF_UNSPEC; 287 sa.sa_len = sizeof(sa); 288 (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0); 289 } 290 291 /* 292 * Resolve an IP address into an ethernet address. If success, 293 * desten is filled in. If there is no entry in arptab, 294 * set one up and broadcast a request for the IP address. 295 * Hold onto this mbuf and resend it once the address 296 * is finally resolved. A return value of 1 indicates 297 * that desten has been filled in and the packet should be sent 298 * normally; a 0 return indicates that the packet has been 299 * taken over here, either now or for later transmission. 300 */ 301 int 302 arpresolve(ac, rt, m, dst, desten, rt0) 303 register struct arpcom *ac; 304 register struct rtentry *rt; 305 struct mbuf *m; 306 register struct sockaddr *dst; 307 register u_char *desten; 308 struct rtentry *rt0; 309 { 310 register struct llinfo_arp *la; 311 struct sockaddr_dl *sdl; 312 313 if (m->m_flags & M_BCAST) { /* broadcast */ 314 (void)memcpy(desten, etherbroadcastaddr, 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 (void)memcpy(desten, LLADDR(sdl), 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 */ 372 void 373 arpintr(void) 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 NETISR_SET(NETISR_ARP, arpintr); 403 404 /* 405 * ARP for Internet protocols on 10 Mb/s Ethernet. 406 * Algorithm is that given in RFC 826. 407 * In addition, a sanity check is performed on the sender 408 * protocol address, to catch impersonators. 409 * We no longer handle negotiations for use of trailer protocol: 410 * Formerly, ARP replied for protocol type ETHERTYPE_TRAIL sent 411 * along with IP replies if we wanted trailers sent to us, 412 * and also sent them in response to IP replies. 413 * This allowed either end to announce the desire to receive 414 * trailer packets. 415 * We no longer reply to requests for ETHERTYPE_TRAIL protocol either, 416 * but formerly didn't normally send requests. 417 */ 418 static void 419 in_arpinput(m) 420 struct mbuf *m; 421 { 422 register struct ether_arp *ea; 423 register struct arpcom *ac = (struct arpcom *)m->m_pkthdr.rcvif; 424 struct ether_header *eh; 425 register struct llinfo_arp *la = 0; 426 register struct rtentry *rt; 427 struct in_ifaddr *ia, *maybe_ia = 0; 428 struct sockaddr_dl *sdl; 429 struct sockaddr sa; 430 struct in_addr isaddr, itaddr, myaddr; 431 int op; 432 433 ea = mtod(m, struct ether_arp *); 434 op = ntohs(ea->arp_op); 435 (void)memcpy(&isaddr, ea->arp_spa, sizeof (isaddr)); 436 (void)memcpy(&itaddr, ea->arp_tpa, sizeof (itaddr)); 437 for (ia = in_ifaddr; ia; ia = ia->ia_next) 438 if (ia->ia_ifp == &ac->ac_if) { 439 maybe_ia = ia; 440 if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) || 441 (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)) 442 break; 443 } 444 if (maybe_ia == 0) 445 goto out; 446 myaddr = ia ? ia->ia_addr.sin_addr : maybe_ia->ia_addr.sin_addr; 447 if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)ac->ac_enaddr, 448 sizeof (ea->arp_sha))) 449 goto out; /* it's from me, ignore it. */ 450 if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr, 451 sizeof (ea->arp_sha))) { 452 log(LOG_ERR, 453 "arp: ether address is broadcast for IP address %s!\n", 454 inet_ntoa(isaddr)); 455 goto out; 456 } 457 if (isaddr.s_addr == myaddr.s_addr) { 458 log(LOG_ERR, 459 "duplicate IP address %s! sent from ethernet address: %s\n", 460 inet_ntoa(isaddr), ether_sprintf(ea->arp_sha)); 461 itaddr = myaddr; 462 goto reply; 463 } 464 la = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0); 465 if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) { 466 if (sdl->sdl_alen && 467 bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) 468 log(LOG_INFO, "arp info overwritten for %s by %s\n", 469 inet_ntoa(isaddr), ether_sprintf(ea->arp_sha)); 470 (void)memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha)); 471 sdl->sdl_alen = sizeof(ea->arp_sha); 472 if (rt->rt_expire) 473 rt->rt_expire = time.tv_sec + arpt_keep; 474 rt->rt_flags &= ~RTF_REJECT; 475 la->la_asked = 0; 476 if (la->la_hold) { 477 (*ac->ac_if.if_output)(&ac->ac_if, la->la_hold, 478 rt_key(rt), rt); 479 la->la_hold = 0; 480 } 481 } 482 reply: 483 if (op != ARPOP_REQUEST) { 484 out: 485 m_freem(m); 486 return; 487 } 488 if (itaddr.s_addr == myaddr.s_addr) { 489 /* I am the target */ 490 (void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha)); 491 (void)memcpy(ea->arp_sha, ac->ac_enaddr, 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 (void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha)); 518 (void)memcpy(ea->arp_sha, ac->ac_enaddr, sizeof(ea->arp_sha)); 519 rtfree(rt); 520 #ifdef DEBUG_PROXY 521 printf("arp: proxying for %s\n", 522 inet_ntoa(itaddr)); 523 #endif 524 #else 525 goto out; 526 #endif 527 } else { 528 rt = la->la_rt; 529 (void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha)); 530 sdl = SDL(rt->rt_gateway); 531 (void)memcpy(ea->arp_sha, LLADDR(sdl), sizeof(ea->arp_sha)); 532 } 533 } 534 535 (void)memcpy(ea->arp_tpa, ea->arp_spa, sizeof(ea->arp_spa)); 536 (void)memcpy(ea->arp_spa, &itaddr, sizeof(ea->arp_spa)); 537 ea->arp_op = htons(ARPOP_REPLY); 538 ea->arp_pro = htons(ETHERTYPE_IP); /* let's be sure! */ 539 eh = (struct ether_header *)sa.sa_data; 540 (void)memcpy(eh->ether_dhost, ea->arp_tha, sizeof(eh->ether_dhost)); 541 eh->ether_type = ETHERTYPE_ARP; 542 sa.sa_family = AF_UNSPEC; 543 sa.sa_len = sizeof(sa); 544 (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0); 545 return; 546 } 547 548 /* 549 * Free an arp entry. 550 */ 551 static void 552 arptfree(la) 553 register struct llinfo_arp *la; 554 { 555 register struct rtentry *rt = la->la_rt; 556 register struct sockaddr_dl *sdl; 557 if (rt == 0) 558 panic("arptfree"); 559 if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) && 560 sdl->sdl_family == AF_LINK) { 561 sdl->sdl_alen = 0; 562 la->la_asked = 0; 563 rt->rt_flags &= ~RTF_REJECT; 564 return; 565 } 566 rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt), 567 0, (struct rtentry **)0); 568 } 569 /* 570 * Lookup or enter a new address in arptab. 571 */ 572 static struct llinfo_arp * 573 arplookup(addr, create, proxy) 574 u_long addr; 575 int create, proxy; 576 { 577 register struct rtentry *rt; 578 static struct sockaddr_inarp sin = {sizeof(sin), AF_INET }; 579 const char *why = 0; 580 581 sin.sin_addr.s_addr = addr; 582 sin.sin_other = proxy ? SIN_PROXY : 0; 583 rt = rtalloc1((struct sockaddr *)&sin, create, 0UL); 584 if (rt == 0) 585 return (0); 586 rt->rt_refcnt--; 587 588 if(rt->rt_flags & RTF_GATEWAY) 589 why = "host is not on local network"; 590 else if((rt->rt_flags & RTF_LLINFO) == 0) 591 why = "could not allocate llinfo"; 592 else if(rt->rt_gateway->sa_family != AF_LINK) 593 why = "gateway route is not ours"; 594 595 if(why && create) { 596 log(LOG_DEBUG, "arplookup %s failed: %s\n", 597 inet_ntoa(sin.sin_addr), why); 598 return 0; 599 } else if(why) { 600 return 0; 601 } 602 return ((struct llinfo_arp *)rt->rt_llinfo); 603 } 604 605 int 606 arpioctl(cmd, data) 607 int cmd; 608 caddr_t data; 609 { 610 return (EOPNOTSUPP); 611 } 612 613 void 614 arp_ifinit(ac, ifa) 615 struct arpcom *ac; 616 struct ifaddr *ifa; 617 { 618 ac->ac_ipaddr = IA_SIN(ifa)->sin_addr; 619 arpwhohas(ac, &ac->ac_ipaddr); 620 ifa->ifa_rtrequest = arp_rtrequest; 621 ifa->ifa_flags |= RTF_CLONING; 622 } 623