Let me describe my problem first. I'm using Sofia SIP for a telephony application and the SIP proxy I'm using is behind a NAT. This means that an incoming invite from the proxy has as Contact header the internal proxy IP (for example 10.0.0.1). This means that when I hang up the phone from my application Sofia automatically sets as destination for the BYE message the IP 10.0.0.1, which as you can imagine is not routable and as a result it fails.
So what I want to do is to change the destination for the BYE message to be the 'external' proxy IP address. The problem is that Sofia doesn't seem to allow me to change the destination for the SIP message; it always uses the contact it got when receiving the INVITE. Here's what I've tried:
Enforcing a hardcoded value for SIPTAG_TO:
nua_bye(op->op_handle, SIPTAG_TO(sip_to_make(ssc->ssc_home, "sip:alice@54.15.123.11")), TAG_END());
The result for this was that the To header was updated with external ip but the SIP message was still destined to the internal proxy ip
Enforcing a a hardcoded value to NUTAG_URL:
sip_to_t * to = sip_to_make(ssc->ssc_home, "sip:alice@54.15.123.11");
ua_bye(op->op_handle, NUTAG_URL(to->a_url), TAG_END());
This had no effect.
Enforcing hardcoded value for SIPTAG_REQUEST_STR:
nua_bye(op->op_handle, SIPTAG_REQUEST_STR("BYE sip:alice@54.15.123.11 SIP/2.0"), TAG_END());
This had no effect.
Did the same but through the transaction handle:
nua_set_hparams(op->op_handle,SIPTAG_REQUEST_STR("BYE sip:alice@54.15.123.11 SIP/2.0"), TAG_NULL());
nua_bye(op->op_handle, TAG_END());
Again no effect
Then I thought of going a little earlier when the incoming INVITE arrived from the proxy and maybe alter the contact, since this is where the subsequent BYE is sent, but again no luck: trying to update it through nua_set_hparams had no effect same for the global params with nua_set_params.
Seems that what I want to do is very simple (and necessary given the NAT configurations out there) but yet it's as if Sofia specifically disallows it (if you check the nua_bye docs there aren't any relevant TAGS documented).
I also thought of using one of Sofia's lower level APIs such as NTA (instead NUA) but it seems very hard to mix NUA with any of the lower level APIs.
Any ideas are more than welcome
Best regards,
Antonis