#include <dns.h> dns_random_init(seed); r = dns_random(m); char seed[128]; unsigned int r; unsigned int m;dns_random computes a pseudorandom 32-bit integer and returns that integer modulo m. It returns 0 if m is 0.
dns_random_init initializes the pseudorandom number generator, taking account of seed, the current process ID, and the current time.
An active sniffing attacker can easily forge responses by copying information from queries. Blind attackers need to guess the time, UDP port, and ID for the targeted query name.
The dns_transmit functions use dns_random to create query IDs and UDP ports. The dns_random generator is designed to be extremely difficult to predict for an attacker who cannot guess seed. Note, however, that there are only about a billion possible ID-port pairs, so a prolonged blind attack will succeed eventually.