summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_fax.c58
-rw-r--r--res/res_pjsip.c10
-rw-r--r--res/res_pjsip/pjsip_configuration.c1
-rw-r--r--res/res_pjsip_mwi.c28
-rw-r--r--res/res_rtp_asterisk.c2
5 files changed, 51 insertions, 48 deletions
diff --git a/res/res_fax.c b/res/res_fax.c
index ad6e2386c..86260d10e 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -468,8 +468,6 @@ struct fax_gateway {
struct fax_detect {
/*! \brief the start of our timeout counter */
struct timeval timeout_start;
- /*! \brief faxdetect timeout */
- int timeout;
/*! \brief DSP Processor */
struct ast_dsp *dsp;
/*! \brief original audio formats */
@@ -3539,13 +3537,13 @@ static void destroy_faxdetect(void *data)
ast_dsp_free(faxdetect->dsp);
faxdetect->dsp = NULL;
}
- ao2_ref(faxdetect->details, -1);
+ ao2_cleanup(faxdetect->details);
ao2_cleanup(faxdetect->orig_format);
}
/*! \brief Create a new fax detect object.
* \param chan the channel attaching to
- * \param timeout remove framehook in this time if set
+ * \param timeout in ms to remove framehook in this time if not zero
* \param flags required options
* \return NULL or a fax gateway object
*/
@@ -3652,8 +3650,9 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
return f;
}
- if ((!ast_tvzero(faxdetect->timeout_start) &&
- (ast_tvdiff_ms(ast_tvnow(), faxdetect->timeout_start) > faxdetect->timeout))) {
+ if (!ast_tvzero(faxdetect->timeout_start)
+ && ast_tvdiff_ms(ast_tvnow(), faxdetect->timeout_start) > details->faxdetect_timeout) {
+ ast_debug(1, "FAXOPT(faxdetect) timeout on %s\n", ast_channel_name(chan));
ast_framehook_detach(chan, details->faxdetect_id);
details->faxdetect_id = -1;
return f;
@@ -3701,30 +3700,36 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
}
if (result) {
- const char *target_context = S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan));
+ const char *target_context;
+
switch (result) {
case 'f':
case 't':
+ target_context = S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan));
+
ast_channel_unlock(chan);
+ ast_frfree(f);
+ f = &ast_null_frame;
if (ast_exists_extension(chan, target_context, "fax", 1,
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
- ast_channel_lock(chan);
ast_verb(2, "Redirecting '%s' to fax extension due to %s detection\n",
ast_channel_name(chan), (result == 'f') ? "CNG" : "T38");
pbx_builtin_setvar_helper(chan, "FAXEXTEN", ast_channel_exten(chan));
if (ast_async_goto(chan, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(chan), target_context);
}
- ast_frfree(f);
- f = &ast_null_frame;
} else {
- ast_channel_lock(chan);
ast_log(LOG_NOTICE, "FAX %s detected but no fax extension in context (%s)\n",
(result == 'f') ? "CNG" : "T38", target_context);
}
+ ast_channel_lock(chan);
+
+ ast_framehook_detach(chan, details->faxdetect_id);
+ details->faxdetect_id = -1;
+ break;
+ default:
+ break;
}
- ast_framehook_detach(chan, details->faxdetect_id);
- details->faxdetect_id = -1;
}
return f;
@@ -3732,7 +3737,7 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
/*! \brief Attach a faxdetect framehook object to a channel.
* \param chan the channel to attach to
- * \param timeout remove framehook in this time if set
+ * \param timeout in ms to remove framehook in this time if not zero
* \return the faxdetect structure or NULL on error
* \param flags required options
* \retval -1 error
@@ -4480,8 +4485,14 @@ static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *dat
details->gateway_timeout = 0;
if (timeout) {
unsigned int gwtimeout;
- if (sscanf(timeout, "%u", &gwtimeout) == 1) {
- details->gateway_timeout = gwtimeout * 1000;
+
+ if (sscanf(timeout, "%30u", &gwtimeout) == 1) {
+ if (gwtimeout >= 0) {
+ details->gateway_timeout = gwtimeout * 1000;
+ } else {
+ ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n",
+ cmd, data);
+ }
} else {
ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n", timeout, data);
}
@@ -4516,11 +4527,18 @@ static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *dat
if (ast_true(val) || !strcasecmp(val, "t38") || !strcasecmp(val, "cng")) {
if (details->faxdetect_id < 0) {
- if (timeout && (sscanf(timeout, "%u", &fdtimeout) == 1)) {
- if (fdtimeout > 0) {
- fdtimeout = fdtimeout * 1000;
+ if (timeout) {
+ if (sscanf(timeout, "%30u", &fdtimeout) == 1) {
+ if (fdtimeout >= 0) {
+ fdtimeout *= 1000;
+ } else {
+ ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n",
+ cmd, data);
+ fdtimeout = 0;
+ }
} else {
- ast_log(LOG_WARNING, "Timeout cannot be negative ignoring timeout\n");
+ ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n",
+ timeout, data);
}
}
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index de8eb3e8a..60b8252ad 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -600,6 +600,14 @@
detected.
</para></description>
</configOption>
+ <configOption name="fax_detect_timeout">
+ <synopsis>How long into a call before fax_detect is disabled for the call</synopsis>
+ <description><para>
+ The option determines how many seconds into a call before the
+ fax_detect option is disabled for the call. Setting the value
+ to zero disables the timeout.
+ </para></description>
+ </configOption>
<configOption name="t38_udptl_nat" default="no">
<synopsis>Whether NAT support is enabled on UDPTL sessions</synopsis>
<description><para>
@@ -4118,6 +4126,7 @@ long ast_sip_threadpool_queue_size(void)
return ast_threadpool_queue_size(sip_threadpool);
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(xml_sanitization_end_null)
{
char sanitized[8];
@@ -4168,6 +4177,7 @@ AST_TEST_DEFINE(xml_sanitization_exceeds_buffer)
return AST_TEST_PASS;
}
+#endif
/*!
* \internal
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index b44512589..48d011067 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1852,6 +1852,7 @@ int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_mod
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "t38_udptl_ec", "none", t38udptl_ec_handler, t38udptl_ec_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.t38.maxdatagram));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, faxdetect));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, faxdetect_timeout));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.nat));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.ipv6));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tone_zone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));
diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c
index 9eba335b5..d86c96c74 100644
--- a/res/res_pjsip_mwi.c
+++ b/res/res_pjsip_mwi.c
@@ -976,38 +976,12 @@ static int create_mwi_subscriptions_for_endpoint(void *obj, void *arg, int flags
{
RAII_VAR(struct mwi_subscription *, aggregate_sub, NULL, ao2_cleanup);
struct ast_sip_endpoint *endpoint = obj;
- char *endpoint_aors, *aor_name, *mailboxes, *mailbox;
- struct ao2_container *contacts = NULL;
+ char *mailboxes, *mailbox;
if (ast_strlen_zero(endpoint->subscription.mwi.mailboxes)) {
return 0;
}
- endpoint_aors = ast_strdupa(endpoint->aors);
-
- while ((aor_name = ast_strip(strsep(&endpoint_aors, ",")))) {
- RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
-
- if (!aor) {
- continue;
- }
-
- contacts = ast_sip_location_retrieve_aor_contacts(aor);
- if (!contacts || (ao2_container_count(contacts) == 0)) {
- ao2_cleanup(contacts);
- contacts = NULL;
- continue;
- }
-
- break;
- }
-
- if (!contacts) {
- return 0;
- }
-
- ao2_ref(contacts, -1);
-
if (endpoint->subscription.mwi.aggregate) {
aggregate_sub = mwi_subscription_alloc(endpoint, 0, NULL);
if (!aggregate_sub) {
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 8055e877f..9db5aefe7 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2592,7 +2592,7 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
/* Set default parameters on the newly created RTP structure */
rtp->ssrc = ast_random();
- rtp->seqno = ast_random() & 0xffff;
+ rtp->seqno = ast_random() & 0x7fff;
rtp->strict_rtp_state = (strictrtp ? STRICT_RTP_LEARN : STRICT_RTP_OPEN);
if (strictrtp) {
rtp_learning_seq_init(&rtp->rtp_source_learn, (uint16_t)rtp->seqno);