Commit dd05d035 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#9910: Update parse received parameter on 606 registration error

parent d83cb80a
...@@ -226,7 +226,6 @@ bool ManagerImpl::outgoingCall(const std::string& account_id, ...@@ -226,7 +226,6 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
try { try {
Call *call = getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned); Call *call = getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned);
switchCall(call_id); switchCall(call_id);
call->setConfId(conf_id); call->setConfId(conf_id);
} catch (const VoipLinkException &e) { } catch (const VoipLinkException &e) {
......
...@@ -99,6 +99,7 @@ SIPAccount::SIPAccount(const std::string& accountID) ...@@ -99,6 +99,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
, registrationStateDetailed_() , registrationStateDetailed_()
, keepAliveTimer_() , keepAliveTimer_()
, link_(SIPVoIPLink::instance()) , link_(SIPVoIPLink::instance())
, receivedParameter_()
{} {}
void SIPAccount::serialize(Conf::YamlEmitter &emitter) void SIPAccount::serialize(Conf::YamlEmitter &emitter)
......
...@@ -495,6 +495,14 @@ class SIPAccount : public Account { ...@@ -495,6 +495,14 @@ class SIPAccount : public Account {
return zrtpHelloHash_; return zrtpHelloHash_;
} }
void setReceivedParameter(std::string received) {
receivedParameter_ = received;
}
std::string getReceivedParameter() {
return receivedParameter_;
}
/** /**
* Timer used to periodically send re-register request based * Timer used to periodically send re-register request based
* on the "Expire" sip header (or the "expire" Contact parameter) * on the "Expire" sip header (or the "expire" Contact parameter)
...@@ -718,6 +726,11 @@ class SIPAccount : public Account { ...@@ -718,6 +726,11 @@ class SIPAccount : public Account {
* Voice over IP Link contains a listener thread and calls * Voice over IP Link contains a listener thread and calls
*/ */
SIPVoIPLink* link_; SIPVoIPLink* link_;
/**
* Received via parameters
*/
std::string receivedParameter_;
}; };
#endif #endif
...@@ -515,6 +515,9 @@ void SIPVoIPLink::sendRegister(Account *a) ...@@ -515,6 +515,9 @@ void SIPVoIPLink::sendRegister(Account *a)
std::string contact(account->getContactHeader()); std::string contact(account->getContactHeader());
pj_str_t pjContact = pj_str((char*) contact.c_str()); pj_str_t pjContact = pj_str((char*) contact.c_str());
std::string received(account->getReceivedParameter());
pj_str_t pjReceived = pj_str((char *) received.c_str());
if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS) if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS)
throw VoipLinkException("Unable to initialize account registration structure"); throw VoipLinkException("Unable to initialize account registration structure");
...@@ -1560,6 +1563,18 @@ void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account) ...@@ -1560,6 +1563,18 @@ void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account)
pj_pool_release(pool); pj_pool_release(pool);
} }
static void looksForReceivedParameter(pjsip_regc_cbparam *param, SIPAccount *account) {
pj_str_t receivedValue = param->rdata->msg_info.via->recvd_param;
std::string publicIpFromReceived = "";
ERROR("looksForReceivedParameter");
if(receivedValue.slen) {
publicIpFromReceived = std::string(receivedValue.ptr, receivedValue.slen);
DEBUG("Cool received received parameter... uhhh?, the value is %s", publicIpFromReceived.c_str());
account->setReceivedParameter(publicIpFromReceived);
}
}
void registration_cb(pjsip_regc_cbparam *param) void registration_cb(pjsip_regc_cbparam *param)
{ {
if (param == NULL) { if (param == NULL) {
...@@ -1599,6 +1614,7 @@ void registration_cb(pjsip_regc_cbparam *param) ...@@ -1599,6 +1614,7 @@ void registration_cb(pjsip_regc_cbparam *param)
if (param->code < 0 || param->code >= 300) { if (param->code < 0 || param->code >= 300) {
switch (param->code) { switch (param->code) {
case 606: case 606:
looksForReceivedParameter(param, account);
account->setRegistrationState(ErrorNotAcceptable); account->setRegistrationState(ErrorNotAcceptable);
break; break;
......
...@@ -752,7 +752,7 @@ static void place_direct_call(const callable_obj_t * c) ...@@ -752,7 +752,7 @@ static void place_direct_call(const callable_obj_t * c)
static int place_registered_call(callable_obj_t * c) static int place_registered_call(callable_obj_t * c)
{ {
account_t * current = NULL; account_t * account = NULL;
if (c->_state != CALL_STATE_DIALING) if (c->_state != CALL_STATE_DIALING)
return -1; return -1;
...@@ -760,51 +760,54 @@ static int place_registered_call(callable_obj_t * c) ...@@ -760,51 +760,54 @@ static int place_registered_call(callable_obj_t * c)
if (!*c->_peer_number) if (!*c->_peer_number)
return -1; return -1;
// No longer usefull
/*
if (account_list_get_size() == 0) { if (account_list_get_size() == 0) {
notify_no_accounts(); notify_no_accounts();
sflphone_fail(c); sflphone_fail(c);
return -1; return -1;
} }
*/
/*
if (account_list_get_by_state(ACCOUNT_STATE_REGISTERED) == NULL) { if (account_list_get_by_state(ACCOUNT_STATE_REGISTERED) == NULL) {
DEBUG("Actions: No registered account, cannot make a call"); DEBUG("Actions: No registered account, cannot make a call");
notify_no_registered_accounts(); notify_no_registered_accounts();
sflphone_fail(c); sflphone_fail(c);
return -1; return -1;
} }
*/
DEBUG("Actions: Get account for this call"); DEBUG("Actions: Get account for this call");
if (strlen(c->_accountID) != 0) { if (strlen(c->_accountID) != 0) {
DEBUG("Actions: Account %s already set for this call", c->_accountID); DEBUG("Actions: Account %s already set for this call", c->_accountID);
current = account_list_get_by_id(c->_accountID); account = account_list_get_by_id(c->_accountID);
} else { } else {
DEBUG("Actions: No account set for this call, use first of the list"); DEBUG("Actions: No account set for this call, use first of the list");
current = account_list_get_current(); account = account_list_get_current();
} }
if (current == NULL) { if (account == NULL) {
DEBUG("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID); DEBUG("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID);
return -1; return -1;
} }
gpointer status = g_hash_table_lookup(current->properties, "Status"); gpointer status = g_hash_table_lookup(account->properties, "Status");
if (utf8_case_equal(status, "REGISTERED")) { if (utf8_case_equal(status, "REGISTERED")) {
/* The call is made with the current account */ /* The call is made with the current account */
// free memory for previous account id and get a new one // free memory for previous account id and get a new one
g_free(c->_accountID); g_free(c->_accountID);
c->_accountID = g_strdup(current->accountID); c->_accountID = g_strdup(account->accountID);
dbus_place_call(c); dbus_place_call(c);
} else { } else {
/* Place the call with the first registered account /* Place the call with the first registered account
* and switch the current account. * and switch the current account.
* If we are here, we can be sure that there is at least one. * If we are here, we can be sure that there is at least one.
*/ */
current = account_list_get_by_state(ACCOUNT_STATE_REGISTERED); account = account_list_get_by_state(ACCOUNT_STATE_REGISTERED);
g_free(c->_accountID); g_free(c->_accountID);
c->_accountID = g_strdup(current->accountID); c->_accountID = g_strdup(account->accountID);
dbus_place_call(c); dbus_place_call(c);
notify_current_account(current); notify_current_account(account);
} }
c->_history_state = g_strdup(OUTGOING_STRING); c->_history_state = g_strdup(OUTGOING_STRING);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment