Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int su_randint ( int  lb,
int  ub 

Random integer in range [lb, ub] (inclusive).

The function randint() generates a pseudo-random integer in the range [ln, ub] (inclusive).

lb [in] lower bound
ub [in] upper bound
The function randint() returns a pseudo-random integer.

Definition at line 290 of file su_uniqueid.c.

References initialized, and su_randint().

Referenced by su_randint(), and tport_recv_dgram().

  unsigned rnd = 0;

  if (!initialized) init();

  if (urandom) {
    size_t len = fread(&rnd, 1, sizeof rnd, urandom); (void)len;
    rnd = random();

  if (ub - lb + 1 != 0)
    rnd %= (ub - lb + 1);

  return rnd + lb;

Generated by  Doxygen 1.6.0   Back to index