| 83 | #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; (void)ADDCARRY(sum);} |
| 84 | |
| 85 | static int |
| 86 | _in6_cksum_pseudo(struct ip6_hdr *ip6, uint32_t len, uint8_t nxt, uint16_t csum) |
| 87 | { |
| 88 | int sum; |
| 89 | uint16_t scope, *w; |
| 90 | union { |
| 91 | u_int16_t phs[4]; |
| 92 | struct { |
| 93 | u_int32_t ph_len; |
| 94 | u_int8_t ph_zero[3]; |
| 95 | u_int8_t ph_nxt; |
| 96 | } __packed ph; |
| 97 | } uph; |
| 98 | |
| 99 | sum = csum; |
| 100 | |
| 101 | /* |
| 102 | * First create IP6 pseudo header and calculate a summary. |
| 103 | */ |
| 104 | uph.ph.ph_len = htonl(len); |
| 105 | uph.ph.ph_zero[0] = uph.ph.ph_zero[1] = uph.ph.ph_zero[2] = 0; |
| 106 | uph.ph.ph_nxt = nxt; |
| 107 | |
| 108 | /* Payload length and upper layer identifier. */ |
| 109 | sum += uph.phs[0]; sum += uph.phs[1]; |
| 110 | sum += uph.phs[2]; sum += uph.phs[3]; |
| 111 | |
| 112 | /* IPv6 source address. */ |
| 113 | scope = in6_getscope(&ip6->ip6_src); |
| 114 | w = (u_int16_t *)&ip6->ip6_src; |
| 115 | sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; |
| 116 | sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; |
| 117 | if (scope != 0) |
| 118 | sum -= scope; |
| 119 | |
| 120 | /* IPv6 destination address. */ |
| 121 | scope = in6_getscope(&ip6->ip6_dst); |
| 122 | w = (u_int16_t *)&ip6->ip6_dst; |
| 123 | sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; |
| 124 | sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; |
| 125 | if (scope != 0) |
| 126 | sum -= scope; |
| 127 | |
| 128 | return (sum); |
| 129 | } |
| 130 | |
| 131 | int |
| 132 | in6_cksum_pseudo(struct ip6_hdr *ip6, uint32_t len, uint8_t nxt, uint16_t csum) |
no test coverage detected