* Set an individual arp entry */
| 349 | * Set an individual arp entry |
| 350 | */ |
| 351 | static int |
| 352 | set(int argc, char **argv) |
| 353 | { |
| 354 | struct sockaddr_in *addr; |
| 355 | struct sockaddr_in *dst; /* what are we looking for */ |
| 356 | struct sockaddr_dl *sdl; |
| 357 | struct rt_msghdr *rtm; |
| 358 | struct ether_addr *ea; |
| 359 | char *host = argv[0], *eaddr = argv[1]; |
| 360 | struct sockaddr_dl sdl_m; |
| 361 | |
| 362 | argc -= 2; |
| 363 | argv += 2; |
| 364 | |
| 365 | bzero(&sdl_m, sizeof(sdl_m)); |
| 366 | sdl_m.sdl_len = sizeof(sdl_m); |
| 367 | sdl_m.sdl_family = AF_LINK; |
| 368 | |
| 369 | dst = getaddr(host); |
| 370 | if (dst == NULL) |
| 371 | return (1); |
| 372 | doing_proxy = flags = expire_time = 0; |
| 373 | while (argc-- > 0) { |
| 374 | if (strcmp(argv[0], "temp") == 0) { |
| 375 | struct timespec tp; |
| 376 | int max_age; |
| 377 | size_t len = sizeof(max_age); |
| 378 | |
| 379 | clock_gettime(CLOCK_MONOTONIC, &tp); |
| 380 | if (sysctlbyname("net.link.ether.inet.max_age", |
| 381 | &max_age, &len, NULL, 0) != 0) |
| 382 | xo_err(1, "sysctlbyname"); |
| 383 | expire_time = tp.tv_sec + max_age; |
| 384 | } else if (strcmp(argv[0], "pub") == 0) { |
| 385 | flags |= RTF_ANNOUNCE; |
| 386 | doing_proxy = 1; |
| 387 | if (argc && strcmp(argv[1], "only") == 0) { |
| 388 | /* |
| 389 | * Compatibility: in pre FreeBSD 8 times |
| 390 | * the "only" keyword used to mean that |
| 391 | * an ARP entry should be announced, but |
| 392 | * not installed into routing table. |
| 393 | */ |
| 394 | argc--; argv++; |
| 395 | } |
| 396 | } else if (strcmp(argv[0], "blackhole") == 0) { |
| 397 | if (flags & RTF_REJECT) { |
| 398 | xo_errx(1, "Choose one of blackhole or reject, " |
| 399 | "not both."); |
| 400 | } |
| 401 | flags |= RTF_BLACKHOLE; |
| 402 | } else if (strcmp(argv[0], "reject") == 0) { |
| 403 | if (flags & RTF_BLACKHOLE) { |
| 404 | xo_errx(1, "Choose one of blackhole or reject, " |
| 405 | "not both."); |
| 406 | } |
| 407 | flags |= RTF_REJECT; |
| 408 | } else { |
no test coverage detected