I am developing an IOS app using pjsip-2.6
and a IPV4 sip server
. First build pjsip with the following code in configsite.h
#define PJ_HAS_IPV6 1
build got successful. Then i added the libraries into my project.Run the application in IPV4
network.Its successfully registered and voice call working great.
Then i switched the network to Apple Nat64
network..Nothings works.Here is my code snippets.
For Creating udp
transport on IPV4
i used the following code.
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);
For Creating transport on IPV6 i used the following code..
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);
For creating the Account in IPV6 network i added..
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;
It would be better if someone can point me out the problem.Any help would be appreciated.
I think you are failed to creating the transport in IPV6 network.
One patch available for this (Link: https://github.com/johanlantz/pj-nat64) you need to integrate that patch for NAT64 issue below are the steps to follow.
1) Download the pj-nat64 source from above link.
2) Unzip the file and copy pj-nat64.c file paste into the pjproject (means pjsip source) (path is: pjsip/src/pjsua-lib)
3) Copy pj-nat64.h file paste into the pjproject (means pjsip source) (path is: pjsip/include/pjsua-lib)
4) Need to add the pj-nat64.o in the makefile of pjsip (Make file path is: pjsip/build)
5) Open the makefile and search for the string in doubles quotes “Defines for building PJSUA-LIB library” there add the pj-nat64.o after pjsua_vid.o
6) Compile the pjsip source for all architecture and take the Library files and headers files
7) After Pjsua_start method has returns success. Include the below lines.
#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 == 1
pj_nat64_enable_rewrite_module();
#endif
8) Add the below code in on_reg_state2() method for calls.
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);
}