diff --git a/conf/autoload_configs/sofia.conf.xml b/conf/autoload_configs/sofia.conf.xml
index 24252d08ce..a5e8614322 100644
--- a/conf/autoload_configs/sofia.conf.xml
+++ b/conf/autoload_configs/sofia.conf.xml
@@ -4,6 +4,7 @@
+
+
diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml
index 2dd094a656..3b19b6ecc6 100644
--- a/conf/sip_profiles/internal.xml
+++ b/conf/sip_profiles/internal.xml
@@ -42,7 +42,8 @@
-
+
+
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 24f2828d35..e540ee7830 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -3434,6 +3434,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
goto done;
}
+ if (!strcasecmp(argv[1], "capture")) {
+ if (argc > 2) {
+ int value = switch_true(argv[2]);
+ nua_set_params(profile->nua, TPTAG_CAPT(value ? mod_sofia_globals.capture_server : NULL), TAG_END());
+ stream->write_function(stream, "%s sip capturing on %s", value ? "Enabled" : "Disabled", profile->name);
+ } else {
+ stream->write_function(stream, "Usage: sofia profile capture \n");
+ }
+ goto done;
+ }
+
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
int value = switch_true(argv[2]);
@@ -3898,6 +3909,7 @@ SWITCH_STANDARD_API(sofia_function)
static const char usage_string[] = "USAGE:\n"
"--------------------------------------------------------------------------------\n"
"sofia global siptrace \n"
+ "sofia capture \n"
" watchdog \n\n"
"sofia profile [start | stop | restart | rescan]\n"
" flush_inbound_reg [ | <[user]@domain>] [reboot]\n"
@@ -3906,6 +3918,7 @@ SWITCH_STANDARD_API(sofia_function)
" killgw \n"
" [stun-auto-disable | stun-enabled] [true | false]]\n"
" siptrace \n"
+ " capture \n"
" watchdog \n\n"
"sofia profile [reg ] | [pres ] | [user ]\n"
"sofia gateway \n\n"
@@ -3965,6 +3978,7 @@ SWITCH_STANDARD_API(sofia_function)
goto done;
} else if (!strcasecmp(argv[0], "global")) {
int ston = -1;
+ int cton = -1;
int wdon = -1;
if (argc > 1) {
@@ -4001,6 +4015,12 @@ SWITCH_STANDARD_API(sofia_function)
}
}
+ if (!strcasecmp(argv[1], "capture")) {
+ if (argc > 2) {
+ cton = switch_true(argv[2]);
+ }
+ }
+
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
wdon = switch_true(argv[2]);
@@ -4011,11 +4031,14 @@ SWITCH_STANDARD_API(sofia_function)
if (ston != -1) {
sofia_glue_global_siptrace(ston);
stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off");
+ } else if (cton != -1) {
+ sofia_glue_global_capture(cton);
+ stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
} else if (wdon != -1) {
sofia_glue_global_watchdog(wdon);
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
} else {
- stream->write_function(stream, "-ERR Usage: siptrace |watchdog |debug write_function(stream, "-ERR Usage: siptrace |capture |watchdog |debug server_rport_level),
NTATAG_CLIENT_RPORT(profile->client_rport_level),
TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)),
+ TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL),
TAG_IF(sofia_test_pflag(profile, PFLAG_SIPCOMPACT),
NTATAG_SIPFLAGS(MSG_DO_COMPACT)),
TAG_IF(profile->timer_t1, NTATAG_SIP_T1(profile->timer_t1)),
@@ -2713,6 +2714,9 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
+ else if (!strcasecmp(var, "capture-server")) {
+ mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
+ }
}
}
@@ -2791,6 +2795,13 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
sofia_clear_flag(profile, TFLAG_TPORT_LOG);
}
nua_set_params(profile->nua, TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_END());
+ } else if (!strcasecmp(var, "sip-capture")) {
+ if (switch_true(val)) {
+ sofia_set_flag(profile, TFLAG_CAPTURE);
+ } else {
+ sofia_clear_flag(profile, TFLAG_CAPTURE);
+ }
+ nua_set_params(profile->nua, TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL), TAG_END());
} else if (!strcasecmp(var, "send-message-query-on-register")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
@@ -3394,6 +3405,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
+ else if (!strcasecmp(var, "capture-server")) {
+ mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
+ }
}
}
@@ -3485,6 +3499,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->shutdown_type = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_TPORT_LOG);
+ } else if (!strcasecmp(var, "sip-capture") && switch_true(val)) {
+ sofia_set_flag(profile, TFLAG_CAPTURE);
+ nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END());
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
if (switch_odbc_available()) {
profile->odbc_dsn = switch_core_strdup(profile->pool, val);
diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index 508e5b19dc..1c3999c110 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -5240,6 +5240,27 @@ void sofia_glue_global_siptrace(switch_bool_t on)
}
+void sofia_glue_global_capture(switch_bool_t on)
+{
+ switch_hash_index_t *hi;
+ const void *var;
+ void *val;
+ sofia_profile_t *pptr;
+
+ switch_mutex_lock(mod_sofia_globals.hash_mutex);
+ if (mod_sofia_globals.profile_hash) {
+ for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &var, NULL, &val);
+ if ((pptr = (sofia_profile_t *) val)) {
+ nua_set_params(pptr->nua, TPTAG_CAPT(on ? mod_sofia_globals.capture_server : NULL), TAG_END());
+ }
+ }
+ }
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+}
+
+
void sofia_glue_global_watchdog(switch_bool_t on)
{
switch_hash_index_t *hi;