ndlb_sendrecv_in_session var NDLB-sendrecv-in-session profile option to reverse the effects of MODENDP-148
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13084 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
56596b4e88
commit
32e2fddef3
|
@ -121,6 +121,8 @@ static const char *EVENT_NAMES[] = {
|
|||
"SESSION_HEARTBEAT",
|
||||
"CLIENT_DISCONNECTED",
|
||||
"SERVER_DISCONNECTED",
|
||||
"SEND_INFO",
|
||||
"RECV_INFO",
|
||||
"ALL"
|
||||
};
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ typedef enum {
|
|||
ESL_EVENT_SESSION_HEARTBEAT,
|
||||
ESL_EVENT_CLIENT_DISCONNECTED,
|
||||
ESL_EVENT_SERVER_DISCONNECTED,
|
||||
ESL_EVENT_SEND_INFO,
|
||||
ESL_EVENT_RECV_INFO,
|
||||
ESL_EVENT_ALL
|
||||
} esl_event_types_t;
|
||||
|
||||
|
|
|
@ -1257,6 +1257,8 @@ typedef enum {
|
|||
SWITCH_EVENT_SESSION_HEARTBEAT,
|
||||
SWITCH_EVENT_CLIENT_DISCONNECTED,
|
||||
SWITCH_EVENT_SERVER_DISCONNECTED,
|
||||
SWITCH_EVENT_SEND_INFO,
|
||||
SWITCH_EVENT_RECV_INFO,
|
||||
SWITCH_EVENT_ALL
|
||||
} switch_event_types_t;
|
||||
|
||||
|
|
|
@ -2867,6 +2867,56 @@ static void general_event_handler(switch_event_t *event)
|
|||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case SWITCH_EVENT_SEND_INFO:
|
||||
{
|
||||
const char *profile_name = switch_event_get_header(event, "profile");
|
||||
const char *ct = switch_event_get_header(event, "content-type");
|
||||
const char *to_uri = switch_event_get_header(event, "to-uri");
|
||||
const char *from_uri = switch_event_get_header(event, "from-uri");
|
||||
const char *body = switch_event_get_body(event);
|
||||
sofia_profile_t *profile;
|
||||
nua_handle_t *nh;
|
||||
|
||||
if (!profile_name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!to_uri) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from_uri) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(profile = sofia_glue_find_profile(profile_name))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nh = nua_handle(profile->nua,
|
||||
NULL,
|
||||
NUTAG_URL(to_uri),
|
||||
SIPTAG_FROM_STR(from_uri),
|
||||
SIPTAG_TO_STR(to_uri),
|
||||
SIPTAG_CONTACT_STR(profile->url),
|
||||
TAG_END());
|
||||
|
||||
nua_info(nh,
|
||||
TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)),
|
||||
TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
TAG_END());
|
||||
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
}
|
||||
break;
|
||||
case SWITCH_EVENT_TRAP:
|
||||
|
@ -3018,6 +3068,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
|||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind(modname, SWITCH_EVENT_SEND_INFO, SWITCH_EVENT_SUBCLASS_ANY, general_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
sofia_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
|
|
|
@ -190,7 +190,8 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
|
||||
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1)
|
||||
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1),
|
||||
PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2)
|
||||
} sofia_NDLB_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -1668,6 +1668,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||
} else {
|
||||
profile->ndlb &= ~PFLAG_NDLB_BROKEN_AUTH_HASH;
|
||||
}
|
||||
} else if (!strcasecmp(var, "NDLB-sendrecv-in-session")) {
|
||||
if (switch_true(val)) {
|
||||
profile->ndlb |= PFLAG_NDLB_SENDRECV_IN_SESSION;
|
||||
} else {
|
||||
profile->ndlb &= ~PFLAG_NDLB_SENDRECV_IN_SESSION;
|
||||
}
|
||||
} else if (!strcasecmp(var, "pass-rfc2833")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
|
||||
|
@ -2215,6 +2221,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||
if (switch_true(val)) {
|
||||
profile->ndlb |= PFLAG_NDLB_BROKEN_AUTH_HASH;
|
||||
}
|
||||
} else if (!strcasecmp(var, "NDLB-sendrecv-in-session")) {
|
||||
if (switch_true(val)) {
|
||||
profile->ndlb |= PFLAG_NDLB_SENDRECV_IN_SESSION;
|
||||
} else {
|
||||
profile->ndlb &= ~PFLAG_NDLB_SENDRECV_IN_SESSION;
|
||||
}
|
||||
} else if (!strcasecmp(var, "pass-rfc2833")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
|
||||
|
@ -3863,6 +3875,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
const char *rec_header;
|
||||
const char *clientcode_header;
|
||||
switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
|
||||
switch_event_t *event;
|
||||
|
||||
if (session) {
|
||||
/* Get the channel */
|
||||
|
@ -3932,7 +3945,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
/* Send 200 OK response */
|
||||
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
return;
|
||||
goto end;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
|
@ -3946,7 +3959,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
} else {
|
||||
goto fail;
|
||||
}
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((rec_header = sofia_glue_get_unknown_header(sip, "record"))) {
|
||||
|
@ -3978,13 +3991,66 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
return;
|
||||
goto end;
|
||||
|
||||
fail:
|
||||
nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
/* *shrug* just ok it */
|
||||
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
end:
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECV_INFO) == SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
if (sip->sip_content_type) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-Content-Type", "%s", sip->sip_content_type->c_type);
|
||||
}
|
||||
|
||||
if (sip->sip_from && sip->sip_from->a_url) {
|
||||
if (sip->sip_from->a_url->url_user) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-From-User", sip->sip_from->a_url->url_user);
|
||||
}
|
||||
|
||||
if (sip->sip_from->a_url->url_host) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-From-Host", sip->sip_from->a_url->url_host);
|
||||
}
|
||||
}
|
||||
|
||||
if (sip->sip_to && sip->sip_to->a_url) {
|
||||
if (sip->sip_to->a_url->url_user) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-To-User", sip->sip_to->a_url->url_user);
|
||||
}
|
||||
|
||||
if (sip->sip_to->a_url->url_host) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-To-Host", sip->sip_to->a_url->url_host);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sip->sip_contact && sip->sip_contact->m_url) {
|
||||
if (sip->sip_contact->m_url->url_user) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-Contact-User", sip->sip_contact->m_url->url_user);
|
||||
}
|
||||
|
||||
if (sip->sip_contact->m_url->url_host) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "SIP-Contact-Host", sip->sip_contact->m_url->url_host);
|
||||
}
|
||||
}
|
||||
|
||||
if (sip->sip_payload->pl_data) {
|
||||
switch_event_add_body(event, "%s", sip->sip_payload->pl_data);
|
||||
}
|
||||
|
||||
switch_event_fire(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dispatched freeswitch event for INFO\n");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params")
|
||||
|
|
|
@ -117,6 +117,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
|||
const char *family;
|
||||
const char *pass_fmtp = switch_channel_get_variable(tech_pvt->channel, "sip_video_fmtp");
|
||||
const char *ov_fmtp = switch_channel_get_variable(tech_pvt->channel, "sip_force_video_fmtp");
|
||||
char srbuf[128] = "";
|
||||
const char *var_val;
|
||||
|
||||
if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) ||
|
||||
((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) ||
|
||||
|
@ -155,14 +157,22 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
|||
|
||||
tech_pvt->session_id++;
|
||||
|
||||
if ((tech_pvt->profile->ndlb & PFLAG_NDLB_SENDRECV_IN_SESSION) ||
|
||||
((var_val=switch_channel_get_variable(tech_pvt->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) {
|
||||
switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr);
|
||||
sr = NULL;
|
||||
}
|
||||
|
||||
family = strchr(ip, ':') ? "IP6" : "IP4";
|
||||
switch_snprintf(buf, sizeof(buf),
|
||||
"v=0\n"
|
||||
"o=FreeSWITCH %010u %010u IN %s %s\n"
|
||||
"s=FreeSWITCH\n"
|
||||
"c=IN %s %s\n" "t=0 0\n"
|
||||
"m=audio %d RTP/%sAVP",
|
||||
tech_pvt->owner_id, tech_pvt->session_id, family, ip, family, ip, port,
|
||||
"%sm=audio %d RTP/%sAVP",
|
||||
tech_pvt->owner_id, tech_pvt->session_id, family, ip, family, ip,
|
||||
srbuf,
|
||||
port,
|
||||
(!switch_strlen_zero(tech_pvt->local_crypto_key)
|
||||
&& sofia_test_flag(tech_pvt,TFLAG_SECURE)) ? "S" : "");
|
||||
|
||||
|
|
|
@ -175,6 +175,8 @@ static char *EVENT_NAMES[] = {
|
|||
"SESSION_HEARTBEAT",
|
||||
"CLIENT_DISCONNECTED",
|
||||
"SERVER_DISCONNECTED",
|
||||
"SEND_INFO",
|
||||
"RECV_INFO",
|
||||
"ALL"
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue