4

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:

  1. 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

  1. 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.

  1. 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.

  1. 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

atsakiridis
  • 1,002
  • 5
  • 19

1 Answers1

2

A BYE is an in-dialog request, and so it should follow the Route headers, if they are present. I'm only vaguely familiar with Sofia, but if you added the IP:port the INVITE was actually received from to the routeset on your side and added it to the list of Route headers when you send future in-dialog requests, Sofia should route by the Route headers first, then the RURI (which is usually derived from the Contact of the other side).

korvus
  • 395
  • 1
  • 5
  • Thanks a lot for the answer; for now I found a way to workaround this by passing an outbound proxy to nua_create in Sofia. Once I get some free time I'll try to test this as well and let you know if it worked – atsakiridis Aug 07 '15 at 14:36