Example #1
0
void AudioRtpFactory::initConfig()
{
    stop();

    const std::string accountId(call_->getAccountId());

    const auto sipaccount = Manager::instance().getAccount<SIPAccount>(accountId);

    if (sipaccount) {
        srtpEnabled_ = sipaccount->getSrtpEnabled();
        std::string key(sipaccount->getSrtpKeyExchange());

        if (srtpEnabled_) {
#if HAVE_ZRTP

            if (key == "sdes")
                keyExchangeProtocol_ = SDES;
            else if (key == "zrtp")
                keyExchangeProtocol_ = ZRTP;

#else
            keyExchangeProtocol_ = SDES;
#endif
        } else {
            keyExchangeProtocol_ = NONE;
        }

        helloHashEnabled_ = sipaccount->getZrtpHelloHash();
    } else {
        srtpEnabled_ = false;
        keyExchangeProtocol_ = NONE;
        helloHashEnabled_ = false;
    }
}
Example #2
0
std::map<std::string, std::string> SIPAccount::getAccountDetails() const
{
    std::map<std::string, std::string> a;

    a[ACCOUNT_ID] = _accountID;
    // The IP profile does not allow to set an alias
    a[CONFIG_ACCOUNT_ALIAS] = (_accountID == IP2IP_PROFILE) ? IP2IP_PROFILE : getAlias();

    a[CONFIG_ACCOUNT_ENABLE] = isEnabled() ? "true" : "false";
    a[CONFIG_ACCOUNT_TYPE] = getType();
    a[HOSTNAME] = getHostname();
    a[USERNAME] = getUsername();

    a[CONFIG_RINGTONE_PATH] = getRingtonePath();
    a[CONFIG_RINGTONE_ENABLED] = getRingtoneEnabled() ? "true" : "false";
    a[CONFIG_ACCOUNT_MAILBOX] = getMailBox();

    RegistrationState state = Unregistered;
    std::string registrationStateCode;
    std::string registrationStateDescription;

    if (_accountID == IP2IP_PROFILE) {
        registrationStateCode = ""; // emtpy field
        registrationStateDescription = "Direct IP call";
    } else {
        state = getRegistrationState();
        int code = getRegistrationStateDetailed().first;
        std::stringstream out;
        out << code;
        registrationStateCode = out.str();
        registrationStateDescription = getRegistrationStateDetailed().second;
    }

    a[REGISTRATION_STATUS] = (_accountID == IP2IP_PROFILE) ? "READY": Manager::instance().mapStateNumberToString (state);
    a[REGISTRATION_STATE_CODE] = registrationStateCode;
    a[REGISTRATION_STATE_DESCRIPTION] = registrationStateDescription;

    // Add sip specific details
    a[ROUTESET] = getServiceRoute();
    a[CONFIG_ACCOUNT_RESOLVE_ONCE] = isResolveOnce() ? "true" : "false";
    a[USERAGENT] = getUseragent();

    a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = getRegistrationExpire();
    a[LOCAL_INTERFACE] = getLocalInterface();
    a[PUBLISHED_SAMEAS_LOCAL] = getPublishedSameasLocal() ? "true" : "false";
    a[PUBLISHED_ADDRESS] = getPublishedAddress();

    std::stringstream localport;
    localport << getLocalPort();
    a[LOCAL_PORT] = localport.str();
    std::stringstream publishedport;
    publishedport << getPublishedPort();
    a[PUBLISHED_PORT] = publishedport.str();
    a[STUN_ENABLE] = isStunEnabled() ? "true" : "false";
    a[STUN_SERVER] = getStunServer();
    a[ACCOUNT_DTMF_TYPE] = (getDtmfType() == OVERRTP) ? "overrtp" : "sipinfo";

    a[SRTP_KEY_EXCHANGE] = getSrtpKeyExchange();
    a[SRTP_ENABLE] = getSrtpEnable() ? "true" : "false";
    a[SRTP_RTP_FALLBACK] = getSrtpFallback() ? "true" : "false";

    a[ZRTP_DISPLAY_SAS] = getZrtpDisplaySas() ? "true" : "false";
    a[ZRTP_DISPLAY_SAS_ONCE] = getZrtpDiaplaySasOnce() ? "true" : "false";
    a[ZRTP_HELLO_HASH] = getZrtpHelloHash() ? "true" : "false";
    a[ZRTP_NOT_SUPP_WARNING] = getZrtpNotSuppWarning() ? "true" : "false";

    // TLS listener is unique and parameters are modified through IP2IP_PROFILE
    std::stringstream tlslistenerport;
    tlslistenerport << getTlsListenerPort();
    a[TLS_LISTENER_PORT] = tlslistenerport.str();
    a[TLS_ENABLE] = getTlsEnable();
    a[TLS_CA_LIST_FILE] = getTlsCaListFile();
    a[TLS_CERTIFICATE_FILE] = getTlsCertificateFile();
    a[TLS_PRIVATE_KEY_FILE] = getTlsPrivateKeyFile();
    a[TLS_PASSWORD] = getTlsPassword();
    a[TLS_METHOD] = getTlsMethod();
    a[TLS_CIPHERS] = getTlsCiphers();
    a[TLS_SERVER_NAME] = getTlsServerName();
    a[TLS_VERIFY_SERVER] = getTlsVerifyServer() ? "true" : "false";
    a[TLS_VERIFY_CLIENT] = getTlsVerifyClient() ? "true" : "false";
    a[TLS_REQUIRE_CLIENT_CERTIFICATE] = getTlsRequireClientCertificate() ? "true" : "false";
    a[TLS_NEGOTIATION_TIMEOUT_SEC] = getTlsNegotiationTimeoutSec();
    a[TLS_NEGOTIATION_TIMEOUT_MSEC] = getTlsNegotiationTimeoutMsec();

    return a;
}