c-如何使用指定的网络接口注册SIP帐户



我正在使用Pjsip库向Sip服务器注册Sip帐户

/* Register to SIP server by creating SIP account. */
  {
 pjsua_acc_config cfg;
 
 pjsua_acc_config_default(&cfg);
 cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN);
 cfg.reg_uri = pj_str("sip:" SIP_DOMAIN);
 cfg.cred_count = 1;
 cfg.cred_info[0].realm = pj_str(SIP_DOMAIN);
 cfg.cred_info[0].scheme = pj_str("digest");
 cfg.cred_info[0].username = pj_str(SIP_USER);
 cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
 cfg.cred_info[0].data = pj_str(SIP_PASSWD);
 
  status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
  if (status != PJ_SUCCESS) error_exit("Error adding account", status);
 }

当我的板只有一个网络接口时,这很好,但当我在一个有很多网络接口的新板上运行它时,它总是通过IP地址值较小的接口注册到服务器。我在这个链接中读到:https://trac.pjsip.org/repos/wiki/FAQ#multihomed并通过其算法实现了Pjsip总是选择一个网络接口进行注册。我尝试将我的应用程序绑定到一个newtork接口,就像这样:https://unix.stackexchange.com/questions/210982/bind-unix-program-to-specific-network-interface但它也不起作用。我需要在代码中手动选择网络接口,我该怎么做?

在pjsip配置中搜索名为bound_addr的参数-传输配置和rtp配置中应该有一个(除非有更新(。这是通过接口地址而不是接口名称进行绑定,但如果需要,它可能是修改的起点。

最新更新