[asterisk-dev] Finding the original sip_pvt

Torbjörn Abrahamsson torbjorn.abrahamsson at gmail.com
Mon May 16 06:06:34 CDT 2011


Hello,

 

I have a problem where I need to find the pvt which handled the original
incoming INVITE, but unforutnatly I cannot find this reference.

 

I have added a field to the sip_pvt, which I populate in
handle_request_invite by:

 

p->testingvariable = !ast_strlen_zero(get_header(req, "P-Testing-Header"));

 

ie if SIP-header P-Testing-Header is set p->testingvariable is set to true
or false. This part work like a charm


 

Now.. I use Dial to create an outbound INVITE to which I would like to add a
header if p->testingvariable is set on the original pvt. The problem is that
I cannot find this reference.

 

I realize that the above can be accomplished using the dialplan, with
SIPHEADER() and SIPAddHeader(), but I also need to extend this to the
response. When the 200 OK is received for the second leg, I want to check if
the header P-Testing-Response is present, and then set another field in the
original pvt, p->testingresponse = 1. So before the 200 OK is sent on the
first leg, the testingresponse variable should be checked, and if set it
should add the P-Testing-Response to the response.

 

So my problem now is that I cannot find a reference to the original pvt or
channel.

 

My dialplan is very simple, as the only thing it does is perform a Dial.

 

I have tried ‘p->owner->tech_pvt’, but this seem to, if I understand it
correct, point back to p itself?

 

I have tried to find the original channel (name sipin-00000000) with:

 

p->owner->name (set to sipout-00000001)

p->owner->masq->name (not set)

p->owner->masqr->name (not set)

p->owner->_bridge->name (not set)

 

These were all ast_channel references I found in p->owner, and the only
reference to an ast_channel in p is owner. So is there a reference in some
place I have missed?

 

Now if I have missed the obvious (and correct) way to do this, please
enlighten me.. Maybe there is somewhere the new pvt is created, and some of
its variables gets populated?

 

Many thanks in advance,

Torbjörn Abrahamsson

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110516/fcd438af/attachment.htm>


More information about the asterisk-dev mailing list