[pjsua] IPv6 accaunt have to use media in IPv6

AV
Alexey Vasilyev
Tue, Jan 22, 2019 9:44 AM

Hi, everybody.

I've tried to use pjsua app in IPv4+IPv6 environment. Pjproject v 2.8
This is config file:
--id sip:204@sip.test.com
--registrar sip:sip.test.com;transport=tcp
--ipv6
--no-udp
--use-srtp=0
--srtp-secure=0
--realm *
--username 204
--password xxxpasswordxxx
--log-level=6
--app-log-level=4
--log-file=pjsua.log
--auto-update-nat=0
--disable-stun
--null-audio
--play-file=demo.wav
--auto-play
--auto-answer=200

sip.test.com is resolved to IPv6 address. Pjsua successfully registered to
it. And all signaling works fine. (With UDP and TLS the same)
When I try to call to pjsua, INVITE comes in IPv6, SDP also contains IPv6
address, but I can see, that RTP and RTCP sockets created are IPv4 only. So
of course I get 488 reply from pjsua.
This is because when adding accounts from config tp_type is always 0. We
don't know it. And when incoming call comes it by default creates sockets
of IPv4.

I think, that if we register over IPv6, we should use the same AF for
media. This patch saves tp_type the same, as transport type used for
registration (auto_rereg is not used):

diff --git a/pjsip/src/pjsua-lib/pjsua_acc1.c
b/pjsip/src/pjsua-lib/pjsua_acc.c
index 64d1124..c28ccd3 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc1.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -2749,10 +2749,11 @@ PJ_DEF(pj_status_t) pjsua_acc_set_registration(
pjsua_acc_id acc_id,
* employed). A more reliable way is to query the regc directly
* when needed.
*/

  •   //pjsip_regc_info reg_info;
    
  •   pjsip_regc_info reg_info;
    
  •   //pjsip_regc_get_info(pjsua_var.acc[acc_id].regc, &reg_info);
    
  •   pjsip_regc_get_info(pjsua_var.acc[acc_id].regc, &reg_info);
      //pjsua_var.acc[acc_id].auto_rereg.reg_tp = reg_info.transport;
    
  •    pjsua_var.acc[acc_id].tp_type =
    

pjsip_transport_get_type_from_flag(reg_info.transport->flag);

     if (pjsua_var.ua_cfg.cb.on_reg_started) {
         (*pjsua_var.ua_cfg.cb.on_reg_started)(acc_id, renew);

After that transport for RTP initialized with correct address family.
Can you please review?

Best regards
Alexey Vasilyev

Hi, everybody. I've tried to use pjsua app in IPv4+IPv6 environment. Pjproject v 2.8 This is config file: --id sip:204@sip.test.com --registrar sip:sip.test.com;transport=tcp --ipv6 --no-udp --use-srtp=0 --srtp-secure=0 --realm * --username 204 --password xxxpasswordxxx --log-level=6 --app-log-level=4 --log-file=pjsua.log --auto-update-nat=0 --disable-stun --null-audio --play-file=demo.wav --auto-play --auto-answer=200 sip.test.com is resolved to IPv6 address. Pjsua successfully registered to it. And all signaling works fine. (With UDP and TLS the same) When I try to call to pjsua, INVITE comes in IPv6, SDP also contains IPv6 address, but I can see, that RTP and RTCP sockets created are IPv4 only. So of course I get 488 reply from pjsua. This is because when adding accounts from config tp_type is always 0. We don't know it. And when incoming call comes it by default creates sockets of IPv4. I think, that if we register over IPv6, we should use the same AF for media. This patch saves tp_type the same, as transport type used for registration (auto_rereg is not used): diff --git a/pjsip/src/pjsua-lib/pjsua_acc1.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 64d1124..c28ccd3 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc1.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -2749,10 +2749,11 @@ PJ_DEF(pj_status_t) pjsua_acc_set_registration( pjsua_acc_id acc_id, * employed). A more reliable way is to query the regc directly * when needed. */ - //pjsip_regc_info reg_info; + pjsip_regc_info reg_info; - //pjsip_regc_get_info(pjsua_var.acc[acc_id].regc, &reg_info); + pjsip_regc_get_info(pjsua_var.acc[acc_id].regc, &reg_info); //pjsua_var.acc[acc_id].auto_rereg.reg_tp = reg_info.transport; + pjsua_var.acc[acc_id].tp_type = pjsip_transport_get_type_from_flag(reg_info.transport->flag); if (pjsua_var.ua_cfg.cb.on_reg_started) { (*pjsua_var.ua_cfg.cb.on_reg_started)(acc_id, renew); After that transport for RTP initialized with correct address family. Can you please review? -- Best regards Alexey Vasilyev