| 225 | } |
| 226 | |
| 227 | static u_int32_t |
| 228 | randomid(struct randomtab *p) |
| 229 | { |
| 230 | int i, n; |
| 231 | |
| 232 | if (p->ru_counter >= p->ru_max || time_uptime > p->ru_reseed) |
| 233 | initid(p); |
| 234 | |
| 235 | /* Skip a random number of ids */ |
| 236 | n = arc4random() & 0x3; |
| 237 | if (p->ru_counter + n >= p->ru_max) |
| 238 | initid(p); |
| 239 | |
| 240 | for (i = 0; i <= n; i++) { |
| 241 | /* Linear Congruential Generator */ |
| 242 | p->ru_x = (u_int32_t)((u_int64_t)p->ru_a * p->ru_x + p->ru_b) % p->ru_m; |
| 243 | } |
| 244 | |
| 245 | p->ru_counter += i; |
| 246 | |
| 247 | return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 + p->ru_x, p->ru_n)) | |
| 248 | p->ru_msb; |
| 249 | } |
| 250 | |
| 251 | u_int32_t |
| 252 | ip6_randomid(void) |
no test coverage detected