} else {
sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
}
+ } else if (!strcasecmp(var, "t38-passthru")) {
+ if (switch_true(val)) {
+ sofia_set_pflag(profile, PFLAG_T38_PASSTHRU);
+ } else {
+ sofia_clear_pflag(profile, PFLAG_T38_PASSTHRU);
+ }
} else if (!strcasecmp(var, "dtmf-type")) {
if (!strcasecmp(val, "rfc2833")) {
profile->dtmf_type = DTMF_2833;
} else {
sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
}
+ } else if (!strcasecmp(var, "t38-passthru")) {
+ if (switch_true(val)) {
+ sofia_set_pflag(profile, PFLAG_T38_PASSTHRU);
+ } else {
+ sofia_clear_pflag(profile, PFLAG_T38_PASSTHRU);
+ }
} else if (!strcasecmp(var, "disable-hold")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_DISABLE_HOLD);
}
}
- if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
+ if (switch_channel_test_flag(channel, CF_PROXY_MODE) ||
+ switch_channel_test_flag(channel, CF_PROXY_MEDIA) ||
+ sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
const char *r_sdp = NULL;
switch_core_session_message_t *msg;
+ private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (sip->sip_payload && sip->sip_payload->pl_data &&
sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
+
+ if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
+ if (sip->sip_payload && sip->sip_payload->pl_data) {
+ switch_t38_options_t *t38_options = sofia_glue_extract_t38_options(session, sip->sip_payload->pl_data);
+ sofia_glue_copy_t38_options(t38_options, other_session);
+ }
+ }
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
msg->from = __FILE__;
msg->numeric_arg = status;
msg->string_arg = switch_core_session_strdup(other_session, phrase);
- if (r_sdp) {
+
+ if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
+ msg->pointer_arg = switch_core_session_strdup(other_session, "t38");
+ } else if (r_sdp) {
msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
msg->pointer_arg_size = strlen(r_sdp);
}
+
+ if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
+ switch_core_session_receive_message(other_session, msg);
+ if (switch_rtp_ready(tech_pvt->rtp_session) && switch_rtp_ready(other_tech_pvt->rtp_session)) {
+ switch_rtp_udptl_mode(tech_pvt->rtp_session);
+ switch_rtp_udptl_mode(other_tech_pvt->rtp_session);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n");
+ }
+ } else {
+ switch_core_session_queue_message(other_session, msg);
+ }
+
- switch_core_session_queue_message(other_session, msg);
switch_core_session_rwunlock(other_session);
}
goto end;
switch_channel_set_state(channel, CS_INIT);
}
} else {
- sdp_parser_t *parser;
- sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(session, sdp);
- }
- sdp_parser_free(parser);
- }
+ match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
break;
case nua_callstate_completed:
if (r_sdp) {
- sdp_parser_t *parser;
- sdp_session_t *sdp;
uint8_t match = 0, is_ok = 1, is_t38 = 0;
tech_pvt->hold_laps = 0;
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (tech_pvt->num_codecs) {
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(session, sdp);
- }
- sdp_parser_free(parser);
- }
+ match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match && switch_channel_test_app_flag(tech_pvt->channel, CF_APP_T38)) {
case nua_callstate_ready:
if (r_sdp && !is_dup_sdp && switch_rtp_ready(tech_pvt->rtp_session)) {
/* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */
- sdp_parser_t *parser;
- sdp_session_t *sdp;
uint8_t match = 0;
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (tech_pvt->num_codecs) {
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(session, sdp);
- }
- sdp_parser_free(parser);
- }
+ match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
}
if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
- sdp_parser_t *parser;
- sdp_session_t *sdp;
uint8_t match = 0;
int is_ok = 1;
sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
if (tech_pvt->num_codecs) {
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(session, sdp);
- }
- sdp_parser_free(parser);
- }
+ match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
}
goto done;
} else {
- sdp_parser_t *parser;
- sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(session, sdp);
- }
- sdp_parser_free(parser);
- }
+ match = sofia_glue_negotiate_sdp(session, r_sdp);
}
sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
const char *family = "IP4";
const char *username = tech_pvt->profile->username;
-
//sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
if (!ip) {
t38_options->T38FaxMaxBuffer,
t38_options->T38FaxMaxDatagram,
t38_options->T38FaxUdpEC,
- t38_options->T38VendorInfo);
+ t38_options->T38VendorInfo ? t38_options->T38VendorInfo : "0 0 0");
switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_sdp)
{
- sdp_parser_t *parser = NULL;
- sdp_session_t *sdp;
uint8_t match = 0;
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_FALSE;
}
- if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
-
- if (tech_pvt->num_codecs) {
- if ((sdp = sdp_session(parser))) {
- match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp);
- }
- }
-
- sdp_parser_free(parser);
- }
-
- if (match) {
+ if ((match = sofia_glue_negotiate_sdp(tech_pvt->session, r_sdp))) {
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
if (tech_pvt->max_missed_hold_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets);
}
-
+
if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = tech_pvt->profile->hold_music;
}
}
}
-uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
+void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_t38_options_t *local_t38_options = switch_channel_get_private(channel, "t38_options");
+
+ if (!local_t38_options) {
+ local_t38_options = switch_core_session_alloc(session, sizeof(switch_t38_options_t));
+ }
+
+ local_t38_options->T38MaxBitRate = t38_options->T38MaxBitRate;
+ local_t38_options->T38FaxFillBitRemoval = t38_options->T38FaxFillBitRemoval;
+ local_t38_options->T38FaxTranscodingMMR = t38_options->T38FaxTranscodingMMR;
+ local_t38_options->T38FaxTranscodingJBIG = t38_options->T38FaxTranscodingJBIG;
+ local_t38_options->T38FaxRateManagement = t38_options->T38FaxRateManagement;
+ local_t38_options->T38FaxMaxBuffer = t38_options->T38FaxMaxBuffer;
+ local_t38_options->T38FaxMaxDatagram = t38_options->T38FaxMaxDatagram;
+ local_t38_options->T38FaxUdpEC = t38_options->T38FaxUdpEC;
+ local_t38_options->T38VendorInfo = t38_options->T38VendorInfo;
+ local_t38_options->ip = NULL;
+ local_t38_options->port = 0;
+
+
+ switch_channel_set_private(channel, "t38_options", local_t38_options);
+
+}
+static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_session_t *sdp, sdp_media_t *m)
+{
+ switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
+ sdp_attribute_t *attr;
+
+ if (!t38_options) {
+ t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
+ }
+
+ t38_options->port = m->m_port;
+
+ if (m->m_connections) {
+ t38_options->ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
+ } else if (sdp && sdp->sdp_connection) {
+ t38_options->ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address);
+ }
+
+ for (attr = m->m_attributes; attr; attr = attr->a_next) {
+ if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) {
+ t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
+ t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
+ t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
+ } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
+ t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
+ } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
+ t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
+ } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
+ t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
+ t38_options->T38FaxMaxBuffer = (uint32_t) atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
+ t38_options->T38FaxMaxDatagram = (uint32_t) atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
+ t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
+ t38_options->T38VendorInfo = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ }
+ }
+
+ switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
+ switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
+ switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
+
+ return t38_options;
+}
+
+switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *session, const char *r_sdp)
+{
+ sdp_media_t *m;
+ sdp_parser_t *parser = NULL;
+ sdp_session_t *sdp;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_t38_options_t *t38_options = NULL;
+
+ if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+ return 0;
+ }
+
+ if (!(sdp = sdp_session(parser))) {
+ sdp_parser_free(parser);
+ return 0;
+ }
+
+ switch_assert(tech_pvt != NULL);
+
+ for (m = sdp->sdp_media; m; m = m->m_next) {
+ if (m->m_proto == sdp_proto_udptl && m->m_type == sdp_media_image && m->m_port) {
+ t38_options = tech_process_udptl(tech_pvt, sdp, m);
+ break;
+ }
+ }
+
+ sdp_parser_free(parser);
+
+ return t38_options;
+
+}
+
+uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_sdp)
{
uint8_t match = 0;
switch_payload_t te = 0, cng_pt = 0;
const char *crypto = NULL;
int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0, got_udptl = 0;
int scrooge = 0;
+ sdp_parser_t *parser = NULL;
+ sdp_session_t *sdp;
+
+ if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+ return 0;
+ }
+
+ if (!(sdp = sdp_session(parser))) {
+ sdp_parser_free(parser);
+ return 0;
+ }
switch_assert(tech_pvt != NULL);
for (m = sdp->sdp_media; m; m = m->m_next) {
sdp_connection_t *connection;
+ switch_core_session_t *other_session;
ptime = dptime;
maxptime = dmaxptime;
}
if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
- switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
-
- if (!t38_options) {
- t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
- }
-
- t38_options->port = m->m_port;
+ switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m);
+
+ if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) {
+ match = 0;
+ goto done;
+ } else {
+ const char *var = switch_channel_get_variable(channel, "t38_passthru");
+ int pass = sofia_test_pflag(tech_pvt->profile, PFLAG_T38_PASSTHRU);
- if (m->m_connections) {
- t38_options->ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
- } else if (sdp && sdp->sdp_connection) {
- t38_options->ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address);
- }
+ if (var) {
+ pass = switch_true(var);
+ }
+
+ if (sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
+ pass = 0;
+ }
- for (attr = m->m_attributes; attr; attr = attr->a_next) {
- if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) {
- t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
- t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
- t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
- } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
- t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
- } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
- t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
- } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
- t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
- t38_options->T38FaxMaxBuffer = (uint32_t) atoi(attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
- t38_options->T38FaxMaxDatagram = (uint32_t) atoi(attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
- t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, attr->a_value);
- } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
- t38_options->T38VendorInfo = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ if (pass && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+ private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
+ switch_core_session_message_t *msg;
+ sofia_glue_copy_t38_options(t38_options, other_session);
+
+ sofia_set_flag(tech_pvt, TFLAG_T38_PASSTHRU);
+ sofia_set_flag(other_tech_pvt, TFLAG_T38_PASSTHRU);
+
+ msg = switch_core_session_alloc(other_session, sizeof(*msg));
+ msg->message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
+ msg->from = __FILE__;
+ msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing T38 req to other leg.\n%s\n", r_sdp);
+ switch_core_session_queue_message(other_session, msg);
+ switch_core_session_rwunlock(other_session);
}
}
- switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
- switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
- switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
+
/* do nothing here, mod_fax will trigger a response (if it's listening =/)*/
match = 1;
goto done;
}
done:
+
+ if (parser) sdp_parser_free(parser);
+
tech_pvt->cng_pt = cng_pt;
sofia_set_flag_locked(tech_pvt, TFLAG_SDP);