| 432 | } |
| 433 | |
| 434 | static int |
| 435 | IcmpAliasIn(struct libalias *la, struct ip *pip) |
| 436 | { |
| 437 | struct icmp *ic; |
| 438 | int iresult; |
| 439 | size_t dlen; |
| 440 | |
| 441 | LIBALIAS_LOCK_ASSERT(la); |
| 442 | |
| 443 | dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); |
| 444 | if (dlen < ICMP_MINLEN) |
| 445 | return (PKT_ALIAS_IGNORED); |
| 446 | |
| 447 | /* Return if proxy-only mode is enabled */ |
| 448 | if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) |
| 449 | return (PKT_ALIAS_OK); |
| 450 | |
| 451 | ic = (struct icmp *)ip_next(pip); |
| 452 | |
| 453 | iresult = PKT_ALIAS_IGNORED; |
| 454 | switch (ic->icmp_type) { |
| 455 | case ICMP_ECHOREPLY: |
| 456 | case ICMP_TSTAMPREPLY: |
| 457 | if (ic->icmp_code == 0) { |
| 458 | iresult = IcmpAliasIn1(la, pip); |
| 459 | } |
| 460 | break; |
| 461 | case ICMP_UNREACH: |
| 462 | case ICMP_SOURCEQUENCH: |
| 463 | case ICMP_TIMXCEED: |
| 464 | case ICMP_PARAMPROB: |
| 465 | if (dlen < ICMP_ADVLENMIN || |
| 466 | dlen < (size_t)ICMP_ADVLEN(ic)) |
| 467 | return (PKT_ALIAS_IGNORED); |
| 468 | iresult = IcmpAliasIn2(la, pip); |
| 469 | break; |
| 470 | case ICMP_ECHO: |
| 471 | case ICMP_TSTAMP: |
| 472 | iresult = IcmpAliasIn1(la, pip); |
| 473 | break; |
| 474 | } |
| 475 | return (iresult); |
| 476 | } |
| 477 | |
| 478 | static int |
| 479 | IcmpAliasOut1(struct libalias *la, struct ip *pip, int create) |
no test coverage detected