| 408 | } while (0); |
| 409 | |
| 410 | static int |
| 411 | correct_mss(struct tcphdr *tc, int hlen, uint16_t maxmss, int flags) |
| 412 | { |
| 413 | int olen, optlen; |
| 414 | u_char *opt; |
| 415 | int accumulate; |
| 416 | int res = 0; |
| 417 | uint16_t sum; |
| 418 | |
| 419 | for (olen = hlen - sizeof(struct tcphdr), opt = (u_char *)(tc + 1); |
| 420 | olen > 0; olen -= optlen, opt += optlen) { |
| 421 | if (*opt == TCPOPT_EOL) |
| 422 | break; |
| 423 | else if (*opt == TCPOPT_NOP) |
| 424 | optlen = 1; |
| 425 | else { |
| 426 | optlen = *(opt + 1); |
| 427 | if (optlen <= 0 || optlen > olen) |
| 428 | break; |
| 429 | if (*opt == TCPOPT_MAXSEG) { |
| 430 | if (optlen != TCPOLEN_MAXSEG) |
| 431 | continue; |
| 432 | accumulate = be16dec(opt + 2); |
| 433 | if (accumulate > maxmss) { |
| 434 | if ((flags & CSUM_TCP) == 0) { |
| 435 | accumulate -= maxmss; |
| 436 | sum = be16dec(&tc->th_sum); |
| 437 | TCPMSS_ADJUST_CHECKSUM(accumulate, sum); |
| 438 | be16enc(&tc->th_sum, sum); |
| 439 | } |
| 440 | be16enc(opt + 2, maxmss); |
| 441 | res = 1; |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | return (res); |
| 447 | } |
no test coverage detected