Thread safe random functions. More...
| Functions | |
| struct ub_randstate * | ub_initstate (struct ub_randstate *from) | 
| Initialize a random generator state for use. | |
| long int | ub_random (struct ub_randstate *state) | 
| Generate next random number from the state passed along. | |
| long int | ub_random_max (struct ub_randstate *state, long int x) | 
| Generate random number between 0 and x-1. | |
| void | ub_randfree (struct ub_randstate *state) | 
| Delete the random state. | |
Thread safe random functions.
Similar to arc4random() with an explicit initialisation routine.
| struct ub_randstate * ub_initstate | ( | struct ub_randstate * | from | ) | 
Initialize a random generator state for use.
| from | if not NULL, the seed is taken from this random structure. can be used to seed random states via a parent-random-state that is itself seeded with entropy. | 
Referenced by daemon_create_workers(), init_cookie_secret(), libworker_setup(), rnd_test(), tcpid_test(), ub_ctx_create_nopipe(), and worker_create().
| long int ub_random | ( | struct ub_randstate * | state | ) | 
Generate next random number from the state passed along.
Thread safe, so random numbers are repeatable.
| state | must have been initialised with ub_initstate. | 
Referenced by daemon_create_workers(), init_cookie_secret(), libworker_setup(), rnd_test(), and serviced_perturb_qname().
| long int ub_random_max | ( | struct ub_randstate * | state, | 
| long int | x | ||
| ) | 
Generate random number between 0 and x-1.
No modulo bias.
| state | must have been initialised with ub_initstate. | 
| x | an upper limit. not (negative or zero). must be smaller than 2**31. | 
Referenced by calc_next_probe(), create_socketpair(), daemon_get_shufport(), fd_for_dest(), iter_filter_order(), iter_ns_probability(), iter_server_selection(), outnet_serviced_query(), pick_outgoing_tcp(), processQueryTargets(), reuse_tcp_select_id(), rnd_test(), select_ifport(), and validate_suspend_setup_timer().
| void ub_randfree | ( | struct ub_randstate * | state | ) | 
Delete the random state.
| state | to delete. | 
Referenced by daemon_delete(), init_cookie_secret(), libworker_delete_env(), rnd_test(), tcpid_test(), ub_ctx_create(), ub_ctx_create_nopipe(), ub_ctx_delete(), and worker_delete().