[Home]

Summary:ASTERISK-03924: Callid generation between restarts in chan_sip
Reporter:chuck_ramirez (chuck_ramirez)Labels:
Date Opened:2005-04-12 15:51:52Date Closed:2008-01-15 15:34:59.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Interoperability
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:chan_sip uses rand() to generate call-id and tags of sip messages. The rand() function need to be seeded with srand(), otherwise it will generate the same sequence os random numbers when the application is restarted (man pages for rand and srand).

Looking at all asterisk source code, only chan_iax2 and app_random use srand(time(NULL)) in load_module() function.

This should also be done in chan_sip to avoid generation of identical callids for different calls when chan_iax2/app_random are not being loaded.

One possible solution for that is to include srand(time(NULL)) in function reload_config().
Comments:By: Kevin P. Fleming (kpfleming) 2005-04-12 23:56:24

Fix committed to CVS, thanks! (I chose to just initialize them in the asterisk.c main() function, once it has decided it is actually going to start up as an instance of Asterisk and not just a console).

By: Mark Spencer (markster) 2005-04-13 02:00:33

made asterisk run srand() automatically.

By: Russell Bryant (russell) 2005-05-15 22:59:15

fixed in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:31:31.000-0600

Repository: asterisk
Revision: 5459

U   trunk/apps/app_random.c
U   trunk/asterisk.c
U   trunk/channels/chan_iax2.c
U   trunk/pbx/pbx_dundi.c
U   trunk/res/res_musiconhold.c

------------------------------------------------------------------------
r5459 | kpfleming | 2008-01-15 15:31:31 -0600 (Tue, 15 Jan 2008) | 4 lines

ensure that the random number generator(s) are always seeded with a different value during Asterisk startup
don't reinitialize random number generators in other modules
(bug ASTERISK-3924)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5459

By: Digium Subversion (svnbot) 2008-01-15 15:34:59.000-0600

Repository: asterisk
Revision: 5694

U   branches/v1-0/apps/app_random.c
U   branches/v1-0/asterisk.c
U   branches/v1-0/channels/chan_iax2.c

------------------------------------------------------------------------
r5694 | russell | 2008-01-15 15:34:59 -0600 (Tue, 15 Jan 2008) | 2 lines

only initialize random number generators in one place (bug ASTERISK-3924)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5694