From c4400d925859008ce8c91beef8c040c4aec72a2b Mon Sep 17 00:00:00 2001 From: Ihor Olkhovskyi Date: Tue, 16 Jul 2024 14:55:12 +0200 Subject: [PATCH] add contact_uri_params --- README.md | 2 ++ src/voip_patrol/action.cc | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 76d0b85..e61fc17 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,7 @@ DISCONNECTED | from | string | From header complete "\"Display Name\" " | | callee | string | request URI user@host (also used in the To header unless to_uri is specified) | | to_uri | string | used@host part of the URI in the To header | +| contact_uri_params | string | string, that will be added to Contact URI as params | | transport | string | force a specific transport | | re_invite_interval | int | Interval in seconds at which a re-invite with SDP will be sent | | rtp_stats | bool | if "true" the json report will include a report on RTP transmission | @@ -422,6 +423,7 @@ DISCONNECTED | password | string | authentication password | | account | string | if not specified username is used, this is the the account name and From/To/Contact header user part | | registrar | string | SIP UAS handling registration where the messages will be sent | +| contact_uri_params | string | string, that will be added to Contact URI as params | | transport | string | force a specific transport | | unregister | bool | unregister the account | | reg_id | int | if present outbound and other related parameters will be added see RFC5626 | diff --git a/src/voip_patrol/action.cc b/src/voip_patrol/action.cc index 2f7acf2..02b503b 100644 --- a/src/voip_patrol/action.cc +++ b/src/voip_patrol/action.cc @@ -123,6 +123,7 @@ void Action::init_actions_params() { do_call_params.push_back(ActionParam("play_dtmf", false, APType::apt_string)); do_call_params.push_back(ActionParam("timer", false, APType::apt_string)); do_call_params.push_back(ActionParam("proxy", false, APType::apt_string)); + do_call_params.push_back(ActionParam("contact_uri_params", false, APType::apt_string)); // do_register do_register_params.push_back(ActionParam("transport", false, APType::apt_string)); do_register_params.push_back(ActionParam("label", false, APType::apt_string)); @@ -138,6 +139,7 @@ void Action::init_actions_params() { do_register_params.push_back(ActionParam("instance_id", false, APType::apt_string)); do_register_params.push_back(ActionParam("srtp", false, APType::apt_string)); do_register_params.push_back(ActionParam("rewrite_contact", true, APType::apt_bool)); + do_register_params.push_back(ActionParam("contact_uri_params", false, APType::apt_string)); // do_accept do_accept_params.push_back(ActionParam("account", false, APType::apt_string)); do_accept_params.push_back(ActionParam("transport", false, APType::apt_string)); @@ -328,6 +330,7 @@ void Action::do_register(vector ¶ms, vector &check string reg_id {}; string instance_id {}; string srtp {}; + string contact_uri_params {}; int expected_cause_code {200}; bool unregister {false}; bool rewrite_contact {false}; @@ -347,6 +350,7 @@ void Action::do_register(vector ¶ms, vector &check else if (param.name.compare("rewrite_contact") == 0) rewrite_contact = param.b_val; else if (param.name.compare("expected_cause_code") == 0) expected_cause_code = param.i_val; else if (param.name.compare("srtp") == 0 && param.s_val.length() > 0) srtp = param.s_val; + else if (param.name.compare("contact_uri_params") == 0 && param.s_val.length() > 0) contact_uri_params = param.s_val; } if (username.empty() || password.empty() || registrar.empty()) { @@ -458,6 +462,10 @@ void Action::do_register(vector ¶ms, vector &check acc_cfg.sipConfig.authCreds.push_back(AuthCredInfo("digest", realm, username, 0, password)); acc_cfg.natConfig.contactRewriteUse = rewrite_contact; + if (!contact_uri_params.empty()) { + acc_cfg.sipConfig.contactUriParams += ";" + contact_uri_params; + } + // SRTP for incoming calls if (srtp.find("dtls") != std::string::npos) { acc_cfg.mediaConfig.srtpUse = PJMEDIA_SRTP_OPTIONAL; @@ -714,6 +722,7 @@ void Action::do_call(vector ¶ms, vector &checks, S string label {}; string proxy {}; string srtp {"none"}; + string contact_uri_params {}; int expected_cause_code {200}; call_state_t wait_until {INV_STATE_NULL}; float min_mos {0.0}; @@ -762,6 +771,7 @@ void Action::do_call(vector ¶ms, vector &checks, S else if (param.name.compare("repeat") == 0) repeat = param.i_val; else if (param.name.compare("early_cancel") == 0) early_cancel = param.i_val; else if (param.name.compare("recording") == 0) recording = true; + else if (param.name.compare("contact_uri_params") == 0 && param.s_val.length() > 0) contact_uri_params = param.s_val; } if (caller.empty() || callee.empty()) { @@ -840,6 +850,10 @@ void Action::do_call(vector ¶ms, vector &checks, S acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", realm, username, 0, password) ); } + if (!contact_uri_params.empty()) { + acc_cfg.sipConfig.contactUriParams += ";" + contact_uri_params; + } + // SRTP if (srtp.find("dtls") != std::string::npos) { acc_cfg.mediaConfig.srtpOpt.keyings.push_back(PJMEDIA_SRTP_KEYING_DTLS_SRTP);