My application needs the destination IP from an incoming/outgoing sip request (SipServletRequest). I am using MessageListener to listen the sip messages coming in and going out. unable to find the destination ip from the sip message (request).
Thanks for your time, yes getRemoteAddr and getInitialRemoteAddr will provide the originating ip. But we need the destination/ termination/target ip, to which the message should reach finally. For instance, If in case OCCAS is acting as a proxy UA1 sending INVITE, to UA2. getInitialRemoteAddr will give the UA1 ip address, but how to get the UA2 ip. Is there any api something like getTermAddr / getDestAddr, I did not find in the SipServletMessage or SipServletRequest. Is there any indirect way to get the destination / termination ip...
There is no API to provide the actually resolved terminating IP where message will finally be sent. This is something which happens at lower level (transport layer) in the container and control is already outside application scope.
But if you enable message-debug in sipserver.xml , you'll see that it prints out the actual IP where message is finally sent..something like following.
am not suer if you look at the appropriate message.
If you send out the request you wont know where it is going to be sent to as the container resolves the address through DNS. However you could do tihs resolution in your app and set a route-header with the IP to send it to.
Alternatively i believe it should be possible to see the remote IP address on the SIP Response you get from the far end. if you call getRemoteAddr on the SipServletResponse you shoudl get the information.
Thanks Anurag, Yes, i am exactly struck there. I need the transport layer info. I saw the sip messages generated by the container. When a message is leaving out the container it is logging the message with destination ip, and port in the sip-messages.log, but the same message when it comes as a SipServletRequest to MessageListener the destination ip, and port are not provided in the object...