Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add contact_uri_params #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ DISCONNECTED
| from | string | From header complete "\&quot;Display Name\&quot; <sip:test at 127.0.0.1>" |
| 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 <tcp,udp,tls,sips> |
| 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 |
Expand All @@ -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 <tcp,udp,tls,sips> |
| unregister | bool | unregister the account <usename@registrar;transport=x> |
| reg_id | int | if present outbound and other related parameters will be added see RFC5626 |
Expand Down
14 changes: 14 additions & 0 deletions src/voip_patrol/action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -328,6 +330,7 @@ void Action::do_register(vector<ActionParam> &params, vector<ActionCheck> &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};
Expand All @@ -347,6 +350,7 @@ void Action::do_register(vector<ActionParam> &params, vector<ActionCheck> &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()) {
Expand Down Expand Up @@ -458,6 +462,10 @@ void Action::do_register(vector<ActionParam> &params, vector<ActionCheck> &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;
Expand Down Expand Up @@ -714,6 +722,7 @@ void Action::do_call(vector<ActionParam> &params, vector<ActionCheck> &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};
Expand Down Expand Up @@ -762,6 +771,7 @@ void Action::do_call(vector<ActionParam> &params, vector<ActionCheck> &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()) {
Expand Down Expand Up @@ -840,6 +850,10 @@ void Action::do_call(vector<ActionParam> &params, vector<ActionCheck> &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);
Expand Down