Tracking a transfer, asterisk 1.2

I am keeping track of all calls on my asterisk box with a complex set of AGI scripts.

Basically, the AGI scripts create and move database entries when a call is made, and when a call ends.

With my SPA942, I can do a conference, and the SPA942 does the audio mixing. I dont want asterisk to do any of the audio mixing which is good.

Now if I do a blind transfer, it just says “exited non-zero” and hangs up on the person you were trying to transfer which is good, because I dont want these people to transfer between each other, but if they make one call on line 1 of their phone, and another call on line 2 of their phone, and then push xferLX, it joins both legs of the call together and hangs up the SPA942. On the asterisk side, this is reflected as a native bridge, but since the 942 is hungup, my scripts remove the database entry for one of the calls, but leaves the other one open.

Now when that bridged call hangs up, the other call still in the database is never removed. Does it have a new channel name or somethign? (Thats how my scripts identify a call).

So the bottom line is that I want to disable call transfers on this asterisk box. I have a feeling that the SPA942 is reinviting asterisk to do this trick. I have canreinvite=no for that phone but that only prevents ASTERISK from reinviting the PHONE - not the other way around unfortunately.

How can I block asterisk from receiving re-invites? Or decline them or something?

I suppose it will require editing the source code, but surely once a call has been invited, it wont need a reinvite! I am happy for asterisk to process RTP streams all day long, and I want it that way so that it has end-to-end control over the calls.

Any help? Thanks!

Well, today I delved into the source code and was surprised to find how neat it was in there.

Well, I tried disabling the “features” called “REFER” and “REPLACE HEADER” but that didn’t work. Asterisk still happily transferred the calls. So I edited channels/chan_sip.c

I found the function “handle_request_refer”, and added this in at the top of the function underneath the erm declarations or whatever they are called:

if (2 > 1) { /*2 is always greater than 1, decline ALL requests! */ res = -1; transmit_response(p, "603 Declined", req); return res; }

Ta da! No more transfers in any shape or form!

Edit: Refined code a little.

I should also mention that when a Sipura tries to transfer a call and gets declined, it ends up losing the call. Basically, all of the calls involved will get disconnected.