Commit 6f1d9147 authored by Adrien Béraud's avatar Adrien Béraud Committed by Tristan Matthews

transport: Forward transport errors to the client

Refs: #55823

Change-Id: I70b269160340630ace1fd2466bcc6a30a6cee08e
parent ba5c3563
......@@ -104,7 +104,7 @@ static const char *const CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiati
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode";
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.registrationDescription";
static const char *const CONFIG_TLS_TRANSPORT_STATE_CODE = "TLS.transportStatusCode";
static const char *const CONFIG_TLS_TRANSPORT_STATE_DESC = "TLS.transportStatusDescription";
static const char *const CONFIG_TRANSPORT_STATE_CODE = "Transport.statusCode";
static const char *const CONFIG_TRANSPORT_STATE_DESC = "Transport.statusDescription";
#endif // ACCOUNT_SCHEMA_H_
......@@ -39,6 +39,8 @@
#include "account_schema.h"
#include <yaml-cpp/yaml.h>
#include "config/yamlparser.h"
#include "client/configurationmanager.h"
#include "manager.h"
bool SIPAccountBase::portsInUse_[HALF_MAX_PORT];
......@@ -235,29 +237,50 @@ SIPAccountBase::getAccountDetails() const
return a;
}
std::map<std::string, std::string>
SIPAccountBase::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = Account::getVolatileAccountDetails();
a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = isIP2IP() ? "READY" : mapStateNumberToString(registrationState_);
std::stringstream codestream;
codestream << transportStatus_;
a[CONFIG_TRANSPORT_STATE_CODE] = codestream.str();
a[CONFIG_TRANSPORT_STATE_DESC] = transportError_ ;
return a;
}
void
SIPAccountBase::onTransportStateChanged(pjsip_transport_state state, const pjsip_transport_state_info *info)
{
pj_status_t currentStatus = transportStatus_;
DEBUG("Transport state changed to %s for account %s !", SipTransport::stateToStr(state), accountID_.c_str());
if (!SipTransport::isAlive(transport_, state)) {
if (info) {
char err_msg[128];
err_msg[0] = '\0';
pj_str_t descr = pj_strerror(info->status, err_msg, sizeof(err_msg));
transportStatus_ = info ? info->status : PJSIP_SC_OK;
transportError_ = std::string(descr.ptr, descr.slen);
ERROR("Transport disconnected: %.*s", descr.slen, descr.ptr);
}
else {
// This is already the generic error used by pjsip.
transportStatus_ = PJSIP_SC_SERVICE_UNAVAILABLE;
transportError_ = "";
}
setRegistrationState(RegistrationState::ERROR_GENERIC);
setTransport();
}
}
std::map<std::string, std::string>
SIPAccountBase::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = Account::getVolatileAccountDetails();
a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = isIP2IP() ? "READY" : mapStateNumberToString(registrationState_);
else {
// The status can be '0', this is the same as OK
transportStatus_ = info && info->status ? info->status : PJSIP_SC_OK;
transportError_ = "";
}
return a;
// Notify the client of the new transport state
if (currentStatus != transportStatus_)
Manager::instance().getClient()->getConfigurationManager()->volatileAccountDetailsChanged(getAccountID());
}
void
......
......@@ -385,6 +385,9 @@ protected:
*/
bool srtpFallback_ {};
pj_status_t transportStatus_ {PJSIP_SC_TRYING};
std::string transportError_ {};
/*
* Port range for audio RTP ports
*/
......
Markdown is supported
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