* Return the largest MTU in sctp_mtu_sizes smaller than val. * If val is smaller than the minimum, just return the largest * multiple of 4 smaller or equal to val. * Ensure that the result is a multiple of 4. */
| 947 | * Ensure that the result is a multiple of 4. |
| 948 | */ |
| 949 | uint32_t |
| 950 | sctp_get_prev_mtu(uint32_t val) |
| 951 | { |
| 952 | uint32_t i; |
| 953 | |
| 954 | val &= 0xfffffffc; |
| 955 | if (val <= sctp_mtu_sizes[0]) { |
| 956 | return (val); |
| 957 | } |
| 958 | for (i = 1; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) { |
| 959 | if (val <= sctp_mtu_sizes[i]) { |
| 960 | break; |
| 961 | } |
| 962 | } |
| 963 | KASSERT((sctp_mtu_sizes[i - 1] & 0x00000003) == 0, |
| 964 | ("sctp_mtu_sizes[%u] not a multiple of 4", i - 1)); |
| 965 | return (sctp_mtu_sizes[i - 1]); |
| 966 | } |
| 967 | |
| 968 | /* |
| 969 | * Return the smallest MTU in sctp_mtu_sizes larger than val. |