Summary:ASTERISK-01483: Channel properties will be setted after "ast_setstate" in several channel modules
Reporter:thaeger (thaeger)Labels:
Date Opened:2004-04-28 07:02:11Date Closed:2008-01-15 14:52:16.000-0600
Versions:Frequency of
Environment:Attachments:( 0) ast_setstate.patch.txt
Description:Hi all together,

i have noticed that in the manager event messages the callerid is often not setted although the callerid is known at this time. I have also found out why it is so...but i don't know in how many channel modules this problem exists..

The Problem is as following for chan_zap and chan_h323:

In every channel module exists an function for getting an ast_channel (chan_h323: oh323_new)... and in this function will be executed the function called "ast_setstate", but this will be done before the channel properies will be setted, and so the manager interface events transport not the correct informations, for example the callerid is "<unkbown>" althouh the callerid is known.

It would be very nice if someone of the CVS Writer can fix these little bugs in the channel modules chan_zap, chan_h323,chan_sip.

In chan_iax2 it was done correctly ;-)


Comments:By: Mark Spencer (markster) 2004-04-28 09:58:11

Fixed it in zap.  Is it really still broken in chan_h323, even in cvs head?

By: thaeger (thaeger) 2004-04-28 10:03:44

Yes it is broken in chan_h323 and also in chan_sip....

By: Mark Spencer (markster) 2004-04-28 10:11:12

Can you at least confirm my change in zap fixes it for zap?

By: thaeger (thaeger) 2004-04-28 10:20:56


i have looked after your change, and i think this should work.
This is the same what i have done at our Asterisk, so that the messages are coming  right. But the same have to be done with chan_h323 and chan_sip.

By: Mark Spencer (markster) 2004-04-28 10:28:53

Fixed in CVS head

By: thaeger (thaeger) 2004-04-28 10:37:48

Sorry Mark,

but i think it is not solved for chan_h323 and chan_sip ....
Please forgive me ;-)

By: Mark Spencer (markster) 2004-04-28 11:51:09

Really the changes are there, you probably just didn't wait for it to get propagated.  Please be sure you see the changes and reopen if you see the changes to chan_sip and chan_h323 and it's still not fixed.

By: thaeger (thaeger) 2004-04-28 12:14:08


i have new checked out the newest cvs repository, but i can't see any changes in chan_sip and chan_h323....

By: Mark Spencer (markster) 2004-04-28 15:18:28

Just find me on IRC.  It really is there.  I can see the changes just as you asked for them.  Again, checkout a clean copy or do whatever you have to do to see the changes and only reopen if you *see* the changes (i.e. ast_setstate just before starting the pbx) and it still doesn't solve your problem.

By: thaeger (thaeger) 2004-04-28 17:07:02


i'am sorry, maybe you have changed somthing, but if so it was not what i meant.
The "ast_setstate" method have to be executed after setting the last channel property, i think. And in the fresh cvs copy the "ast_setstate" method will be executed before setting the properties, like the line "tmp->callerid=strdup..." in chan_zap.c
I mean the excution of "ast_setstate" in "zt_new" chan_zap, "oh323_new" in chan_h323 and "sip_new" in chan_sip.
In all three modules.

I've added a little patch so that you can see what i mean.
And...i have really checked out a very fresh copy from cvs....



By: Mark Spencer (markster) 2004-04-28 22:56:15

Are you running -stable or head?

By: thaeger (thaeger) 2004-04-29 03:39:03

Now i looked after in "head" (without any tag) and stable(v1-0_stable), but i don't see any changes. Meanwhile i checked out on two different machines.
Have you seen my patch ?

By: Mark Spencer (markster) 2004-04-29 09:24:49

[root@localhost channels]# patch -p0 < /root/ast_setstate.patch.txt
patching file chan_h323.c
Hunk #1 FAILED at 656.
Hunk #2 FAILED at 700.
2 out of 2 hunks FAILED -- saving rejects to file chan_h323.c.rej
patching file chan_sip.c
Hunk #1 FAILED at 1557.
Hunk #2 succeeded at 1601 (offset -1 lines).
1 out of 2 hunks FAILED -- saving rejects to file chan_sip.c.rej
patching file chan_zap.c
Hunk #1 FAILED at 4087.
Hunk #2 succeeded at 4105 (offset -5 lines).
1 out of 2 hunks FAILED -- saving rejects to file chan_zap.c.rej

What a surprise, your patch doesn't apply...  Maybe that's because changes are already there that somehow you're just not getting.  They're only in CVS head, so please be sure you're using CVS head.

By: thaeger (thaeger) 2004-04-29 09:34:28

hello Mark,

what a surprise ;-) now i can see the changes too.


By: thaeger (thaeger) 2004-04-29 09:40:00


i swear i don't see the changes yesterday and today morning, although i checked out the newest version in a freh directory... i don't know what the problem was.

However, thank you for your efforts and be longanimous with me :-)



By: Mark Spencer (markster) 2004-04-29 09:48:11

No prob, sorry you had trouble getting them.


By: Digium Subversion (svnbot) 2008-01-15 14:52:16.000-0600

Repository: asterisk
Revision: 2793

U   trunk/asterisk.c
U   trunk/channels/chan_zap.c

r2793 | markster | 2008-01-15 14:52:16 -0600 (Tue, 15 Jan 2008) | 2 lines

Provide gethostbyname_r emulation for FreeBSD and fix zap call to setstate to include callerid (bug ASTERISK-1396, ASTERISK-1483)