MCPcopy Create free account
hub / github.com/F-Stack/f-stack / randomid

Function randomid

freebsd/netinet6/ip6_id.c:227–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static u_int32_t
228randomid(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
251u_int32_t
252ip6_randomid(void)

Callers 2

ip6_randomidFunction · 0.85
ip6_randomflowlabelFunction · 0.85

Calls 3

initidFunction · 0.85
pmodFunction · 0.85
arc4randomFunction · 0.50

Tested by

no test coverage detected