registration gets return code 401 from pbx

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

 



Hello,

I am trying to register with pjsip against an asterisk pbx but I keep
getting 401 unauthorized back, also I can't see any of the credentials in
my sip register message.
I can register with a normal phone.

This is what I have done:

sipreg_t sipreg =
{
ON_OFF,             /* check_contact    */
ON_OFF,             /* add_xuid_param   */
"basic",                /* title        */
NULL,               /* alt_registrar    */
1,                  /* contact cnt  */
{ "<sip:501 at 192.168.82.160:5060;transport=udp;x-param=1234>" },  /*
contacts[]  */
600,                /* expires      */

/* registrar config: */
/* respond  code    auth      contact  exp_prm expires more_contacts */
{ PJ_TRUE,  200,    PJ_TRUE, EXACT,    7500,     6500,     {NULL, 0}},

/* client expected results: */
/* error    code    have_reg    expiration  contact_cnt auth?*/
{ PJ_FALSE, 200,    PJ_TRUE,   7500,      1,      PJ_TRUE }
};

static struct client client_result;
pjsip_regc *regc;
const pj_str_t aor = pj_str("<sip:501 at 192.168.82.160>");

status = pjsip_regc_create(sip_endpt, &client_result, &client_cb, &regc);
if (status != PJ_SUCCESS)
return;

char registrar_uri_buf[80];
pj_str_t registrar_uri;
pj_str_t contacts[8];

pj_ansi_snprintf(registrar_uri_buf,
sizeof(registrar_uri_buf),"sip:192.168.82.150:%d", (int)5060);
registrar_uri = pj_str(registrar_uri_buf);

int j = 0;
for (j=0; j< sipreg.contact_cnt; ++j) {
contacts[j] = pj_str(sipreg.contacts[j]);
}

status = pjsip_regc_init(regc, &registrar_uri, &aor, &aor,
sipreg.contact_cnt,contacts, sipreg.expires ? sipreg.expires : 60);
if (status != PJ_SUCCESS)
{
pjsip_regc_destroy(regc);
return;
}

pjsip_cred_info cred;
pj_bzero(&cred, sizeof(cred));
cred.realm = pj_str("asterisk");
cred.scheme = pj_str("digest");
cred.username = pj_str("501");
cred.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
cred.data = pj_str("pincode501");

status = pjsip_regc_set_credentials(regc, 1, &cred);
if (status != PJ_SUCCESS) {
pjsip_regc_destroy(regc);
return;
}

pjsip_tx_data *tdata;

/* Register */
status = pjsip_regc_register(regc, PJ_TRUE, &tdata);
if (status != PJ_SUCCESS)
{
pjsip_regc_destroy(regc);
return;
}
status = pjsip_regc_send(regc, tdata);

I have also tried the realm * but it didn't help.
The 401 I get back from the pbx indicates the realm is asterisk.
Anyone have an idea what might go wrong here?

Cheers,
Gerard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150702/37963781/attachment.html>


[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