[SPAM] - Each account has it´s own different SIP UDP-Port. Is that possible? - Character set not allowed (n/a)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael , you must create a different transport (one for each count) and 
assign it to that count. Ex:

Creating a transport:
----------------------
 pj_status_t pjStatus;
 pjsua_transport_config pjConfig;
 char c_strPublicIPAddress[255];

 strcpy (c_strPublicIPAddress, strPublicIp.c_str());

 pjsua_transport_config_default (&pjConfig);

 pjConfig.port = lSipPort; //here you specify the new port (ie: 
5060,5061,5062, etc)
 pjConfig.public_addr = pj_str(c_strPublicIPAddress);

 pjStatus = pjsua_transport_create (PJSIP_TRANSPORT_UDP, &pjConfig, 
&m_pjTransportId);

 if (pjStatus != PJ_SUCCESS)
 {
  m_oLogger.write ("CDialerSIP - createtransport() - 
pjsua_transport_create - Fall?.", CDialerLogger::iLogError);
  return false;
 }

 m_oLogger.write ("CDialerSIP - createtransport() - Ok.", 
CDialerLogger::iLogInformation);
 m_isTransportCreated = true;
 return true;
}


//-----------

Then you must assign that transport to your account. In the following 
function, I create an account and assign its transport id to the tansport 
that I've created before.


bool CDialerSIP::registeraccount ()
{
 pj_status_t pjStatus;
 pjsua_acc_config pjConfig;
 pj_str_t pjStrId, pjStrRegURL;
 pjsua_acc_id pjAccountId;
 int iEvent;


 pjStrId.ptr = (char*) pj_pool_alloc (m_pjPool, 255);

 if (!pjStrId.ptr)
 {
  m_oLogger.write ("registeraccount - pj_pool_alloc - Fall? <pjStrId.ptr>.", 
CDialerLogger::iLogError);
  return false;
 }

 pjsua_acc_config_default (&pjConfig);

     pj_strcpy (&pjStrId, &(pj_str("sip:")));
     pj_strcat (&pjStrId, &m_pjStrSipUser);
 pj_strcat (&pjStrId, &(pj_str("@")));
 pj_strcat (&pjStrId, &m_pjStrSipDomain);

 pjConfig.id = pjStrId;

 pjStrRegURL.ptr = (char*) pj_pool_alloc (m_pjPool, 255);

 if (!pjStrRegURL.ptr)
 {
  m_oLogger.write ("registeraccount - pj_pool_alloc - Fall? 
<pjStrRegURL.ptr>.", CDialerLogger::iLogError);
  return false;
 }

 pj_strcpy2 (&pjStrRegURL, "sip:");
 pj_strcat (&pjStrRegURL, &m_pjStrSipDomain);

 pjConfig.reg_uri  = pjStrRegURL;

 pjConfig.cred_count  = 1;
 pjConfig.cred_info[0].realm = pj_str("*");
 pjConfig.cred_info[0].scheme    = pj_str("digest");
 pjConfig.cred_info[0].username = m_pjStrSipUser;
 pjConfig.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
 pjConfig.cred_info[0].data = m_pjStrSipPwd;

 pjConfig.transport_id  = m_pjTransportId; //HERE I ASSIGN THE TRANSPORT ID 
THAT I'VE CREATED BEFORE USING pjsua_transport_create.

 pjStatus = pjsua_acc_add (&pjConfig, PJ_TRUE, &pjAccountId);

 if (pjStatus != PJ_SUCCESS)
 {
  m_oLogger.write ("registeraccount - pjsua_acc_add - Fall?.", 
CDialerLogger::iLogError);
  return false;
 }

 pthread_mutex_lock (&m_iMutex_AccountId);
 m_pjAccountId = pjAccountId;
 pthread_mutex_unlock (&m_iMutex_AccountId);

 this->waitevent (&iEvent, false);

 if (iEvent != CDialerDialer::i_UserAgent_Register)
 {
  m_oLogger.write ("registeraccount - Failed.", 
CDialerLogger::iLogInformation);
  return false;
 }

 pthread_mutex_lock (&m_iMutex_IsRegistered);
 m_isRegistered = true;   //la cuenta fue registrada en el sip proxy con 
exito. Luego solo se mantendra su estado
    // desde la clase CDialerSIPController
 pthread_mutex_unlock (&m_iMutex_IsRegistered);

 setregisterstate (true);

 m_oLogger.write ("registeraccount - Ok.", CDialerLogger::iLogInformation);
 return true;

}

that's all.

Let me know if you have a doubt.

bye.
Jose






----- Original Message ----- 
From: <MichaelUndJutta@xxxxxxx>
To: <pjsip at lists.pjsip.org>
Sent: Thursday, October 07, 2010 9:41 AM
Subject: [SPAM] - Each account has it?s own different SIP UDP-Port. 
Is that possible? - Character set not allowed (n/a)


> Hello,
>
> My computer is connected to internet via a combined DSL-Router and 
> telephone system (so called FritzBox 7270). On this Fritzbox, there are 
> also some internal Telephones connected (Fritzbox has internaly also a SIP 
> SW-Stack for this telefones).
>
> I would like to write a PJSUA Phone Application on my computer, and to 
> have two accounts - one to the Fritzbox, for internal calls, one to the 
> SIP IP-Provider (for external calls).
>
> Now I get a conflict with Port 5060 (which is also used by Fritzbox), and 
> which can not be forwarded by internal Router.
>
> Using Port 5080 instead (in PJSUA), works fine, as long as I only connect 
> to SIP IP-Provider _OR_ Fritzbox. When using 5080 as port for Account to 
> Fritzbox, there is a conflict (when receiving a call), that the ACK 
> Telegram (which switches SIP phone-call from CONNECTING to CONFIRMED) gets 
> lost in the fritzbox, and after timeout PJSUA disconnects the call ...
>
>
> The only thing - I could imagine, to make this run - is, to have the 
> SIP-port separated for every account (5060 for Fritzbox, 5080 for 
> external)
>
> What I don?t know: In which way to get separated Port
>
>  x  A hack in Transport layer, opening two ports, sending telegrams on
>     the correct port (depending on IP-Adress from the receiver), recei-
>     ving on both ports ???
>  x  A copy uf UDP-Transport, so having two UDP-Transports inside (seems
>     to be much work; no easy solution possible).
>  x  Where to read, in which way transport is integrated (and what?s the
>     difference UDP-Transport and SIP-UDP-Transport)``
>  x  How to figure out, which transport mechanism?s my SIP-Provider is `
>     able to support?
>
> Who has a tip, in which way it makes sense to proceed ...
>
> With Regards,
> Michael
>
>
> -- 
> GRATIS! Movie-FLAT mit ?ber 300 Videos.
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
> ? 




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux