IOS 从 Nat64 网络到 IPV4 服务器的 PJSIP 注册
PJSIP Registration to IPV4 Server from Nat64 network in IOS
我正在使用 pjsip-2.6
和 IPV4 sip server
开发一个 IOS 应用程序。首先在 configsite.h
中使用以下代码构建 pjsip
#define PJ_HAS_IPV6 1
构建成功。然后我将这些库添加到我的 project.Run IPV4
network.Its 中的应用程序中成功注册并且语音通话效果很好。
然后我将网络切换到 Apple Nat64
网络..Nothings works.Here 是我的代码片段。
为了在 IPV4
上创建 udp
传输,我使用了以下代码。
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5060;
// Add UDP transport.
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, &transport_id);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
为了在 IPV6 上创建传输,我使用了以下代码..
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5070;
// Add UDP transport for ipv6
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP6, &cfg, &transport_id_udp6);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
为了在 IPV6 网络中创建帐户,我添加了..
acc_cfg.cred_info[0].username = pj_str((char*)uname);
acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
acc_cfg.cred_info[0].data = pj_str((char *)passwd);
acc_cfg.cred_info[0].realm = pj_str("*");
acc_cfg.cred_info[0].scheme=pj_str((char*)"Digest");
char regUri[PJSIP_MAX_URL_SIZE];
sprintf(regUri, "sip:%s", sip_server);
acc_cfg.reg_uri = pj_str(regUri);
acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED;
acc_cfg.transport_id = transport_id_udp6;
如果有人能指出我会更好 problem.Any 帮助将不胜感激。
我认为您在 IPV6 网络中创建传输失败。
一个可用补丁(Link:https://github.com/johanlantz/pj-nat64)
您需要为 NAT64 问题集成该补丁,下面是要遵循的步骤。
1) 从上面下载 pj-nat64 源 link.
2) 解压文件并复制pj-nat64.c文件粘贴到pjproject中(指pjsip源)(路径为:pjsip/src/pjsua-lib)
3) 复制pj-nat64.h 文件粘贴到pjproject(指pjsip源)(路径是:pjsip/include/pjsua-lib)
4)需要在pjsip的makefile中添加pj-nat64.o(Make文件路径为:pjsip/build)
5) 打开 makefile 并搜索双引号中的字符串“Defines for building PJSUA-LIB library”,在 pjsua_vid.o
之后添加 pj-nat64.o
6) 编译所有架构的 pjsip 源代码并获取库文件和头文件
7) Pjsua_start 方法后 returns 成功。包括以下几行。
#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 == 1
pj_nat64_enable_rewrite_module();
#endif
8) 在调用的on_reg_state2() 方法中添加以下代码。
the_transport = rp->rdata->tp_info.transport;
NSLog(@"transport called %s",the_transport->factory->type_name);
if (the_transport->factory->type & PJSIP_TRANSPORT_IPV6)
{
ipv4=FALSE;
NSLog(@"enter into the ipv6 loop ");
pjsua_var.acc[0].cfg.ipv6_media_use=PJSUA_IPV6_ENABLED ;
nat64_options option=NAT64_REWRITE_INCOMING_SDP | NAT64_REWRITE_ROUTE_AND_CONTACT;
pj_nat64_set_options(option);
}
我正在使用 pjsip-2.6
和 IPV4 sip server
开发一个 IOS 应用程序。首先在 configsite.h
#define PJ_HAS_IPV6 1
构建成功。然后我将这些库添加到我的 project.Run IPV4
network.Its 中的应用程序中成功注册并且语音通话效果很好。
然后我将网络切换到 Apple Nat64
网络..Nothings works.Here 是我的代码片段。
为了在 IPV4
上创建 udp
传输,我使用了以下代码。
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5060;
// Add UDP transport.
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, &transport_id);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
为了在 IPV6 上创建传输,我使用了以下代码..
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5070;
// Add UDP transport for ipv6
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP6, &cfg, &transport_id_udp6);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
为了在 IPV6 网络中创建帐户,我添加了..
acc_cfg.cred_info[0].username = pj_str((char*)uname);
acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
acc_cfg.cred_info[0].data = pj_str((char *)passwd);
acc_cfg.cred_info[0].realm = pj_str("*");
acc_cfg.cred_info[0].scheme=pj_str((char*)"Digest");
char regUri[PJSIP_MAX_URL_SIZE];
sprintf(regUri, "sip:%s", sip_server);
acc_cfg.reg_uri = pj_str(regUri);
acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED;
acc_cfg.transport_id = transport_id_udp6;
如果有人能指出我会更好 problem.Any 帮助将不胜感激。
我认为您在 IPV6 网络中创建传输失败。
一个可用补丁(Link:https://github.com/johanlantz/pj-nat64) 您需要为 NAT64 问题集成该补丁,下面是要遵循的步骤。
1) 从上面下载 pj-nat64 源 link.
2) 解压文件并复制pj-nat64.c文件粘贴到pjproject中(指pjsip源)(路径为:pjsip/src/pjsua-lib)
3) 复制pj-nat64.h 文件粘贴到pjproject(指pjsip源)(路径是:pjsip/include/pjsua-lib)
4)需要在pjsip的makefile中添加pj-nat64.o(Make文件路径为:pjsip/build)
5) 打开 makefile 并搜索双引号中的字符串“Defines for building PJSUA-LIB library”,在 pjsua_vid.o
之后添加 pj-nat64.o6) 编译所有架构的 pjsip 源代码并获取库文件和头文件
7) Pjsua_start 方法后 returns 成功。包括以下几行。
#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 == 1
pj_nat64_enable_rewrite_module();
#endif
8) 在调用的on_reg_state2() 方法中添加以下代码。
the_transport = rp->rdata->tp_info.transport;
NSLog(@"transport called %s",the_transport->factory->type_name);
if (the_transport->factory->type & PJSIP_TRANSPORT_IPV6)
{
ipv4=FALSE;
NSLog(@"enter into the ipv6 loop ");
pjsua_var.acc[0].cfg.ipv6_media_use=PJSUA_IPV6_ENABLED ;
nat64_options option=NAT64_REWRITE_INCOMING_SDP | NAT64_REWRITE_ROUTE_AND_CONTACT;
pj_nat64_set_options(option);
}