update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3384 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
394a188b7e
commit
594ccf8bb8
|
@ -264,9 +264,9 @@ ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, c
|
||||||
session->id = apr_pstrdup(session->pool, id);
|
session->id = apr_pstrdup(session->pool, id);
|
||||||
session->them = apr_pstrdup(session->pool, them);
|
session->them = apr_pstrdup(session->pool, them);
|
||||||
|
|
||||||
//if (me) {
|
if (me) {
|
||||||
//session->initiator = apr_pstrdup(session->pool, them);
|
session->initiator = apr_pstrdup(session->pool, me);
|
||||||
//}
|
}
|
||||||
|
|
||||||
if (ldl_test_flag(handle, LDL_FLAG_COMPONENT)) {
|
if (ldl_test_flag(handle, LDL_FLAG_COMPONENT)) {
|
||||||
session->login = apr_pstrdup(session->pool, me);
|
session->login = apr_pstrdup(session->pool, me);
|
||||||
|
@ -1468,14 +1468,29 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_elements(ldl_session_t *session, iks *tag)
|
||||||
|
{
|
||||||
|
apr_hash_index_t *hi;
|
||||||
|
|
||||||
|
for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) {
|
||||||
|
void *val = NULL;
|
||||||
|
const void *key = NULL;
|
||||||
|
|
||||||
|
apr_hash_this(hi, &key, NULL, &val);
|
||||||
|
if (val) {
|
||||||
|
iks *var = iks_insert(tag, "info_element");
|
||||||
|
iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie");
|
||||||
|
iks_insert_attrib(var, "name", (char *) key);
|
||||||
|
iks_insert_attrib(var, "value", (char *) val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp, unsigned int *id, char *type)
|
static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp, unsigned int *id, char *type)
|
||||||
{
|
{
|
||||||
iks *iq, *sess;
|
iks *iq, *sess;
|
||||||
unsigned int myid;
|
unsigned int myid;
|
||||||
char idbuf[80];
|
char idbuf[80];
|
||||||
apr_hash_index_t *hi;
|
|
||||||
|
|
||||||
myid = next_id();
|
myid = next_id();
|
||||||
snprintf(idbuf, sizeof(idbuf), "%u", myid);
|
snprintf(idbuf, sizeof(idbuf), "%u", myid);
|
||||||
|
@ -1491,18 +1506,6 @@ static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp,
|
||||||
iks_insert_attrib(sess, "type", type);
|
iks_insert_attrib(sess, "type", type);
|
||||||
iks_insert_attrib(sess, "id", session->id);
|
iks_insert_attrib(sess, "id", session->id);
|
||||||
iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them);
|
iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them);
|
||||||
for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) {
|
|
||||||
void *val = NULL;
|
|
||||||
const void *key = NULL;
|
|
||||||
|
|
||||||
apr_hash_this(hi, &key, NULL, &val);
|
|
||||||
if (val) {
|
|
||||||
iks *var = iks_insert(sess, "info_element");
|
|
||||||
iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie");
|
|
||||||
iks_insert_attrib(var, "name", (char *) key);
|
|
||||||
iks_insert_attrib(var, "value", (char *) val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*sessp = sess;
|
*sessp = sess;
|
||||||
*iqp = iq;
|
*iqp = iq;
|
||||||
|
@ -1717,6 +1720,8 @@ unsigned int ldl_session_candidates(ldl_session_t *session,
|
||||||
new_session_iq(session, &iq, &sess, &id, "transport-info");
|
new_session_iq(session, &iq, &sess, &id, "transport-info");
|
||||||
tag = iks_insert(sess, "transport");
|
tag = iks_insert(sess, "transport");
|
||||||
iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");
|
iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");
|
||||||
|
|
||||||
|
add_elements(session, tag);
|
||||||
tag = iks_insert(tag, "candidate");
|
tag = iks_insert(tag, "candidate");
|
||||||
|
|
||||||
if (candidates[x].name) {
|
if (candidates[x].name) {
|
||||||
|
|
|
@ -248,7 +248,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||||
}
|
}
|
||||||
rpid = translate_rpid(rpid, status);
|
rpid = translate_rpid(rpid, status);
|
||||||
|
|
||||||
ldl_handle_send_presence(profile->handle, sub_to, sub_from, "probe", rpid, status);
|
//ldl_handle_send_presence(profile->handle, sub_to, sub_from, "probe", rpid, status);
|
||||||
ldl_handle_send_presence(profile->handle, sub_to, sub_from, type, rpid, status);
|
ldl_handle_send_presence(profile->handle, sub_to, sub_from, type, rpid, status);
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,7 +333,6 @@ static void pres_event_handler(switch_event_t *event)
|
||||||
type, rpid, status, proto, from);
|
type, rpid, status, proto, from);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (hi = switch_hash_first(apr_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
for (hi = switch_hash_first(apr_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
switch_hash_this(hi, NULL, NULL, &val);
|
switch_hash_this(hi, NULL, NULL, &val);
|
||||||
|
@ -819,6 +818,7 @@ static int do_candidates(struct private_object *tech_pvt, int force)
|
||||||
cand[0].protocol = "udp";
|
cand[0].protocol = "udp";
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
|
||||||
tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
|
tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
|
||||||
|
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
|
switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
|
||||||
}
|
}
|
||||||
switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
|
switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
|
||||||
|
@ -913,6 +913,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
|
||||||
started = switch_time_now();
|
started = switch_time_now();
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||||
|
tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
|
||||||
tech_pvt->next_desc = switch_time_now();
|
tech_pvt->next_desc = switch_time_now();
|
||||||
} else {
|
} else {
|
||||||
tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
|
tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
|
||||||
|
@ -1567,9 +1568,9 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session,
|
||||||
ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, user);
|
ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, user);
|
||||||
tech_pvt->profile = mdl_profile;
|
tech_pvt->profile = mdl_profile;
|
||||||
ldl_session_set_private(dlsession, *new_session);
|
ldl_session_set_private(dlsession, *new_session);
|
||||||
ldl_session_set_value(dlsession, "dnis", dnis);
|
//ldl_session_set_value(dlsession, "dnis", dnis);
|
||||||
ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name);
|
//ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name);
|
||||||
ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
|
//ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
|
||||||
tech_pvt->dlsession = dlsession;
|
tech_pvt->dlsession = dlsession;
|
||||||
if (!get_codecs(tech_pvt)) {
|
if (!get_codecs(tech_pvt)) {
|
||||||
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
|
@ -2101,6 +2102,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
execute_sql(profile->dbname, sql, profile->mutex);
|
execute_sql(profile->dbname, sql, profile->mutex);
|
||||||
switch_core_db_free(sql);
|
switch_core_db_free(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_special(to)) {
|
||||||
|
ldl_handle_send_presence(profile->handle, to, from, NULL, "unknown", "Click To Call");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (is_special(to)) {
|
if (is_special(to)) {
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||||
|
@ -2111,6 +2118,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case LDL_SIGNAL_ROSTER:
|
case LDL_SIGNAL_ROSTER:
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -2135,6 +2143,11 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (is_special(to)) {
|
||||||
|
ldl_handle_send_presence(profile->handle, to, from, NULL, "unknown", "Click To Call");
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
if (is_special(to)) {
|
if (is_special(to)) {
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||||
|
@ -2146,7 +2159,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case LDL_SIGNAL_PRESENCE_OUT:
|
case LDL_SIGNAL_PRESENCE_OUT:
|
||||||
|
|
||||||
if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
|
if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
|
||||||
|
@ -2285,6 +2298,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
|
||||||
ldl_session_set_private(dlsession, session);
|
ldl_session_set_private(dlsession, session);
|
||||||
tech_pvt->dlsession = dlsession;
|
tech_pvt->dlsession = dlsession;
|
||||||
|
switch_channel_set_name(channel, "DingaLing/new");
|
||||||
switch_channel_set_state(channel, CS_INIT);
|
switch_channel_set_state(channel, CS_INIT);
|
||||||
switch_core_session_thread_launch(session);
|
switch_core_session_thread_launch(session);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2415,175 +2429,177 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LDL_SIGNAL_CANDIDATES:
|
case LDL_SIGNAL_CANDIDATES:
|
||||||
if (signal) {
|
if (signal) {
|
||||||
ldl_candidate_t *candidates;
|
ldl_candidate_t *candidates;
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
|
unsigned int x;
|
||||||
|
|
||||||
if (ldl_session_get_candidates(dlsession, &candidates, &len) == LDL_STATUS_SUCCESS) {
|
if (ldl_session_get_candidates(dlsession, &candidates, &len) != LDL_STATUS_SUCCESS) {
|
||||||
unsigned int x;
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Candidate Error!\n");
|
||||||
|
switch_set_flag(tech_pvt, TFLAG_BYE);
|
||||||
|
switch_clear_flag(tech_pvt, TFLAG_IO);
|
||||||
|
status = LDL_STATUS_FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tech_pvt->remote_ip) {
|
if (tech_pvt->remote_ip) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
|
||||||
|
for(x = 0; x < len; x++) {
|
||||||
|
uint8_t lanaddr = 0;
|
||||||
|
|
||||||
|
if (profile->lanaddr) {
|
||||||
|
lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
|
||||||
for(x = 0; x < len; x++) {
|
|
||||||
uint8_t lanaddr = 0;
|
|
||||||
|
|
||||||
if (profile->lanaddr) {
|
if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) &&
|
||||||
lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
|
((profile->lanaddr && lanaddr) ||
|
||||||
|
(strncasecmp(candidates[x].address, "10.", 3) &&
|
||||||
|
strncasecmp(candidates[x].address, "192.168.", 8) &&
|
||||||
|
strncasecmp(candidates[x].address, "127.", 4) &&
|
||||||
|
strncasecmp(candidates[x].address, "1.", 2) &&
|
||||||
|
strncasecmp(candidates[x].address, "2.", 2) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.16.", 7) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.17.", 7) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.18.", 7) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.19.", 7) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.2", 5) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.30.", 7) &&
|
||||||
|
strncasecmp(candidates[x].address, "172.31.", 7)
|
||||||
|
))) {
|
||||||
|
ldl_payload_t payloads[5];
|
||||||
|
char *exten;
|
||||||
|
char *context;
|
||||||
|
char *cid_name;
|
||||||
|
char *cid_num;
|
||||||
|
char *tmp, *t, *them = NULL;
|
||||||
|
|
||||||
|
memset(payloads, 0, sizeof(payloads));
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
|
||||||
|
|
||||||
|
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||||
|
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
|
||||||
|
ldl_session_accept_candidate(dlsession, &candidates[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
|
if (!(exten = ldl_session_get_value(dlsession, "dnis"))) {
|
||||||
|
exten = profile->exten;
|
||||||
if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) &&
|
/* if it's _auto_ set the extension to match the username portion of the called address */
|
||||||
((profile->lanaddr && lanaddr) ||
|
if (!strcmp(exten, "_auto_")) {
|
||||||
(strncasecmp(candidates[x].address, "10.", 3) &&
|
if ((t = ldl_session_get_callee(dlsession))) {
|
||||||
strncasecmp(candidates[x].address, "192.168.", 8) &&
|
if ((them = strdup(t))) {
|
||||||
strncasecmp(candidates[x].address, "127.", 4) &&
|
char *a, *b, *p;
|
||||||
strncasecmp(candidates[x].address, "1.", 2) &&
|
if ((p = strchr(them, '/'))) {
|
||||||
strncasecmp(candidates[x].address, "2.", 2) &&
|
*p = '\0';
|
||||||
strncasecmp(candidates[x].address, "172.16.", 7) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.17.", 7) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.18.", 7) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.19.", 7) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.2", 5) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.30.", 7) &&
|
|
||||||
strncasecmp(candidates[x].address, "172.31.", 7)
|
|
||||||
))) {
|
|
||||||
ldl_payload_t payloads[5];
|
|
||||||
char *exten;
|
|
||||||
char *context;
|
|
||||||
char *cid_name;
|
|
||||||
char *cid_num;
|
|
||||||
char *tmp, *t, *them = NULL;
|
|
||||||
|
|
||||||
memset(payloads, 0, sizeof(payloads));
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
|
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
|
||||||
ldl_session_accept_candidate(dlsession, &candidates[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(exten = ldl_session_get_value(dlsession, "dnis"))) {
|
|
||||||
exten = profile->exten;
|
|
||||||
/* if it's _auto_ set the extension to match the username portion of the called address */
|
|
||||||
if (!strcmp(exten, "_auto_")) {
|
|
||||||
if ((t = ldl_session_get_callee(dlsession))) {
|
|
||||||
if ((them = strdup(t))) {
|
|
||||||
char *a, *b, *p;
|
|
||||||
if ((p = strchr(them, '/'))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((a = strchr(them, '+')) && (b = strrchr(them, '+')) && a != b) {
|
|
||||||
*b++ = '\0';
|
|
||||||
switch_channel_set_variable(channel, "dl_user", them);
|
|
||||||
switch_channel_set_variable(channel, "dl_host", b);
|
|
||||||
}
|
|
||||||
exten = them;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((a = strchr(them, '+')) && (b = strrchr(them, '+')) && a != b) {
|
||||||
|
*b++ = '\0';
|
||||||
|
switch_channel_set_variable(channel, "dl_user", them);
|
||||||
|
switch_channel_set_variable(channel, "dl_host", b);
|
||||||
|
}
|
||||||
|
exten = them;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(context = ldl_session_get_value(dlsession, "context"))) {
|
if (!(context = ldl_session_get_value(dlsession, "context"))) {
|
||||||
context = profile->context;
|
context = profile->context;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cid_name = ldl_session_get_value(dlsession, "caller_id_name"))) {
|
if (!(cid_name = ldl_session_get_value(dlsession, "caller_id_name"))) {
|
||||||
cid_name = tech_pvt->recip;
|
cid_name = tech_pvt->recip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cid_num = ldl_session_get_value(dlsession, "caller_id_number"))) {
|
if (!(cid_num = ldl_session_get_value(dlsession, "caller_id_number"))) {
|
||||||
cid_num = tech_pvt->recip;
|
cid_num = tech_pvt->recip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* context of "_auto_" means set it to the domain */
|
/* context of "_auto_" means set it to the domain */
|
||||||
if (profile->context && !strcmp(profile->context, "_auto_")) {
|
if (profile->context && !strcmp(profile->context, "_auto_")) {
|
||||||
context = profile->name;
|
context = profile->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
tech_pvt->them = switch_core_session_strdup(session, ldl_session_get_callee(dlsession));
|
tech_pvt->them = switch_core_session_strdup(session, ldl_session_get_callee(dlsession));
|
||||||
tech_pvt->us = switch_core_session_strdup(session, ldl_session_get_caller(dlsession));
|
tech_pvt->us = switch_core_session_strdup(session, ldl_session_get_caller(dlsession));
|
||||||
|
|
||||||
if ((tmp = strdup(tech_pvt->us))) {
|
if ((tmp = strdup(tech_pvt->us))) {
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
if ((p = strchr(tmp, '@'))) {
|
if ((p = strchr(tmp, '@'))) {
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
if ((q = strchr(p, '/'))) {
|
if ((q = strchr(p, '/'))) {
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
}
|
|
||||||
switch_channel_set_variable(channel, "dl_from_user", tmp);
|
|
||||||
switch_channel_set_variable(channel, "dl_from_host", p);
|
|
||||||
}
|
}
|
||||||
|
switch_channel_set_variable(channel, "dl_from_user", tmp);
|
||||||
switch_safe_free(tmp);
|
switch_channel_set_variable(channel, "dl_from_host", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tech_pvt->caller_profile) {
|
switch_safe_free(tmp);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating an identity for %s %s <%s> %s\n",
|
}
|
||||||
ldl_session_get_id(dlsession), cid_name, cid_num, exten);
|
|
||||||
|
|
||||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
if (!tech_pvt->caller_profile) {
|
||||||
ldl_handle_get_login(profile->handle),
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating an identity for %s %s <%s> %s\n",
|
||||||
profile->dialplan,
|
ldl_session_get_id(dlsession), cid_name, cid_num, exten);
|
||||||
cid_name,
|
|
||||||
cid_num,
|
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||||
ldl_session_get_ip(dlsession),
|
ldl_handle_get_login(profile->handle),
|
||||||
ldl_session_get_value(dlsession, "ani"),
|
profile->dialplan,
|
||||||
ldl_session_get_value(dlsession, "aniii"),
|
cid_name,
|
||||||
ldl_session_get_value(dlsession, "rdnis"),
|
cid_num,
|
||||||
(char *)modname,
|
ldl_session_get_ip(dlsession),
|
||||||
context,
|
ldl_session_get_value(dlsession, "ani"),
|
||||||
exten)) != 0) {
|
ldl_session_get_value(dlsession, "aniii"),
|
||||||
char name[128];
|
ldl_session_get_value(dlsession, "rdnis"),
|
||||||
snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
|
(char *)modname,
|
||||||
switch_channel_set_name(channel, name);
|
context,
|
||||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
exten)) != 0) {
|
||||||
}
|
char name[128];
|
||||||
|
snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
|
||||||
|
switch_channel_set_name(channel, name);
|
||||||
|
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch_safe_free(them);
|
switch_safe_free(them);
|
||||||
|
|
||||||
if (lanaddr) {
|
if (lanaddr) {
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
|
switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_codecs(tech_pvt)) {
|
if (!get_codecs(tech_pvt)) {
|
||||||
|
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
|
status = LDL_STATUS_FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tech_pvt->remote_ip = switch_core_session_strdup(session, candidates[x].address);
|
||||||
|
ldl_session_set_ip(dlsession, tech_pvt->remote_ip);
|
||||||
|
tech_pvt->remote_port = candidates[x].port;
|
||||||
|
tech_pvt->remote_user = switch_core_session_strdup(session, candidates[x].username);
|
||||||
|
|
||||||
|
|
||||||
|
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||||
|
if (!do_candidates(tech_pvt, 0)) {
|
||||||
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
status = LDL_STATUS_FALSE;
|
status = LDL_STATUS_FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tech_pvt->remote_ip = switch_core_session_strdup(session, candidates[x].address);
|
|
||||||
ldl_session_set_ip(dlsession, tech_pvt->remote_ip);
|
|
||||||
tech_pvt->remote_port = candidates[x].port;
|
|
||||||
tech_pvt->remote_user = switch_core_session_strdup(session, candidates[x].username);
|
|
||||||
|
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
|
||||||
if (!do_candidates(tech_pvt, 0)) {
|
|
||||||
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
|
||||||
status = LDL_STATUS_FALSE;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
|
|
||||||
|
|
||||||
status = LDL_STATUS_SUCCESS;
|
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = LDL_STATUS_SUCCESS;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -765,7 +765,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||||
rtp_session->last_time = switch_time_now();
|
rtp_session->last_time = switch_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;;) {
|
while(rtp_session->ready) {
|
||||||
bytes = sizeof(rtp_msg_t);
|
bytes = sizeof(rtp_msg_t);
|
||||||
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
|
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue