I added the append_hf() inside the if condition in oureply_route[] block as given below, and it is working. I still want to learn how to store data in a variable to use it later in another block.
Thanks, Ajay
Hi Daniel,
Thanks for your response. But I don't want the IP in the received parameter of the incoming request. Instead, I want to read it (i.e. the public IP address of my own network where the local user and Kamailio are located) from the incoming response received from another proxy located outside the network. And I need that because Kamailio strips the top most via (where the received parameter is present ) in the incoming response before sending it back to the local user, which I guess is correct. But the user needs to know that IP address. So we are planning to send that IP address in a custom header in the response back to the user.
After going through some Kamailio documents I found that $sel(via.received) would return the IP address in top most via of a message. Can I store it in a variable inside onreply_route[MANAGE_REPLY] block and use that variable later in some appropriate route block to insert a new header in the response to the local user?
Can I do something as given below to fetch and store the IP address from received parameter in the via header of incoming response
onreply_route[MANAGE_REPLY] { ... if(search_hf("Via", "received", "f")) { xdbg("received param exists on top most via header \n"); $var(public_ip) = $sel(via.received); } ... }
and insert a new header as given below in an appropriate route block which is executed while sending response back? append_hf("My-custom-hdr: $var(public_ip) \r\n");
I am not sure if this logic would work. Is the $var() variable retained through two different sip transactions? And which route block should be used to insert the header as mentioned above? Please help.
Thanks, Ajay
Hello,
the received parameter is constructed from source IP of the incoming request. You get it via $si script variable.
Cheers, Daniel
On 3/12/13 7:22 PM, Ajay Sabat wrote:
-- Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio World Conference, April 16-17, 2013, Berlin - http://conference.kamailio.com -