From e884116c08afb0f445201c0b9ca8871231a581ed Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 27 Jun 2013 16:25:59 -0500 Subject: [PATCH 001/203] add answer work tag to httapi --- .../mod_httapi/docs/mod_httapi_doc.txt | 6 ++++++ src/mod/applications/mod_httapi/mod_httapi.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt index f659db39af..399ea1a335 100644 --- a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt +++ b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt @@ -230,6 +230,12 @@ action : Change url to submit to. temp-action : Change url to submit to. just for the next loop. + + : Answer the call + +ATTRS: +is-conference : true|false (set the conference flag for RFC4579 stuff. + : Hangup the call diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 005f66bdbd..8b76f36101 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -877,6 +877,19 @@ static switch_status_t parse_hangup(const char *tag_name, client_t *client, swit return SWITCH_STATUS_FALSE; } +static switch_status_t parse_answer(const char *tag_name, client_t *client, switch_xml_t tag, const char *body) +{ + const char *conf = switch_xml_attr(tag, "is-conference"); + + if (conf && switch_true(conf)) { + switch_channel_set_flag(client->channel, CF_CONFERENCE); + } + + switch_channel_answer(client->channel); + + return SWITCH_STATUS_FALSE; +} + static switch_status_t parse_record_call(const char *tag_name, client_t *client, switch_xml_t tag, const char *body) { const char *limit_ = switch_xml_attr(tag, "limit"); @@ -2997,6 +3010,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load) bind_parser("sms", parse_sms); bind_parser("dial", parse_dial); bind_parser("pause", parse_playback); + bind_parser("answer", parse_answer); bind_parser("hangup", parse_hangup); bind_parser("record", parse_record); bind_parser("recordCall", parse_record_call); From fd67c196640c3989446092162dfedb9146592062 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 27 Jun 2013 16:31:29 -0500 Subject: [PATCH 002/203] add preAnswer and ringReady too --- .../mod_httapi/docs/mod_httapi_doc.txt | 7 +++++++ src/mod/applications/mod_httapi/mod_httapi.c | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt index 399ea1a335..b313dc5e15 100644 --- a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt +++ b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt @@ -237,6 +237,13 @@ ATTRS: is-conference : true|false (set the conference flag for RFC4579 stuff. + + : Establish media on the call without answering. + + + : Indicate ringing to an unaswered channel. + + : Hangup the call diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 8b76f36101..52e4a21a6b 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -879,14 +879,21 @@ static switch_status_t parse_hangup(const char *tag_name, client_t *client, swit static switch_status_t parse_answer(const char *tag_name, client_t *client, switch_xml_t tag, const char *body) { - const char *conf = switch_xml_attr(tag, "is-conference"); - if (conf && switch_true(conf)) { - switch_channel_set_flag(client->channel, CF_CONFERENCE); + if (!strcasecmp(tag_name, "answer")) { + const char *conf = switch_xml_attr(tag, "is-conference"); + + if (conf && switch_true(conf)) { + switch_channel_set_flag(client->channel, CF_CONFERENCE); + } + + switch_channel_answer(client->channel); + } else if (!strcasecmp(tag_name, "preAnswer")) { + switch_channel_pre_answer(client->channel); + } else if (!strcasecmp(tag_name, "ringReady")) { + switch_channel_ring_ready(client->channel); } - switch_channel_answer(client->channel); - return SWITCH_STATUS_FALSE; } @@ -3011,6 +3018,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load) bind_parser("dial", parse_dial); bind_parser("pause", parse_playback); bind_parser("answer", parse_answer); + bind_parser("preAnswer", parse_answer); + bind_parser("ringReady", parse_answer); bind_parser("hangup", parse_hangup); bind_parser("record", parse_record); bind_parser("recordCall", parse_record_call); From ba6bf28a5e00a9468e5bdc77f0f90d9988877e47 Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 28 Jun 2013 09:48:28 -0500 Subject: [PATCH 003/203] punt without return --- src/switch_core_media_bug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 0ad3f11183..9831d0099f 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -430,6 +430,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t if (punt) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!\n"); + return SWITCH_STATUS_GENERR; } From 007ddda5601d16402da571a84f9bbfbbec9ae1ed Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Fri, 28 Jun 2013 11:16:06 -0400 Subject: [PATCH 004/203] mod_rayo: dtmf #*A-D was broken --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 4 +++ src/mod/event_handlers/mod_rayo/nlsml.c | 33 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index e6b2d20322..66f59c9def 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -3674,6 +3674,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) "0123456789]]>" "" ""); + rayo_add_cmd_alias("input", "" + "" + "0123456789*#]]>" + ""); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/nlsml.c b/src/mod/event_handlers/mod_rayo/nlsml.c index 81f45dc6fb..e446d1bfd0 100644 --- a/src/mod/event_handlers/mod_rayo/nlsml.c +++ b/src/mod/event_handlers/mod_rayo/nlsml.c @@ -363,6 +363,37 @@ iks *nlsml_normalize(const char *result) return result_xml; } +/** + * @return true if digit is a DTMF + */ +static int isdtmf(const char digit) +{ + switch(digit) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '*': + case '#': + case 'a': + case 'A': + case 'b': + case 'B': + case 'c': + case 'C': + case 'd': + case 'D': + return 1; + } + return 0; +} + /** * Construct an NLSML result for digit match * @param digits the matching digits @@ -387,7 +418,7 @@ iks *nlsml_create_dtmf_match(const char *digits) SWITCH_STANDARD_STREAM(stream); for (i = 0; i < num_digits; i++) { - if (isdigit(digits[i])) { + if (isdtmf(digits[i])) { if (first) { stream.write_function(&stream, "%c", digits[i]); first = 0; From 74740cca5f21911edadabb4d2795d28743c099da Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 28 Jun 2013 10:42:01 -0500 Subject: [PATCH 005/203] FS-5527 --resolve Conflicts: libs/sofia-sip/.update libs/sofia-sip/libsofia-sip-ua/nta/nta.c --- libs/sofia-sip/.update | 1 - libs/sofia-sip/libsofia-sip-ua/nta/nta.c | 45 ++++++++++--------- .../libsofia-sip-ua/su/sofia-sip/su_time.h | 7 ++- libs/sofia-sip/libsofia-sip-ua/su/su_time0.c | 14 ++++++ src/mod/endpoints/mod_sofia/sofia.c | 19 ++++++++ 5 files changed, 64 insertions(+), 22 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 3cdde5d830..e69de29bb2 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +0,0 @@ -Thu Jun 20 10:51:51 CDT 2013 diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index 3fe081f429..86355a5f45 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -149,9 +149,7 @@ struct nta_agent_s nta_update_magic_t *sa_update_magic; nta_update_tport_f *sa_update_tport; - su_time_t sa_now; /**< Timestamp in microsecond resolution. */ uint32_t sa_next; /**< Timestamp for next agent_timer. */ - uint32_t sa_millisec; /**< Timestamp in milliseconds. */ msg_mclass_t const *sa_mclass; uint32_t sa_flags; /**< SIP message flags */ @@ -1237,15 +1235,12 @@ void agent_timer(su_root_magic_t *rm, su_timer_t *timer, nta_agent_t *agent) agent->sa_next = 0; - agent->sa_now = stamp; - agent->sa_millisec = now; agent->sa_in_timer = 1; + _nta_outgoing_timer(agent); _nta_incoming_timer(agent); - /* agent->sa_now is used only if sa_millisec != 0 */ - agent->sa_millisec = 0; agent->sa_in_timer = 0; /* Calculate next timeout */ @@ -1330,12 +1325,12 @@ uint32_t set_timeout(nta_agent_t *agent, uint32_t offset) if (offset == 0) return 0; - if (agent->sa_millisec) /* Avoid expensive call to su_now() */ - now = agent->sa_now, ms = agent->sa_millisec; - else - now = su_now(), ms = su_time_ms(now); + now = su_now(); + ms = su_time_ms(now); - next = ms + offset; if (next == 0) next = 1; + next = ms + offset; + + if (next == 0) next = 1; if (agent->sa_in_timer) /* Currently executing timer */ return next; @@ -1360,9 +1355,6 @@ uint32_t set_timeout(nta_agent_t *agent, uint32_t offset) static su_time_t agent_now(nta_agent_t const *agent) { - if (agent && agent->sa_millisec != 0) - return agent->sa_now; - else return su_now(); } @@ -2764,8 +2756,6 @@ void agent_recv_message(nta_agent_t *agent, { sip_t *sip = sip_object(msg); - agent->sa_millisec = su_time_ms(agent->sa_now = now); - if (sip && sip->sip_request) { agent_recv_request(agent, msg, sip, tport); } @@ -2775,8 +2765,6 @@ void agent_recv_message(nta_agent_t *agent, else { agent_recv_garbage(agent, msg, tport); } - - agent->sa_millisec = 0; } /** @internal Handle incoming requests. */ @@ -6849,7 +6837,7 @@ enum { static void _nta_incoming_timer(nta_agent_t *sa) { - uint32_t now = sa->sa_millisec; + uint32_t now = su_time_ms(su_now()); nta_incoming_t *irq, *irq_next; size_t retransmitted = 0, timeout = 0, terminated = 0, destroyed = 0; size_t unconfirmed = @@ -6866,6 +6854,9 @@ _nta_incoming_timer(nta_agent_t *sa) /* Handle retry queue */ while ((irq = sa->sa_in.re_list)) { + + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_retry - now) > 0) break; if (retransmitted >= timer_max_retransmit) @@ -6923,6 +6914,8 @@ _nta_incoming_timer(nta_agent_t *sa) } while ((irq = sa->sa_in.final_failed->q_head)) { + + incoming_remove(irq); irq->irq_final_failed = 0; @@ -6954,6 +6947,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_status < 200); assert(irq->irq_timeout); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0) break; if (timeout >= timer_max_timeout) @@ -6974,6 +6969,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_timeout); assert(irq->irq_method == sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || timeout >= timer_max_timeout || terminated >= timer_max_terminate) @@ -7002,6 +6999,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_status >= 200); assert(irq->irq_method == sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || terminated >= timer_max_terminate) break; @@ -7024,6 +7023,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_timeout); assert(irq->irq_method != sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || terminated >= timer_max_terminate) break; @@ -7043,6 +7044,7 @@ _nta_incoming_timer(nta_agent_t *sa) } for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) { + irq_next = irq->irq_next; if (irq->irq_destroyed) incoming_free_queue(rq, irq); @@ -8699,7 +8701,7 @@ void outgoing_destroy(nta_outgoing_t *orq) static void _nta_outgoing_timer(nta_agent_t *sa) { - uint32_t now = sa->sa_millisec; + uint32_t now = su_time_ms(su_now()); nta_outgoing_t *orq; outgoing_queue_t rq[1]; size_t retransmitted = 0, terminated = 0, timeout = 0, destroyed; @@ -8713,6 +8715,9 @@ _nta_outgoing_timer(nta_agent_t *sa) outgoing_queue_init(sa->sa_out.free = rq, 0); while ((orq = sa->sa_out.re_list)) { + + now = su_time_ms(su_now()); + if ((int32_t)(orq->orq_retry - now) > 0) break; if (retransmitted >= timer_max_retransmit) diff --git a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h index b4acba6a7d..ea347e80a0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h +++ b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h @@ -85,6 +85,11 @@ typedef uint64_t su_nanotime_t; #define SU_E9 (1000000000U) +typedef void (*su_time_func_t)(su_time_t *tv); + + +SOFIAPUBFUN void su_set_time_func(su_time_func_t func); + SOFIAPUBFUN su_nanotime_t su_nanotime(su_nanotime_t *return_time); SOFIAPUBFUN su_nanotime_t su_monotime(su_nanotime_t *return_time); @@ -138,7 +143,7 @@ su_inline uint32_t su_ntp_fraq(su_time_t t) /** Time as milliseconds. */ su_inline uint32_t su_time_ms(su_time_t t) { - return t.tv_sec * 1000 + (t.tv_usec + 500) / 1000; + return (t.tv_sec * 1000) + ((t.tv_usec + 500) / 1000); } #endif diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c index 0543e45aa0..7267213156 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c @@ -69,6 +69,13 @@ void (*_su_time)(su_time_t *tv); uint64_t (*_su_nanotime)(uint64_t *); +static su_time_func_t custom_time_func = NULL; + +void su_set_time_func(su_time_func_t func) { + custom_time_func = func; +} + + /** Get current time. * * The function @c su_time() fills its argument with the current NTP @@ -79,6 +86,13 @@ uint64_t (*_su_nanotime)(uint64_t *); void su_time(su_time_t *tv) { su_time_t ltv = {0,0}; + + if (custom_time_func) { + custom_time_func(<v); + if (tv) *tv = ltv; + return; + } + #if HAVE_CLOCK_GETTIME struct timespec ctv = {0}; if (clock_gettime(CLOCK_REALTIME, &ctv) == 0) { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 157092a005..8095a83c31 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3434,6 +3434,21 @@ static void config_sofia_profile_urls(sofia_profile_t * profile) } } +#ifdef SOFIA_CUSTOM_TIME +/* appears to not be granular enough */ +static void sofia_time(su_time_t *tv) +{ + switch_time_t now; + + if (tv) { + now = switch_micro_time_now(); + tv->tv_sec = ((uint32_t) (now / 1000000)) + 2208988800UL; + tv->tv_usec = (uint32_t) (now % 1000000); + } + +} +#endif + switch_status_t sofia_init(void) { su_init(); @@ -3442,6 +3457,10 @@ switch_status_t sofia_init(void) return SWITCH_STATUS_GENERR; } +#ifdef SOFIA_TIME + su_set_time_func(sofia_time); +#endif + /* Redirect loggers in sofia */ su_log_redirect(su_log_default, logger, NULL); su_log_redirect(tport_log, logger, NULL); From 5e2f808de6e59155ec17260c5153fe9438d7a3d5 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 28 Jun 2013 11:05:27 -0500 Subject: [PATCH 006/203] FS-5527 fix compiler error windows (cherry picked from commit a52a604fbb561dbb604676b1a17888bd74625101) --- libs/sofia-sip/libsofia-sip-ua/su/su_time0.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c index 7267213156..cae14a35a8 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c @@ -85,6 +85,12 @@ void su_set_time_func(su_time_func_t func) { */ void su_time(su_time_t *tv) { +#if HAVE_FILETIME + union { + FILETIME ft[1]; + ULARGE_INTEGER ull[1]; + } date; +#endif su_time_t ltv = {0,0}; if (custom_time_func) { @@ -105,10 +111,6 @@ void su_time(su_time_t *tv) ltv.tv_sec += NTP_EPOCH; #elif HAVE_FILETIME - union { - FILETIME ft[1]; - ULARGE_INTEGER ull[1]; - } date; GetSystemTimeAsFileTime(date.ft); From 929f52b15ccaae4d2c687c4a4c83c20d793a774a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 28 Jun 2013 14:20:58 -0500 Subject: [PATCH 007/203] fix race condition on device state destroy --- src/mod/applications/mod_skel/mod_skel.c | 25 ++++++++++++++++++ src/switch_channel.c | 33 ++++++++++++++---------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/mod/applications/mod_skel/mod_skel.c b/src/mod/applications/mod_skel/mod_skel.c index 907e6e102d..521a845a2c 100644 --- a/src/mod/applications/mod_skel/mod_skel.c +++ b/src/mod/applications/mod_skel/mod_skel.c @@ -157,6 +157,28 @@ SWITCH_STANDARD_API(skel_function) return SWITCH_STATUS_SUCCESS; } +static void mycb(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, + "%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n", + switch_channel_get_name(channel), + drec->device_id, + switch_channel_callstate2str(callstate), + switch_channel_device_state2str(drec->last_state), + switch_channel_device_state2str(drec->state), + drec->stats.total, + drec->stats.offhook, + drec->stats.active, + drec->stats.held, + drec->stats.hup, + drec->active_stop ? (uint32_t)(drec->active_stop - drec->active_start) / 1000 : 0, + switch_channel_test_flag(channel, CF_FINAL_DEVICE_LEG) ? "FINAL LEG" : ""); + +} + + /* Macro expands to: switch_status_t mod_skel_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load) { @@ -170,6 +192,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load) SWITCH_ADD_API(api_interface, "skel", "Skel API", skel_function, "syntax"); + switch_channel_bind_device_state_handler(mycb, NULL); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } @@ -180,6 +204,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skel_shutdown) { /* Cleanup dynamically allocated config settings */ + switch_channel_unbind_device_state_handler(mycb); switch_xml_config_cleanup(instructions); return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_channel.c b/src/switch_channel.c index 2709ee24d3..fd9de596b0 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -4681,31 +4681,36 @@ SWITCH_DECLARE(void) switch_channel_clear_device_record(switch_channel_t *channe static void process_device_hup(switch_channel_t *channel) { switch_hold_record_t *hr, *newhr, *last = NULL; + switch_device_record_t *drec = NULL; + switch_device_node_t *node; if (!channel->device_node) { return; } switch_mutex_lock(globals.device_mutex); - channel->device_node->hup_profile = switch_caller_profile_dup(channel->device_node->parent->pool, channel->caller_profile); - fetch_device_stats(channel->device_node->parent); + node = channel->device_node; + drec = channel->device_node->parent; - switch_ivr_generate_xml_cdr(channel->session, &channel->device_node->xml_cdr); - if (switch_event_create(&channel->device_node->event, SWITCH_EVENT_CALL_DETAIL) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_extended_data(channel, channel->device_node->event); + node->hup_profile = switch_caller_profile_dup(drec->pool, channel->caller_profile); + fetch_device_stats(drec); + + switch_ivr_generate_xml_cdr(channel->session, &node->xml_cdr); + if (switch_event_create(&node->event, SWITCH_EVENT_CALL_DETAIL) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_extended_data(channel, node->event); } for (hr = channel->hold_record; hr; hr = hr->next) { - newhr = switch_core_alloc(channel->device_node->parent->pool, sizeof(*newhr)); + newhr = switch_core_alloc(drec->pool, sizeof(*newhr)); newhr->on = hr->on; newhr->off = hr->off; if (hr->uuid) { - newhr->uuid = switch_core_strdup(channel->device_node->parent->pool, hr->uuid); + newhr->uuid = switch_core_strdup(drec->pool, hr->uuid); } - if (!channel->device_node->hold_record) { - channel->device_node->hold_record = newhr; + if (!node->hold_record) { + node->hold_record = newhr; } else { last->next = newhr; } @@ -4713,15 +4718,17 @@ static void process_device_hup(switch_channel_t *channel) last = newhr; } - if (!channel->device_node->parent->stats.offhook) { /* this is final call */ + if (!drec->stats.offhook) { /* this is final call */ - switch_core_hash_delete(globals.device_hash, channel->device_node->parent->device_id); + switch_core_hash_delete(globals.device_hash, drec->device_id); switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Processing last call from device [%s]\n", - channel->device_node->parent->device_id); + drec->device_id); switch_channel_set_flag(channel, CF_FINAL_DEVICE_LEG); + } else { + channel->device_node = NULL; } - channel->device_node->parent->refs--; + drec->refs--; switch_mutex_unlock(globals.device_mutex); From 0548f33a468000562ae8b484a7bfac8dcfd94bfe Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 1 Jul 2013 14:31:43 -0500 Subject: [PATCH 008/203] fix input event checker pre-empting return value from dtmf checker when both are present --- src/switch_ivr.c | 15 ++++++++++++--- src/switch_ivr_play_say.c | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index a99070d241..ba4ad8bead 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -275,7 +275,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, switch_event_t *event = NULL; if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + switch_status_t ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if (ostatus != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } switch_event_destroy(&event); } } @@ -1092,7 +1095,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { if (args && args->input_callback) { - if ((status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { + switch_status_t ostatus; + + if ((ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { + status = ostatus; break; } } else { @@ -1210,7 +1216,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s } if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + switch_status_t ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if (ostatus != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } switch_event_destroy(&event); } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index ece8c32935..e792c0d32b 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -687,9 +687,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se if (args->input_callback) { switch_event_t *event = NULL; + switch_status_t ostatus; if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if ((ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } + switch_event_destroy(&event); } } @@ -941,7 +945,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi switch_event_t *event; if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + switch_status_t ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if (ostatus != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } switch_event_destroy(&event); } } @@ -1433,7 +1440,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_event_t *event; if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + switch_status_t ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if (ostatus != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } switch_event_destroy(&event); } } @@ -2277,7 +2287,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session if (args->input_callback) { if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + switch_status_t ostatus = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen); + if (ostatus != SWITCH_STATUS_SUCCESS) { + status = ostatus; + } switch_event_destroy(&event); } } From f721a2592bea2d35aee0594b4d939ca9210d4437 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Mon, 1 Jul 2013 17:03:00 -0500 Subject: [PATCH 009/203] --resolve FS-5566 When you use $12345 in regex substitutions, it isn't obvious whenever you mean $1-concatenated-2345 or $12-concatenated-345 or any other variation. In all other languages, in order to solve this ambiguity, a braces {} are allowed to be used to separate variable name (or a reference) from surrounding text, like ${1}2345 or ${12}345. Use the same for freeswitch too. While at it, fix a buffer overflow as well: the index[] variable which is used to copy the "variable" name is 10 chars long, but it is used in the code without bounds checking, so a reference which is >9 chars long ($1234567890) will overflow the buffer, crashing freeswitch. And another overflow is in the way how size of the "substituted" variable is handled. First, in the outer loop, we compare the wrong variable with the size of `substituted' buffer (amount of bytes we took from the source instead of amount of bytes we used in `substituted'). And second, when actual regex match is being substitured, amount of room in `substituted' variable is not checked at all. Patch contributed by Michael Tokarev --- src/switch_regex.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/switch_regex.c b/src/switch_regex.c index 0a3479582e..2a98638134 100644 --- a/src/switch_regex.c +++ b/src/switch_regex.c @@ -132,20 +132,37 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c const char *replace = NULL; switch_size_t x, y = 0, z = 0; int num = 0; + int brace; - for (x = 0; x < (len - 1) && x < strlen(data);) { + for (x = 0; y < (len - 1) && x < strlen(data);) { if (data[x] == '$') { x++; + brace = data[x] == '{'; + if (brace) { + x++; + } + if (!(data[x] > 47 && data[x] < 58)) { + x -= brace; substituted[y++] = data[x - 1]; continue; } - while (data[x] > 47 && data[x] < 58) { + while (data[x] > 47 && data[x] < 58 && z < sizeof(index) - 1) { index[z++] = data[x]; x++; } + if (brace) { + if (data[x] != '}') { + x -= z - 1; + substituted[y++] = data[x - 1]; + continue; + } + else { + x++; + } + } index[z++] = '\0'; z = 0; num = atoi(index); @@ -156,7 +173,7 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c if (pcre_get_substring(field_data, ovector, match_count, num, &replace) > 0) { switch_size_t r; - for (r = 0; r < strlen(replace); r++) { + for (r = 0; r < strlen(replace) && y < (len - 1); r++) { substituted[y++] = replace[r]; } pcre_free_substring(replace); From 3c6e6e4d92bc9becee1fdd7e5030565be9336ab2 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Mon, 1 Jul 2013 17:10:23 -0500 Subject: [PATCH 010/203] Bump --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 09714c971c..ba600af73e 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.2.10], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.2.11], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [2]) -AC_SUBST(SWITCH_VERSION_MICRO, [10]) +AC_SUBST(SWITCH_VERSION_MICRO, [11]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) From 620a5804e61cea8ac7dd68257030abe35867a275 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Mon, 1 Jul 2013 22:19:15 -0500 Subject: [PATCH 011/203] partial rollback of ec6754262863475136c6a53b012eb7b0bb62d7ba to fix skinny breakage --- src/mod/endpoints/mod_skinny/mod_skinny.c | 49 +++++++------------- src/mod/endpoints/mod_skinny/skinny_server.c | 4 -- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index f5c01481d4..6845ab2070 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1051,39 +1051,26 @@ switch_status_t channel_receive_message(switch_core_session_t *session, switch_c private_t *tech_pvt = switch_core_session_get_private(session); switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_ANSWER: - switch_clear_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); - return channel_answer_channel(session); - - case SWITCH_MESSAGE_INDICATE_DISPLAY: - skinny_session_send_call_info_all(session); - break; - - case SWITCH_MESSAGE_INDICATE_PROGRESS: - if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) { - /* early media */ - switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); + case SWITCH_MESSAGE_INDICATE_ANSWER: + switch_clear_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); return channel_answer_channel(session); - } - break; - - case SWITCH_MESSAGE_INDICATE_BRIDGE: - if (switch_rtp_ready(tech_pvt->rtp_session)) { - rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK); - } - break; - case SWITCH_MESSAGE_INDICATE_UNBRIDGE: - if (switch_rtp_ready(tech_pvt->rtp_session)) { - rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK); - } - break; - - default: - break; - - } - return SWITCH_STATUS_SUCCESS; + case SWITCH_MESSAGE_INDICATE_DISPLAY: + skinny_session_send_call_info_all(session); + return SWITCH_STATUS_SUCCESS; + + case SWITCH_MESSAGE_INDICATE_PROGRESS: + if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) { + /* early media */ + switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); + return channel_answer_channel(session); + } + return SWITCH_STATUS_SUCCESS; + + default: + return SWITCH_STATUS_SUCCESS; + + } } diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index a6e0fa9a1c..f4999f4d33 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1733,10 +1733,6 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste switch_channel_t *channel = NULL; struct in_addr addr; - flags[SWITCH_RTP_FLAG_DATAWAIT]++; - flags[SWITCH_RTP_FLAG_AUTOADJ]++; - flags[SWITCH_RTP_FLAG_RAW_WRITE]++; - tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); From c5b8d3ee9ba61d2c1794612d34ae95d05477d1e5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 2 Jul 2013 08:44:47 -0500 Subject: [PATCH 012/203] FS-5568 --resolve the real problem is that L=-1 is not valid because the L param is about how many times to generate the output while generating the tone so -1 is impossible because it can never end to let you hear it. The real fix is to not allow -1 loops=-1 is the correct way to do this because that is parsed after the tone is generated and repeats the entire thing. Doing something like L=100 actually generates the whole slinear audio 100 times into memore where loops=100 only generates the little snippet and repeats it after it was generated. --- libs/freetdm/src/libteletone_generate.c | 8 ++++++-- libs/libteletone/src/libteletone_generate.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c index 3654d1ec34..ef7a7e03ec 100644 --- a/libs/freetdm/src/libteletone_generate.c +++ b/libs/freetdm/src/libteletone_generate.c @@ -382,9 +382,12 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm break; case 'L': if (!LOOPING) { - ts->LOOPS = atoi(cur + 2); + int L; + if ((L = atoi(cur + 2)) > 0) { + ts->LOOPS = L; + LOOPING++; + } } - LOOPING++; break; } } else { @@ -480,6 +483,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm bottom: free(data); data = NULL; + if (ts->LOOPS > 0) { ts->LOOPS--; } diff --git a/libs/libteletone/src/libteletone_generate.c b/libs/libteletone/src/libteletone_generate.c index 3654d1ec34..ef7a7e03ec 100644 --- a/libs/libteletone/src/libteletone_generate.c +++ b/libs/libteletone/src/libteletone_generate.c @@ -382,9 +382,12 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm break; case 'L': if (!LOOPING) { - ts->LOOPS = atoi(cur + 2); + int L; + if ((L = atoi(cur + 2)) > 0) { + ts->LOOPS = L; + LOOPING++; + } } - LOOPING++; break; } } else { @@ -480,6 +483,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm bottom: free(data); data = NULL; + if (ts->LOOPS > 0) { ts->LOOPS--; } From e6ae610bec6947386cb1d15e25fb6e2888c6a14d Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Tue, 2 Jul 2013 09:33:23 -0500 Subject: [PATCH 013/203] slight tweak to the spec file --- freeswitch.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/freeswitch.spec b/freeswitch.spec index 4e77fc5e4a..c93c9ecc41 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -1766,6 +1766,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/switch.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/syslog.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/timezones.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/translate.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/tts_commandline.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/unicall.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/unimrcp.conf.xml From 5e2c513e432fdb4a63bbb5bed710eee2a32ba154 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 3 Jul 2013 04:22:15 +0000 Subject: [PATCH 014/203] Add mod_rayo to debian packaging --- debian/control-modules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/control-modules b/debian/control-modules index 188f17ff96..2236c3407b 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -490,6 +490,10 @@ Module: event_handlers/mod_radius_cdr Description: mod_radius_cdr Adds mod_radius_cdr. +Module: event_handlers/mod_rayo +Description: mod_rayo + Adds mod_rayo. + Module: event_handlers/mod_snmp Description: mod_snmp Adds mod_snmp. From b48ffd056cc58a1a074391341a82e133348f5df6 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 3 Jul 2013 04:22:26 +0000 Subject: [PATCH 015/203] Add mod_ssml to Debian packaging --- debian/control-modules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/control-modules b/debian/control-modules index 2236c3407b..de260c7edb 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -527,6 +527,10 @@ Description: mod_sndfile Adds mod_sndfile. Build-Depends: libflac-dev, libogg-dev, libvorbis-dev +Module: formats/mod_ssml +Description: mod_ssml + Adds mod_ssml. + Module: formats/mod_tone_stream Description: mod_tone_stream Adds mod_tone_stream. From 4efa17347503c809f02268675ea5600f1a8ea09f Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 3 Jul 2013 04:25:48 +0000 Subject: [PATCH 016/203] Tweak such that control-modules.gen matches --- debian/control-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control-modules b/debian/control-modules index de260c7edb..ec291c71b6 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -227,9 +227,9 @@ Description: Voicemail detection This module detects voicemail beeps at any frequency in O(1) time. Module: applications/mod_voicemail -Depends: mail-transport-agent Description: Voicemail This module provides a voicemail system. +Depends: mail-transport-agent Module: applications/mod_voicemail_ivr Description: Voicemail IVR From 0a4bbaf5a55520da82968cc4bdb7a3d86a165620 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 3 Jul 2013 15:58:46 +0000 Subject: [PATCH 017/203] Fix uninitialized use of length variable Bad things must have been happening when this was hit. This was introduced in commit 7656a075c750f63d4095f6ed9b558c6f18443698 --- src/switch_ivr_async.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 9caa164852..0be6c07d59 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1202,6 +1202,9 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s switch_time_t diff; rh->wready = 1; + nframe = switch_core_media_bug_get_native_write_frame(bug); + len = nframe->datalen; + if (!rh->rready) { unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0}; switch_size_t fill_len = len; @@ -1210,8 +1213,6 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s } - nframe = switch_core_media_bug_get_native_write_frame(bug); - len = nframe->datalen; if (rh->last_write_time && rh->last_write_time < now) { From 842c5ea87785e5a121fd2c1e6acaff4d29d590ac Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 3 Jul 2013 10:32:25 +0000 Subject: [PATCH 018/203] Fix spacing --- debian/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index 473bae5539..5843872904 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -179,7 +179,7 @@ Build-Depends: # bootstrapping automake (>= 1.9), autoconf, libtool, # core build - dpkg-dev (>= 1.15.8.12), gcc (>= 4:4.4.5) , g++ (>= 4:4.4.5), + dpkg-dev (>= 1.15.8.12), gcc (>= 4:4.4.5), g++ (>= 4:4.4.5), libc6-dev (>= 2.11.3), make (>= 3.81), wget, pkg-config, # configure options From a4408e62a6ca1bc36e26109396af332d05fae812 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 10:34:06 -0500 Subject: [PATCH 019/203] --resolve FS-3918 using patch that adds conference_moderator_pin channel variable --- src/mod/applications/mod_conference/mod_conference.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 1e4990b66b..0f41cb3912 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -7355,7 +7355,7 @@ SWITCH_STANDARD_APP(conference_function) switch_core_session_message_t msg = { 0 }; uint8_t rl = 0, isbr = 0; char *dpin = ""; - char *mdpin = ""; + const char *mdpin = ""; conf_xml_cfg_t xml_cfg = { 0 }; switch_event_t *params = NULL; int locked = 0; @@ -7597,6 +7597,9 @@ SWITCH_STANDARD_APP(conference_function) rl++; } + /* Moderator PIN as a channel variable */ + mdpin = switch_channel_get_variable(channel, "conference_moderator_pin"); + if (zstr(dpin) && conference->pin) { dpin = conference->pin; } From d2c9ee0d23cb308d541481aa66c02afa8cb39dd7 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Wed, 3 Jul 2013 14:22:30 -0400 Subject: [PATCH 020/203] mod_rayo: move example config so that make config-rayo works --- .../rayo}/autoload_configs/acl.conf.xml | 0 .../rayo}/autoload_configs/cdr_csv.conf.xml | 0 .../autoload_configs/conference.conf.xml | 0 .../rayo}/autoload_configs/console.conf.xml | 0 .../autoload_configs/distributor.conf.xml | 0 .../autoload_configs/event_socket.conf.xml | 0 .../rayo}/autoload_configs/hash.conf.xml | 0 .../autoload_configs/http_cache.conf.xml | 0 .../autoload_configs/local_stream.conf.xml | 0 .../rayo}/autoload_configs/logfile.conf.xml | 0 .../rayo}/autoload_configs/lua.conf.xml | 0 .../rayo}/autoload_configs/memcache.conf.xml | 0 .../rayo}/autoload_configs/modules.conf.xml | 0 .../autoload_configs/pocketsphinx.conf.xml | 0 .../post_load_modules.conf.xml | 0 .../autoload_configs/presence_map.conf.xml | 0 conf/rayo/autoload_configs/rayo.conf.xml | 43 +++++++++++++++++++ .../rayo}/autoload_configs/shout.conf.xml | 0 .../rayo}/autoload_configs/sofia.conf.xml | 0 .../rayo}/autoload_configs/spandsp.conf.xml | 0 .../rayo}/autoload_configs/ssml.conf.xml | 0 .../rayo}/autoload_configs/switch.conf.xml | 0 .../rayo}/autoload_configs/timezones.conf.xml | 0 .../mod_rayo/conf => conf/rayo}/cacert.pem | 0 .../conf => conf/rayo}/dialplan/public.xml | 0 .../conf => conf/rayo}/directory/default.xml | 0 .../rayo}/directory/default/usera.xml | 0 .../rayo}/directory/default/userb.xml | 0 .../rayo}/directory/default/userc.xml | 0 .../rayo}/directory/default/userd.xml | 0 .../conf => conf/rayo}/freeswitch.xml | 0 .../conf => conf/rayo}/lang/de/de.xml | 0 .../conf => conf/rayo}/lang/de/demo/demo.xml | 0 .../conf => conf/rayo}/lang/de/vm/sounds.xml | 0 .../conf => conf/rayo}/lang/de/vm/tts.xml | 0 .../rayo}/lang/en/demo/demo-ivr.xml | 0 .../conf => conf/rayo}/lang/en/demo/demo.xml | 0 .../rayo}/lang/en/demo/funnies.xml | 0 .../rayo}/lang/en/demo/new-demo-ivr.xml | 0 .../conf => conf/rayo}/lang/en/dir/sounds.xml | 0 .../conf => conf/rayo}/lang/en/dir/tts.xml | 0 .../conf => conf/rayo}/lang/en/en.xml | 0 .../conf => conf/rayo}/lang/en/ivr/sounds.xml | 0 .../conf => conf/rayo}/lang/en/vm/sounds.xml | 0 .../conf => conf/rayo}/lang/en/vm/tts.xml | 0 .../rayo}/lang/en/vm/voicemail_ivr.xml | 0 .../rayo}/lang/es/demo/demo-es-ES.xml | 0 .../rayo}/lang/es/demo/demo-es-MX.xml | 0 .../rayo}/lang/es/demo/demo-ivr-es-ES.xml | 0 .../rayo}/lang/es/demo/demo-ivr-es-MX.xml | 0 .../rayo}/lang/es/dir/sounds-es-ES.xml | 0 .../rayo}/lang/es/dir/sounds-es-MX.xml | 0 .../rayo}/lang/es/dir/tts-es-ES.xml | 0 .../rayo}/lang/es/dir/tts-es-MX.xml | 0 .../conf => conf/rayo}/lang/es/es_ES.xml | 0 .../conf => conf/rayo}/lang/es/es_MX.xml | 0 .../rayo}/lang/es/vm/sounds-es-ES.xml | 0 .../rayo}/lang/es/vm/sounds-es-MX.xml | 0 .../rayo}/lang/es/vm/tts-es-ES.xml | 0 .../rayo}/lang/es/vm/tts-es-MX.xml | 0 .../conf => conf/rayo}/lang/fr/demo/demo.xml | 0 .../conf => conf/rayo}/lang/fr/dir/sounds.xml | 0 .../conf => conf/rayo}/lang/fr/dir/tts.xml | 0 .../conf => conf/rayo}/lang/fr/fr.xml | 0 .../conf => conf/rayo}/lang/fr/vm/sounds.xml | 0 .../rayo}/lang/he/demo/demo-ivr.xml | 0 .../conf => conf/rayo}/lang/he/demo/demo.xml | 0 .../conf => conf/rayo}/lang/he/dir/sounds.xml | 0 .../conf => conf/rayo}/lang/he/he.xml | 0 .../conf => conf/rayo}/lang/he/vm/sounds.xml | 0 .../rayo}/lang/pt/demo/demo-ivr-pt-BR.xml | 0 .../rayo}/lang/pt/demo/demo-ivr-pt-PT.xml | 0 .../rayo}/lang/pt/demo/demo-pt-BR.xml | 0 .../rayo}/lang/pt/demo/demo-pt-PT.xml | 0 .../rayo}/lang/pt/dir/sounds-pt-BR.xml | 0 .../rayo}/lang/pt/dir/sounds-pt-PT.xml | 0 .../rayo}/lang/pt/dir/tts-pt-BR.xml | 0 .../rayo}/lang/pt/dir/tts-pt-PT.xml | 0 .../conf => conf/rayo}/lang/pt/pt_BR.xml | 0 .../conf => conf/rayo}/lang/pt/pt_PT.xml | 0 .../rayo}/lang/pt/vm/sounds-pt-BR.xml | 0 .../rayo}/lang/pt/vm/sounds-pt-PT.xml | 0 .../rayo}/lang/pt/vm/tts-pt-BR.xml | 0 .../rayo}/lang/pt/vm/tts-pt-PT.xml | 0 .../rayo}/lang/ru/demo/demo-ivr.xml | 0 .../conf => conf/rayo}/lang/ru/demo/demo.xml | 0 .../conf => conf/rayo}/lang/ru/dir/sounds.xml | 0 .../conf => conf/rayo}/lang/ru/dir/tts.xml | 0 .../conf => conf/rayo}/lang/ru/ru.xml | 0 .../conf => conf/rayo}/lang/ru/vm/sounds.xml | 0 .../conf => conf/rayo}/lang/ru/vm/tts.xml | 0 .../mod_rayo/conf => conf/rayo}/mime.types | 0 .../rayo}/sip_profiles/external.xml | 0 .../rayo}/sip_profiles/external/example.xml | 0 .../mod_rayo/conf => conf/rayo}/vars.xml | 0 95 files changed, 43 insertions(+) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/acl.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/cdr_csv.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/conference.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/console.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/distributor.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/event_socket.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/hash.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/http_cache.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/local_stream.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/logfile.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/lua.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/memcache.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/modules.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/pocketsphinx.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/post_load_modules.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/presence_map.conf.xml (100%) create mode 100644 conf/rayo/autoload_configs/rayo.conf.xml rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/shout.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/sofia.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/spandsp.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/ssml.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/switch.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/autoload_configs/timezones.conf.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/cacert.pem (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/dialplan/public.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/directory/default.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/directory/default/usera.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/directory/default/userb.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/directory/default/userc.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/directory/default/userd.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/freeswitch.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/de/de.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/de/demo/demo.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/de/vm/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/de/vm/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/demo/demo-ivr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/demo/demo.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/demo/funnies.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/demo/new-demo-ivr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/dir/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/dir/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/en.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/ivr/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/vm/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/vm/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/en/vm/voicemail_ivr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/demo/demo-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/demo/demo-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/demo/demo-ivr-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/demo/demo-ivr-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/dir/sounds-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/dir/sounds-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/dir/tts-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/dir/tts-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/es_ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/es_MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/vm/sounds-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/vm/sounds-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/vm/tts-es-ES.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/es/vm/tts-es-MX.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/fr/demo/demo.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/fr/dir/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/fr/dir/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/fr/fr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/fr/vm/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/he/demo/demo-ivr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/he/demo/demo.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/he/dir/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/he/he.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/he/vm/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/demo/demo-ivr-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/demo/demo-ivr-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/demo/demo-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/demo/demo-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/dir/sounds-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/dir/sounds-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/dir/tts-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/dir/tts-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/pt_BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/pt_PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/vm/sounds-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/vm/sounds-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/vm/tts-pt-BR.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/pt/vm/tts-pt-PT.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/demo/demo-ivr.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/demo/demo.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/dir/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/dir/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/ru.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/vm/sounds.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/lang/ru/vm/tts.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/mime.types (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/sip_profiles/external.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/sip_profiles/external/example.xml (100%) rename {src/mod/event_handlers/mod_rayo/conf => conf/rayo}/vars.xml (100%) diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/acl.conf.xml b/conf/rayo/autoload_configs/acl.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/acl.conf.xml rename to conf/rayo/autoload_configs/acl.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/cdr_csv.conf.xml b/conf/rayo/autoload_configs/cdr_csv.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/cdr_csv.conf.xml rename to conf/rayo/autoload_configs/cdr_csv.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/conference.conf.xml b/conf/rayo/autoload_configs/conference.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/conference.conf.xml rename to conf/rayo/autoload_configs/conference.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/console.conf.xml b/conf/rayo/autoload_configs/console.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/console.conf.xml rename to conf/rayo/autoload_configs/console.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/distributor.conf.xml b/conf/rayo/autoload_configs/distributor.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/distributor.conf.xml rename to conf/rayo/autoload_configs/distributor.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/event_socket.conf.xml b/conf/rayo/autoload_configs/event_socket.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/event_socket.conf.xml rename to conf/rayo/autoload_configs/event_socket.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/hash.conf.xml b/conf/rayo/autoload_configs/hash.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/hash.conf.xml rename to conf/rayo/autoload_configs/hash.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/http_cache.conf.xml b/conf/rayo/autoload_configs/http_cache.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/http_cache.conf.xml rename to conf/rayo/autoload_configs/http_cache.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/local_stream.conf.xml b/conf/rayo/autoload_configs/local_stream.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/local_stream.conf.xml rename to conf/rayo/autoload_configs/local_stream.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/logfile.conf.xml b/conf/rayo/autoload_configs/logfile.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/logfile.conf.xml rename to conf/rayo/autoload_configs/logfile.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/lua.conf.xml b/conf/rayo/autoload_configs/lua.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/lua.conf.xml rename to conf/rayo/autoload_configs/lua.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/memcache.conf.xml b/conf/rayo/autoload_configs/memcache.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/memcache.conf.xml rename to conf/rayo/autoload_configs/memcache.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/modules.conf.xml b/conf/rayo/autoload_configs/modules.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/modules.conf.xml rename to conf/rayo/autoload_configs/modules.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/pocketsphinx.conf.xml b/conf/rayo/autoload_configs/pocketsphinx.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/pocketsphinx.conf.xml rename to conf/rayo/autoload_configs/pocketsphinx.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/post_load_modules.conf.xml b/conf/rayo/autoload_configs/post_load_modules.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/post_load_modules.conf.xml rename to conf/rayo/autoload_configs/post_load_modules.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/presence_map.conf.xml b/conf/rayo/autoload_configs/presence_map.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/presence_map.conf.xml rename to conf/rayo/autoload_configs/presence_map.conf.xml diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml new file mode 100644 index 0000000000..f9ac49b99d --- /dev/null +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/shout.conf.xml b/conf/rayo/autoload_configs/shout.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/shout.conf.xml rename to conf/rayo/autoload_configs/shout.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/sofia.conf.xml b/conf/rayo/autoload_configs/sofia.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/sofia.conf.xml rename to conf/rayo/autoload_configs/sofia.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/spandsp.conf.xml b/conf/rayo/autoload_configs/spandsp.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/spandsp.conf.xml rename to conf/rayo/autoload_configs/spandsp.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/ssml.conf.xml b/conf/rayo/autoload_configs/ssml.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/ssml.conf.xml rename to conf/rayo/autoload_configs/ssml.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/switch.conf.xml b/conf/rayo/autoload_configs/switch.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/switch.conf.xml rename to conf/rayo/autoload_configs/switch.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/timezones.conf.xml b/conf/rayo/autoload_configs/timezones.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/timezones.conf.xml rename to conf/rayo/autoload_configs/timezones.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/cacert.pem b/conf/rayo/cacert.pem similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/cacert.pem rename to conf/rayo/cacert.pem diff --git a/src/mod/event_handlers/mod_rayo/conf/dialplan/public.xml b/conf/rayo/dialplan/public.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/dialplan/public.xml rename to conf/rayo/dialplan/public.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default.xml b/conf/rayo/directory/default.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default.xml rename to conf/rayo/directory/default.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/usera.xml b/conf/rayo/directory/default/usera.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/usera.xml rename to conf/rayo/directory/default/usera.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userb.xml b/conf/rayo/directory/default/userb.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userb.xml rename to conf/rayo/directory/default/userb.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userc.xml b/conf/rayo/directory/default/userc.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userc.xml rename to conf/rayo/directory/default/userc.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userd.xml b/conf/rayo/directory/default/userd.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userd.xml rename to conf/rayo/directory/default/userd.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/freeswitch.xml b/conf/rayo/freeswitch.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/freeswitch.xml rename to conf/rayo/freeswitch.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/de.xml b/conf/rayo/lang/de/de.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/de.xml rename to conf/rayo/lang/de/de.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/demo/demo.xml b/conf/rayo/lang/de/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/demo/demo.xml rename to conf/rayo/lang/de/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/vm/sounds.xml b/conf/rayo/lang/de/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/vm/sounds.xml rename to conf/rayo/lang/de/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/vm/tts.xml b/conf/rayo/lang/de/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/vm/tts.xml rename to conf/rayo/lang/de/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo-ivr.xml b/conf/rayo/lang/en/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo-ivr.xml rename to conf/rayo/lang/en/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo.xml b/conf/rayo/lang/en/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo.xml rename to conf/rayo/lang/en/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/funnies.xml b/conf/rayo/lang/en/demo/funnies.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/funnies.xml rename to conf/rayo/lang/en/demo/funnies.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/new-demo-ivr.xml b/conf/rayo/lang/en/demo/new-demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/new-demo-ivr.xml rename to conf/rayo/lang/en/demo/new-demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/dir/sounds.xml b/conf/rayo/lang/en/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/dir/sounds.xml rename to conf/rayo/lang/en/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/dir/tts.xml b/conf/rayo/lang/en/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/dir/tts.xml rename to conf/rayo/lang/en/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/en.xml b/conf/rayo/lang/en/en.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/en.xml rename to conf/rayo/lang/en/en.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/ivr/sounds.xml b/conf/rayo/lang/en/ivr/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/ivr/sounds.xml rename to conf/rayo/lang/en/ivr/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/sounds.xml b/conf/rayo/lang/en/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/sounds.xml rename to conf/rayo/lang/en/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/tts.xml b/conf/rayo/lang/en/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/tts.xml rename to conf/rayo/lang/en/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/voicemail_ivr.xml b/conf/rayo/lang/en/vm/voicemail_ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/voicemail_ivr.xml rename to conf/rayo/lang/en/vm/voicemail_ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-ES.xml b/conf/rayo/lang/es/demo/demo-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-ES.xml rename to conf/rayo/lang/es/demo/demo-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-MX.xml b/conf/rayo/lang/es/demo/demo-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-MX.xml rename to conf/rayo/lang/es/demo/demo-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-ES.xml b/conf/rayo/lang/es/demo/demo-ivr-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-ES.xml rename to conf/rayo/lang/es/demo/demo-ivr-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-MX.xml b/conf/rayo/lang/es/demo/demo-ivr-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-MX.xml rename to conf/rayo/lang/es/demo/demo-ivr-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-ES.xml b/conf/rayo/lang/es/dir/sounds-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-ES.xml rename to conf/rayo/lang/es/dir/sounds-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-MX.xml b/conf/rayo/lang/es/dir/sounds-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-MX.xml rename to conf/rayo/lang/es/dir/sounds-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-ES.xml b/conf/rayo/lang/es/dir/tts-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-ES.xml rename to conf/rayo/lang/es/dir/tts-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-MX.xml b/conf/rayo/lang/es/dir/tts-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-MX.xml rename to conf/rayo/lang/es/dir/tts-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/es_ES.xml b/conf/rayo/lang/es/es_ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/es_ES.xml rename to conf/rayo/lang/es/es_ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/es_MX.xml b/conf/rayo/lang/es/es_MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/es_MX.xml rename to conf/rayo/lang/es/es_MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-ES.xml b/conf/rayo/lang/es/vm/sounds-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-ES.xml rename to conf/rayo/lang/es/vm/sounds-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-MX.xml b/conf/rayo/lang/es/vm/sounds-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-MX.xml rename to conf/rayo/lang/es/vm/sounds-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-ES.xml b/conf/rayo/lang/es/vm/tts-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-ES.xml rename to conf/rayo/lang/es/vm/tts-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-MX.xml b/conf/rayo/lang/es/vm/tts-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-MX.xml rename to conf/rayo/lang/es/vm/tts-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/demo/demo.xml b/conf/rayo/lang/fr/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/demo/demo.xml rename to conf/rayo/lang/fr/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/sounds.xml b/conf/rayo/lang/fr/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/sounds.xml rename to conf/rayo/lang/fr/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/tts.xml b/conf/rayo/lang/fr/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/tts.xml rename to conf/rayo/lang/fr/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/fr.xml b/conf/rayo/lang/fr/fr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/fr.xml rename to conf/rayo/lang/fr/fr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/vm/sounds.xml b/conf/rayo/lang/fr/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/vm/sounds.xml rename to conf/rayo/lang/fr/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo-ivr.xml b/conf/rayo/lang/he/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo-ivr.xml rename to conf/rayo/lang/he/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo.xml b/conf/rayo/lang/he/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo.xml rename to conf/rayo/lang/he/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/dir/sounds.xml b/conf/rayo/lang/he/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/dir/sounds.xml rename to conf/rayo/lang/he/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/he.xml b/conf/rayo/lang/he/he.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/he.xml rename to conf/rayo/lang/he/he.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/vm/sounds.xml b/conf/rayo/lang/he/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/vm/sounds.xml rename to conf/rayo/lang/he/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-BR.xml b/conf/rayo/lang/pt/demo/demo-ivr-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-BR.xml rename to conf/rayo/lang/pt/demo/demo-ivr-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-PT.xml b/conf/rayo/lang/pt/demo/demo-ivr-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-PT.xml rename to conf/rayo/lang/pt/demo/demo-ivr-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-BR.xml b/conf/rayo/lang/pt/demo/demo-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-BR.xml rename to conf/rayo/lang/pt/demo/demo-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-PT.xml b/conf/rayo/lang/pt/demo/demo-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-PT.xml rename to conf/rayo/lang/pt/demo/demo-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-BR.xml b/conf/rayo/lang/pt/dir/sounds-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-BR.xml rename to conf/rayo/lang/pt/dir/sounds-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-PT.xml b/conf/rayo/lang/pt/dir/sounds-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-PT.xml rename to conf/rayo/lang/pt/dir/sounds-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-BR.xml b/conf/rayo/lang/pt/dir/tts-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-BR.xml rename to conf/rayo/lang/pt/dir/tts-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-PT.xml b/conf/rayo/lang/pt/dir/tts-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-PT.xml rename to conf/rayo/lang/pt/dir/tts-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_BR.xml b/conf/rayo/lang/pt/pt_BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_BR.xml rename to conf/rayo/lang/pt/pt_BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_PT.xml b/conf/rayo/lang/pt/pt_PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_PT.xml rename to conf/rayo/lang/pt/pt_PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-BR.xml b/conf/rayo/lang/pt/vm/sounds-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-BR.xml rename to conf/rayo/lang/pt/vm/sounds-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-PT.xml b/conf/rayo/lang/pt/vm/sounds-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-PT.xml rename to conf/rayo/lang/pt/vm/sounds-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-BR.xml b/conf/rayo/lang/pt/vm/tts-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-BR.xml rename to conf/rayo/lang/pt/vm/tts-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-PT.xml b/conf/rayo/lang/pt/vm/tts-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-PT.xml rename to conf/rayo/lang/pt/vm/tts-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo-ivr.xml b/conf/rayo/lang/ru/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo-ivr.xml rename to conf/rayo/lang/ru/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo.xml b/conf/rayo/lang/ru/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo.xml rename to conf/rayo/lang/ru/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/sounds.xml b/conf/rayo/lang/ru/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/sounds.xml rename to conf/rayo/lang/ru/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/tts.xml b/conf/rayo/lang/ru/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/tts.xml rename to conf/rayo/lang/ru/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/ru.xml b/conf/rayo/lang/ru/ru.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/ru.xml rename to conf/rayo/lang/ru/ru.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/sounds.xml b/conf/rayo/lang/ru/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/sounds.xml rename to conf/rayo/lang/ru/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/tts.xml b/conf/rayo/lang/ru/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/tts.xml rename to conf/rayo/lang/ru/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/mime.types b/conf/rayo/mime.types similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/mime.types rename to conf/rayo/mime.types diff --git a/src/mod/event_handlers/mod_rayo/conf/sip_profiles/external.xml b/conf/rayo/sip_profiles/external.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/sip_profiles/external.xml rename to conf/rayo/sip_profiles/external.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/sip_profiles/external/example.xml b/conf/rayo/sip_profiles/external/example.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/sip_profiles/external/example.xml rename to conf/rayo/sip_profiles/external/example.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/vars.xml b/conf/rayo/vars.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/vars.xml rename to conf/rayo/vars.xml From eb19191c88879819134b7c29114021f0d62dc928 Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 3 Jul 2013 14:55:13 -0400 Subject: [PATCH 021/203] add missing modules --- build/modules.conf.in | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build/modules.conf.in b/build/modules.conf.in index 81ae32f4c2..d60b1211ef 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -26,10 +26,14 @@ applications/mod_httapi #applications/mod_lcr #applications/mod_memcache #applications/mod_mongo +#applications/mod_mp4 #applications/mod_nibblebill +#applications/mod_oreka #applications/mod_osp +#applications/mod_rad_auth #applications/mod_redis #applications/mod_rss +#applications/mod_sonar applications/mod_sms #applications/mod_snapshot #applications/mod_snipe_hunt @@ -63,17 +67,20 @@ codecs/mod_h26x codecs/mod_vp8 #codecs/mod_ilbc #codecs/mod_isac +#codecs/mod_mp4v #codecs/mod_opus #codecs/mod_sangoma_codec #codecs/mod_silk #codecs/mod_siren codecs/mod_speex +#codecs/mod_theora dialplans/mod_dialplan_asterisk #dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml #directories/mod_ldap #endpoints/mod_alsa #endpoints/mod_dingaling +#endpoints/mod_gsmopen #endpoints/mod_h323 #endpoints/mod_html5 #endpoints/mod_khomp @@ -81,9 +88,10 @@ endpoints/mod_loopback #endpoints/mod_opal #endpoints/mod_portaudio #endpoints/mod_rtmp -#endpoints/mod_skinny +endpoints/mod_skinny #endpoints/mod_skypopen endpoints/mod_sofia +#endpoints/mod_unicall event_handlers/mod_cdr_csv #event_handlers/mod_cdr_mongodb #event_handlers/mod_cdr_pg_csv @@ -92,6 +100,7 @@ event_handlers/mod_cdr_sqlite #event_handlers/mod_event_multicast event_handlers/mod_event_socket #event_handlers/mod_event_zmq +#event_handlers/mod_json_cdr #event_handlers/mod_radius_cdr #event_handlers/mod_rayo #event_handlers/mod_snmp @@ -117,10 +126,13 @@ loggers/mod_syslog #say/mod_say_de say/mod_say_en #say/mod_say_es +#say/mod_say_fa #say/mod_say_fr #say/mod_say_he +#say/mod_say_hr #say/mod_say_hu #say/mod_say_it +#say/mod_say_ja #say/mod_say_nl #say/mod_say_pl #say/mod_say_pt @@ -140,4 +152,4 @@ xml_int/mod_xml_scgi #../../libs/openzap/mod_openzap ## Experimental Modules (don't cry if they're broken) -#../../contrib/mod/xml_int/mod_xml_odbc +#../../contrib/mod/xml_int/mod_xml_odbc \ No newline at end of file From 42916f81764dd1b8e41a312f136a243969c811d5 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 11:21:03 -0500 Subject: [PATCH 022/203] --resolve FS-5432 --- conf/vanilla/sip_profiles/internal.xml | 4 ++++ src/mod/endpoints/mod_sofia/conf/sofia.conf.xml | 4 ++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 8 ++++++++ src/mod/endpoints/mod_sofia/sofia_presence.c | 13 +++++++++++++ 5 files changed, 30 insertions(+) diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index 7beecbfeab..375eecbbc3 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -302,6 +302,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml index bf6bee7b28..5bd3a6dc12 100644 --- a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml +++ b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml @@ -353,6 +353,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index fb1c345f07..263ca80f0b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -702,6 +702,7 @@ struct sofia_profile { su_strlst_t *tls_verify_in_subjects; uint32_t sip_force_expires; uint32_t sip_expires_max_deviation; + uint32_t sip_subscription_max_deviation; int ireg_seconds; sofia_paid_type_t paid_type; uint32_t rtp_digit_delay; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8095a83c31..813e2a0f36 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3630,6 +3630,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->rtp_digit_delay = 40; profile->sip_force_expires = 0; profile->sip_expires_max_deviation = 0; + profile->sip_subscription_max_deviation = 0; profile->tls_version = 0; profile->tls_timeout = 300; profile->mflags = MFLAG_REFER | MFLAG_REGISTER; @@ -4573,6 +4574,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { profile->sip_expires_max_deviation = 0; } + } else if (!strcasecmp(var, "sip-subscription-max-deviation")) { + int32_t sip_subscription_max_deviation = atoi(val); + if (sip_subscription_max_deviation >= 0) { + profile->sip_subscription_max_deviation = sip_subscription_max_deviation; + } else { + profile->sip_subscription_max_deviation = 0; + } } else if (!strcasecmp(var, "reuse-connections")) { switch_bool_t value = switch_true(val); if (!value) { diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 30e8bc3390..be21bf8b1c 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -3516,6 +3516,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, long exp_delta = 0; char exp_delta_str[30] = ""; + uint32_t sub_max_deviation_var = 0; sip_to_t const *to; const char *from_user = NULL, *from_host = NULL; const char *to_user = NULL, *to_host = NULL; @@ -3615,6 +3616,18 @@ void sofia_presence_handle_sip_i_subscribe(int status, } } + if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) { + if (sub_max_deviation_var > 0) { + int sub_deviation; + srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) ); + /* random negative number between 0 and negative sub_max_deviation_var: */ + sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var; + if ( (exp_delta + sub_deviation) > 45 ) { + exp_delta += sub_deviation; + } + } + } + if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DELTA %ld\n", exp_delta); } From c58b1508a293170341d36469256599f43dde67eb Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 11:21:47 -0500 Subject: [PATCH 023/203] --resolve FS-5426 --- conf/vanilla/sip_profiles/internal.xml | 4 ++++ src/mod/endpoints/mod_sofia/conf/sofia.conf.xml | 4 ++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 5 ++++- src/mod/endpoints/mod_sofia/sofia_reg.c | 8 ++++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index 375eecbbc3..9eb66259af 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -178,6 +178,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml index 5bd3a6dc12..411ea3e44e 100644 --- a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml +++ b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml @@ -205,6 +205,10 @@ + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 263ca80f0b..f1fadd2475 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -240,6 +240,7 @@ typedef enum { PFLAG_DISABLE_NAPTR, PFLAG_AUTOFLUSH, PFLAG_NAT_OPTIONS_PING, + PFLAG_UDP_NAT_OPTIONS_PING, PFLAG_ALL_REG_OPTIONS_PING, PFLAG_AUTOFIX_TIMING, PFLAG_MESSAGE_QUERY_ON_REGISTER, diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 813e2a0f36..f2aa652f82 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4282,10 +4282,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else if (!strcasecmp(var, "contact-user")) { profile->contact_user = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "nat-options-ping")) { - if (switch_true(val)) { + if (!strcasecmp(val, "udp-only")) { + sofia_set_pflag(profile, PFLAG_UDP_NAT_OPTIONS_PING); + } else if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_NAT_OPTIONS_PING); } else { sofia_clear_pflag(profile, PFLAG_NAT_OPTIONS_PING); + sofia_clear_pflag(profile, PFLAG_UDP_NAT_OPTIONS_PING); } } else if (!strcasecmp(var, "all-reg-options-ping")) { if (switch_true(val)) { diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index fc4a448100..3487b4f0fc 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -802,6 +802,14 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot) " from sip_registrations where hostname='%s' and " "profile_name='%s'", mod_sofia_globals.hostname, profile->name); + sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile); + switch_safe_free(sql); + } else if (sofia_test_pflag(profile, PFLAG_UDP_NAT_OPTIONS_PING)) { + sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid," + "expires,user_agent,server_user,server_host,profile_name" + " from sip_registrations where status like '%%UDP-NAT%%' " + "and hostname='%s' and profile_name='%s'", mod_sofia_globals.hostname, profile->name); + sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile); switch_safe_free(sql); } else if (sofia_test_pflag(profile, PFLAG_NAT_OPTIONS_PING)) { From d2cd255a8f9bf84315c8691a9ad1e4fda615a9b9 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 14:59:53 -0500 Subject: [PATCH 024/203] --resolve FS-5569 --- .../applications/mod_commands/mod_commands.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index ef34a985f7..2acead56c8 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4543,6 +4543,34 @@ SWITCH_STANDARD_API(alias_function) return SWITCH_STATUS_SUCCESS; } +#define COALESCE_SYNTAX "[^^],,..." +SWITCH_STANDARD_API(coalesce_function) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + char *data = (char *) cmd; + char *mydata = NULL, *argv[256] = { 0 }; + int argc = -1; + + if (data && *data && (mydata = strdup(data))) { + argc = switch_separate_string(mydata, ',', argv, + (sizeof(argv) / sizeof(argv[0]))); + } + + if (argc > 0) { + for (int i = 0; i < argc; i++) { + if (argv[i] && *argv[i]) { + stream->write_function(stream, argv[i]); + status = SWITCH_STATUS_SUCCESS; + break; + } + } + } else if (argc <= 0){ + stream->write_function(stream, "-USAGE: %s\n", COALESCE_SYNTAX); + } + + return status; +} + #define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like ]|calls|detailed_calls|bridged_calls|detailed_bridged_calls|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits|status" SWITCH_STANDARD_API(show_function) { @@ -5982,7 +6010,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "acl", "Compare an ip to an acl list", acl_function, " "); - SWITCH_ADD_API(commands_api_interface, "alias", "Alias", alias_function, ALIAS_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "alias", "Alias", alias_function, ALIAS_SYNTAX); SWITCH_ADD_API(commands_api_interface, "coalesce", "Return first nonempty parameter", coalesce_function, COALESCE_SYNTAX); SWITCH_ADD_API(commands_api_interface, "banner", "Return the system banner", banner_function, ""); SWITCH_ADD_API(commands_api_interface, "bgapi", "Execute an api command in a thread", bgapi_function, "[ ]"); SWITCH_ADD_API(commands_api_interface, "bg_system", "Execute a system command in the background", bg_system_function, SYSTEM_SYNTAX); @@ -6108,6 +6136,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add alias add"); switch_console_set_complete("add alias del"); + switch_console_set_complete("add coalesce"); switch_console_set_complete("add complete add"); switch_console_set_complete("add complete del"); switch_console_set_complete("add db_cache status"); From 60adf50f86ae742e2c1a80e885d230d609a9ce81 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 15:01:03 -0500 Subject: [PATCH 025/203] --resolve FS-5558 --- .../applications/mod_dptools/mod_dptools.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index c02e162b85..fc1806e3c0 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1519,6 +1519,33 @@ SWITCH_STANDARD_APP(unset_function) } } +SWITCH_STANDARD_APP(multiunset_function) +{ + char delim = ' '; + char *arg = (char *) data; + + if (!zstr(arg) && *arg == '^' && *(arg+1) == '^') { + arg += 2; + delim = *arg++; + } + + if (arg) { + char *array[256] = {0}; + int i, argc; + + arg = switch_core_session_strdup(session, arg); + argc = switch_split(arg, delim, array); + + for(i = 0; i < argc; i++) { + switch_channel_set_variable(switch_core_session_get_channel(session), array[i], NULL); + } + + } else { + switch_channel_set_variable(switch_core_session_get_channel(session), arg, NULL); + } +} + + SWITCH_STANDARD_APP(log_function) { char *level, *log_str; @@ -5506,6 +5533,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "multiunset", "Unset many channel variables", SET_LONG_DESC, multiunset_function, "[^^] ", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "[]", SAF_NONE); SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA); From 667a8d88683c508dc6f453468e9cc33f855de216 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Thu, 4 Jul 2013 12:27:59 -0500 Subject: [PATCH 026/203] fix stupid c89 for windows --- src/mod/applications/mod_commands/mod_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2acead56c8..2d0d02d7fe 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4557,7 +4557,8 @@ SWITCH_STANDARD_API(coalesce_function) } if (argc > 0) { - for (int i = 0; i < argc; i++) { + int i; + for (i = 0; i < argc; i++) { if (argv[i] && *argv[i]) { stream->write_function(stream, argv[i]); status = SWITCH_STATUS_SUCCESS; From ab03347c3d3bff21e922fbf7577d8e2fcb61ccc1 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 16:07:15 -0500 Subject: [PATCH 027/203] --resolve FS-3922 --- src/include/switch_core.h | 4 ++++ src/switch_xml.c | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index e169c1d8e6..7b9b4fc205 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2520,6 +2520,10 @@ SWITCH_DECLARE(void) switch_sql_queue_manger_execute_sql_event_callback(switch_s SWITCH_DECLARE(pid_t) switch_fork(void); +SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait); +SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream); +SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/switch_xml.c b/src/switch_xml.c index 018c01dd47..c13e33bea4 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -105,6 +105,42 @@ void globfree(glob_t *); /* Use UTF-8 as the general encoding */ static switch_bool_t USE_UTF_8_ENCODING = SWITCH_TRUE; +static void preprocess_exec_set(char *keyval) +{ + char *key = keyval; + char *val = strchr(key, '='); + + if (val) { + char *ve = val++; + while (*val && *val == ' ') { + val++; + } + *ve-- = '\0'; + while (*ve && *ve == ' ') { + *ve-- = '\0'; + } + } + + if (key && val) { + switch_stream_handle_t exec_result = { 0 }; + SWITCH_STANDARD_STREAM(exec_result); + if (switch_stream_system_fork(val, &exec_result) == 0) { + if (!zstr(exec_result.data)) { + char *tmp = (char *) exec_result.data; + tmp = &tmp[strlen(tmp)-1]; + while (tmp >= (char *) exec_result.data && ( tmp[0] == ' ' || tmp[0] == '\n') ) { + tmp[0] = '\0'; /* remove trailing spaces and newlines */ + tmp--; + } + switch_core_set_variable(key, exec_result.data); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while executing command: %s\n", val); + } + switch_safe_free(exec_result.data); + } +} + static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rlevel); typedef struct switch_xml_root *switch_xml_root_t; @@ -1457,6 +1493,8 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle switch_core_set_variable(name, val); } + } else if (!strcasecmp(tcmd, "exec-set")) { + preprocess_exec_set(targ); } else if (!strcasecmp(tcmd, "include")) { preprocess_glob(cwd, targ, write_fd, rlevel + 1); } else if (!strcasecmp(tcmd, "exec")) { @@ -1515,6 +1553,8 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle switch_core_set_variable(name, val); } + } else if (!strcasecmp(cmd, "exec-set")) { + preprocess_exec_set(arg); } else if (!strcasecmp(cmd, "include")) { preprocess_glob(cwd, arg, write_fd, rlevel + 1); } else if (!strcasecmp(cmd, "exec")) { From 28f0ade282c60e179f32f799c2755a66ba4c3f45 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Thu, 4 Jul 2013 22:02:47 -0500 Subject: [PATCH 028/203] fix libuuid detection --- acinclude.m4 | 1 + build/config/uuid.m4 | 17 +++++++++++++++++ configure.in | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 build/config/uuid.m4 diff --git a/acinclude.m4 b/acinclude.m4 index aeba17b5c3..58b5500a80 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -6,6 +6,7 @@ m4_include([build/config/ac_gcc_archflag.m4]) m4_include([build/config/ac_gcc_x86_cpuid.m4]) m4_include([build/config/ax_lib_mysql.m4]) m4_include([build/config/ax_check_java.m4]) +m4_include([build/config/uuid.m4]) m4_include([build/config/erlang.m4]) m4_include([build/config/odbc.m4]) m4_include([build/config/sched_setaffinity.m4]) diff --git a/build/config/uuid.m4 b/build/config/uuid.m4 new file mode 100644 index 0000000000..ecfa719b5e --- /dev/null +++ b/build/config/uuid.m4 @@ -0,0 +1,17 @@ +AC_DEFUN([CHECK_LIBUUID], + [ + PKG_CHECK_MODULES([LIBUUID], [uuid >= 1.41.2], + [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) + if test "$LIBUUID_FOUND" = "no" ; then + PKG_CHECK_MODULES([LIBUUID], [uuid], + [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) + if test "$LIBUUID_FOUND" = "no" ; then + AC_MSG_ERROR([libuuid development files required]) + else + LIBUUID_INCLUDEDIR=$(pkg-config --variable=includedir uuid) + LIBUUID_CFLAGS+=" -I$LIBUUID_INCLUDEDIR/uuid " + fi + fi + AC_SUBST([LIBUUID_CFLAGS]) + AC_SUBST([LIBUUID_LIBS]) + ]) diff --git a/configure.in b/configure.in index ba600af73e..94cdbe52f4 100644 --- a/configure.in +++ b/configure.in @@ -400,6 +400,10 @@ if test "x$enable_core_odbc_support" != "xno"; then AC_CHECK_LIB([odbc], [SQLDisconnect],, AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent])) fi +CHECK_LIBUUID +SWITCH_AM_LDFLAGS="$LIBUUID_LIBS $SWITCH_AM_LDFLAGS" +SWITCH_AM_CFLAGS="$LIBUUID_CFLAGS $SWITCH_AM_CFLAGS" + AC_ARG_ENABLE(core-pgsql-support, [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"]) @@ -409,7 +413,7 @@ AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) if test "$PG_CONFIG" != "no"; then AC_MSG_CHECKING([for PostgreSQL libraries]) POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" - POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags` -L`$PG_CONFIG --libdir` -lpq" + POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.[0-9]+#\1#'` POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.([0-9]+).[0-9]+#\1#'` From 756dd2ebb9ad5247f020c998d8d7181c07c40a7d Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Fri, 5 Jul 2013 09:49:28 -0500 Subject: [PATCH 029/203] fix typo --- conf/vanilla/sip_profiles/internal.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index 9eb66259af..3a5f0eb4ce 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -180,7 +180,7 @@ - + From 47d35790bdeb3940e27140ab07e0717a1cd02c05 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Fri, 5 Jul 2013 10:12:45 -0500 Subject: [PATCH 030/203] Make this a warning not an error. libuuid and its associated dev packages are HIGHLY recommended. --- build/config/uuid.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/config/uuid.m4 b/build/config/uuid.m4 index ecfa719b5e..7f37c23c66 100644 --- a/build/config/uuid.m4 +++ b/build/config/uuid.m4 @@ -6,7 +6,7 @@ AC_DEFUN([CHECK_LIBUUID], PKG_CHECK_MODULES([LIBUUID], [uuid], [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) if test "$LIBUUID_FOUND" = "no" ; then - AC_MSG_ERROR([libuuid development files required]) + AC_MSG_WARN([libuuid development package highly recommended!]) else LIBUUID_INCLUDEDIR=$(pkg-config --variable=includedir uuid) LIBUUID_CFLAGS+=" -I$LIBUUID_INCLUDEDIR/uuid " From 4c6886d7e2607d85bd80ee548a73d2acdb36ee75 Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 5 Jul 2013 19:50:43 -0500 Subject: [PATCH 031/203] fix race --- src/mod/applications/mod_fifo/mod_fifo.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index f53bb0aa63..905c13fc8f 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -3087,16 +3087,21 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(other_session)); switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(session)); + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", "true"); + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", "caller"); + switch_channel_set_variable(switch_core_session_get_channel(session), "fifo_initiated_bridge", "true"); + switch_channel_set_variable(switch_core_session_get_channel(session), "fifo_bridge_role", "consumer"); + switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session); - if (!switch_channel_test_flag(other_channel, CF_TRANSFER) || !switch_channel_up(other_channel)) { - switch_channel_set_variable(other_channel, "fifo_initiated_bridge", "true"); - switch_channel_set_variable(other_channel, "fifo_bridge_role", "caller"); + if (switch_channel_test_flag(other_channel, CF_TRANSFER) || switch_channel_up(other_channel)) { + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL); + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL); } - - if (!switch_channel_test_flag(channel, CF_TRANSFER) || !switch_channel_up(channel)) { - switch_channel_set_variable(channel, "fifo_initiated_bridge", "true"); - switch_channel_set_variable(channel, "fifo_bridge_role", "consumer"); + + if (switch_channel_test_flag(channel, CF_TRANSFER) || switch_channel_up(channel)) { + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL); + switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL); } if (outbound_id) { From 84de992b8bcc4cdb5f2e3a097b982dfffad3bc4d Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Sat, 6 Jul 2013 12:52:50 -0500 Subject: [PATCH 032/203] FS-3127 --resolve please reopen if not fixed --- .../applications/mod_callcenter/mod_callcenter.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index c758147078..9f74d2f9cc 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -562,27 +562,28 @@ char *cc_execute_sql2str(cc_queue_t *queue, switch_mutex_t *mutex, char *sql, ch switch_cache_db_handle_t *dbh = NULL; - if (!(dbh = cc_get_db_handle())) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); - return NULL; - } - if (mutex) { switch_mutex_lock(mutex); } else { switch_mutex_lock(globals.mutex); } + if (!(dbh = cc_get_db_handle())) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); + goto end; + } + ret = switch_cache_db_execute_sql2str(dbh, sql, resbuf, len, NULL); +end: + switch_cache_db_release_db_handle(&dbh); + if (mutex) { switch_mutex_unlock(mutex); } else { switch_mutex_unlock(globals.mutex); } - switch_cache_db_release_db_handle(&dbh); - return ret; } From 2fd21a47b1527e2ea6721b171a5f866435865799 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Sat, 6 Jul 2013 21:37:11 -0500 Subject: [PATCH 033/203] FS-2816 --resolve --- libs/esl/fs_cli.c | 28 +++++++++++++++++++---- src/mod/loggers/mod_console/mod_console.c | 15 +++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 0e6521908c..393fcf80d3 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -57,6 +57,7 @@ typedef struct { int debug; const char *console_fnkeys[12]; char loglevel[128]; + int log_uuid; int quiet; int batch_mode; char prompt_color[12]; @@ -595,6 +596,7 @@ static const char *usage_str = " -i, --interrupt Allow Control-c to interrupt\n" " -x, --execute=command Execute Command and Exit\n" " -l, --loglevel=command Log Level\n" + " -U, --log-uuid Include UUID in log output\n" " -q, --quiet Disable logging\n" " -r, --retry Retry connection on failure\n" " -R, --reconnect Reconnect if disconnected\n" @@ -745,10 +747,14 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) if (aok) { if (feature_level) clear_line(); if(!(global_profile->batch_mode)) { - printf("%s%s", colors[level], handle->last_event->body); + printf("%s", colors[level]); + } + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + printf("%s ", userdata); + } + printf("%s", handle->last_event->body); + if(!(global_profile->batch_mode)) { if (!feature_level) printf("%s", ESL_SEQ_DEFAULT_COLOR); - } else { - printf("%s", handle->last_event->body); } if (feature_level) redisplay(); } @@ -757,6 +763,10 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) if(!(global_profile->batch_mode)) { SetConsoleTextAttribute(hStdout, colors[level]); } + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + WriteFile(hStdout, userdata, strlen(userdata), &outbytes, NULL); + WriteFile(hStdout, " ", strlen(" "), &outbytes, NULL); + } WriteFile(hStdout, handle->last_event->body, len, &outbytes, NULL); if(!(global_profile->batch_mode)) { SetConsoleTextAttribute(hStdout, wOldColorAttrs); @@ -1221,6 +1231,8 @@ static void read_config(const char *dft_cfile, const char *cfile) { } } else if(!strcasecmp(var, "loglevel")) { esl_set_string(profiles[pcount-1].loglevel, val); + } else if(!strcasecmp(var, "log-uuid")) { + profiles[pcount-1].log_uuid = esl_true(val); } else if(!strcasecmp(var, "quiet")) { profiles[pcount-1].quiet = esl_true(val); } else if(!strcasecmp(var, "prompt-color")) { @@ -1282,6 +1294,7 @@ int main(int argc, char *argv[]) {"debug", 1, 0, 'd'}, {"execute", 1, 0, 'x'}, {"loglevel", 1, 0, 'l'}, + {"log-uuid", 0, 0, 'U'}, {"quiet", 0, 0, 'q'}, {"batchmode", 0, 0, 'b'}, {"retry", 0, 0, 'r'}, @@ -1303,6 +1316,7 @@ int main(int argc, char *argv[]) int argv_exec = 0; char argv_command[1024] = ""; char argv_loglevel[128] = ""; + int argv_log_uuid = 0; int argv_quiet = 0; int argv_batch = 0; int loops = 2, reconnect = 0, timeout = 0; @@ -1340,7 +1354,7 @@ int main(int argc, char *argv[]) esl_global_set_default_logger(6); /* default debug level to 6 (info) */ for(;;) { int option_index = 0; - opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:t:qrRhib?n", options, &option_index); + opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:Ut:qrRhib?n", options, &option_index); if (opt == -1) break; switch (opt) { case 'H': @@ -1383,6 +1397,9 @@ int main(int argc, char *argv[]) case 'l': esl_set_string(argv_loglevel, optarg); break; + case 'U': + argv_log_uuid = 1; + break; case 'q': argv_quiet = 1; break; @@ -1445,6 +1462,9 @@ int main(int argc, char *argv[]) esl_set_string(profile->loglevel, argv_loglevel); profile->quiet = 0; } + if (argv_log_uuid) { + profile->log_uuid = 1; + } esl_log(ESL_LOG_DEBUG, "Using profile %s [%s]\n", profile->name, profile->host); esl_set_string(prompt_color, profile->prompt_color); esl_set_string(input_text_color, profile->input_text_color); diff --git a/src/mod/loggers/mod_console/mod_console.c b/src/mod/loggers/mod_console/mod_console.c index 905029b92b..4b80add5e4 100644 --- a/src/mod/loggers/mod_console/mod_console.c +++ b/src/mod/loggers/mod_console/mod_console.c @@ -60,6 +60,7 @@ static switch_memory_pool_t *module_pool = NULL; static switch_hash_t *log_hash = NULL; static uint32_t all_level = 0; static int32_t hard_log_level = SWITCH_LOG_DEBUG; +static switch_bool_t log_uuid = SWITCH_FALSE; //static int32_t failed_write = 0; static void del_mapping(char *var) { @@ -138,6 +139,8 @@ static switch_status_t config_logger(void) #endif } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { hard_log_level = switch_log_str2level(val); + } else if (!strcasecmp(var, "uuid") && switch_true(val)) { + log_uuid = SWITCH_TRUE; } } } @@ -244,11 +247,21 @@ static switch_status_t switch_console_logger(const switch_log_node_t *node, swit DWORD len = (DWORD) strlen(node->data); DWORD outbytes = 0; SetConsoleTextAttribute(hStdout, COLORS[node->level]); + if (log_uuid && !zstr(node->userdata)) { + WriteFile(hStdout, node->userdata, strlen(node->userdata), &outbytes, NULL); + WriteFile(hStdout, " ", strlen(" "), &outbytes, NULL); + } WriteFile(hStdout, node->data, len, &outbytes, NULL); SetConsoleTextAttribute(hStdout, wOldColorAttrs); #else - fprintf(handle, "%s%s%s", COLORS[node->level], node->data, SWITCH_SEQ_DEFAULT_COLOR); + if (log_uuid && !zstr(node->userdata)) { + fprintf(handle, "%s%s %s%s", COLORS[node->level], node->userdata, node->data, SWITCH_SEQ_DEFAULT_COLOR); + } else { + fprintf(handle, "%s%s%s", COLORS[node->level], node->data, SWITCH_SEQ_DEFAULT_COLOR); + } #endif + } else if (log_uuid && !zstr(node->userdata)) { + fprintf(handle, "%s %s", node->userdata, node->data); } else { fprintf(handle, "%s", node->data); } From cfd388301d603c567ce71596c3d22a06824866be Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 8 Jul 2013 00:03:11 +0800 Subject: [PATCH 034/203] --resolve FS-5072 --- .../applications/mod_dptools/mod_dptools.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index fc1806e3c0..8f1057a137 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -31,6 +31,7 @@ * Luke Dashjr (OpenMethods, LLC) * Cesar Cepeda * Christopher M. Rienzo + * Seven Du * * mod_dptools.c -- Raw Audio File Streaming Application Module * @@ -2685,6 +2686,55 @@ SWITCH_STANDARD_APP(endless_playback_function) } +SWITCH_STANDARD_APP(loop_playback_function) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_status_t status = SWITCH_STATUS_SUCCESS; + const char *file = data; + int loop = 1; + + if (*file == '+') { + const char *p = ++file; + while(*file && *file++ != ' ') { } + + if (zstr(p)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing loop in data [%s]\n", data); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return; + } + + loop = atoi(p); + } + + if (zstr(file)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing file arg in data [%s]\n", data); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return; + } + + while (switch_channel_ready(channel) && (loop < 0 || loop-- > 0)) { + status = switch_ivr_play_file(session, NULL, file, NULL); + + if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { + break; + } + } + + switch (status) { + case SWITCH_STATUS_SUCCESS: + case SWITCH_STATUS_BREAK: + switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED"); + break; + case SWITCH_STATUS_NOTFOUND: + switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE NOT FOUND"); + break; + default: + switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PLAYBACK ERROR"); + break; + } + +} + SWITCH_STANDARD_APP(gentones_function) { char *tone_script = NULL; @@ -5604,6 +5654,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "playback", "Playback File", "Playback a file to the channel", playback_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "endless_playback", "Playback File Endlessly", "Endlessly Playback a file to the channel", endless_playback_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "loop_playback", "Playback File looply", "Playback a file to the channel looply for limted times", + loop_playback_function, "[+loops] ", SAF_NONE); SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function, " ", SAF_NONE); From 4bcaf1e60b890514bc77205a9919e07e0caa5eff Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Mon, 8 Jul 2013 13:09:27 -0400 Subject: [PATCH 035/203] mod_rayo: fix - client messages not accepted over s2s connection --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 66f59c9def..24b187d739 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -2884,7 +2884,7 @@ static struct rayo_actor *xmpp_stream_client_locate(struct xmpp_stream *stream, struct rayo_peer_server *rserver = RAYO_PEER_SERVER(xmpp_stream_get_private(stream)); actor = RAYO_ACTOR(rayo_client_create(jid, xmpp_stream_get_jid(stream), PS_UNKNOWN, rayo_client_send, rserver)); RAYO_RDLOCK(actor); - } else if (!strcmp(RAT_CLIENT, actor->type)) { + } else if (strcmp(RAT_CLIENT, actor->type)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, not a client: %s\n", xmpp_stream_get_jid(stream), jid); RAYO_UNLOCK(actor); actor = NULL; From aa68eac35260063d77b1401c054371271933fba8 Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 8 Jul 2013 13:19:10 -0500 Subject: [PATCH 036/203] fix logic from race fix --- src/mod/applications/mod_fifo/mod_fifo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 905c13fc8f..fa0978d647 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -3094,12 +3094,12 @@ SWITCH_STANDARD_APP(fifo_function) switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session); - if (switch_channel_test_flag(other_channel, CF_TRANSFER) || switch_channel_up(other_channel)) { + if (switch_channel_test_flag(other_channel, CF_TRANSFER) && switch_channel_up(other_channel)) { switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL); switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL); } - if (switch_channel_test_flag(channel, CF_TRANSFER) || switch_channel_up(channel)) { + if (switch_channel_test_flag(channel, CF_TRANSFER) && switch_channel_up(channel)) { switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL); switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL); } From 3e92f570d11e0bd9936be281533b0c193734e2e6 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 9 Jul 2013 14:03:06 +0800 Subject: [PATCH 037/203] debug audio on h323 channel --- src/mod/endpoints/mod_h323/mod_h323.cpp | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp index 2e7050e850..4368116a22 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.cpp +++ b/src/mod/endpoints/mod_h323/mod_h323.cpp @@ -1591,7 +1591,35 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t } break; } + case SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA:{ + if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { + switch_rtp_flag_t flags = 0; + int x = 0; + if (!strcasecmp(msg->string_array_arg[0], "read")) { + x++; flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ; + } else if (!strcasecmp(msg->string_array_arg[0], "write")) { + x++; flags |= SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; + } else if (!strcasecmp(msg->string_array_arg[0], "both")) { + x++; + x++; flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ | SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; + } else if (*msg->string_array_arg[0] == 'v') { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_fsSession), SWITCH_LOG_ERROR, "Video is not supported yet\n"); + break; + } + + if (x) { + if (switch_true(msg->string_array_arg[1])) { + switch_rtp_set_flag(tech_pvt->rtp_session, flags); + } else { + switch_rtp_clear_flag(tech_pvt->rtp_session, flags); + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_fsSession), SWITCH_LOG_ERROR, "Invalid Options\n"); + } + } + break; + } default:{ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message id = %d [%p]\n", msg->message_id,this); } From ca73adbea0dec23bb312c2f05e283489e28e5585 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Tue, 9 Jul 2013 07:59:41 -0500 Subject: [PATCH 038/203] FS-5588 --resolve windows compiler fixes --- libs/esl/fs_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 393fcf80d3..5d87d521d3 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -764,8 +764,8 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) SetConsoleTextAttribute(hStdout, colors[level]); } if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { - WriteFile(hStdout, userdata, strlen(userdata), &outbytes, NULL); - WriteFile(hStdout, " ", strlen(" "), &outbytes, NULL); + WriteFile(hStdout, userdata, (DWORD)strlen(userdata), &outbytes, NULL); + WriteFile(hStdout, " ", (DWORD)strlen(" "), &outbytes, NULL); } WriteFile(hStdout, handle->last_event->body, len, &outbytes, NULL); if(!(global_profile->batch_mode)) { From 0b3cafcf0a0c14d149d67453184ae665a8d5a8f2 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Tue, 9 Jul 2013 08:50:56 -0500 Subject: [PATCH 039/203] FS-5275 -resolve --- src/mod/say/mod_say_de/mod_say_de.c | 89 ++++++++++++++++++----------- 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/src/mod/say/mod_say_de/mod_say_de.c b/src/mod/say/mod_say_de/mod_say_de.c index af970430c5..a461bebe1f 100644 --- a/src/mod/say/mod_say_de/mod_say_de.c +++ b/src/mod/say/mod_say_de/mod_say_de.c @@ -91,7 +91,7 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ } else { say_file("digits/%d.wav", a); } - say_file("digits/hundred.wav"); + say_file("digits/hundred.wav"); } if (b) { @@ -106,13 +106,25 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ say_file("currency/and.wav"); } if (method == SSM_COUNTED) { - say_file("digits/h-%d0.wav", b); + if ( gender == SSG_MASCULINE ) { + say_file("digits/h-%d0_m.wav", b); + } else if ( gender == SSG_NEUTER ) { + say_file("digits/h-%d0_n.wav", b); + } else { + say_file("digits/h-%d0.wav", b); + } } else { say_file("digits/%d0.wav", b); } } else { if (method == SSM_COUNTED) { - say_file("digits/h-%d%d.wav", b, c); + if ( gender == SSG_MASCULINE ) { + say_file("digits/h-%d%d_m.wav", b,c); + } else if ( gender == SSG_NEUTER ) { + say_file("digits/h-%d%d_n.wav", b,c); + } else { + say_file("digits/h-%d%d.wav", b,c); + } } else { say_file("digits/%d%d.wav", b, c); } @@ -122,12 +134,18 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ if (c) { if (method == SSM_COUNTED) { - say_file("digits/h-%d.wav", c); + if ( gender == SSG_MASCULINE ) { + say_file("digits/h-%d_m.wav", c); + } else if ( gender == SSG_NEUTER ) { + say_file("digits/h-%d_n.wav", c); + } else { + say_file("digits/h-%d.wav", c); + } } else { /*"one" used as an article is feminine or masculine in german, e.g. voicemail-message is feminine only applies to the likes of 1, 101, 1001 etc.*/ if ( b == 0 && c == 1 && gender == SSG_FEMININE ) { - say_file("digits/%d_f.wav", c); + say_file("digits/1_f.wav"); } else if ( b == 0 && c == 1 && what ) { say_file("digits/s-1.wav"); } else { @@ -251,10 +269,11 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, } if (hours) { - say_num(hours, SSM_PRONOUNCED); if (hours == 1) { + say_file("digits/1_f.wav"); say_file("time/hour.wav"); } else { + say_num(hours, SSM_PRONOUNCED); say_file("time/hours.wav"); } } else { @@ -263,10 +282,11 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, } if (minutes) { - say_num(minutes, SSM_PRONOUNCED); if (minutes == 1) { + say_file("digits/1_f.wav"); say_file("time/minute.wav"); } else { + say_num(minutes, SSM_PRONOUNCED); say_file("time/minutes.wav"); } } else { @@ -274,11 +294,13 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, say_file("time/minutes.wav"); } + say_file("currency/and.wav"); if (seconds) { - say_num(seconds, SSM_PRONOUNCED); if (seconds == 1) { + say_file("digits/1_f.wav"); say_file("time/second.wav"); } else { + say_num(seconds, SSM_PRONOUNCED); say_file("time/seconds.wav"); } } else { @@ -311,6 +333,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, } if (say_date) { + say_args->gender = SSG_MASCULINE; say_file("time/day-%d.wav", tm.tm_wday); say_num(tm.tm_mday, SSM_COUNTED); say_file("time/mon-%d.wav", tm.tm_mon); @@ -318,29 +341,27 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, } if (say_time) { - int32_t hour = tm.tm_hour, pm = 0; - - if (hour > 12) { - hour -= 12; - pm = 1; - } else if (hour == 12) { - pm = 1; - } else if (hour == 0) { - hour = 12; - pm = 0; + if (say_date) { + say_file("time/at.wav"); } - say_num(hour, SSM_PRONOUNCED); - say_file("time/oclock.wav"); - - if (tm.tm_min > 9) { - say_num(tm.tm_min, SSM_PRONOUNCED); - } else if (tm.tm_min) { - say_file("time/oh.wav"); - say_num(tm.tm_min, SSM_PRONOUNCED); + if (tm.tm_hour == 1) { + say_file("digits/s-1.wav"); + } else { + say_num(tm.tm_hour, SSM_PRONOUNCED); + } + say_file("time/oclock.wav"); + + if (tm.tm_min > 0) { + say_file("currency/and.wav"); + if (tm.tm_min == 1) { + say_file("digits/1_f.wav") + say_file("time/minute.wav"); + } else { + say_num(tm.tm_min, SSM_PRONOUNCED); + say_file("time/minutes.wav"); + } } - - say_file("time/%s.wav", pm ? "p-m" : "a-m"); } return SWITCH_STATUS_SUCCESS; @@ -378,23 +399,25 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, dollars++; } + /* Say dollar amount */ - de_say_general_count(session, dollars, say_args, args); if (atoi(dollars) == 1) { + say_file("digits/s-1.wav"); say_file("currency/dollar.wav"); } else { + de_say_general_count(session, dollars, say_args, args); say_file("currency/dollars.wav"); } - /* Say "and" */ - say_file("currency/and.wav"); - /* Say cents */ if (cents) { - de_say_general_count(session, cents, say_args, args); + /* Say "and" */ + say_file("currency/and.wav"); if (atoi(cents) == 1) { + say_file("digits/s-1.wav"); say_file("currency/cent.wav"); } else { + de_say_general_count(session, cents, say_args, args); say_file("currency/cents.wav"); } } else { From 2f2a8791385e11f73db294709b62e6add98ec070 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 10 Jul 2013 09:43:33 -0500 Subject: [PATCH 040/203] FS-5589 --resolve --- src/switch_ivr_play_say.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index e792c0d32b..3739e25308 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -1704,7 +1704,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess if (read_impl.samples_per_second) { switch_channel_set_variable_printf(channel, "playback_seconds", "%d", fh->samples_in / fh->native_rate); - switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_in / fh->native_rate); + switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_in / (fh->native_rate / 1000)); } switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_in); From 2ec821b74b1949bf3b69a287d0872040db264d34 Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 10 Jul 2013 10:52:40 -0400 Subject: [PATCH 041/203] FS-3911 --resolve patch applied --- .../applications/mod_commands/mod_commands.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2d0d02d7fe..1837328356 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4390,7 +4390,11 @@ static int show_as_json_callback(void *pArg, int argc, char **argv, char **colum } if (holder->justcount) { - holder->count++; + if (zstr(argv[0])) { + holder->count = 0; + } else { + holder->count = (uint32_t) atoi(argv[0]); + } return 0; } @@ -4430,7 +4434,11 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column } if (holder->justcount) { - holder->count++; + if (zstr(argv[0])) { + holder->count = 0; + } else { + holder->count = (uint32_t) atoi(argv[0]); + } return 0; } @@ -4468,7 +4476,11 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames) int x; if (holder->justcount) { - holder->count++; + if (zstr(argv[0])) { + holder->count = 0; + } else { + holder->count = (uint32_t) atoi(argv[0]); + } return 0; } @@ -4704,6 +4716,7 @@ SWITCH_STANDARD_API(show_function) if (!strcasecmp(command, "calls")) { sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", hostname); if (argv[1] && !strcasecmp(argv[1], "count")) { + sprintf(sql, "select count(*) from basic_calls where hostname='%s'", hostname); holder.justcount = 1; if (argv[3] && !strcasecmp(argv[2], "as")) { as = argv[3]; @@ -4712,6 +4725,7 @@ SWITCH_STANDARD_API(show_function) } else if (!strcasecmp(command, "registrations")) { sprintf(sql, "select * from registrations where hostname='%s'", hostname); if (argv[1] && !strcasecmp(argv[1], "count")) { + sprintf(sql, "select count(*) from registrations where hostname='%s'", hostname); holder.justcount = 1; if (argv[3] && !strcasecmp(argv[2], "as")) { as = argv[3]; @@ -4743,6 +4757,7 @@ SWITCH_STANDARD_API(show_function) } else if (!strcasecmp(command, "channels")) { sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", hostname); if (argv[1] && !strcasecmp(argv[1], "count")) { + sprintf(sql, "select count(*) from channels where hostname='%s'", hostname); holder.justcount = 1; if (argv[3] && !strcasecmp(argv[2], "as")) { as = argv[3]; From 13de330c60ad87b8c6a54c8348e80e44206b431c Mon Sep 17 00:00:00 2001 From: Michael S Collins Date: Wed, 10 Jul 2013 08:28:17 -0700 Subject: [PATCH 042/203] FS-5393: --resolve mod_voicemail: add skip_record_check and skip_record_urgent_check vars --- .../mod_voicemail/mod_voicemail.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 83bb8eaf23..eb552f77b1 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1186,6 +1186,7 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t cc_t cc = { 0 }; switch_codec_implementation_t read_impl = { 0 }; int got_file = 0; + switch_bool_t skip_record_check = switch_true(switch_channel_get_variable(channel, "skip_record_check")); switch_core_session_get_read_impl(session, &read_impl); @@ -1265,6 +1266,9 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *(input + 1) = '\0'; status = SWITCH_STATUS_SUCCESS; *cc.buf = '\0'; + } else if (skip_record_check) { + /* Skip the record check and simply return */ + goto end; } else { (void) vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout); } @@ -3311,10 +3315,12 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p int disk_quota = 0; switch_bool_t skip_greeting = switch_true(switch_channel_get_variable(channel, "skip_greeting")); switch_bool_t skip_instructions = switch_true(switch_channel_get_variable(channel, "skip_instructions")); + switch_bool_t skip_record_urgent_check = switch_true(switch_channel_get_variable(channel, "skip_record_urgent_check")); switch_bool_t vm_enabled = SWITCH_TRUE; switch_channel_set_variable(channel, "skip_greeting", NULL); switch_channel_set_variable(channel, "skip_instructions", NULL); + switch_channel_set_variable(channel, "skip_record_urgent_check", NULL); memset(&cbt, 0, sizeof(cbt)); @@ -3589,13 +3595,14 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p char input[10] = "", term = 0; switch_snprintf(key_buf, sizeof(key_buf), "%s:%s", profile->urgent_key, profile->terminator_key); - - (void) vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout); - if (*profile->urgent_key == *input) { - read_flags = URGENT_FLAG_STRING; - (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "marked-urgent", NULL, NULL); - } else { - (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL); + if (!skip_record_urgent_check) { + (void) vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout); + if (*profile->urgent_key == *input) { + read_flags = URGENT_FLAG_STRING; + (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "marked-urgent", NULL, NULL); + } else { + (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL); + } } } From ddf1908faee86b84e716ad90ea3a3bffecb8293e Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 10 Jul 2013 12:16:34 -0400 Subject: [PATCH 043/203] FS-5467 --resolve patch applied --- src/mod/applications/mod_db/mod_db.c | 44 +++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_db/mod_db.c b/src/mod/applications/mod_db/mod_db.c index 5cb6dd7cfa..ed9a8cf877 100644 --- a/src/mod/applications/mod_db/mod_db.c +++ b/src/mod/applications/mod_db/mod_db.c @@ -342,6 +342,8 @@ static switch_status_t do_config() /* CORE DB STUFF */ +static int group_callback(void *pArg, int argc, char **argv, char **columnNames); + SWITCH_STANDARD_API(db_api_function) { int argc = 0; @@ -409,6 +411,44 @@ SWITCH_STANDARD_API(db_api_function) else { stream->write_function(stream, "true"); } + goto done; + } else if (!strcasecmp(argv[0], "count")) { + char buf[256] = ""; + if (argc < 2) { + sql = switch_mprintf("select count(distinct realm) from db_data"); + } else if (argc < 3) { + sql = switch_mprintf("select count(data_key) from db_data where realm='%q'", argv[1]); + } else { + goto error; + } + limit_execute_sql2str(sql, buf, sizeof(buf)); + switch_safe_free(sql); + stream->write_function(stream, "%s", buf); + goto done; + } else if (!strcasecmp(argv[0], "list")) { + char buf[4096] = ""; + callback_t cbt = { 0 }; + cbt.buf = buf; + cbt.len = sizeof(buf); + + if (argc < 2) { + sql = switch_mprintf("select distinct realm,',' from db_data"); + } else if (argc < 3) { + sql = switch_mprintf("select distinct data_key,',' from db_data where realm='%q'", argv[1]); + } else { + goto error; + } + switch_assert(sql); + + limit_execute_sql_callback(sql, group_callback, &cbt); + switch_safe_free(sql); + + if (!zstr(buf)) { + *(buf + (strlen(buf) - 1)) = '\0'; + } + + stream->write_function(stream, "%s", buf); + goto done; } @@ -628,11 +668,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_db_load) SWITCH_ADD_APP(app_interface, "db", "Insert to the db", DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC); - SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[insert|delete|select]///"); + SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[insert|delete|select|exists|count|list]///"); switch_console_set_complete("add db insert"); switch_console_set_complete("add db delete"); switch_console_set_complete("add db select"); switch_console_set_complete("add db exists"); + switch_console_set_complete("add db count"); + switch_console_set_complete("add db list"); SWITCH_ADD_API(commands_api_interface, "group", "group [insert|delete|call]", group_api_function, "[insert|delete|call]::"); switch_console_set_complete("add group insert"); switch_console_set_complete("add group delete"); From 0ed5126c0cda37787dae4044a941b3da343996ee Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 10 Jul 2013 12:46:34 -0400 Subject: [PATCH 044/203] add chatplan info app --- src/mod/applications/mod_sms/mod_sms.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 102acb3db8..49037f24d9 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -24,6 +24,7 @@ * Contributor(s): * * Anthony Minessale II + * Raymond Chandler * * mod_sms.c -- Abstract SMS * @@ -448,6 +449,23 @@ static switch_status_t chat_send(switch_event_t *message_event) } +SWITCH_STANDARD_CHAT_APP(info_function) +{ + char *buf; + int level = SWITCH_LOG_INFO; + + if (!zstr(data)) { + level = switch_log_str2level(data); + } + + switch_event_serialize(message, &buf, SWITCH_FALSE); + switch_assert(buf); + switch_log_printf(SWITCH_CHANNEL_LOG, level, "CHANNEL_DATA:\n%s\n", buf); + free(buf); + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_STANDARD_CHAT_APP(system_function) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n", data); @@ -546,6 +564,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load) SWITCH_ADD_CHAT(chat_interface, SMS_CHAT_PROTO, chat_send); + SWITCH_ADD_CHAT_APP(chat_app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SCAF_NONE); SWITCH_ADD_CHAT_APP(chat_app_interface, "reply", "reply to a message", "reply to a message", reply_function, "", SCAF_NONE); SWITCH_ADD_CHAT_APP(chat_app_interface, "stop", "stop execution", "stop execution", stop_function, "", SCAF_NONE); SWITCH_ADD_CHAT_APP(chat_app_interface, "set", "set a variable", "set a variable", set_function, "", SCAF_NONE); From d1b43f36f0f53885bbe88faa1f7413acba9d3b05 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 10 Jul 2013 11:25:30 -0500 Subject: [PATCH 045/203] FS-5559 --resolve --- src/mod/endpoints/mod_sofia/sofia_presence.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index be21bf8b1c..3bff37b2ee 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -260,9 +260,22 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) } if (!list) { + switch_event_t *event; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nNobody to send to: Profile %s\n", proto, from, to, body ? body : "[no body]", prof ? prof : "NULL"); + // emit no recipient event + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Error-Type", "chat"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Error-Reason", "no recipient"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-To", to); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-From", from); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof ? prof : "NULL"); + switch_event_add_body(event, body); + switch_event_fire(&event); + } + goto end; } From 27ccb69c94faf59d29c495f828b1d01bb2ca22ef Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 10 Jul 2013 11:26:41 -0500 Subject: [PATCH 046/203] FS-5524 --resolve --- conf/vanilla/autoload_configs/lua.conf.xml | 2 + src/mod/languages/mod_lua/mod_lua.cpp | 50 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/conf/vanilla/autoload_configs/lua.conf.xml b/conf/vanilla/autoload_configs/lua.conf.xml index 1eb594f0b5..f50307ea89 100644 --- a/conf/vanilla/autoload_configs/lua.conf.xml +++ b/conf/vanilla/autoload_configs/lua.conf.xml @@ -26,5 +26,7 @@ --> + + diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp index 642ad3fbf7..3d79dd8d0e 100644 --- a/src/mod/languages/mod_lua/mod_lua.cpp +++ b/src/mod/languages/mod_lua/mod_lua.cpp @@ -32,6 +32,7 @@ #include +#include SWITCH_BEGIN_EXTERN_C #include "lua.h" #include @@ -44,6 +45,7 @@ SWITCH_MODULE_DEFINITION_EX(mod_lua, mod_lua_load, mod_lua_shutdown, NULL, SMODF static struct { switch_memory_pool_t *pool; char *xml_handler; + switch_event_node_t *node; } globals; int luaopen_freeswitch(lua_State * L); @@ -287,10 +289,12 @@ static switch_xml_t lua_fetch(const char *section, } +static void lua_event_handler(switch_event_t *event); + static switch_status_t do_config(void) { const char *cf = "lua.conf"; - switch_xml_t cfg, xml, settings, param; + switch_xml_t cfg, xml, settings, param, hook; switch_stream_handle_t path_stream = {0}; switch_stream_handle_t cpath_stream = {0}; @@ -327,6 +331,31 @@ static switch_status_t do_config(void) path_stream.write_function(&path_stream, "%s", val); } } + + for (hook = switch_xml_child(settings, "hook"); hook; hook = hook->next) { + char *event = (char *) switch_xml_attr_soft(hook, "event"); + char *subclass = (char *) switch_xml_attr_soft(hook, "subclass"); + //char *script = strdup( (char *) switch_xml_attr_soft(hook, "script")); + char *script = (char *) switch_xml_attr_soft(hook, "script"); + switch_event_types_t evtype; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "hook params: '%s' | '%s' | '%s'\n", event, subclass, script); + + if (switch_name_event(event,&evtype) == SWITCH_STATUS_SUCCESS) { + if (!zstr(script)) { + if (switch_event_bind_removable(modname, evtype, !zstr(subclass) ? subclass : SWITCH_EVENT_SUBCLASS_ANY, + lua_event_handler, script, &globals.node) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "event handler for '%s' set to '%s'\n", switch_event_name(evtype), script); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set event handler: unsuccessful bind\n"); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set event handler: no script name\n", event); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set event handler: unknown event type '%s'\n", event); + } + } } if (cpath_stream.data_len) { @@ -405,6 +434,23 @@ int lua_thread(const char *text) return 0; } +static void lua_event_handler(switch_event_t *event) +{ + lua_State *L = lua_init(); + char *script = NULL; + + if (event->bind_user_data) { + script = strdup((char *)event->bind_user_data); + } + + mod_lua_conjure_event(L, event, "event", 1); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "lua event hook: execute '%s'\n", (char *)script); + lua_parse_and_execute(L, (char *)script); + lua_uninit(L); + + switch_safe_free(script); +} + SWITCH_STANDARD_APP(lua_function) { lua_State *L = lua_init(); @@ -645,6 +691,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown) { + switch_event_unbind(&globals.node); + return SWITCH_STATUS_SUCCESS; } From 24669125e4f1e77c053264a11f11f331eb7e7c78 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 10 Jul 2013 12:08:54 -0500 Subject: [PATCH 047/203] FS-5555 --resolve --- src/include/switch_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 99ff664868..97cdfcc5cc 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -604,12 +604,15 @@ static inline char *switch_sanitize_number(char *number) switch_assert(number); - if (!(strchr(p, '/') || strchr(p, ':') || strchr(p, '@'))) { + if (!(strchr(p, '/') || strchr(p, ':') || strchr(p, '@') || strchr(p, '%'))) { return number; } while ((q = strrchr(p, '@'))) *q = '\0'; + + while ((q = strrchr(p, '%'))) + *q = '\0'; for (i = 0; i < (int) strlen(warp); i++) { while (p && (q = strchr(p, warp[i]))) From db3c1abce00bf754fbf013b8273efdcbcaa4065d Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 10 Jul 2013 17:53:42 -0400 Subject: [PATCH 048/203] FS-4123 --resolve slightly modified patch applied --- .../mod_conference/mod_conference.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 0f41cb3912..8778e93f5d 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -7539,6 +7539,8 @@ SWITCH_STANDARD_APP(conference_function) /* if the conference exists, get the pointer to it */ if (!conference) { const char *max_members_str; + const char *endconf_grace_time_str; + const char *auto_record_str; /* couldn't find the conference, create one */ conference = conference_new(conf_name, xml_cfg, session, NULL); @@ -7558,11 +7560,19 @@ SWITCH_STANDARD_APP(conference_function) if (zstr(conference->moh_sound)) { conference->moh_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_moh_sound")); } + /* Set perpetual-sound from variable if not set */ if (zstr(conference->perpetual_sound)) { conference->perpetual_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_perpetual_sound")); } + /* Override auto-record profile parameter from variable */ + if (!zstr(auto_record_str = switch_channel_get_variable(channel, "conference_auto_record"))) { + conference->auto_record = switch_core_strdup(conference->pool, auto_record_str); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "conference_auto_record set from variable to %s\n", auto_record_str); + } + /* Set the minimum number of members (once you go above it you cannot go below it) */ conference->min = 1; @@ -7579,6 +7589,21 @@ SWITCH_STANDARD_APP(conference_function) } } + /* check for variable to override endconf_grace_time profile value */ + if (!zstr(endconf_grace_time_str = switch_channel_get_variable(channel, "conference_endconf_grace_time"))) { + uint32_t grace_time_val; + errno = 0; /* sanity first */ + grace_time_val = strtol(endconf_grace_time_str, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */ + if (errno == ERANGE || errno == EINVAL || (int32_t) grace_time_val < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "conference_endconf_grace_time variable %s is invalid, not setting a time limit\n", endconf_grace_time_str); + } else { + conference->endconf_grace_time = grace_time_val; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "conference endconf_grace_time set from variable to %d\n", grace_time_val); + } + } + /* Indicate the conference is dynamic */ switch_set_flag_locked(conference, CFLAG_DYNAMIC); From d9e5a55c55a9fc79663fb9f8cb105b2f16f2001d Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 10 Jul 2013 17:31:00 -0500 Subject: [PATCH 049/203] FS-5003 --resolve --- src/switch_ivr_bridge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index fc3240c742..71cf891e18 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -865,6 +865,8 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) { if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_continue_on_cancel"))) { switch_channel_set_state(channel, CS_EXECUTE); + } else if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_park_on_cancel"))) { + switch_ivr_park_session(session); } else if (!switch_channel_test_flag(channel, CF_TRANSFER)) { switch_channel_hangup(channel, SWITCH_CAUSE_ORIGINATOR_CANCEL); } From 0e2a590afa514b996417e3892b97c2fc89319f03 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Thu, 11 Jul 2013 01:15:16 +0200 Subject: [PATCH 050/203] mod_sofia: Add missing format string to switch_event_add_body() call Fixes GCC format string warning/error. Signed-off-by: Stefan Knoblich --- src/mod/endpoints/mod_sofia/sofia_presence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 3bff37b2ee..4c2f436f87 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -272,7 +272,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-To", to); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-From", from); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof ? prof : "NULL"); - switch_event_add_body(event, body); + switch_event_add_body(event, "%s", body); switch_event_fire(&event); } From e20fbadc12339d604da0cfa370180e9f2ef0b532 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Thu, 11 Jul 2013 03:12:25 +0200 Subject: [PATCH 051/203] mod_shout: Rework our_mpg123_new() to handle error cases correctly and to clean up the code Keeping parameter handling quirks for backwards compatibility reasons. Signed-off-by: Stefan Knoblich --- src/mod/formats/mod_shout/mod_shout.c | 61 ++++++++++++--------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index eb081a226f..0b64ba7e5b 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -60,52 +60,43 @@ static struct { mpg123_handle *our_mpg123_new(const char *decoder, int *error) { - mpg123_handle *mh; const char *arch = "auto"; + const char *err = NULL; + mpg123_handle *mh; int x64 = 0; int rc = 0; - const char *err = NULL; - if (*globals.decoder || globals.outscale || globals.vol) { - if (*globals.decoder) { - arch = globals.decoder; - } - if ((mh = mpg123_new(arch, &rc))) { - if (rc) { - err = mpg123_plain_strerror(rc); - } - if (globals.outscale) { - mpg123_param(mh, MPG123_OUTSCALE, globals.outscale, 0); - } - if (globals.vol) { - mpg123_volume(mh, globals.vol); - } - } + if (*globals.decoder) { + arch = globals.decoder; + } +#ifndef WIN32 + else if (sizeof(void *) == 4) { + arch = "i586"; } else { - -#ifdef WIN32 - x64++; + x64 = 1; + } #else - if (sizeof(void *) == 4) { - arch = "i586"; - } else { - x64++; - } + x64 = 1; #endif + mh = mpg123_new(arch, &rc); + if (!mh) { + err = mpg123_plain_strerror(rc); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating mpg123 handle! %s\n", switch_str_nil(err)); + return NULL; + } - if ((mh = mpg123_new(arch, &rc))) { - if (rc) { - err = mpg123_plain_strerror(rc); - } - if (x64) { - mpg123_param(mh, MPG123_OUTSCALE, 8192, 0); - } + /* NOTE: keeping the globals.decoder check here for behaviour backwards compat - stkn */ + if (*globals.decoder || globals.outscale || globals.vol) { + if (globals.outscale) { + mpg123_param(mh, MPG123_OUTSCALE, globals.outscale, 0); } + if (globals.vol) { + mpg123_volume(mh, globals.vol); + } + } else if (x64) { + mpg123_param(mh, MPG123_OUTSCALE, 8192, 0); } - if (err) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating mpg123 handle! %s\n", err); - } return mh; } From c67795fca244d5f5eb3b79cc1156dd98984ec1af Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 11 Jul 2013 15:06:15 +0000 Subject: [PATCH 052/203] Ignore .deb files from e.g. mk-build-deps --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 766adfb371..87492e50ea 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ *.xz *.bz2 *.tbz2 +*.deb *.swp aclocal.m4 autom4te.cache From bdbc93ac72adf9539678cea6556e87c89661e8a6 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 11 Jul 2013 15:06:30 +0000 Subject: [PATCH 053/203] Ignore test-driver files from autotools --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 87492e50ea..69f8cb476e 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ config.cache configure.lineno config.log config.status +test-driver core.* TAGS *.2010.log From bbbb44253a2abac742371f477591dac7fcfc11b2 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Thu, 11 Jul 2013 11:09:28 -0500 Subject: [PATCH 054/203] FS-5567 --resolve --- src/switch_xml.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/switch_xml.c b/src/switch_xml.c index c13e33bea4..076244939f 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1328,20 +1328,24 @@ static FILE *preprocess_exec(const char *cwd, const char *command, FILE *write_f } -static FILE *preprocess_glob(const char *cwd, const char *pattern, FILE *write_fd, int rlevel) +static FILE *preprocess_glob(const char *cwd, const char *pattern, FILE *write_fd, int rlevel, switch_bool_t ignore_nomatch) { char *full_path = NULL; char *dir_path = NULL, *e = NULL; glob_t glob_data; size_t n; + int globres; if (!switch_is_file_path(pattern)) { full_path = switch_mprintf("%s%s%s", cwd, SWITCH_PATH_SEPARATOR, pattern); pattern = full_path; } - if (glob(pattern, GLOB_NOCHECK, NULL, &glob_data) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error including %s\n", pattern); + globres = glob(pattern, ignore_nomatch ? GLOB_NOMATCH : GLOB_NOCHECK, NULL, &glob_data); + if ( globres != 0) { + if ( !ignore_nomatch || globres != GLOB_NOMATCH ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error including %s\n", pattern); + } goto end; } @@ -1496,7 +1500,9 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle } else if (!strcasecmp(tcmd, "exec-set")) { preprocess_exec_set(targ); } else if (!strcasecmp(tcmd, "include")) { - preprocess_glob(cwd, targ, write_fd, rlevel + 1); + preprocess_glob(cwd, targ, write_fd, rlevel + 1, SWITCH_FALSE); + } else if (!strcasecmp(tcmd, "include_silent")) { + preprocess_glob(cwd, targ, write_fd, rlevel + 1, SWITCH_TRUE); } else if (!strcasecmp(tcmd, "exec")) { preprocess_exec(cwd, targ, write_fd, rlevel + 1); } @@ -1556,7 +1562,9 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle } else if (!strcasecmp(cmd, "exec-set")) { preprocess_exec_set(arg); } else if (!strcasecmp(cmd, "include")) { - preprocess_glob(cwd, arg, write_fd, rlevel + 1); + preprocess_glob(cwd, arg, write_fd, rlevel + 1, SWITCH_FALSE); + } else if (!strcasecmp(cmd, "include_silent")) { + preprocess_glob(cwd, arg, write_fd, rlevel + 1, SWITCH_TRUE); } else if (!strcasecmp(cmd, "exec")) { preprocess_exec(cwd, arg, write_fd, rlevel + 1); } From 6c5e4e2119059478fe7ffad178b62d36756b7ce6 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Thu, 11 Jul 2013 12:05:49 -0500 Subject: [PATCH 055/203] Revert "FS-5567 --resolve" lets leave this one out til later This reverts commit bbbb44253a2abac742371f477591dac7fcfc11b2. --- src/switch_xml.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/switch_xml.c b/src/switch_xml.c index 076244939f..c13e33bea4 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1328,24 +1328,20 @@ static FILE *preprocess_exec(const char *cwd, const char *command, FILE *write_f } -static FILE *preprocess_glob(const char *cwd, const char *pattern, FILE *write_fd, int rlevel, switch_bool_t ignore_nomatch) +static FILE *preprocess_glob(const char *cwd, const char *pattern, FILE *write_fd, int rlevel) { char *full_path = NULL; char *dir_path = NULL, *e = NULL; glob_t glob_data; size_t n; - int globres; if (!switch_is_file_path(pattern)) { full_path = switch_mprintf("%s%s%s", cwd, SWITCH_PATH_SEPARATOR, pattern); pattern = full_path; } - globres = glob(pattern, ignore_nomatch ? GLOB_NOMATCH : GLOB_NOCHECK, NULL, &glob_data); - if ( globres != 0) { - if ( !ignore_nomatch || globres != GLOB_NOMATCH ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error including %s\n", pattern); - } + if (glob(pattern, GLOB_NOCHECK, NULL, &glob_data) != 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error including %s\n", pattern); goto end; } @@ -1500,9 +1496,7 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle } else if (!strcasecmp(tcmd, "exec-set")) { preprocess_exec_set(targ); } else if (!strcasecmp(tcmd, "include")) { - preprocess_glob(cwd, targ, write_fd, rlevel + 1, SWITCH_FALSE); - } else if (!strcasecmp(tcmd, "include_silent")) { - preprocess_glob(cwd, targ, write_fd, rlevel + 1, SWITCH_TRUE); + preprocess_glob(cwd, targ, write_fd, rlevel + 1); } else if (!strcasecmp(tcmd, "exec")) { preprocess_exec(cwd, targ, write_fd, rlevel + 1); } @@ -1562,9 +1556,7 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle } else if (!strcasecmp(cmd, "exec-set")) { preprocess_exec_set(arg); } else if (!strcasecmp(cmd, "include")) { - preprocess_glob(cwd, arg, write_fd, rlevel + 1, SWITCH_FALSE); - } else if (!strcasecmp(cmd, "include_silent")) { - preprocess_glob(cwd, arg, write_fd, rlevel + 1, SWITCH_TRUE); + preprocess_glob(cwd, arg, write_fd, rlevel + 1); } else if (!strcasecmp(cmd, "exec")) { preprocess_exec(cwd, arg, write_fd, rlevel + 1); } From 2eab94be7859008b529a078fd2da8844c533f8e1 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Thu, 11 Jul 2013 13:14:44 -0500 Subject: [PATCH 056/203] skinny: improve cleanup of devices during registration and unregistration, resolves some weird state issues when devices get disconnected --- src/mod/endpoints/mod_skinny/mod_skinny.c | 47 ++++++++++++++------ src/mod/endpoints/mod_skinny/mod_skinny.h | 1 + src/mod/endpoints/mod_skinny/skinny_server.c | 10 ++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 6845ab2070..790eb7836c 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1315,25 +1315,12 @@ static int flush_listener_callback(void *pArg, int argc, char **argv, char **col return 0; } -static void flush_listener(listener_t *listener) +void skinny_clean_listener_from_db(listener_t *listener) { - if(!zstr(listener->device_name)) { skinny_profile_t *profile = listener->profile; char *sql; - if ((sql = switch_mprintf( - "SELECT '%q', value, '%q', '%q', '%d' " - "FROM skinny_lines " - "WHERE device_name='%s' AND device_instance=%d " - "ORDER BY position", - profile->name, profile->domain, listener->device_name, listener->device_instance, - listener->device_name, listener->device_instance - ))) { - skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL); - switch_safe_free(sql); - } - if ((sql = switch_mprintf( "DELETE FROM skinny_devices " "WHERE name='%s' and instance=%d", @@ -1358,6 +1345,38 @@ static void flush_listener(listener_t *listener) switch_safe_free(sql); } + if ((sql = switch_mprintf( + "DELETE FROM skinny_active_lines " + "WHERE device_name='%s' and device_instance=%d", + listener->device_name, listener->device_instance))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + + } +} + +static void flush_listener(listener_t *listener) +{ + + if(!zstr(listener->device_name)) { + skinny_profile_t *profile = listener->profile; + char *sql; + + if ((sql = switch_mprintf( + "SELECT '%q', value, '%q', '%q', '%d' " + "FROM skinny_lines " + "WHERE device_name='%s' AND device_instance=%d " + "ORDER BY position", + profile->name, profile->domain, listener->device_name, listener->device_instance, + listener->device_name, listener->device_instance + ))) { + skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL); + switch_safe_free(sql); + } + + skinny_clean_listener_from_db(listener); + strcpy(listener->device_name, ""); } } diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index e0e3515da4..717bcd0378 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -271,6 +271,7 @@ switch_bool_t skinny_execute_sql_callback(skinny_profile_t *profile, uint8_t listener_is_ready(listener_t *listener); switch_status_t kill_listener(listener_t *listener, void *pvt); switch_status_t keepalive_listener(listener_t *listener, void *pvt); +void skinny_clean_listener_from_db(listener_t *listener); /*****************************************************************************/ /* CHANNEL FUNCTIONS */ diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index f4999f4d33..010e5b2379 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -964,8 +964,8 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r if (!zstr(listener->device_name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "A device is already registred on this listener.\n"); - send_register_reject(listener, "A device is already registred on this listener"); + "A device is already registered on this listener.\n"); + send_register_reject(listener, "A device is already registered on this listener"); return SWITCH_STATUS_FALSE; } @@ -993,6 +993,9 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r goto end; } + /* clean up all traces before adding to database */ + skinny_clean_listener_from_db(listener); + if ((sql = switch_mprintf( "INSERT INTO skinny_devices " "(name, user_id, instance, ip, type, max_streams, codec_string) " @@ -1951,6 +1954,9 @@ switch_status_t skinny_handle_unregister(listener_t *listener, skinny_message_t /* Close socket */ switch_clear_flag_locked(listener, LFLAG_RUNNING); + /* Clear this device from database and any active lines/etc. */ + skinny_clean_listener_from_db(listener); + return SWITCH_STATUS_SUCCESS; } From b5b23e830982e1057746da555152e3827cc70fcc Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 10:16:32 -0500 Subject: [PATCH 057/203] add files to spandsp ignore list --- libs/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/.gitignore b/libs/.gitignore index 093c5bdf10..9bf6e4bab6 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -558,11 +558,13 @@ opal /spandsp/src/Makefile.in /spandsp/src/make_math_fixed_tables /spandsp/src/make_modem_filter +/spandsp/src/make_t43_gray_code_tables /spandsp/src/math_fixed_tables.h /spandsp/src/msvc/All/BuildLog make_at_dictionary.htm /spandsp/src/msvc/All/BuildLog make_modem_filter.htm /spandsp/src/spandsp.h /spandsp/src/stamp-h1 +/spandsp/src/t43_gray_code_tables.h /spandsp/src/v17_v32bis_rx_fixed_rrc.h /spandsp/src/v17_v32bis_rx_floating_rrc.h /spandsp/src/v17_v32bis_tx_fixed_rrc.h From 079d65896bf981360a5477a09002bbdf272463cd Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 11:04:32 -0500 Subject: [PATCH 058/203] update device types list with more known types --- src/mod/endpoints/mod_skinny/skinny_tables.c | 61 ++++++++++++++++---- src/mod/endpoints/mod_skinny/skinny_tables.h | 2 +- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index 62c97aacf5..e896245955 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -115,18 +115,59 @@ SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1) {1, "Cisco 30 SP+"}, {2, "Cisco 12 SP+"}, {3, "Cisco 12 SP"}, - {4, "Cisco 12"}, + {4, "Cisco 12 S"}, {5, "Cisco 30 VIP"}, - {6, "Cisco IP Phone 7910"}, - {7, "Cisco IP Phone 7960"}, - {8, "Cisco IP Phone 7940"}, - {9, "Cisco IP Phone 7935"}, + {6, "Cisco 7910"}, + {7, "Cisco 7960"}, + {8, "Cisco 7940"}, + {9, "Cisco 7935"}, + {10, "Cisco VGC Phone"}, + {11, "Cisco VGC Virtual Phone"}, {12, "Cisco ATA 186"}, - {365, "Cisco IP Phone CP-7921G"}, - {404, "Cisco IP Phone CP-7962G"}, - {436, "Cisco IP Phone CP-7965G"}, - {30018, "Cisco IP Phone CP-7961G"}, - {30019, "Cisco IP Phone 7936"}, + {30, "Cisco Analog Access"}, + {40, "Cisco Digital Access"}, + {42, "Cisco Digital Access+"}, + {43, "Cisco Digital Access WS-X6608"}, + {47, "Cisco Analog Access WS-X6624"}, + {51, "Cisco Conference Bridge WS-X6608"}, + {61, "Cisco H.323 Phone"}, + {100, "Cisco Load Simulator"}, + {111, "Cisco Media Termination Point Hardware"}, + {115, "Cisco 7941"}, + {115, "Cisco CP-7941G"}, + {119, "Cisco 7971"}, + {120, "Cisco MGCP Station"}, + {121, "Cisco MGCP Trunk"}, + {124, "Cisco 7914 14-Button Line Expansion Module"}, + {302, "Cisco 7985"}, + {307, "Cisco 7911"}, + {308, "Cisco 7961G-GE"}, + {309, "Cisco 7941G-GE"}, + {335, "Cisco Motorola CN622"}, + {348, "Cisco 7931"}, + {358, "Cisco Unified Personal Communicator"}, + {365, "Cisco 7921"}, + {369, "Cisco 7906"}, + {375, "Cisco TelePresence"}, + {404, "Cisco 7962"}, + {412, "Cisco 3951"}, + {431, "Cisco 7937"}, + {434, "Cisco 7942"}, + {435, "Cisco 7945"}, + {436, "Cisco 7965"}, + {437, "Cisco 7975"}, + {446, "Cisco 3911"}, + {20000, "Cisco 7905"}, + {30002, "Cisco 7920"}, + {30006, "Cisco 7970"}, + {30007, "Cisco 7912"}, + {30008, "Cisco 7902"}, + {30018, "Cisco 7961"}, + {30019, "Cisco 7936"}, + {30027, "Cisco Analog Phone"}, + {30028, "Cisco ISDN BRI Phone"}, + {30032, "Cisco SCCP gateway virtual phone"}, + {30035, "Cisco IP-STE"}, {0, NULL} }; SKINNY_DECLARE_ID2STR(skinny_device_type2str, SKINNY_DEVICE_TYPES, "UnknownDeviceType") diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index a35e4be18d..b4b1e1bb66 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -92,7 +92,7 @@ const char *skinny_message_type2str(uint32_t id); uint32_t skinny_str2message_type(const char *str); #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES) -extern struct skinny_table SKINNY_DEVICE_TYPES[16]; +extern struct skinny_table SKINNY_DEVICE_TYPES[75]; const char *skinny_device_type2str(uint32_t id); uint32_t skinny_str2device_type(const char *str); #define SKINNY_PUSH_DEVICE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_DEVICE_TYPES) From fd31247ef9137cc8dc26b35819df64288877a855 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 11:05:18 -0500 Subject: [PATCH 059/203] skinny correct field name --- src/mod/endpoints/mod_skinny/skinny_protocol.c | 4 ++-- src/mod/endpoints/mod_skinny/skinny_protocol.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index eb472167ee..fa27bd1de3 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -155,8 +155,8 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) memcpy(request, mbuf, bytes); #ifdef SKINNY_MEGA_DEBUG switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Got request: length=%d,reserved=%x,type=%x\n", - request->length,request->reserved,request->type); + "Got request: length=%d,version=%x,type=%x\n", + request->length,request->version,request->type); #endif if(request->length < SKINNY_MESSAGE_FIELD_SIZE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index dcea93f891..d3b84ffabc 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -702,7 +702,7 @@ union skinny_data { #endif /* - * header is length+reserved + * header is length+version * body is type+data * length is length of body */ From 37e6195e3533e4165b8aa064c046512037e6c924 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 11:05:52 -0500 Subject: [PATCH 060/203] add a few additional skinny message types --- src/mod/endpoints/mod_skinny/skinny_protocol.h | 11 +++++++++++ src/mod/endpoints/mod_skinny/skinny_tables.c | 3 +++ src/mod/endpoints/mod_skinny/skinny_tables.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index d3b84ffabc..f4f89f4c6b 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -145,6 +145,8 @@ struct PACKED capabilities_res_message { struct station_capabilities caps[SWITCH_MAX_CODECS]; }; +#define SERVER_REQ_MESSAGE 0x0012 + /* AlarmMessage */ #define ALARM_MESSAGE 0x0020 struct PACKED alarm_message { @@ -207,6 +209,8 @@ struct PACKED data_message { #define DEVICE_TO_USER_DATA_RESPONSE_MESSAGE 0x002F /* See struct PACKED data_message */ +#define DEVICE_UPDATECAPABILITIES 0x0030 + /* ServiceUrlStatReqMessage */ #define SERVICE_URL_STAT_REQ_MESSAGE 0x0033 struct PACKED service_url_stat_req_message { @@ -442,6 +446,8 @@ struct PACKED register_reject_message { char error[33]; }; +#define SERVER_RESPONSE_MESSAGE 0x009E + /* ResetMessage */ #define RESET_MESSAGE 0x009F struct PACKED reset_message { @@ -723,6 +729,8 @@ typedef struct skinny_message skinny_message_t; /* SKINNY TYPES */ /*****************************************************************************/ enum skinny_codecs { + SKINNY_CODEC_NONE = 0, + SKINNY_CODEC_NONSTANDARD = 1, SKINNY_CODEC_ALAW_64K = 2, SKINNY_CODEC_ALAW_56K = 3, SKINNY_CODEC_ULAW_64K = 4, @@ -744,6 +752,8 @@ enum skinny_codecs { SKINNY_CODEC_WIDEBAND_256K = 25, SKINNY_CODEC_DATA_64K = 32, SKINNY_CODEC_DATA_56K = 33, + SKINNY_CODEC_G722_1_32K = 40, + SKINNY_CODEC_G722_1_24K = 41, SKINNY_CODEC_GSM = 80, SKINNY_CODEC_ACTIVEVOICE = 81, SKINNY_CODEC_G726_32K = 82, @@ -754,6 +764,7 @@ enum skinny_codecs { SKINNY_CODEC_H261 = 100, SKINNY_CODEC_H263 = 101, SKINNY_CODEC_VIDEO = 102, + SKINNY_CODEC_H264 = 103, SKINNY_CODEC_T120 = 105, SKINNY_CODEC_H224 = 106, SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257 diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index e896245955..7a7027b049 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -61,6 +61,7 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {REGISTER_AVAILABLE_LINES_MESSAGE, "RegisterAvailableLinesMessage"}, {DEVICE_TO_USER_DATA_MESSAGE, "DeviceToUserDataMessage"}, {DEVICE_TO_USER_DATA_RESPONSE_MESSAGE, "DeviceToUserDataResponseMessage"}, + {DEVICE_UPDATECAPABILITIES, "DeviceUpdateCapabilities"}, {SERVICE_URL_STAT_REQ_MESSAGE, "ServiceUrlStatReqMessage"}, {FEATURE_STAT_REQ_MESSAGE, "FeatureStatReqMessage"}, {DEVICE_TO_USER_DATA_VERSION1_MESSAGE, "DeviceToUserDataVersion1Message"}, @@ -84,7 +85,9 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {BUTTON_TEMPLATE_RES_MESSAGE, "ButtonTemplateResMessage"}, {VERSION_MESSAGE, "VersionMessage"}, {CAPABILITIES_REQ_MESSAGE, "CapabilitiesReqMessage"}, + {SERVER_REQ_MESSAGE, "Server Request Message"}, {REGISTER_REJECT_MESSAGE, "RegisterRejectMessage"}, + {SERVER_RESPONSE_MESSAGE, "ServerResponseMessage"}, {RESET_MESSAGE, "ResetMessage"}, {KEEP_ALIVE_ACK_MESSAGE, "KeepAliveAckMessage"}, {OPEN_RECEIVE_CHANNEL_MESSAGE, "OpenReceiveChannelMessage"}, diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index b4b1e1bb66..1e35a7d208 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -87,7 +87,7 @@ if (my_matches) {\ } -extern struct skinny_table SKINNY_MESSAGE_TYPES[72]; +extern struct skinny_table SKINNY_MESSAGE_TYPES[75]; const char *skinny_message_type2str(uint32_t id); uint32_t skinny_str2message_type(const char *str); #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES) From 5c9bb344abb5dae2f833033f73fcce9b670d2853 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 11:15:46 -0500 Subject: [PATCH 061/203] skinny typedef --- src/mod/endpoints/mod_skinny/skinny_protocol.c | 2 +- src/mod/endpoints/mod_skinny/skinny_protocol.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index fa27bd1de3..3e1748d6e2 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -37,7 +37,7 @@ /*****************************************************************************/ /* SKINNY FUNCTIONS */ /*****************************************************************************/ -char* skinny_codec2string(enum skinny_codecs skinnycodec) +char* skinny_codec2string(skinny_codecs skinnycodec) { switch (skinnycodec) { case SKINNY_CODEC_ALAW_64K: diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index f4f89f4c6b..5127b1b54b 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -728,7 +728,7 @@ typedef struct skinny_message skinny_message_t; /*****************************************************************************/ /* SKINNY TYPES */ /*****************************************************************************/ -enum skinny_codecs { +typedef enum { SKINNY_CODEC_NONE = 0, SKINNY_CODEC_NONSTANDARD = 1, SKINNY_CODEC_ALAW_64K = 2, @@ -768,9 +768,9 @@ enum skinny_codecs { SKINNY_CODEC_T120 = 105, SKINNY_CODEC_H224 = 106, SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257 -}; +} skinny_codecs; -char* skinny_codec2string(enum skinny_codecs skinnycodec); +char* skinny_codec2string(skinny_codecs skinnycodec); /*****************************************************************************/ /* SKINNY FUNCTIONS */ From f21d4a0fc06a44f0f2239fc5c6585257864bd07f Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 11:39:23 -0500 Subject: [PATCH 062/203] fixup and merge in FS-4027 enhancements for additional device support --- .../endpoints/mod_skinny/skinny_protocol.c | 20 ++ .../endpoints/mod_skinny/skinny_protocol.h | 253 ++++++++++++++---- src/mod/endpoints/mod_skinny/skinny_server.c | 79 +++++- 3 files changed, 306 insertions(+), 46 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 3e1748d6e2..677c703b39 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -623,6 +623,26 @@ switch_status_t perform_send_set_speaker_mode(listener_t *listener, return skinny_send_reply_quiet(listener, message); } +switch_status_t perform_send_srvreq_response(listener_t *listener, + const char *file, const char *func, int line, + char *ip, uint32_t port) +{ + skinny_message_t *message; + + message = switch_core_alloc(listener->pool, 12+sizeof(message->data.serv_res_mess)); + message->type = SERVER_RESPONSE_MESSAGE; + message->length = 4 + sizeof(message->data.serv_res_mess); + + message->data.serv_res_mess.serverListenPort[0] = port; + switch_inet_pton(AF_INET,ip, &message->data.serv_res_mess.serverIpAddr[0]); + switch_copy_string(message->data.serv_res_mess.server[0].serverName,ip,sizeof(message->data.serv_res_mess.server[0].serverName)); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Sending Server Request Response with IP (%s) and Port (%d)\n", ip, port); + + return skinny_send_reply(listener, message); +} + switch_status_t perform_send_start_media_transmission(listener_t *listener, const char *file, const char *func, int line, uint32_t conference_id, diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 5127b1b54b..9bdd584b69 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -36,6 +36,53 @@ /* mod_skinny.h should be loaded first */ #include "mod_skinny.h" +/*****************************************************************************/ +/* SKINNY TYPES */ +/*****************************************************************************/ +typedef enum { + SKINNY_CODEC_NONE = 0, + SKINNY_CODEC_NONSTANDARD = 1, + SKINNY_CODEC_ALAW_64K = 2, + SKINNY_CODEC_ALAW_56K = 3, + SKINNY_CODEC_ULAW_64K = 4, + SKINNY_CODEC_ULAW_56K = 5, + SKINNY_CODEC_G722_64K = 6, + SKINNY_CODEC_G722_56K = 7, + SKINNY_CODEC_G722_48K = 8, + SKINNY_CODEC_G723_1 = 9, + SKINNY_CODEC_G728 = 10, + SKINNY_CODEC_G729 = 11, + SKINNY_CODEC_G729A = 12, + SKINNY_CODEC_IS11172 = 13, + SKINNY_CODEC_IS13818 = 14, + SKINNY_CODEC_G729B = 15, + SKINNY_CODEC_G729AB = 16, + SKINNY_CODEC_GSM_FULL = 18, + SKINNY_CODEC_GSM_HALF = 19, + SKINNY_CODEC_GSM_EFULL = 20, + SKINNY_CODEC_WIDEBAND_256K = 25, + SKINNY_CODEC_DATA_64K = 32, + SKINNY_CODEC_DATA_56K = 33, + SKINNY_CODEC_G722_1_32K = 40, + SKINNY_CODEC_G722_1_24K = 41, + SKINNY_CODEC_GSM = 80, + SKINNY_CODEC_ACTIVEVOICE = 81, + SKINNY_CODEC_G726_32K = 82, + SKINNY_CODEC_G726_24K = 83, + SKINNY_CODEC_G726_16K = 84, + SKINNY_CODEC_G729B_BIS = 85, + SKINNY_CODEC_G729B_LOW = 86, + SKINNY_CODEC_H261 = 100, + SKINNY_CODEC_H263 = 101, + SKINNY_CODEC_VIDEO = 102, + SKINNY_CODEC_H264 = 103, + SKINNY_CODEC_T120 = 105, + SKINNY_CODEC_H224 = 106, + SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257 +} skinny_codecs; + +char* skinny_codec2string(skinny_codecs skinnycodec); + /*****************************************************************************/ /* SKINNY MESSAGE DATA */ /*****************************************************************************/ @@ -211,6 +258,145 @@ struct PACKED data_message { #define DEVICE_UPDATECAPABILITIES 0x0030 +#define MAX_CUSTOM_PICTURES 6 +#define MAX_LAYOUT_WITH_SAME_SERVICE 5 +#define MAX_SERVICE_TYPE 4 +#define SKINNY_MAX_CAPABILITIES 18 /*!< max capabilities allowed in Cap response message */ +#define SKINNY_MAX_VIDEO_CAPABILITIES 10 +#define SKINNY_MAX_DATA_CAPABILITIES 5 +#define MAX_LEVEL_PREFERENCE 4 + +/*! + * \brief Picture Format Structure + */ +typedef struct { + uint32_t customPictureFormatWidth; /*!< Picture Width */ + uint32_t customPictureFormatHeight; /*!< Picture Height */ + uint32_t customPictureFormatpixelAspectRatio; /*!< Picture Pixel Aspect Ratio */ + uint32_t customPictureFormatpixelclockConversionCode; /*!< Picture Pixel Conversion Code */ + uint32_t customPictureFormatpixelclockDivisor; /*!< Picture Pixel Divisor */ +} customPictureFormat_t; + + +/*! + * \brief Video Level Preference Structure + */ +typedef struct { + uint32_t transmitPreference; /*!< Transmit Preference */ + uint32_t format; /*!< Format / Codec */ + uint32_t maxBitRate; /*!< Maximum BitRate */ + uint32_t minBitRate; /*!< Minimum BitRate */ + uint32_t MPI; /*!< */ + uint32_t serviceNumber; /*!< Service Number */ +} levelPreference_t; /*!< Level Preference Structure */ + +/*! + * \brief Layout Config Structure (Update Capabilities Message Struct) + * \since 20080111 + */ +typedef struct { + uint32_t layout; /*!< Layout \todo what is layout? */ +} layoutConfig_t; /*!< Layout Config Structure */ + + +/*! + * \brief Service Resource Structure + */ +typedef struct { + uint32_t layoutCount; /*!< Layout Count */ + layoutConfig_t layout[MAX_LAYOUT_WITH_SAME_SERVICE]; /*!< Layout */ + uint32_t serviceNum; /*!< Service Number */ + uint32_t maxStreams; /*!< Maximum number of Streams */ + uint32_t maxConferences; /*!< Maximum number of Conferences */ + uint32_t activeConferenceOnRegistration; /*!< Active Conference On Registration */ +} serviceResource_t; + + + +/*! + * \brief Audio Capabilities Structure + */ +typedef struct { + skinny_codecs lel_payloadCapability; /*!< PayLoad Capability */ + uint32_t lel_maxFramesPerPacket; /*!< Maximum Number of Frames per IP Packet */ + uint32_t lel_unknown[2]; /*!< this are related to G.723 */ +} audioCap_t; + +/*! + * \brief Video Capabilities Structure + */ +typedef struct { + skinny_codecs lel_payloadCapability; /*!< PayLoad Capability */ + uint32_t lel_transmitOreceive; /*!< Transmit of Receive */ + uint32_t lel_levelPreferenceCount; /*!< Level of Preference Count */ + + levelPreference_t levelPreference[MAX_LEVEL_PREFERENCE]; /*!< Level Preference */ + +// uint32_t lel_codec_options[2]; /*!< Codec Options */ + + union { + struct { + uint32_t unknown1; + uint32_t unknown2; + } h263; + struct { + uint32_t profile; /*!< H264 profile */ + uint32_t level; /*!< H264 level */ + } h264; + } codec_options; + + /** + * Codec options contains data specific for every codec + * + * Here is a list of known parameters per codec + // H.261 + uint32_t lel_temporalSpatialTradeOffCapability; + uint32_t lel_stillImageTransmission; + + // H.263 + uint32_t lel_h263_capability_bitfield; + uint32_t lel_annexNandWFutureUse; + + // Video + uint32_t lel_modelNumber; + uint32_t lel_bandwidth; + */ +} videoCap_t; /*!< Video Capabilities Structure */ + +/*! + * \brief Data Capabilities Structure + */ +typedef struct { + uint32_t payloadCapability; /*!< Payload Capability */ + uint32_t transmitOrReceive; /*!< Transmit or Receive */ + uint32_t protocolDependentData; /*!< Protocol Dependent Data */ + uint32_t maxBitRate; /*!< Maximum BitRate */ +} dataCap_t; /*!< Data Capabilities Structure */ + + +struct PACKED update_capabilities_message { + uint32_t lel_audioCapCount; /*!< Audio Capability Count */ + uint32_t lel_videoCapCount; /*!< Video Capability Count */ + uint32_t lel_dataCapCount; /*!< Data Capability Count */ + uint32_t RTPPayloadFormat; /*!< RTP Payload Format */ + uint32_t customPictureFormatCount; /*!< Custom Picture Format Count */ + + customPictureFormat_t customPictureFormat[MAX_CUSTOM_PICTURES]; /*!< Custom Picture Format */ + + uint32_t activeStreamsOnRegistration; /*!< Active Streams on Registration */ + uint32_t maxBW; /*!< Max BW ?? */ + + uint32_t serviceResourceCount; /*!< Service Resource Count */ + serviceResource_t serviceResource[MAX_SERVICE_TYPE]; /*!< Service Resource */ + + audioCap_t audioCaps[SKINNY_MAX_CAPABILITIES]; /*!< Audio Capabilities */ + videoCap_t videoCaps[SKINNY_MAX_VIDEO_CAPABILITIES]; /*!< Video Capabilities */ + dataCap_t dataCaps[SKINNY_MAX_DATA_CAPABILITIES]; /*!< Data Capabilities */ + + uint32_t unknown; /*!< Unknown */ +}; + + /* ServiceUrlStatReqMessage */ #define SERVICE_URL_STAT_REQ_MESSAGE 0x0033 struct PACKED service_url_stat_req_message { @@ -447,6 +633,21 @@ struct PACKED register_reject_message { }; #define SERVER_RESPONSE_MESSAGE 0x009E +#define ServerMaxNameSize 48 +#define StationMaxServers 5 +/*! + * \brief Station Identifier Structure + */ +typedef struct { + char serverName[ServerMaxNameSize]; /*!< Server Name */ +} ServerIdentifier; + +struct PACKED server_response_message { + ServerIdentifier server[StationMaxServers]; /*!< Server Identifier */ + uint32_t serverListenPort[StationMaxServers]; /*!< Server is Listening on Port */ + uint32_t serverIpAddr[StationMaxServers]; /*!< Server IP Port */ +}; /*!< Server Result Message Structure */ + /* ResetMessage */ #define RESET_MESSAGE 0x009F @@ -676,6 +877,7 @@ union skinny_data { /* no data for CAPABILITIES_REQ_MESSAGE */ struct register_reject_message reg_rej; struct reset_message reset; + struct server_response_message serv_res_mess; /* no data for KEEP_ALIVE_ACK_MESSAGE */ struct open_receive_channel_message open_receive_channel; struct close_receive_channel_message close_receive_channel; @@ -696,6 +898,7 @@ union skinny_data { /* see field "extended_data" for USER_TO_DEVICE_DATA_VERSION1_MESSAGE */ struct dialed_phone_book_ack_message dialed_phone_book_ack; + struct update_capabilities_message upd_cap; struct data_message data; struct extended_data_message extended_data; @@ -725,52 +928,7 @@ struct PACKED skinny_message { typedef struct skinny_message skinny_message_t; -/*****************************************************************************/ -/* SKINNY TYPES */ -/*****************************************************************************/ -typedef enum { - SKINNY_CODEC_NONE = 0, - SKINNY_CODEC_NONSTANDARD = 1, - SKINNY_CODEC_ALAW_64K = 2, - SKINNY_CODEC_ALAW_56K = 3, - SKINNY_CODEC_ULAW_64K = 4, - SKINNY_CODEC_ULAW_56K = 5, - SKINNY_CODEC_G722_64K = 6, - SKINNY_CODEC_G722_56K = 7, - SKINNY_CODEC_G722_48K = 8, - SKINNY_CODEC_G723_1 = 9, - SKINNY_CODEC_G728 = 10, - SKINNY_CODEC_G729 = 11, - SKINNY_CODEC_G729A = 12, - SKINNY_CODEC_IS11172 = 13, - SKINNY_CODEC_IS13818 = 14, - SKINNY_CODEC_G729B = 15, - SKINNY_CODEC_G729AB = 16, - SKINNY_CODEC_GSM_FULL = 18, - SKINNY_CODEC_GSM_HALF = 19, - SKINNY_CODEC_GSM_EFULL = 20, - SKINNY_CODEC_WIDEBAND_256K = 25, - SKINNY_CODEC_DATA_64K = 32, - SKINNY_CODEC_DATA_56K = 33, - SKINNY_CODEC_G722_1_32K = 40, - SKINNY_CODEC_G722_1_24K = 41, - SKINNY_CODEC_GSM = 80, - SKINNY_CODEC_ACTIVEVOICE = 81, - SKINNY_CODEC_G726_32K = 82, - SKINNY_CODEC_G726_24K = 83, - SKINNY_CODEC_G726_16K = 84, - SKINNY_CODEC_G729B_BIS = 85, - SKINNY_CODEC_G729B_LOW = 86, - SKINNY_CODEC_H261 = 100, - SKINNY_CODEC_H263 = 101, - SKINNY_CODEC_VIDEO = 102, - SKINNY_CODEC_H264 = 103, - SKINNY_CODEC_T120 = 105, - SKINNY_CODEC_H224 = 106, - SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257 -} skinny_codecs; -char* skinny_codec2string(skinny_codecs skinnycodec); /*****************************************************************************/ /* SKINNY FUNCTIONS */ @@ -862,6 +1020,11 @@ switch_status_t perform_send_set_speaker_mode(listener_t *listener, uint32_t mode); #define send_set_speaker_mode(listener, ...) perform_send_set_speaker_mode(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) +switch_status_t perform_send_srvreq_response(listener_t *listener, + const char *file, const char *func, int line, + char *ip, uint32_t port); +#define send_srvreq_response(listener, ...) perform_send_srvreq_response(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + switch_status_t perform_send_start_media_transmission(listener_t *listener, const char *file, const char *func, int line, uint32_t conference_id, diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 010e5b2379..8a0c18ebd8 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -2183,6 +2183,79 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski return SWITCH_STATUS_SUCCESS; } +switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_message_t *request) +{ + char *sql; + skinny_profile_t *profile; + + uint32_t i = 0; + uint32_t n = 0; + char *codec_order[SWITCH_MAX_CODECS]; + char *codec_string; + + size_t string_len, string_pos, pos; + + switch_assert(listener->profile); + switch_assert(listener->device_name); + + profile = listener->profile; + + skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount)); + + n = request->data.upd_cap.lel_audioCapCount; + if (n > SWITCH_MAX_CODECS) { + n = SWITCH_MAX_CODECS; + } + string_len = -1; + + skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount) + n * sizeof(request->data.upd_cap.audioCaps[0])); + + for (i = 0; i < n; i++) { + char *codec = skinny_codec2string(request->data.upd_cap.audioCaps[i].lel_payloadCapability); + codec_order[i] = codec; + string_len += strlen(codec)+1; + } + i = 0; + pos = 0; + codec_string = switch_core_alloc(listener->pool, string_len+1); + for (string_pos = 0; string_pos < string_len; string_pos++) { + char *codec = codec_order[i]; + switch_assert(i < n); + if(pos == strlen(codec)) { + codec_string[string_pos] = ','; + i++; + pos = 0; + } else { + codec_string[string_pos] = codec[pos++]; + } + } + codec_string[string_len] = '\0'; + if ((sql = switch_mprintf( + "UPDATE skinny_devices SET codec_string='%s' WHERE name='%s'", + codec_string, + listener->device_name + ))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "Codecs %s supported.\n", codec_string); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t skinny_handle_server_req_message(listener_t *listener, skinny_message_t *request) +{ + skinny_profile_t *profile; + + profile = listener->profile; + + skinny_log_l(listener, SWITCH_LOG_INFO, "Received Server Request Message (length=%d).\n", request->length); + + send_srvreq_response(listener, profile->ip, profile->port); + return SWITCH_STATUS_SUCCESS; +} + switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t *request) { switch_event_t *event = NULL; @@ -2208,7 +2281,7 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); } - if(zstr(listener->device_name) && request->type != REGISTER_MESSAGE && request->type != ALARM_MESSAGE && request->type != XML_ALARM_MESSAGE) { + if(zstr(listener->device_name) && request->type != REGISTER_MESSAGE && request->type != ALARM_MESSAGE && request->type != XML_ALARM_MESSAGE && request->type != KEEP_ALIVE_MESSAGE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Device should send a register message first. Received %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); return SWITCH_STATUS_FALSE; @@ -2280,6 +2353,10 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re return skinny_handle_accessory_status_message(listener, request); case XML_ALARM_MESSAGE: return skinny_handle_xml_alarm(listener, request); + case DEVICE_UPDATECAPABILITIES: + return skinny_handle_updatecapabilities(listener, request); + case SERVER_REQ_MESSAGE: + return skinny_handle_server_req_message(listener, request); default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); From f4c37613abcbeba7c16ff7a4826339f49922681d Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 12 Jul 2013 11:50:03 -0500 Subject: [PATCH 063/203] FS-5555 improvement --resolve --- src/include/switch_utils.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 97cdfcc5cc..d91831cc87 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -595,31 +595,39 @@ switch_mutex_unlock(obj->flag_mutex); #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst)) +SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len); +SWITCH_DECLARE(char *) switch_url_decode(char *s); static inline char *switch_sanitize_number(char *number) { - char *p = number, *q; + char *p, *q; char warp[] = "/:"; int i; + char *val; switch_assert(number); - if (!(strchr(p, '/') || strchr(p, ':') || strchr(p, '@') || strchr(p, '%'))) { + p = strdup(number); + val = p; + switch_url_decode(val); + + if (!(strchr(val, '/') || strchr(val, ':') || strchr(val, '@') || strchr(val, '%'))) { return number; } - while ((q = strrchr(p, '@'))) + while ((q = strrchr(val, '@'))) *q = '\0'; - while ((q = strrchr(p, '%'))) + while ((q = strrchr(val, '%'))) *q = '\0'; for (i = 0; i < (int) strlen(warp); i++) { - while (p && (q = strchr(p, warp[i]))) - p = q + 1; + while (val && (q = strchr(val, warp[i]))) + val = q + 1; } + free(p); - return p; + return val; } static inline switch_bool_t switch_string_var_check(char *s, switch_bool_t disable) @@ -927,8 +935,6 @@ SWITCH_DECLARE(char *) switch_util_quote_shell_arg_pool(const char *string, swit #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) -SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len); -SWITCH_DECLARE(char *) switch_url_decode(char *s); SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *from, const char *headers, From 27f0744160f62b8478ad7dc783176ca77b65212b Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 12 Jul 2013 12:00:57 -0500 Subject: [PATCH 064/203] FS-4027 - improve adherence to code conventions --- .../endpoints/mod_skinny/skinny_protocol.h | 52 +++++++++---------- src/mod/endpoints/mod_skinny/skinny_server.c | 10 ++-- src/mod/endpoints/mod_skinny/skinny_tables.c | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 9bdd584b69..2fe1336aa6 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -256,7 +256,7 @@ struct PACKED data_message { #define DEVICE_TO_USER_DATA_RESPONSE_MESSAGE 0x002F /* See struct PACKED data_message */ -#define DEVICE_UPDATECAPABILITIES 0x0030 +#define UPDATE_CAPABILITIES_MESSAGE 0x0030 #define MAX_CUSTOM_PICTURES 6 #define MAX_LAYOUT_WITH_SAME_SERVICE 5 @@ -270,12 +270,12 @@ struct PACKED data_message { * \brief Picture Format Structure */ typedef struct { - uint32_t customPictureFormatWidth; /*!< Picture Width */ - uint32_t customPictureFormatHeight; /*!< Picture Height */ - uint32_t customPictureFormatpixelAspectRatio; /*!< Picture Pixel Aspect Ratio */ - uint32_t customPictureFormatpixelclockConversionCode; /*!< Picture Pixel Conversion Code */ - uint32_t customPictureFormatpixelclockDivisor; /*!< Picture Pixel Divisor */ -} customPictureFormat_t; + uint32_t custom_picture_format_width; /*!< Picture Width */ + uint32_t custom_picture_format_height; /*!< Picture Height */ + uint32_t custom_picture_format_pixelAspectRatio; /*!< Picture Pixel Aspect Ratio */ + uint32_t custom_picture_format_pixelclockConversionCode; /*!< Picture Pixel Conversion Code */ + uint32_t custom_picture_format_pixelclockDivisor; /*!< Picture Pixel Divisor */ +} custom_picture_format_t; /*! @@ -317,22 +317,22 @@ typedef struct { * \brief Audio Capabilities Structure */ typedef struct { - skinny_codecs lel_payloadCapability; /*!< PayLoad Capability */ - uint32_t lel_maxFramesPerPacket; /*!< Maximum Number of Frames per IP Packet */ - uint32_t lel_unknown[2]; /*!< this are related to G.723 */ + skinny_codecs payload_capability; /*!< PayLoad Capability */ + uint32_t maxFramesPerPacket; /*!< Maximum Number of Frames per IP Packet */ + uint32_t unknown[2]; /*!< this are related to G.723 */ } audioCap_t; /*! * \brief Video Capabilities Structure */ typedef struct { - skinny_codecs lel_payloadCapability; /*!< PayLoad Capability */ - uint32_t lel_transmitOreceive; /*!< Transmit of Receive */ - uint32_t lel_levelPreferenceCount; /*!< Level of Preference Count */ + skinny_codecs payload_capability; /*!< PayLoad Capability */ + uint32_t transmitOreceive; /*!< Transmit of Receive */ + uint32_t levelPreferenceCount; /*!< Level of Preference Count */ levelPreference_t levelPreference[MAX_LEVEL_PREFERENCE]; /*!< Level Preference */ -// uint32_t lel_codec_options[2]; /*!< Codec Options */ +// uint32_t codec_options[2]; /*!< Codec Options */ union { struct { @@ -350,16 +350,16 @@ typedef struct { * * Here is a list of known parameters per codec // H.261 - uint32_t lel_temporalSpatialTradeOffCapability; - uint32_t lel_stillImageTransmission; + uint32_t temporalSpatialTradeOffCapability; + uint32_t stillImageTransmission; // H.263 - uint32_t lel_h263_capability_bitfield; - uint32_t lel_annexNandWFutureUse; + uint32_t h263_capability_bitfield; + uint32_t annexNandWFutureUse; // Video - uint32_t lel_modelNumber; - uint32_t lel_bandwidth; + uint32_t modelNumber; + uint32_t bandwidth; */ } videoCap_t; /*!< Video Capabilities Structure */ @@ -367,7 +367,7 @@ typedef struct { * \brief Data Capabilities Structure */ typedef struct { - uint32_t payloadCapability; /*!< Payload Capability */ + uint32_t payload_capability; /*!< Payload Capability */ uint32_t transmitOrReceive; /*!< Transmit or Receive */ uint32_t protocolDependentData; /*!< Protocol Dependent Data */ uint32_t maxBitRate; /*!< Maximum BitRate */ @@ -375,13 +375,13 @@ typedef struct { struct PACKED update_capabilities_message { - uint32_t lel_audioCapCount; /*!< Audio Capability Count */ - uint32_t lel_videoCapCount; /*!< Video Capability Count */ - uint32_t lel_dataCapCount; /*!< Data Capability Count */ + uint32_t audio_cap_count; /*!< Audio Capability Count */ + uint32_t videoCapCount; /*!< Video Capability Count */ + uint32_t dataCapCount; /*!< Data Capability Count */ uint32_t RTPPayloadFormat; /*!< RTP Payload Format */ - uint32_t customPictureFormatCount; /*!< Custom Picture Format Count */ + uint32_t custom_picture_formatCount; /*!< Custom Picture Format Count */ - customPictureFormat_t customPictureFormat[MAX_CUSTOM_PICTURES]; /*!< Custom Picture Format */ + custom_picture_format_t custom_picture_format[MAX_CUSTOM_PICTURES]; /*!< Custom Picture Format */ uint32_t activeStreamsOnRegistration; /*!< Active Streams on Registration */ uint32_t maxBW; /*!< Max BW ?? */ diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 8a0c18ebd8..2573ba173c 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -2200,18 +2200,18 @@ switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_me profile = listener->profile; - skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount)); + skinny_check_data_length(request, sizeof(request->data.upd_cap.audio_cap_count)); - n = request->data.upd_cap.lel_audioCapCount; + n = request->data.upd_cap.audio_cap_count; if (n > SWITCH_MAX_CODECS) { n = SWITCH_MAX_CODECS; } string_len = -1; - skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount) + n * sizeof(request->data.upd_cap.audioCaps[0])); + skinny_check_data_length(request, sizeof(request->data.upd_cap.audio_cap_count) + n * sizeof(request->data.upd_cap.audioCaps[0])); for (i = 0; i < n; i++) { - char *codec = skinny_codec2string(request->data.upd_cap.audioCaps[i].lel_payloadCapability); + char *codec = skinny_codec2string(request->data.upd_cap.audioCaps[i].payload_capability); codec_order[i] = codec; string_len += strlen(codec)+1; } @@ -2353,7 +2353,7 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re return skinny_handle_accessory_status_message(listener, request); case XML_ALARM_MESSAGE: return skinny_handle_xml_alarm(listener, request); - case DEVICE_UPDATECAPABILITIES: + case UPDATE_CAPABILITIES_MESSAGE: return skinny_handle_updatecapabilities(listener, request); case SERVER_REQ_MESSAGE: return skinny_handle_server_req_message(listener, request); diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index 7a7027b049..9f04f8cd63 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -61,7 +61,7 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {REGISTER_AVAILABLE_LINES_MESSAGE, "RegisterAvailableLinesMessage"}, {DEVICE_TO_USER_DATA_MESSAGE, "DeviceToUserDataMessage"}, {DEVICE_TO_USER_DATA_RESPONSE_MESSAGE, "DeviceToUserDataResponseMessage"}, - {DEVICE_UPDATECAPABILITIES, "DeviceUpdateCapabilities"}, + {UPDATE_CAPABILITIES_MESSAGE, "DeviceUpdateCapabilities"}, {SERVICE_URL_STAT_REQ_MESSAGE, "ServiceUrlStatReqMessage"}, {FEATURE_STAT_REQ_MESSAGE, "FeatureStatReqMessage"}, {DEVICE_TO_USER_DATA_VERSION1_MESSAGE, "DeviceToUserDataVersion1Message"}, From 433fc6a9873b50670d260c8ed79ea652b59f73e5 Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 12 Jul 2013 13:03:28 -0500 Subject: [PATCH 065/203] REVERT FS-5555 --- src/include/switch_utils.h | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index d91831cc87..5deb8ee313 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -595,39 +595,28 @@ switch_mutex_unlock(obj->flag_mutex); #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst)) -SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len); -SWITCH_DECLARE(char *) switch_url_decode(char *s); static inline char *switch_sanitize_number(char *number) { - char *p, *q; + char *p = number, *q; char warp[] = "/:"; int i; - char *val; switch_assert(number); - p = strdup(number); - val = p; - switch_url_decode(val); - - if (!(strchr(val, '/') || strchr(val, ':') || strchr(val, '@') || strchr(val, '%'))) { + if (!(strchr(p, '/') || strchr(p, ':') || strchr(p, '@'))) { return number; } - while ((q = strrchr(val, '@'))) + while ((q = strrchr(p, '@'))) *q = '\0'; - while ((q = strrchr(val, '%'))) - *q = '\0'; - for (i = 0; i < (int) strlen(warp); i++) { - while (val && (q = strchr(val, warp[i]))) - val = q + 1; + while (p && (q = strchr(p, warp[i]))) + p = q + 1; } - free(p); - return val; + return p; } static inline switch_bool_t switch_string_var_check(char *s, switch_bool_t disable) @@ -935,6 +924,8 @@ SWITCH_DECLARE(char *) switch_util_quote_shell_arg_pool(const char *string, swit #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) +SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len); +SWITCH_DECLARE(char *) switch_url_decode(char *s); SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *from, const char *headers, From 30926251cb0bcbfb39cc304ae318567d6529ee90 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 12 Jul 2013 13:35:59 -0500 Subject: [PATCH 066/203] FS-5396 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 27066d924a..c4e67bdf0d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5043,6 +5043,24 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } } else { host++; + + if (!strchr(host, '.')) { + struct sockaddr_in sa; + struct hostent *he = gethostbyname(host); + char *ip, *tmp; + + if (he) { + memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr)); + ip = inet_ntoa(sa.sin_addr); + + tmp = switch_string_replace(dest, host, ip); + //host = switch_core_session_strdup(nsession, ip); + //dest = switch_core_session_strdup(nsession, tmp); + switch_channel_set_variable_printf(nchannel, "sip_route_uri", "sip:%s", tmp); + free(tmp); + } + } + tech_pvt->dest = switch_core_session_alloc(nsession, strlen(dest) + 5); tech_pvt->e_dest = switch_core_session_strdup(nsession, dest); switch_snprintf(tech_pvt->dest, strlen(dest) + 5, "sip:%s", dest); From 4336f4fc28a5e66203dac74e3349f1033b06d01e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 12 Jul 2013 13:54:50 -0500 Subject: [PATCH 067/203] use this and send {sip_gethostbyname=true} in the dial string to force this behaviour --- src/mod/endpoints/mod_sofia/mod_sofia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c4e67bdf0d..bdc1944725 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5044,7 +5044,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } else { host++; - if (!strchr(host, '.')) { + if (!strchr(host, '.') || switch_true(switch_event_get_header(var_event, "sip_gethostbyname"))) { struct sockaddr_in sa; struct hostent *he = gethostbyname(host); char *ip, *tmp; From 0505879846e18645f4edf3a515b8c5369f98f8b8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 12 Jul 2013 14:06:29 -0500 Subject: [PATCH 068/203] FS-5575 --resolve --- libs/esl/java/esl_wrap.cpp | 69 +++++- .../org/freeswitch/esl/ESLconnection.java | 14 +- libs/esl/java/org/freeswitch/esl/eslJNI.java | 8 +- libs/esl/lua/esl_wrap.cpp | 110 ++++++++- libs/esl/managed/ESLPINVOKE.cs | 12 +- libs/esl/managed/ESLconnection.cs | 12 +- libs/esl/managed/esl_wrap.cpp | 40 ++- libs/esl/perl/esl_wrap.cpp | 227 ++++++++++++++++-- libs/esl/php/esl_wrap.cpp | 126 +++++++++- libs/esl/python/esl_wrap.cpp | 172 ++++++++++++- libs/esl/ruby/esl_wrap.cpp | 153 +++++++++++- libs/esl/src/esl_oop.cpp | 14 ++ libs/esl/src/include/esl_oop.h | 2 + 13 files changed, 907 insertions(+), 52 deletions(-) diff --git a/libs/esl/java/esl_wrap.cpp b/libs/esl/java/esl_wrap.cpp index 0550231dde..c5c4fa60c2 100644 --- a/libs/esl/java/esl_wrap.cpp +++ b/libs/esl/java/esl_wrap.cpp @@ -634,7 +634,70 @@ SWIGEXPORT jstring JNICALL Java_org_freeswitch_esl_eslJNI_ESLevent_1nextHeader(J } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jstring jarg3, jstring jarg4) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = (int)jarg2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + *(ESLconnection **)&jresult = result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4); + return jresult; +} + + +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jstring jarg3) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = (int)jarg2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + *(ESLconnection **)&jresult = result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + return jresult; +} + + +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4) { jlong jresult = 0 ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -674,7 +737,7 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SW } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_13(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) { jlong jresult = 0 ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -707,7 +770,7 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SW } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jint jarg1) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_14(JNIEnv *jenv, jclass jcls, jint jarg1) { jlong jresult = 0 ; int arg1 ; ESLconnection *result = 0 ; diff --git a/libs/esl/java/org/freeswitch/esl/ESLconnection.java b/libs/esl/java/org/freeswitch/esl/ESLconnection.java index 588cefcc99..a45613473d 100644 --- a/libs/esl/java/org/freeswitch/esl/ESLconnection.java +++ b/libs/esl/java/org/freeswitch/esl/ESLconnection.java @@ -33,16 +33,24 @@ public class ESLconnection { swigCPtr = 0; } - public ESLconnection(String host, String port, String user, String password) { + public ESLconnection(String host, int port, String user, String password) { this(eslJNI.new_ESLconnection__SWIG_0(host, port, user, password), true); } - public ESLconnection(String host, String port, String password) { + public ESLconnection(String host, int port, String password) { this(eslJNI.new_ESLconnection__SWIG_1(host, port, password), true); } + public ESLconnection(String host, String port, String user, String password) { + this(eslJNI.new_ESLconnection__SWIG_2(host, port, user, password), true); + } + + public ESLconnection(String host, String port, String password) { + this(eslJNI.new_ESLconnection__SWIG_3(host, port, password), true); + } + public ESLconnection(int socket) { - this(eslJNI.new_ESLconnection__SWIG_2(socket), true); + this(eslJNI.new_ESLconnection__SWIG_4(socket), true); } public int socketDescriptor() { diff --git a/libs/esl/java/org/freeswitch/esl/eslJNI.java b/libs/esl/java/org/freeswitch/esl/eslJNI.java index ff3744e9df..e7da6f5fdf 100644 --- a/libs/esl/java/org/freeswitch/esl/eslJNI.java +++ b/libs/esl/java/org/freeswitch/esl/eslJNI.java @@ -31,9 +31,11 @@ class eslJNI { public final static native boolean ESLevent_delHeader(long jarg1, ESLevent jarg1_, String jarg2); public final static native String ESLevent_firstHeader(long jarg1, ESLevent jarg1_); public final static native String ESLevent_nextHeader(long jarg1, ESLevent jarg1_); - public final static native long new_ESLconnection__SWIG_0(String jarg1, String jarg2, String jarg3, String jarg4); - public final static native long new_ESLconnection__SWIG_1(String jarg1, String jarg2, String jarg3); - public final static native long new_ESLconnection__SWIG_2(int jarg1); + public final static native long new_ESLconnection__SWIG_0(String jarg1, int jarg2, String jarg3, String jarg4); + public final static native long new_ESLconnection__SWIG_1(String jarg1, int jarg2, String jarg3); + public final static native long new_ESLconnection__SWIG_2(String jarg1, String jarg2, String jarg3, String jarg4); + public final static native long new_ESLconnection__SWIG_3(String jarg1, String jarg2, String jarg3); + public final static native long new_ESLconnection__SWIG_4(int jarg1); public final static native void delete_ESLconnection(long jarg1); public final static native int ESLconnection_socketDescriptor(long jarg1, ESLconnection jarg1_); public final static native int ESLconnection_connected(long jarg1, ESLconnection jarg1_); diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index 9420f853bb..9dac86544d 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -2231,6 +2231,63 @@ static const char *swig_ESLevent_base_names[] = {0}; static swig_lua_class _wrap_class_ESLevent = { "ESLevent", &SWIGTYPE_p_ESLevent,_wrap_new_ESLevent, swig_delete_ESLevent, swig_ESLevent_methods, swig_ESLevent_attributes, swig_ESLevent_bases, swig_ESLevent_base_names }; static int _wrap_new_ESLconnection__SWIG_0(lua_State* L) { + int SWIG_arg = -1; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + SWIG_check_num_args("ESLconnection",4,4) + if(!lua_isstring(L,1)) SWIG_fail_arg("ESLconnection",1,"char const *"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("ESLconnection",2,"int const"); + if(!lua_isstring(L,3)) SWIG_fail_arg("ESLconnection",3,"char const *"); + if(!lua_isstring(L,4)) SWIG_fail_arg("ESLconnection",4,"char const *"); + arg1 = (char *)lua_tostring(L, 1); + arg2 = (int const)lua_tonumber(L, 2); + arg3 = (char *)lua_tostring(L, 3); + arg4 = (char *)lua_tostring(L, 4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + SWIG_arg=0; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLconnection,1); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) { + int SWIG_arg = -1; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + SWIG_check_num_args("ESLconnection",3,3) + if(!lua_isstring(L,1)) SWIG_fail_arg("ESLconnection",1,"char const *"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("ESLconnection",2,"int const"); + if(!lua_isstring(L,3)) SWIG_fail_arg("ESLconnection",3,"char const *"); + arg1 = (char *)lua_tostring(L, 1); + arg2 = (int const)lua_tonumber(L, 2); + arg3 = (char *)lua_tostring(L, 3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + SWIG_arg=0; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLconnection,1); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_ESLconnection__SWIG_2(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2260,7 +2317,7 @@ fail: } -static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) { +static int _wrap_new_ESLconnection__SWIG_3(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2287,7 +2344,7 @@ fail: } -static int _wrap_new_ESLconnection__SWIG_2(lua_State* L) { +static int _wrap_new_ESLconnection__SWIG_4(lua_State* L) { int SWIG_arg = -1; int arg1 ; ESLconnection *result = 0 ; @@ -2321,7 +2378,26 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isnumber(L,argv[0]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_2(L); + return _wrap_new_ESLconnection__SWIG_4(L); + } + } + if (argc == 3) { + int _v; + { + _v = lua_isstring(L,argv[0]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[1]); + } + if (_v) { + { + _v = lua_isstring(L,argv[2]); + } + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(L); + } + } } } if (argc == 3) { @@ -2338,7 +2414,31 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isstring(L,argv[2]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_1(L); + return _wrap_new_ESLconnection__SWIG_3(L); + } + } + } + } + if (argc == 4) { + int _v; + { + _v = lua_isstring(L,argv[0]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[1]); + } + if (_v) { + { + _v = lua_isstring(L,argv[2]); + } + if (_v) { + { + _v = lua_isstring(L,argv[3]); + } + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(L); + } } } } @@ -2361,7 +2461,7 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isstring(L,argv[3]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_0(L); + return _wrap_new_ESLconnection__SWIG_2(L); } } } diff --git a/libs/esl/managed/ESLPINVOKE.cs b/libs/esl/managed/ESLPINVOKE.cs index 5ada2c148d..749ebeabfe 100644 --- a/libs/esl/managed/ESLPINVOKE.cs +++ b/libs/esl/managed/ESLPINVOKE.cs @@ -251,13 +251,19 @@ class ESLPINVOKE { public static extern string ESLevent_NextHeader(HandleRef jarg1); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_0")] - public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, string jarg2, string jarg3, string jarg4); + public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, int jarg2, string jarg3, string jarg4); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_1")] - public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, string jarg2, string jarg3); + public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, int jarg2, string jarg3); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_2")] - public static extern IntPtr new_ESLconnection__SWIG_2(int jarg1); + public static extern IntPtr new_ESLconnection__SWIG_2(string jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_3")] + public static extern IntPtr new_ESLconnection__SWIG_3(string jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_4")] + public static extern IntPtr new_ESLconnection__SWIG_4(int jarg1); [DllImport("ESL", EntryPoint="CSharp_delete_ESLconnection")] public static extern void delete_ESLconnection(HandleRef jarg1); diff --git a/libs/esl/managed/ESLconnection.cs b/libs/esl/managed/ESLconnection.cs index 2d1e6d4dc3..82efb907ed 100644 --- a/libs/esl/managed/ESLconnection.cs +++ b/libs/esl/managed/ESLconnection.cs @@ -38,13 +38,19 @@ public class ESLconnection : IDisposable { } } - public ESLconnection(string host, string port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, user, password), true) { + public ESLconnection(string host, int port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, user, password), true) { } - public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(host, port, password), true) { + public ESLconnection(string host, int port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(host, port, password), true) { } - public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_2(socket), true) { + public ESLconnection(string host, string port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_2(host, port, user, password), true) { + } + + public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_3(host, port, password), true) { + } + + public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_4(socket), true) { } public int SocketDescriptor() { diff --git a/libs/esl/managed/esl_wrap.cpp b/libs/esl/managed/esl_wrap.cpp index 65da98a15a..010ece83e2 100644 --- a/libs/esl/managed/esl_wrap.cpp +++ b/libs/esl/managed/esl_wrap.cpp @@ -576,7 +576,41 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_NextHeader(void * jarg1) { } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, char * jarg2, char * jarg3, char * jarg4) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, int jarg2, char * jarg3, char * jarg4) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, int jarg2, char * jarg3) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(char * jarg1, char * jarg2, char * jarg3, char * jarg4) { void * jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -594,7 +628,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, cha } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, char * jarg2, char * jarg3) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_3(char * jarg1, char * jarg2, char * jarg3) { void * jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -610,7 +644,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, cha } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(int jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_4(int jarg1) { void * jresult ; int arg1 ; ESLconnection *result = 0 ; diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index 832289f156..e2b7eec88c 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -2673,6 +2673,117 @@ XS(_wrap_ESLevent_nextHeader) { XS(_wrap_new_ESLconnection__SWIG_0) { + { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: new_ESLconnection(host,port,user,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_1) { + { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: new_ESLconnection(host,port,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_2) { { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2734,7 +2845,7 @@ XS(_wrap_new_ESLconnection__SWIG_0) { } -XS(_wrap_new_ESLconnection__SWIG_1) { +XS(_wrap_new_ESLconnection__SWIG_3) { { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2785,7 +2896,7 @@ XS(_wrap_new_ESLconnection__SWIG_1) { } -XS(_wrap_new_ESLconnection__SWIG_2) { +XS(_wrap_new_ESLconnection__SWIG_4) { { int arg1 ; ESLconnection *result = 0 ; @@ -2855,8 +2966,10 @@ XS(_wrap_new_ESLconnection) { _rankm += _pi; _pi *= SWIG_MAXCASTRANK; { - int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); - _v = SWIG_CheckState(res); + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } } if (!_v) goto check_2; _ranki += _v*_pi; @@ -2877,7 +2990,7 @@ XS(_wrap_new_ESLconnection) { } check_2: - if (items == 4) { + if (items == 3) { SWIG_TypeRank _ranki = 0; SWIG_TypeRank _rankm = 0; SWIG_TypeRank _pi = 1; @@ -2906,14 +3019,6 @@ XS(_wrap_new_ESLconnection) { _ranki += _v*_pi; _rankm += _pi; _pi *= SWIG_MAXCASTRANK; - { - int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); - _v = SWIG_CheckState(res); - } - if (!_v) goto check_3; - _ranki += _v*_pi; - _rankm += _pi; - _pi *= SWIG_MAXCASTRANK; if (!_index || (_ranki < _rank)) { _rank = _ranki; _index = 3; if (_rank == _rankm) goto dispatch; @@ -2921,14 +3026,108 @@ XS(_wrap_new_ESLconnection) { } check_3: + if (items == 4) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 4; + if (_rank == _rankm) goto dispatch; + } + } + check_4: + + if (items == 4) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 5; + if (_rank == _rankm) goto dispatch; + } + } + check_5: + dispatch: switch(_index) { case 1: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return; + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_4); return; case 2: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_1); return; case 3: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_3); return; + case 4: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_0); return; + case 5: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return; } } diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index b5fd7a7d52..8c91f25452 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -1796,6 +1796,93 @@ fail: ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + zval **args[4]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_array_ex(4, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG@*/; + + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + zval **args[3]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -1842,7 +1929,7 @@ fail: } -ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_3) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -1882,7 +1969,7 @@ fail: } -ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_4) { int arg1 ; ESLconnection *result = 0 ; zval **args[1]; @@ -1918,7 +2005,20 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { int _v; _v = (Z_TYPE_PP(argv[0]) == IS_LONG); if (_v) { - return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_4(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + if (argc == 3) { + int _v; + _v = (Z_TYPE_PP(argv[0]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG); + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_STRING); + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } } } if (argc == 3) { @@ -1929,7 +2029,23 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[2]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_3(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + if (argc == 4) { + int _v; + _v = (Z_TYPE_PP(argv[0]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG); + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[3]) == IS_STRING); + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } } } } @@ -1944,7 +2060,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[3]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); } } } diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index 35d600e0b0..b12f21cab0 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -3786,6 +3786,124 @@ SWIGINTERN PyObject *ESLevent_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObj } SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (!PyArg_ParseTuple(args,(char *)"OOOO:new_ESLconnection",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_PYTHON_THREAD_END_BLOCK; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (!PyArg_ParseTuple(args,(char *)"OOO:new_ESLconnection",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_PYTHON_THREAD_END_BLOCK; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -3853,7 +3971,7 @@ fail: } -SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -3909,7 +4027,7 @@ fail: } -SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; ESLconnection *result = 0 ; @@ -3957,7 +4075,26 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { } if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_2(self, args); + return _wrap_new_ESLconnection__SWIG_4(self, args); + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + SWIG_PYTHON_THREAD_END_BLOCK; + return _wrap_new_ESLconnection__SWIG_1(self, args); + } + } } } if (argc == 3) { @@ -3972,7 +4109,30 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_1(self, args); + return _wrap_new_ESLconnection__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + SWIG_PYTHON_THREAD_END_BLOCK; + return _wrap_new_ESLconnection__SWIG_0(self, args); + } } } } @@ -3992,7 +4152,7 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_0(self, args); + return _wrap_new_ESLconnection__SWIG_2(self, args); } } } @@ -4003,6 +4163,8 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_ESLconnection'.\n" " Possible C/C++ prototypes are:\n" + " ESLconnection(char const *,int const,char const *,char const *)\n" + " ESLconnection(char const *,int const,char const *)\n" " ESLconnection(char const *,char const *,char const *,char const *)\n" " ESLconnection(char const *,char const *,char const *)\n" " ESLconnection(int)\n"); diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 223ba3ea34..2d7e906402 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -2745,6 +2745,107 @@ swig_class cESLconnection; SWIGINTERN VALUE _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","ESLconnection", 1, argv[0] )); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","ESLconnection", 2, argv[1] )); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(argv[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","ESLconnection", 4, argv[3] )); + } + arg4 = reinterpret_cast< char * >(buf4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4);DATA_PTR(self) = result; + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + + if ((argc < 3) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","ESLconnection", 1, argv[0] )); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","ESLconnection", 2, argv[1] )); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3);DATA_PTR(self) = result; + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -2803,7 +2904,7 @@ fail: SWIGINTERN VALUE -_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { +_wrap_new_ESLconnection__SWIG_3(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -2868,7 +2969,7 @@ _wrap_ESLconnection_allocate(VALUE self) { SWIGINTERN VALUE -_wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { +_wrap_new_ESLconnection__SWIG_4(int argc, VALUE *argv, VALUE self) { int arg1 ; ESLconnection *result = 0 ; int val1 ; @@ -2907,7 +3008,25 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_new_ESLconnection__SWIG_2(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_4(nargs, args, self); + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(nargs, args, self); + } + } } } if (argc == 3) { @@ -2921,7 +3040,29 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_ESLconnection__SWIG_1(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_3(nargs, args, self); + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(nargs, args, self); + } } } } @@ -2940,7 +3081,7 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_ESLconnection__SWIG_0(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_2(nargs, args, self); } } } @@ -2949,6 +3090,8 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 4, "ESLconnection.new", + " ESLconnection.new(char const *host, int const port, char const *user, char const *password)\n" + " ESLconnection.new(char const *host, int const port, char const *password)\n" " ESLconnection.new(char const *host, char const *port, char const *user, char const *password)\n" " ESLconnection.new(char const *host, char const *port, char const *password)\n" " ESLconnection.new(int socket)\n"); diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index 3fa4dcce56..9c202f2160 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -9,6 +9,20 @@ void eslSetLogLevel(int level) esl_global_set_default_logger(level); } +ESLconnection::ESLconnection(const char *host, const int port, const char *password) +{ + connection_construct_common(); + + esl_connect(&handle, host, port, NULL, password); +} + +ESLconnection::ESLconnection(const char *host, const int port, const char *user, const char *password) +{ + connection_construct_common(); + + esl_connect(&handle, host, port, user, password); +} + ESLconnection::ESLconnection(const char *host, const char *port, const char *password) { connection_construct_common(); diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 450b047afc..93ce487965 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -74,6 +74,8 @@ class ESLconnection { private: esl_handle_t handle; public: + ESLconnection(const char *host, const int port, const char *user, const char *password); + ESLconnection(const char *host, const int port, const char *password); ESLconnection(const char *host, const char *port, const char *user, const char *password); ESLconnection(const char *host, const char *port, const char *password); ESLconnection(int socket); From 823c2a81dda156f419a6f21a78ebc6c4b0ee665f Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Sat, 13 Jul 2013 11:57:19 -0500 Subject: [PATCH 069/203] FS-5598 --resolve --- libs/win32/apr/libapr.2010.vcxproj | 4 ++-- libs/win32/apr/libapr.2012.vcxproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/win32/apr/libapr.2010.vcxproj b/libs/win32/apr/libapr.2010.vcxproj index 5c6b686ee0..1bce164a1d 100644 --- a/libs/win32/apr/libapr.2010.vcxproj +++ b/libs/win32/apr/libapr.2010.vcxproj @@ -112,7 +112,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / /EHsc %(AdditionalOptions) Disabled ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - _DEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + _DEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 true @@ -181,7 +181,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MaxSpeed OnlyExplicitInline ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - NDEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + NDEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDLL true diff --git a/libs/win32/apr/libapr.2012.vcxproj b/libs/win32/apr/libapr.2012.vcxproj index c491751b00..39cc98d863 100644 --- a/libs/win32/apr/libapr.2012.vcxproj +++ b/libs/win32/apr/libapr.2012.vcxproj @@ -116,7 +116,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / /EHsc %(AdditionalOptions) Disabled ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - _DEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + _DEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 true @@ -185,7 +185,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MaxSpeed OnlyExplicitInline ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - NDEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + NDEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDLL true From f90e828bd55c6230e966d03387343c223a3b6b74 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sun, 14 Jul 2013 10:34:35 +0800 Subject: [PATCH 070/203] FS-2809 --resolved --- src/mod/say/mod_say_zh/mod_say_zh.c | 98 ++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/src/mod/say/mod_say_zh/mod_say_zh.c b/src/mod/say/mod_say_zh/mod_say_zh.c index 7dab05e57c..87ab0042b8 100644 --- a/src/mod/say/mod_say_zh/mod_say_zh.c +++ b/src/mod/say/mod_say_zh/mod_say_zh.c @@ -40,7 +40,7 @@ * Anthony Minessale II * PeteDao * Steve Underwood 0.0.1 - * + * Seven Du * * mod_say_zh.c -- Say for Mandarin, Cantonese, and probably any other Chinese * dialect. @@ -430,6 +430,58 @@ static switch_status_t zh_say_money(switch_core_session_t *session, char *tosay, return SWITCH_STATUS_SUCCESS; } +static switch_status_t zh_CN_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) +{ + char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */ + char dbuf[16] = ""; /* enough for digits/x.wav */ + char *yuan = NULL; + char *rest = NULL; + int i; + + if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); + return SWITCH_STATUS_GENERR; + } + + yuan = sbuf; + + if ((rest = strchr(sbuf, '.'))) { + *rest++ = '\0'; + } + + /* If positive sign - skip over" */ + if (sbuf[0] == '+') { + yuan++; + } + + /* If negative say "negative" */ + if (sbuf[0] == '-') { + say_file("currency/negative.wav"); + yuan++; + } + + /* Say dollar amount */ + zh_say_general_count(session, yuan, say_args, args); + say_file("currency/yuan.wav"); + + if (!rest) return SWITCH_STATUS_SUCCESS; + + /* Say cents */ + for (i=0; *rest; i++, rest++) { + sprintf(dbuf, "digits/%c.wav", *rest); + say_file(dbuf); + if (i == 0) { + say_file("currency/jiao.wav"); + } else if (i == 1) { + say_file("currency/fen.wav"); + } else if (i == 2) { + say_file("currency/li.wav"); + } /* else just say the rest of digits */ + } + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { switch_say_callback_t say_cb = NULL; @@ -469,15 +521,59 @@ static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switc return SWITCH_STATUS_FALSE; } +static switch_status_t zh_CN_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) +{ + switch_say_callback_t say_cb = NULL; + + switch (say_args->type) { + case SST_NUMBER: + case SST_ITEMS: + case SST_PERSONS: + case SST_MESSAGES: + say_cb = zh_say_general_count; + break; + case SST_TIME_MEASUREMENT: + case SST_CURRENT_DATE: + case SST_CURRENT_TIME: + case SST_CURRENT_DATE_TIME: + say_cb = zh_say_time; + break; + case SST_IP_ADDRESS: + return switch_ivr_say_ip(session, tosay, zh_say_general_count, say_args, args); + break; + case SST_NAME_SPELLED: + case SST_NAME_PHONETIC: + return switch_ivr_say_spell(session, tosay, say_args, args); + break; + case SST_CURRENCY: + say_cb = zh_CN_say_money; + break; + default: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type); + break; + } + + if (say_cb) { + return say_cb(session, tosay, say_args, args); + } + + return SWITCH_STATUS_FALSE; +} + SWITCH_MODULE_LOAD_FUNCTION(mod_say_zh_load) { switch_say_interface_t *say_interface; + switch_say_interface_t *say_zh_CN_interface; /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); say_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SAY_INTERFACE); say_interface->interface_name = "zh"; say_interface->say_function = zh_say; + say_zh_CN_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SAY_INTERFACE); + say_zh_CN_interface->interface_name = "zh_CN"; + say_zh_CN_interface->say_function = zh_CN_say; + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } From 59616956ca5a5ff5c4fc820e381ffe2c484aa881 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Mon, 15 Jul 2013 15:19:18 -0500 Subject: [PATCH 071/203] skinny: improve hangup handling --- src/mod/endpoints/mod_skinny/mod_skinny.c | 17 ++++++++++++++--- src/mod/endpoints/mod_skinny/mod_skinny.h | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 790eb7836c..407aa65499 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -848,11 +848,22 @@ int channel_on_hangup_callback(void *pArg, int argc, char **argv, char **columnN skinny_line_set_state(listener, line_instance, call_id, SKINNY_ON_HOOK); send_select_soft_keys(listener, line_instance, call_id, SKINNY_KEY_SET_ON_HOOK, 0xffff); send_define_current_time_date(listener); - if((call_state == SKINNY_PROCEED) || (call_state == SKINNY_RING_OUT) || (call_state == SKINNY_CONNECTED)) { /* calling parties */ + + skinny_log_ls(listener, helper->tech_pvt->session, SWITCH_LOG_DEBUG, + "channel_on_hangup_callback - cause=%s [%d], call_state = %s [%d]\n", + switch_channel_cause2str(helper->cause), helper->cause, + skinny_call_state2str(call_state), call_state); + + if ( call_state == SKINNY_RING_OUT && helper->cause == SWITCH_CAUSE_USER_BUSY ) + { + // don't hang up speaker here + } + else if((call_state == SKINNY_PROCEED) || (call_state == SKINNY_RING_OUT) || (call_state == SKINNY_CONNECTED)) { /* calling parties */ // This is NOT correct, but results in slightly better behavior than before // leaving note here to revisit. - //send_set_speaker_mode(listener, SKINNY_SPEAKER_OFF); + /* re-enabling for testing to bring back bad behavior */ + send_set_speaker_mode(listener, SKINNY_SPEAKER_OFF); } send_set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, call_id); } @@ -869,7 +880,7 @@ switch_status_t channel_on_hangup(switch_core_session_t *session) switch_clear_flag_locked(tech_pvt, TFLAG_IO); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP [%s]\n", + skinny_log_s(session, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP [%s]\n", switch_channel_get_name(channel), switch_channel_cause2str(cause)); helper.tech_pvt= tech_pvt; diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 717bcd0378..76ca8017ac 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -61,6 +61,10 @@ "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ listener->remote_port) +#define skinny_log_s(session, level, _fmt, ...) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, \ + _fmt, __VA_ARGS__) + + /*****************************************************************************/ /* MODULE TYPES */ /*****************************************************************************/ From 9ef232a4bb5d2656905cb13307ce0b06d7292c28 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 15 Jul 2013 16:57:55 -0500 Subject: [PATCH 072/203] FS-5610 --resolve --- libs/iksemel/.update | 2 +- libs/iksemel/include/iksemel.h | 1 + libs/iksemel/src/stream.c | 74 +++++++++++++++++++++++++++++++--- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/libs/iksemel/.update b/libs/iksemel/.update index b391edc878..a3a56a0ec9 100644 --- a/libs/iksemel/.update +++ b/libs/iksemel/.update @@ -1 +1 @@ -Tue May 14 07:44:21 CDT 2013 +Mon Jul 15 16:57:11 CDT 2013 diff --git a/libs/iksemel/include/iksemel.h b/libs/iksemel/include/iksemel.h index 9ef479a9ee..2b11070671 100644 --- a/libs/iksemel/include/iksemel.h +++ b/libs/iksemel/include/iksemel.h @@ -226,6 +226,7 @@ void iks_disconnect (iksparser *prs); int iks_has_tls (void); int iks_is_secure (iksparser *prs); int iks_start_tls (iksparser *prs); +int iks_proceed_tls (iksparser *prs, const char *cert_file, const char *key_file, int use_ssl); int iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char *pass); /***** jabber *****/ diff --git a/libs/iksemel/src/stream.c b/libs/iksemel/src/stream.c index 559335b16e..658c40207c 100644 --- a/libs/iksemel/src/stream.c +++ b/libs/iksemel/src/stream.c @@ -35,6 +35,8 @@ typedef unsigned __int32 uint32_t; #define SF_FOREIGN 1 #define SF_TRY_SECURE 2 #define SF_SECURE 4 +#define SF_SERVER 8 +#define SF_SSLv23 16 struct stream_data { iksparser *prs; @@ -51,6 +53,8 @@ struct stream_data { unsigned int flags; char *auth_username; char *auth_pass; + char *cert_file; + char *key_file; #ifdef HAVE_GNUTLS gnutls_session sess; gnutls_certificate_credentials cred; @@ -201,6 +205,7 @@ handshake (struct stream_data *data) gnutls_certificate_free_credentials (data->cred); return IKS_NOMEM; } + gnutls_protocol_set_priority (data->sess, protocol_priority); gnutls_cipher_set_priority(data->sess, cipher_priority); gnutls_compression_set_priority(data->sess, comp_priority); @@ -224,7 +229,9 @@ handshake (struct stream_data *data) data->flags &= (~SF_TRY_SECURE); data->flags |= SF_SECURE; - iks_send_header (data->prs, data->server); + if (!(data->flags & SF_SERVER)) { + iks_send_header (data->prs, data->server); + } return IKS_OK; } // HAVE_GNUTLS @@ -311,8 +318,25 @@ handshake (struct stream_data *data) SSL_library_init(); SSL_load_error_strings(); - data->ssl_ctx = SSL_CTX_new(TLSv1_method()); - if(!data->ssl_ctx) return IKS_NOMEM; + if (data->flags & SF_SERVER) { + if (data->flags & SF_SSLv23) { + data->ssl_ctx = SSL_CTX_new(SSLv23_server_method()); + } else { + data->ssl_ctx = SSL_CTX_new(TLSv1_server_method()); + } + if(!data->ssl_ctx) return IKS_NOMEM; + + if (SSL_CTX_use_certificate_file(data->ssl_ctx, data->cert_file, SSL_FILETYPE_PEM) <= 0) { + return IKS_NET_TLSFAIL; + } + if (SSL_CTX_use_PrivateKey_file(data->ssl_ctx, data->key_file, SSL_FILETYPE_PEM) <= 0) { + return IKS_NET_TLSFAIL; + } + SSL_CTX_set_verify(data->ssl_ctx, SSL_VERIFY_NONE, NULL); + } else { + data->ssl_ctx = SSL_CTX_new(TLSv1_method()); + if(!data->ssl_ctx) return IKS_NOMEM; + } data->ssl = SSL_new(data->ssl_ctx); if(!data->ssl) return IKS_NOMEM; @@ -329,7 +353,11 @@ handshake (struct stream_data *data) do { - ret = SSL_connect(data->ssl); + if (data->flags & SF_SERVER) { + ret = SSL_accept(data->ssl); + } else { + ret = SSL_connect(data->ssl); + } if( ret != 1 ) { @@ -346,7 +374,9 @@ handshake (struct stream_data *data) data->flags &= (~SF_TRY_SECURE); data->flags |= SF_SECURE; - iks_send_header (data->prs, data->server); + if (!(data->flags & SF_SERVER)) { + iks_send_header (data->prs, data->server); + } } return ret == 1 ? IKS_OK : IKS_NET_TLSFAIL; @@ -954,6 +984,40 @@ iks_start_tls (iksparser *prs) #endif } +int +iks_proceed_tls (iksparser *prs, const char *cert_file, const char *key_file, int use_ssl) +{ +#ifdef HAVE_GNUTLS + int ret; + struct stream_data *data = iks_user_data (prs); + + ret = iks_send_raw (prs, ""); + if (ret) return ret; + data->cert_file = iks_stack_strdup(data->s, cert_file, 0); + data->key_file = iks_stack_strdup(data->s, key_file, 0); + data->flags |= SF_TRY_SECURE | SF_SERVER; + if (use_ssl) { + data->flags |= SF_SSLv23; + } + return handshake (data); +#elif HAVE_SSL + int ret; + struct stream_data *data = iks_user_data (prs); + + ret = iks_send_raw (prs, ""); + if (ret) return ret; + data->cert_file = iks_stack_strdup(data->s, cert_file, 0); + data->key_file = iks_stack_strdup(data->s, key_file, 0); + data->flags |= SF_TRY_SECURE | SF_SERVER; + if (use_ssl) { + data->flags |= SF_SSLv23; + } + return handshake (data); +#else + return IKS_NET_NOTSUPP; +#endif +} + /***** sasl *****/ int From 3541d9d353562857ed97a92abffd5d28872ec52c Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Mon, 15 Jul 2013 18:52:09 -0400 Subject: [PATCH 073/203] mod_rayo: support secure client-to-server connections --- conf/rayo/autoload_configs/rayo.conf.xml | 4 +- .../conf/autoload_configs/rayo.conf.xml | 4 +- src/mod/event_handlers/mod_rayo/iks_helpers.h | 3 +- src/mod/event_handlers/mod_rayo/mod_rayo.c | 26 ++-- .../event_handlers/mod_rayo/xmpp_streams.c | 129 +++++++++++------- .../event_handlers/mod_rayo/xmpp_streams.h | 2 + 6 files changed, 103 insertions(+), 65 deletions(-) diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml index f9ac49b99d..0cb46d7992 100644 --- a/conf/rayo/autoload_configs/rayo.conf.xml +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -11,8 +11,10 @@ - + + + diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml index f9ac49b99d..0cb46d7992 100644 --- a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml +++ b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml @@ -11,8 +11,10 @@ - + + + diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.h b/src/mod/event_handlers/mod_rayo/iks_helpers.h index 4e21113452..442722a267 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.h +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.h @@ -39,8 +39,7 @@ #define IKS_NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" #define IKS_NS_XMPP_STREAMS "http://etherx.jabber.org/streams" #define IKS_NS_XMPP_DIALBACK "jabber:server:dialback" -#define IKS_NS_BIDI_FEATURE "urn:xmpp:features:bidi" -#define IKS_NS_BIDI "urn:xmpp:bidi" +#define IKS_NS_XMPP_TLS "urn:ietf:params:xml:ns:xmpp-tls" struct xmpp_error { const char *name; diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 24b187d739..a110cdb703 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -3079,6 +3079,8 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_ switch_xml_t l; const char *shared_secret = switch_xml_attr_soft(domain, "shared-secret"); const char *name = switch_xml_attr_soft(domain, "name"); + const char *cert = switch_xml_attr_soft(domain, "cert"); + const char *key = switch_xml_attr_soft(domain, "key"); if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing #include +#include + #include "xmpp_streams.h" #include "iks_helpers.h" #include "sasl.h" @@ -63,6 +65,10 @@ struct xmpp_stream_context { int shutdown; /** prevents context shutdown until all threads are finished */ switch_thread_rwlock_t *shutdown_rwlock; + /** path to cert PEM file */ + const char *cert_pem_file; + /** path to key PEM file */ + const char *key_pem_file; }; /** @@ -71,8 +77,8 @@ struct xmpp_stream_context { enum xmpp_stream_state { /** new connection */ XSS_CONNECT, - /** bidirectional comms established */ - XSS_BIDI, + /** encrypted comms established */ + XSS_SECURE, /** remote party authenticated */ XSS_AUTHENTICATED, /** client resource bound */ @@ -159,7 +165,7 @@ static const char *xmpp_stream_state_to_string(enum xmpp_stream_state state) { switch(state) { case XSS_CONNECT: return "CONNECT"; - case XSS_BIDI: return "BIDI"; + case XSS_SECURE: return "SECURE"; case XSS_AUTHENTICATED: return "AUTHENTICATED"; case XSS_RESOURCE_BOUND: return "RESOURCE_BOUND"; case XSS_READY: return "READY"; @@ -358,6 +364,31 @@ static void xmpp_send_client_header_auth(struct xmpp_stream *stream) free(header); } +/** + * Send sasl + starttls reply to xmpp + * @param stream the xmpp stream + */ +static void xmpp_send_client_header_tls(struct xmpp_stream *stream) +{ + if (stream->context->key_pem_file && stream->context->cert_pem_file) { + struct xmpp_stream_context *context = stream->context; + char *header = switch_mprintf( + "" + "" + "" + "PLAIN" + "", context->domain, stream->id); + iks_send_raw(stream->parser, header); + free(header); + } else { + /* not set up for TLS, skip it */ + stream->state = XSS_SECURE; + xmpp_send_client_header_auth(stream); + } +} + /** * Send sasl reply to xmpp * @param stream the xmpp stream @@ -370,12 +401,6 @@ static void xmpp_send_server_header_auth(struct xmpp_stream *stream) " from='%s' id='%s' xml:lang='en' version='1.0'" " xmlns:stream='"IKS_NS_XMPP_STREAMS"'>" "" -#if 0 - "" - "" - "PLAIN" - "" -#endif "", context->domain, stream->id); iks_send_raw(stream->parser, header); @@ -417,6 +442,21 @@ static void xmpp_send_outbound_server_header(struct xmpp_stream *stream) free(header); } +/** + * Handle message. + * @param the xmpp stream + * @param node the packet + */ +static void on_stream_starttls(struct xmpp_stream *stream, iks *node) +{ + /* wait for handshake to start */ + if (iks_proceed_tls(stream->parser, stream->context->cert_pem_file, stream->context->key_pem_file, 1) == IKS_OK) { + stream->state = XSS_SECURE; + } else { + stream->state = XSS_ERROR; + } +} + /** * Handle message. Only PLAIN supported. * @param stream the xmpp stream @@ -431,7 +471,7 @@ static void on_stream_auth(struct xmpp_stream *stream, iks *node) switch_log_printf(SWITCH_CHANNEL_UUID_LOG(stream->id), SWITCH_LOG_DEBUG, "%s, auth, state = %s\n", stream->jid, xmpp_stream_state_to_string(stream->state)); /* wrong state for authentication */ - if (stream->state != XSS_BIDI) { + if (stream->state != XSS_SECURE) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(stream->id), SWITCH_LOG_WARNING, "%s, auth UNEXPECTED, state = %s\n", stream->jid, xmpp_stream_state_to_string(stream->state)); /* on_auth unexpected error */ stream->state = XSS_ERROR; @@ -486,38 +526,6 @@ static void on_stream_auth(struct xmpp_stream *stream, iks *node) } } -/** - * Handle message. - * @param stream the xmpp stream - * @param node the packet - */ -static void on_stream_bidi(struct xmpp_stream *stream, iks *node) -{ - /* only allow bidi on s2s connections before auth */ - if (stream->s2s) { - switch(stream->state) { - case XSS_CONNECT: - stream->state = XSS_BIDI; - break; - case XSS_BIDI: - case XSS_AUTHENTICATED: - case XSS_RESOURCE_BOUND: - case XSS_READY: - case XSS_SHUTDOWN: - case XSS_ERROR: - case XSS_DESTROY: - /* error */ - stream->state = XSS_ERROR; - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(stream->id), SWITCH_LOG_INFO, "%s, bad state: %s\n", stream->jid, xmpp_stream_state_to_string(stream->state)); - break; - } - } else { - /* error */ - stream->state = XSS_ERROR; - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(stream->id), SWITCH_LOG_INFO, "%s, bidi not allowed from client\n", stream->jid); - } -} - /** * Handle request * @param stream the xmpp stream @@ -606,7 +614,7 @@ static void on_stream_iq(struct xmpp_stream *stream, iks *iq) struct xmpp_stream_context *context = stream->context; switch(stream->state) { case XSS_CONNECT: - case XSS_BIDI: { + case XSS_SECURE: { iks *error = iks_new_error(iq, STANZA_ERROR_NOT_AUTHORIZED); xmpp_stream_stanza_send(stream, error); break; @@ -689,7 +697,9 @@ static void on_client_stream_start(struct xmpp_stream *stream, iks *node) switch (stream->state) { case XSS_CONNECT: - case XSS_BIDI: + xmpp_send_client_header_tls(stream); + break; + case XSS_SECURE: xmpp_send_client_header_auth(stream); break; case XSS_AUTHENTICATED: @@ -960,7 +970,7 @@ static void on_outbound_server_stream_start(struct xmpp_stream *stream, iks *nod /* strange... I expect IKS_NODE_STOP, this is a workaround. */ stream->state = XSS_DESTROY; break; - case XSS_BIDI: + case XSS_SECURE: case XSS_AUTHENTICATED: case XSS_RESOURCE_BOUND: case XSS_READY: @@ -1001,7 +1011,7 @@ static void on_inbound_server_stream_start(struct xmpp_stream *stream, iks *node case XSS_CONNECT: xmpp_send_server_header_auth(stream); break; - case XSS_BIDI: + case XSS_SECURE: break; case XSS_AUTHENTICATED: { /* all set */ @@ -1075,8 +1085,8 @@ static int on_stream(void *user_data, int type, iks *node) on_stream_presence(stream, node); } else if (!strcmp("auth", name)) { on_stream_auth(stream, node); - } else if (!strcmp("bidi", name)) { - on_stream_bidi(stream, node); + } else if (!strcmp("starttls", name)) { + on_stream_starttls(stream, node); } else if (!strcmp("db:result", name)) { on_stream_dialback_result(stream, node); } else if (!strcmp("db:verify", name)) { @@ -1194,6 +1204,7 @@ static void *SWITCH_THREAD_FUNC xmpp_stream_thread(switch_thread_t *thread, void case IKS_OK: err_count = 0; break; + case IKS_NET_TLSFAIL: case IKS_NET_RWERR: case IKS_NET_NOCONN: case IKS_NET_NOSOCK: @@ -1291,11 +1302,6 @@ static struct xmpp_stream *xmpp_stream_init(struct xmpp_stream_context *context, stream->incoming = incoming; switch_queue_create(&stream->msg_queue, MAX_QUEUE_LEN, pool); - if (!stream->s2s) { - /* client is already bi-directional */ - stream->state = XSS_BIDI; - } - /* set up XMPP stream parser */ stream->parser = iks_stream_new(stream->s2s ? IKS_NS_SERVER : IKS_NS_CLIENT, stream, on_stream); @@ -1829,6 +1835,23 @@ void *xmpp_stream_get_private(struct xmpp_stream *stream) return stream->user_private; } +/** + * Add PEM cert file to stream for new SSL connections + */ +void xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file) +{ + context->cert_pem_file = switch_core_strdup(context->pool, cert_pem_file); +} + +/** + * Add PEM key file to stream for new SSL connections + */ +void xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file) +{ + context->key_pem_file = switch_core_strdup(context->pool, key_pem_file); +} + + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/event_handlers/mod_rayo/xmpp_streams.h b/src/mod/event_handlers/mod_rayo/xmpp_streams.h index d4ba663246..a07c75d025 100644 --- a/src/mod/event_handlers/mod_rayo/xmpp_streams.h +++ b/src/mod/event_handlers/mod_rayo/xmpp_streams.h @@ -37,6 +37,8 @@ typedef void (* xmpp_stream_recv_callback)(struct xmpp_stream *stream, iks *stan typedef void (* xmpp_stream_destroy_callback)(struct xmpp_stream *stream); extern struct xmpp_stream_context *xmpp_stream_context_create(const char *domain, const char *domain_secret, xmpp_stream_ready_callback ready, xmpp_stream_recv_callback recv, xmpp_stream_destroy_callback destroy); +extern void xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file); +extern void xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file); extern void xmpp_stream_context_add_user(struct xmpp_stream_context *context, const char *user, const char *password); extern void xmpp_stream_context_dump(struct xmpp_stream_context *context, switch_stream_handle_t *stream); extern void xmpp_stream_context_destroy(struct xmpp_stream_context *context); From c9790ea16e70d66710d6b05e67c4682250644e36 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 16 Jul 2013 10:45:45 +0800 Subject: [PATCH 074/203] finally found a router supporting uPnP --- htdocs/portal/assets/js/fsportal.js | 24 ++++++++++++++++++++++++ htdocs/portal/index.html | 24 +++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/htdocs/portal/assets/js/fsportal.js b/htdocs/portal/assets/js/fsportal.js index 32c3b24703..618b3d5004 100644 --- a/htdocs/portal/assets/js/fsportal.js +++ b/htdocs/portal/assets/js/fsportal.js @@ -154,6 +154,12 @@ App.ShowSaysRoute = Ember.Route.extend({ } }); +App.ShowNatMapsRoute = Ember.Route.extend({ + setupController: function(controller) { + App.showNatMapsController.load(); + } +}); + App.ShowChatsRoute = Ember.Route.extend({ setupController: function(controller) { App.showChatsController.load(); @@ -203,6 +209,7 @@ App.Router.map(function(){ this.route("showAliases"); this.route("showCompletes"); this.route("showManagements"); + this.route("showNatMaps"); this.route("showSays"); this.route("showChats"); this.route("showInterfaces"); @@ -550,6 +557,23 @@ App.showManagementsController = Ember.ArrayController.create({ } }); +App.showNatMapsController = Ember.ArrayController.create({ + content: [], + init: function(){ + }, + load: function() { + var me = this; + $.getJSON("/txtapi/show?nat_map%20as%20json", function(data){ + me.set('total', data.row_count); + me.content.clear(); + if (data.row_count == 0) return; + + me.pushObjects(data.rows); + + }); + } +}); + App.showSaysController = Ember.ArrayController.create({ content: [], init: function(){ diff --git a/htdocs/portal/index.html b/htdocs/portal/index.html index 47270e6814..8771a8f09e 100644 --- a/htdocs/portal/index.html +++ b/htdocs/portal/index.html @@ -357,6 +357,28 @@ + + From b38a7f5392bf8b36dd8c2c60423c4feee7b8aa9d Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Tue, 30 Jul 2013 14:35:39 -0500 Subject: [PATCH 143/203] mod_skinny: initial reg wasn't able to clean up due to missing device name, add new function to clean up given explicit device name, also add more logging --- src/mod/endpoints/mod_skinny/mod_skinny.c | 55 ++++++++++++++++++++ src/mod/endpoints/mod_skinny/mod_skinny.h | 1 + src/mod/endpoints/mod_skinny/skinny_server.c | 11 ++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 407aa65499..72cc82f9fa 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1326,12 +1326,64 @@ static int flush_listener_callback(void *pArg, int argc, char **argv, char **col return 0; } +void skinny_clean_device_from_db(listener_t *listener, char *device_name) +{ + if(!zstr(device_name)) { + skinny_profile_t *profile = listener->profile; + char *sql; + + skinny_log_l(listener, SWITCH_LOG_DEBUG, + "Clean device from DB with name '%s'\n", + device_name); + + if ((sql = switch_mprintf( + "DELETE FROM skinny_devices " + "WHERE name='%s'", + device_name))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + + if ((sql = switch_mprintf( + "DELETE FROM skinny_lines " + "WHERE device_name='%s'", + device_name))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + + if ((sql = switch_mprintf( + "DELETE FROM skinny_buttons " + "WHERE device_name='%s'", + device_name))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + + if ((sql = switch_mprintf( + "DELETE FROM skinny_active_lines " + "WHERE device_name='%s'", + device_name))) { + skinny_execute_sql(profile, sql, profile->sql_mutex); + switch_safe_free(sql); + } + + } else { + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, + "Clean device from DB, missing device name.\n"); + } +} + void skinny_clean_listener_from_db(listener_t *listener) { if(!zstr(listener->device_name)) { skinny_profile_t *profile = listener->profile; char *sql; + skinny_log_l(listener, SWITCH_LOG_DEBUG, + "Clean listener from DB with name '%s' and instance '%d'\n", + listener->device_name, listener->device_instance); + if ((sql = switch_mprintf( "DELETE FROM skinny_devices " "WHERE name='%s' and instance=%d", @@ -1364,6 +1416,9 @@ void skinny_clean_listener_from_db(listener_t *listener) switch_safe_free(sql); } + } else { + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, + "Clean listener from DB, missing device name.\n"); } } diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 76ca8017ac..d8ed1b03bf 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -276,6 +276,7 @@ uint8_t listener_is_ready(listener_t *listener); switch_status_t kill_listener(listener_t *listener, void *pvt); switch_status_t keepalive_listener(listener_t *listener, void *pvt); void skinny_clean_listener_from_db(listener_t *listener); +void skinny_clean_device_from_db(listener_t *listener, char *device_name); /*****************************************************************************/ /* CHANNEL FUNCTIONS */ diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 5edb669682..88db5b5347 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -975,6 +975,9 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r skinny_device_event(listener, ¶ms, SWITCH_EVENT_REQUEST_PARAMS, SWITCH_EVENT_SUBCLASS_ANY); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "skinny-auth"); + /* clean up all traces before adding to database */ + skinny_clean_device_from_db(listener, request->data.reg.device_name); + if (switch_xml_locate_user("id", request->data.reg.device_name, profile->domain, "", &xroot, &xdomain, &xuser, &xgroup, params) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't find device [%s@%s]\n" "You must define a domain called '%s' in your directory and add a user with id=\"%s\".\n" @@ -984,6 +987,11 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r goto end; } + /* we clean up device above, so this below block will never trigger. I don't + know the full details of why there would be multiple listeners with + the same device - maybe a VGC or similar? Not really high priority for + support at the moment, but may need to revisit this later */ + skinny_profile_find_listener_by_device_name_and_instance(listener->profile, request->data.reg.device_name, request->data.reg.instance, &listener2); if (listener2) { @@ -995,9 +1003,6 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r goto end; } - /* clean up all traces before adding to database */ - skinny_clean_listener_from_db(listener); - if ((sql = switch_mprintf( "INSERT INTO skinny_devices " "(name, user_id, instance, ip, type, max_streams, codec_string) " From 343cddd9148ea32468f956da02e2b06a56a5b434 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Wed, 31 Jul 2013 07:16:23 -0400 Subject: [PATCH 144/203] mod_spandsp: added UUID command completion to start/stop_tone_detect commands --- src/mod/applications/mod_spandsp/mod_spandsp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 91c907426a..51e2505758 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -648,7 +648,7 @@ switch_status_t load_configuration(switch_bool_t reload) "Unable to add tone_descriptor: %s, tone: %s. (too many tones)\n", name, tone_name); switch_goto_status(SWITCH_STATUS_FALSE, done); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id); /* add elements to tone */ for (element = switch_xml_child(tone, "element"); element; element = switch_xml_next(element)) { @@ -683,7 +683,7 @@ switch_status_t load_configuration(switch_bool_t reload) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid element param.\n"); switch_goto_status(SWITCH_STATUS_FALSE, done); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Adding tone_descriptor: %s, tone: %s(%d), element (%d, %d, %d, %d)\n", name, tone_name, id, freq1, freq2, min, max); tone_descriptor_add_tone_element(descriptor, id, freq1, freq2, min, max); } @@ -713,7 +713,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) *module_interface = switch_loadable_module_create_module_interface(pool, modname); switch_mutex_init(&spandsp_globals.mutex, SWITCH_MUTEX_NESTED, pool); - SWITCH_ADD_APP(app_interface, "t38_gateway", "Convert to T38 Gateway if tones are heard", "Convert to T38 Gateway if tones are heard", + SWITCH_ADD_APP(app_interface, "t38_gateway", "Convert to T38 Gateway if tones are heard", "Convert to T38 Gateway if tones are heard", t38_gateway_function, "", SAF_MEDIA_TAP); SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE, @@ -734,7 +734,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_ADD_APP(app_interface, "spandsp_send_tdd", "Send TDD data", "Send TDD data", tdd_send_function, "", SAF_NONE); - SWITCH_ADD_APP(app_interface, "spandsp_start_fax_detect", "start fax detect", "start fax detect", spandsp_fax_detect_session_function, + SWITCH_ADD_APP(app_interface, "spandsp_start_fax_detect", "start fax detect", "start fax detect", spandsp_fax_detect_session_function, "[ ][ ][ ]", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_stop_fax_detect", "stop fax detect", "stop fax detect", spandsp_stop_fax_detect_session_function, "", SAF_NONE); @@ -752,9 +752,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); SWITCH_ADD_API(api_interface, "start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, " "); SWITCH_ADD_API(api_interface, "stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, ""); + switch_console_set_complete("add start_tone_detect ::console::list_uuid"); + switch_console_set_complete("add stop_tone_detect ::console::list_uuid"); } - SWITCH_ADD_API(api_interface, "start_tdd_detect", "Start background tdd detection", start_tdd_detect_api, ""); SWITCH_ADD_API(api_interface, "stop_tdd_detect", "Stop background tdd detection", stop_tdd_detect_api, ""); From a8e779fab659d1a8a45816df22dba17ea9ffd97c Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Wed, 31 Jul 2013 17:16:43 -0500 Subject: [PATCH 145/203] mod_skinny: filter sip mwi events --- src/mod/endpoints/mod_skinny/mod_skinny.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 72cc82f9fa..165624a303 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -2253,6 +2253,10 @@ static void skinny_message_waiting_event_handler(switch_event_t *event) return; } + if (!strncmp("sip:", account, 4)) { + return; + } + if (!(yn = switch_event_get_header(event, "mwi-messages-waiting"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required Header 'MWI-Messages-Waiting'\n"); return; From b472e1c9b75b022d62055dacaa2f83d13106aa70 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Wed, 31 Jul 2013 17:17:07 -0500 Subject: [PATCH 146/203] mod_skinny: allow to work with native pgsql --- src/mod/endpoints/mod_skinny/mod_skinny.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 165624a303..dc83c47294 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1850,14 +1850,8 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c profile->keep_alive = atoi(val); } else if (!strcasecmp(var, "date-format")) { strncpy(profile->date_format, val, 6); - } else if (!strcasecmp(var, "odbc-dsn")) { - if (!zstr(val)) { - if (switch_odbc_available()) { - profile->odbc_dsn = switch_core_strdup(profile->pool, val); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); - } - } + } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { + profile->odbc_dsn = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "debug")) { profile->debug = atoi(val); } else if (!strcasecmp(var, "auto-restart")) { From 2543982a4f232ef45c18c1704351af041d91fe0e Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 1 Aug 2013 09:50:51 +0800 Subject: [PATCH 147/203] add SHORT_DATE_TIME support --- src/mod/say/mod_say_zh/mod_say_zh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/say/mod_say_zh/mod_say_zh.c b/src/mod/say/mod_say_zh/mod_say_zh.c index 87ab0042b8..ac5ba32e42 100644 --- a/src/mod/say/mod_say_zh/mod_say_zh.c +++ b/src/mod/say/mod_say_zh/mod_say_zh.c @@ -497,6 +497,7 @@ static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switc case SST_CURRENT_DATE: case SST_CURRENT_TIME: case SST_CURRENT_DATE_TIME: + case SST_SHORT_DATE_TIME: say_cb = zh_say_time; break; case SST_IP_ADDRESS: From 99a0f6bfc863d3a8aed0ee50e33b19cb86259a66 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Thu, 1 Aug 2013 14:02:56 -0400 Subject: [PATCH 148/203] FS-5659 --resolve Add logging for spandsp dtmf detector when dtmf_verbose channel variable is set to true Conflicts: src/mod/applications/mod_spandsp/mod_spandsp_fax.c --- .../applications/mod_spandsp/mod_spandsp.h | 4 +- .../mod_spandsp/mod_spandsp_dsp.c | 21 +++-- .../mod_spandsp/mod_spandsp_fax.c | 89 +++++++++---------- .../mod_spandsp/mod_spandsp_modem.c | 10 +-- 4 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index fafccae693..323ff07a45 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -1,4 +1,4 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2012, Anthony Minessale II * @@ -141,7 +141,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, int hits, const char *app, const char *data, switch_tone_detect_callback_t callback); switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session); -void spanfax_log_message(void *user_data, int level, const char *msg); +void mod_spandsp_log_message(void *session, int level, const char *msg); switch_status_t load_configuration(switch_bool_t reload); void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 086a737b5a..0958c8c310 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -349,6 +349,7 @@ switch_status_t spandsp_tdd_decode_session(switch_core_session_t *session) typedef struct { switch_core_session_t *session; dtmf_rx_state_t *dtmf_detect; + int verbose; char last_digit; uint32_t samples; uint32_t last_digit_end; @@ -394,6 +395,10 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da switch (type) { case SWITCH_ABC_TYPE_INIT: { pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL); + span_log_set_message_handler(dtmf_rx_get_logging_state(pvt->dtmf_detect), mod_spandsp_log_message, pvt->session); + if (pvt->verbose) { + span_log_set_level(dtmf_rx_get_logging_state(pvt->dtmf_detect), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + } dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, pvt->twist, pvt->reverse_twist, pvt->threshold); dtmf_rx_set_realtime_callback(pvt->dtmf_detect, spandsp_dtmf_rx_realtime_callback, pvt); break; @@ -500,6 +505,10 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session) pvt->filter_dialtone = 0; } + if ((value = switch_channel_get_variable(channel, "dtmf_verbose"))) { + pvt->verbose = switch_true(value); + } + if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; } @@ -554,7 +563,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu * Allocate the tone descriptor * * @param descriptor the descriptor to create - * @param name the descriptor name + * @param name the descriptor name * @param memory_pool the pool to use * @return SWITCH_STATUS_SUCCESS if successful */ @@ -632,7 +641,7 @@ static void tone_report_callback(void *user_data, int code, int level, int delay /** * Process tone segment report from spandsp (for debugging) - * + * * @param user_data the tone_detector * @param f1 the first frequency of the segment * @param f2 the second frequency of the segment @@ -705,7 +714,7 @@ static switch_bool_t tone_detector_process_buffer(tone_detector_t *detector, voi * Destroy the tone detector * @param detector the detector to destroy */ -static void tone_detector_destroy(tone_detector_t *detector) +static void tone_detector_destroy(tone_detector_t *detector) { if (detector) { if (detector->spandsp_detector) { @@ -720,7 +729,7 @@ static void tone_detector_destroy(tone_detector_t *detector) * Start call progress detection * * @param session the session to detect - * @param name of the descriptor to use + * @param name of the descriptor to use * @return SWITCH_STATUS_SUCCESS if successful */ switch_status_t callprogress_detector_start(switch_core_session_t *session, const char *name) @@ -759,7 +768,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons /** * Process a buffer of audio data for call progress tones * - * @param bug the session's media bug + * @param bug the session's media bug * @param user_data the detector * @param type the type of data available from the bug * @return SWITCH_TRUE @@ -817,7 +826,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu /** * Stop call progress detection - * @param session the session to stop + * @param session the session to stop * @return SWITCH_STATUS_SUCCESS if successful */ switch_status_t callprogress_detector_stop(switch_core_session_t *session) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index dec91830e1..06712bb6ff 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -1,4 +1,4 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2012, Anthony Minessale II * @@ -167,7 +167,7 @@ static int del_pvt(pvt_t *del_pvt) r = 1; break; } - + l = p; } @@ -259,15 +259,11 @@ static void counter_increment(void) switch_mutex_unlock(spandsp_globals.mutex); } -void spanfax_log_message(void *user_data, int level, const char *msg) +void mod_spandsp_log_message(void *user_data, int level, const char *msg) { int fs_log_level; - switch_core_session_t *session; - pvt_t *pvt; - - pvt = (pvt_t *) user_data; - session = pvt->session; - + switch_core_session_t *session = (switch_core_session_t *)user_data; + switch (level) { case SPAN_LOG_NONE: return; @@ -329,7 +325,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) switch_channel_set_variable(channel, "fax_remote_model", switch_str_nil(t30_get_rx_model(s))); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "=== Negotiation Result =======================================================\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "=== Negotiation Result =======================================================\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote station id: %s\n", far_ident); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local station id: %s\n", local_ident); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t30_stats.bit_rate); @@ -339,7 +335,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(s))); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(s))); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n"); switch_channel_execute_on(channel, "execute_on_fax_phase_b"); @@ -673,9 +669,9 @@ static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uin if (r < 0) { t30_state_t *t30; - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "TERMINATING T30 STATE\n"); - + if (pvt->t38_state && (t30 = t38_terminal_get_t30_state(pvt->t38_state))) { t30_terminate(t30); } @@ -733,8 +729,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) fax_set_transmit_on_idle(fax, TRUE); - span_log_set_message_handler(fax_get_logging_state(fax), spanfax_log_message, pvt); - span_log_set_message_handler(t30_get_logging_state(t30), spanfax_log_message, pvt); + span_log_set_message_handler(fax_get_logging_state(fax), mod_spandsp_log_message, pvt->session); + span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, pvt->session); if (pvt->verbose) { span_log_set_level(fax_get_logging_state(fax), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); @@ -772,7 +768,7 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state); - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, + if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); return SWITCH_STATUS_FALSE; @@ -789,8 +785,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } } - span_log_set_message_handler(t38_terminal_get_logging_state(t38), spanfax_log_message, pvt); - span_log_set_message_handler(t30_get_logging_state(t30), spanfax_log_message, pvt); + span_log_set_message_handler(t38_terminal_get_logging_state(t38), mod_spandsp_log_message, pvt->session); + span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, pvt->session); if (pvt->verbose) { span_log_set_level(t38_terminal_get_logging_state(t38), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); @@ -811,13 +807,13 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); t38_gateway_free(pvt->t38_gateway_state); pvt->t38_gateway_state = NULL; - + return SWITCH_STATUS_FALSE; } pvt->t38_core = t38_gateway_get_t38_core_state(pvt->t38_gateway_state); - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, + if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); t38_gateway_free(pvt->t38_gateway_state); @@ -843,9 +839,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) t38_gateway_set_ecm_capability(pvt->t38_gateway_state, TRUE); } - - span_log_set_message_handler(t38_gateway_get_logging_state(pvt->t38_gateway_state), spanfax_log_message, pvt); - span_log_set_message_handler(t38_core_get_logging_state(pvt->t38_core), spanfax_log_message, pvt); + span_log_set_message_handler(t38_gateway_get_logging_state(pvt->t38_gateway_state), mod_spandsp_log_message, pvt->session); + span_log_set_message_handler(t38_core_get_logging_state(pvt->t38_core), mod_spandsp_log_message, pvt->session); if (pvt->verbose) { span_log_set_level(t38_gateway_get_logging_state(pvt->t38_gateway_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); @@ -982,7 +977,7 @@ static t38_mode_t configure_t38(pvt_t *pvt) t38_set_jbig_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingJBIG); t38_set_max_datagram_size(pvt->t38_core, t38_options->T38FaxMaxDatagram); - if (t38_options->T38FaxRateManagement) { + if (t38_options->T38FaxRateManagement) { if (!strcasecmp(t38_options->T38FaxRateManagement, "transferredTCF")) { method = 2; } else { @@ -1037,7 +1032,7 @@ static t38_mode_t negotiate_t38(pvt_t *pvt) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxDatagram = %d\n", t38_options->T38FaxMaxDatagram); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxUdpEC = '%s'\n", t38_options->T38FaxUdpEC); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38VendorInfo = '%s'\n", switch_str_nil(t38_options->T38VendorInfo)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ip = '%s'\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ip = '%s'\n", t38_options->remote_ip ? t38_options->remote_ip : "Not specified"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "port = %d\n", t38_options->remote_port); @@ -1122,7 +1117,7 @@ static t38_mode_t request_t38(pvt_t *pvt) } if ((t38_options = switch_channel_get_private(channel, "t38_options"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s already has T.38 data\n", switch_channel_get_name(channel)); enabled = 0; } @@ -1421,11 +1416,11 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat int tx = 0; switch_status_t status; - /* + /* if we are in T.38 mode, we should: 1- initialize the ptv->t38_state stuff, if not done and then set some callbacks when reading frames. The only thing we need, then, in this loop, is: - - read a frame without blocking + - read a frame without blocking - eventually feed that frame in spandsp, - call t38_terminal_send_timeout(), sleep for a while @@ -1452,7 +1447,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); spanfax_init(pvt, T38_MODE); configure_t38(pvt); - + /* This will change the rtp stack to udptl mode */ msg.from = __FILE__; msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; @@ -1469,7 +1464,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat request_t38(pvt); } } - + if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) { /* is is safe to call this again, it was already called above in AUDIO_MODE */ @@ -1487,11 +1482,11 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat /* dunno what to do, most likely you will not get too many of these since we turn off the timer in udptl mode */ continue; } - + if (switch_test_flag(read_frame, SFF_UDPTL_PACKET) && read_frame->packet && read_frame->packetlen) { /* now we know we can cast frame->packet to a udptl structure */ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "READ %d udptl bytes\n", read_frame->packetlen); - + udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); } } @@ -1596,7 +1591,7 @@ static switch_status_t t38_gateway_on_soft_execute(switch_core_session_t *sessio if (!(other_session = switch_core_session_locate(peer_uuid))) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot locate channel with uuid %s", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot locate channel with uuid %s", switch_channel_get_name(channel), peer_uuid); goto end; } @@ -1823,13 +1818,13 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL); if (switch_true(t38_trace)) { - trace_read = switch_core_session_sprintf(session, "%s%s%s_read.raw", SWITCH_GLOBAL_dirs.temp_dir, + trace_read = switch_core_session_sprintf(session, "%s%s%s_read.raw", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing inbound audio to %s\n", trace_read); switch_channel_set_variable(channel, "t38_trace_read", trace_read); - trace_write = switch_core_session_sprintf(session, "%s%s%s_write.raw", SWITCH_GLOBAL_dirs.temp_dir, + trace_write = switch_core_session_sprintf(session, "%s%s%s_write.raw", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing outbound audio to %s\n", trace_write); @@ -1859,7 +1854,7 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi } else { if (read_fd != FAX_INVALID_SOCKET) { switch_ssize_t rv; - do { rv = write(read_fd, read_frame->data, read_frame->datalen); } while (rv == -1 && errno == EINTR); + do { rv = write(read_fd, read_frame->data, read_frame->datalen); } while (rv == -1 && errno == EINTR); } if (t38_gateway_rx(pvt->t38_gateway_state, (int16_t *) read_frame->data, read_frame->samples)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx reported an error\n"); @@ -1988,7 +1983,7 @@ switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app, switch_channel_set_variable(peer ? channel : other_channel, "t38_gateway_format", "audio"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n", switch_channel_get_name(peer ? channel : other_channel), switch_channel_get_name(peer ? other_channel : channel)); @@ -2027,20 +2022,20 @@ typedef struct { int expires; int default_sleep; int default_expires; - switch_tone_detect_callback_t callback; + switch_tone_detect_callback_t callback; modem_connect_tones_rx_state_t rx_tones; switch_media_bug_t *bug; switch_core_session_t *session; int bug_running; - + } spandsp_fax_tone_container_t; static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction) { switch_channel_t *channel = switch_core_session_get_channel(session); spandsp_fax_tone_container_t *cont = switch_channel_get_private(channel, "_fax_tone_detect_"); - + if (!cont || dtmf->digit != 'f') { return SWITCH_STATUS_SUCCESS; @@ -2054,7 +2049,7 @@ static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch switch_core_session_execute_application_async(cont->session, cont->app, cont->data); } } - + return SWITCH_STATUS_SUCCESS; } @@ -2079,13 +2074,13 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da case SWITCH_ABC_TYPE_WRITE_REPLACE: { int skip = 0; - + if (type == SWITCH_ABC_TYPE_READ_REPLACE) { frame = switch_core_media_bug_get_read_replace_frame(bug); } else { frame = switch_core_media_bug_get_write_replace_frame(bug); } - + if (cont->sleep) { cont->sleep--; if (cont->sleep) { @@ -2116,7 +2111,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da if (cont->hits) { switch_event_t *event; - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "Fax Tone Detected. [%s][%s]\n", cont->app, switch_str_nil(cont->data)); @@ -2128,7 +2123,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da switch_core_session_execute_application_async(cont->session, cont->app, cont->data); } } - + if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) { switch_event_t *dup; @@ -2142,7 +2137,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da channel = switch_core_session_get_channel(session); if (channel) switch_channel_event_set_data(channel, event); } - + if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) { switch_event_fire(&dup); } @@ -2157,7 +2152,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da rval = SWITCH_FALSE; } - + } break; case SWITCH_ABC_TYPE_WRITE: diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index b1a794a387..dec93970a0 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -346,23 +346,23 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl if (spandsp_globals.modem_verbose) { logging = t31_get_logging_state(modem->t31_state); - span_log_set_message_handler(logging, spanfax_log_message, NULL); + span_log_set_message_handler(logging, mod_spandsp_log_message, NULL); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); logging = v17_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v17_rx); - span_log_set_message_handler(logging, spanfax_log_message, NULL); + span_log_set_message_handler(logging, mod_spandsp_log_message, NULL); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); logging = v29_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v29_rx); - span_log_set_message_handler(logging, spanfax_log_message, NULL); + span_log_set_message_handler(logging, mod_spandsp_log_message, NULL); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); logging = v27ter_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v27ter_rx); - span_log_set_message_handler(logging, spanfax_log_message, NULL); + span_log_set_message_handler(logging, mod_spandsp_log_message, NULL); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); logging = t38_core_get_logging_state(modem->t38_core); - span_log_set_message_handler(logging, spanfax_log_message, NULL); + span_log_set_message_handler(logging, mod_spandsp_log_message, NULL); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); } From c1bc8a5ad71d000bc03d3c1f1345458bda682993 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Thu, 1 Aug 2013 14:37:28 -0400 Subject: [PATCH 149/203] FS-5657 --resolve fix mod_rayo build errors in CentOS 5 --- src/mod/event_handlers/mod_rayo/Makefile | 2 + src/mod/event_handlers/mod_rayo/iks_helpers.c | 87 +++++++++++++ src/mod/event_handlers/mod_rayo/iks_helpers.h | 97 ++------------- .../event_handlers/mod_rayo/rayo_elements.c | 117 ++++++++++++++++++ .../event_handlers/mod_rayo/rayo_elements.h | 82 ++---------- 5 files changed, 221 insertions(+), 164 deletions(-) create mode 100644 src/mod/event_handlers/mod_rayo/rayo_elements.c diff --git a/src/mod/event_handlers/mod_rayo/Makefile b/src/mod/event_handlers/mod_rayo/Makefile index d15ae1cbb1..6fccfdf318 100644 --- a/src/mod/event_handlers/mod_rayo/Makefile +++ b/src/mod/event_handlers/mod_rayo/Makefile @@ -10,6 +10,7 @@ LOCAL_OBJS= $(IKS_LA) \ iks_helpers.o \ nlsml.o \ rayo_components.o \ + rayo_elements.o \ rayo_input_component.o \ rayo_output_component.o \ rayo_prompt_component.o \ @@ -21,6 +22,7 @@ LOCAL_SOURCES= \ iks_helpers.c \ nlsml.c \ rayo_components.c \ + rayo_elements.c \ rayo_input_component.c \ rayo_output_component.c \ rayo_prompt_component.c \ diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.c b/src/mod/event_handlers/mod_rayo/iks_helpers.c index 46fd1c4cea..0b5616a1f3 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.c +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.c @@ -305,6 +305,93 @@ int value_matches(const char *value, const char *rule) return 0; } +/** + * Validate boolean + * @param value + * @return SWTICH_TRUE if boolean + */ +int iks_attrib_is_bool(const char *value) +{ + if (value && *value && (!strcasecmp("true", value) || !strcasecmp("false", value))) { + return SWITCH_TRUE; + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if not negative + */ +int iks_attrib_is_not_negative(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i >= 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if positive + */ +int iks_attrib_is_positive(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i > 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate integer + * @param value + * @return SWTICH_TRUE if positive or -1 + */ +int iks_attrib_is_positive_or_neg_one(const char *value) +{ + if (value && *value && switch_is_number(value)) { + int value_i = atoi(value); + if (value_i == -1 || value_i > 0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * Validate string + * @param value + * @return SWTICH_TRUE + */ +int iks_attrib_is_any(const char *value) +{ + return SWITCH_TRUE; +} + +/** + * Validate decimal + * @param value + * @return SWTICH_TRUE if 0.0 <= x <= 1.0 + */ +int iks_attrib_is_decimal_between_zero_and_one(const char *value) +{ + if (value && *value && switch_is_number(value)) { + double value_d = atof(value); + if (value_d >= 0.0 || value_d <= 1.0) { + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + #define IKS_SHA256_HEX_DIGEST_LENGTH ((SHA256_DIGEST_LENGTH * 2) + 1) /** diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.h b/src/mod/event_handlers/mod_rayo/iks_helpers.h index 442722a267..90a5ca688d 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.h +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.h @@ -73,101 +73,20 @@ extern char *iks_server_dialback_key(const char *secret, const char *receiving_s /** A function to validate attribute value */ typedef int (*iks_attrib_validation_function)(const char *); -#define ELEMENT(name) inline int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0; +#define ELEMENT_DECL(name) extern int VALIDATE_##name(iks *node); +#define ELEMENT(name) int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0; #define ATTRIB(name, def, rule) result &= iks_attrib_is_##rule(iks_find_attrib_default(node, #name, #def)); #define STRING_ATTRIB(name, def, rule) result &= value_matches(iks_find_attrib_default(node, #name, #def), rule); #define ELEMENT_END return result; } extern int value_matches(const char *value, const char *rule); -#define ATTRIB_RULE(rule) inline int iks_attrib_is_ ## rule (const char *value) - -/** - * Validate boolean - * @param value - * @return SWTICH_TRUE if boolean - */ -ATTRIB_RULE(bool) -{ - if (value && *value && (!strcasecmp("true", value) || !strcasecmp("false", value))) { - return SWITCH_TRUE; - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if not negative - */ -ATTRIB_RULE(not_negative) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i >= 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if positive - */ -ATTRIB_RULE(positive) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i > 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate integer - * @param value - * @return SWTICH_TRUE if positive or -1 - */ -ATTRIB_RULE(positive_or_neg_one) -{ - if (value && *value && switch_is_number(value)) { - int value_i = atoi(value); - if (value_i == -1 || value_i > 0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} - -/** - * Validate string - * @param value - * @return SWTICH_TRUE - */ -ATTRIB_RULE(any) -{ - return SWITCH_TRUE; -} - -/** - * Validate decimal - * @param value - * @return SWTICH_TRUE if 0.0 <= x <= 1.0 - */ -ATTRIB_RULE(decimal_between_zero_and_one) -{ - if (value && *value && switch_is_number(value)) { - double value_d = atof(value); - if (value_d >= 0.0 || value_d <= 1.0) { - return SWITCH_TRUE; - } - } - return SWITCH_FALSE; -} +extern int iks_attrib_is_bool(const char *value); +extern int iks_attrib_is_not_negative(const char *value); +extern int iks_attrib_is_positive(const char *value); +extern int iks_attrib_is_positive_or_neg_one(const char *value); +extern int iks_attrib_is_any(const char *value); +extern int iks_attrib_is_decimal_between_zero_and_one(const char *value); #endif diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.c b/src/mod/event_handlers/mod_rayo/rayo_elements.c new file mode 100644 index 0000000000..07051c1474 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.c @@ -0,0 +1,117 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_elements.c -- Rayo XML element definition + * + */ +#include "rayo_elements.h" + +/** + * component validation + */ +ELEMENT(RAYO_INPUT) + STRING_ATTRIB(mode, any, "any,dtmf,voice") + ATTRIB(terminator,, any) + ATTRIB(recognizer,, any) + ATTRIB(language, en-US, any) + ATTRIB(initial-timeout, -1, positive_or_neg_one) + ATTRIB(inter-digit-timeout, -1, positive_or_neg_one) + ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one) + ATTRIB(min-confidence, 0, decimal_between_zero_and_one) + ATTRIB(max-silence, -1, positive_or_neg_one) + /* for now, only NLSML */ + STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml") + /* internal attribs for prompt support */ + ATTRIB(barge-event, false, bool) + ATTRIB(start-timers, true, bool) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_OUTPUT) + ATTRIB(start-offset, 0, not_negative) + ATTRIB(start-paused, false, bool) + ATTRIB(repeat-interval, 0, not_negative) + ATTRIB(repeat-times, 1, not_negative) + ATTRIB(max-time, -1, positive_or_neg_one) + ATTRIB(renderer,, any) + ATTRIB(voice,, any) +ELEMENT_END + +/** + * validation + */ +ELEMENT(RAYO_OUTPUT_SEEK) + STRING_ATTRIB(direction,, "forward,back") + ATTRIB(amount,-1, positive) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_PROMPT) + ATTRIB(barge-in, true, bool) +ELEMENT_END + +/** + * component validation + */ +ELEMENT(RAYO_RECORD) + ATTRIB(format, mp3, any) + ATTRIB(start-beep, false, bool) + ATTRIB(stop-beep, false, bool) + ATTRIB(start-paused, false, bool) + ATTRIB(max-duration, -1, positive_or_neg_one) + ATTRIB(initial-timeout, -1, positive_or_neg_one) + ATTRIB(final-timeout, -1, positive_or_neg_one) + STRING_ATTRIB(direction, duplex, "duplex,send,recv") + ATTRIB(mix, false, bool) +ELEMENT_END + +/** + * command validation + */ +ELEMENT(RAYO_JOIN) + /* for now, only allow duplex + STRING_ATTRIB(direction, duplex, "send,recv,duplex"); */ + STRING_ATTRIB(direction, duplex, "duplex") + STRING_ATTRIB(media, bridge, "bridge,direct") + ATTRIB(call-uri,, any) + ATTRIB(mixer-name,, any) +ELEMENT_END + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ + diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.h b/src/mod/event_handlers/mod_rayo/rayo_elements.h index be2d68d054..c780f160cf 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.h +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.h @@ -23,7 +23,7 @@ * Contributor(s): * Chris Rienzo * - * rayo_elements.h -- Rayo XML element definition + * rayo_elements.h -- Rayo XML elements * */ #ifndef RAYO_ELEMENTS_H @@ -31,80 +31,12 @@ #include "iks_helpers.h" -/** - * component validation - */ -ELEMENT(RAYO_INPUT) - STRING_ATTRIB(mode, any, "any,dtmf,voice") - ATTRIB(terminator,, any) - ATTRIB(recognizer,, any) - ATTRIB(language, en-US, any) - ATTRIB(initial-timeout, -1, positive_or_neg_one) - ATTRIB(inter-digit-timeout, -1, positive_or_neg_one) - ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one) - ATTRIB(min-confidence, 0, decimal_between_zero_and_one) - ATTRIB(max-silence, -1, positive_or_neg_one) - /* for now, only NLSML */ - STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml") - /* internal attribs for prompt support */ - ATTRIB(barge-event, false, bool) - ATTRIB(start-timers, true, bool) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_OUTPUT) - ATTRIB(start-offset, 0, not_negative) - ATTRIB(start-paused, false, bool) - ATTRIB(repeat-interval, 0, not_negative) - ATTRIB(repeat-times, 1, not_negative) - ATTRIB(max-time, -1, positive_or_neg_one) - ATTRIB(renderer,, any) - ATTRIB(voice,, any) -ELEMENT_END - -/** - * validation - */ -ELEMENT(RAYO_OUTPUT_SEEK) - STRING_ATTRIB(direction,, "forward,back") - ATTRIB(amount,-1, positive) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_PROMPT) - ATTRIB(barge-in, true, bool) -ELEMENT_END - -/** - * component validation - */ -ELEMENT(RAYO_RECORD) - ATTRIB(format, mp3, any) - ATTRIB(start-beep, false, bool) - ATTRIB(stop-beep, false, bool) - ATTRIB(start-paused, false, bool) - ATTRIB(max-duration, -1, positive_or_neg_one) - ATTRIB(initial-timeout, -1, positive_or_neg_one) - ATTRIB(final-timeout, -1, positive_or_neg_one) - STRING_ATTRIB(direction, duplex, "duplex,send,recv") - ATTRIB(mix, false, bool) -ELEMENT_END - -/** - * command validation - */ -ELEMENT(RAYO_JOIN) - /* for now, only allow duplex - STRING_ATTRIB(direction, duplex, "send,recv,duplex"); */ - STRING_ATTRIB(direction, duplex, "duplex") - STRING_ATTRIB(media, bridge, "bridge,direct") - ATTRIB(call-uri,, any) - ATTRIB(mixer-name,, any) -ELEMENT_END +ELEMENT_DECL(RAYO_INPUT) +ELEMENT_DECL(RAYO_OUTPUT) +ELEMENT_DECL(RAYO_OUTPUT_SEEK) +ELEMENT_DECL(RAYO_PROMPT) +ELEMENT_DECL(RAYO_RECORD) +ELEMENT_DECL(RAYO_JOIN) #endif From c10bdf1494ec99f582ae0ffd2bb71d4c98bf839c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Czu=C5=82ada?= Date: Fri, 2 Aug 2013 10:23:38 +0200 Subject: [PATCH 150/203] Describe patches related to JIRA issues --- docs/SubmittingPatches | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches index 4be7eaefca..d65e62bbb8 100644 --- a/docs/SubmittingPatches +++ b/docs/SubmittingPatches @@ -77,6 +77,21 @@ message might look like this: > After appropriate amounts of frobbing have been done, a new variable > `frobbing_done` is set in the caller's channel. +Patches related to JIRA issues +------------------------------ + +If your patch is related to an JIRA issue, you should add its name +(i.e. FS-555) to your commit message. You can also use some JIRA +directives, like '--resolve'. For example, if your patch fixes some +error reported by case FS-555, just add the following line somewhere +in your commit message: + +> FS-555 --resolve + +or modify the subject: + +> FS-555 --resolve Add frobinator support to mod_sofia + Where to Go for Help -------------------- From 5d363ac67ce546ca065ecc75800707dc381792e6 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 2 Aug 2013 14:37:54 +0000 Subject: [PATCH 151/203] Tweak style and content of last commit The directions here anticipate planned improvements to our JIRA bot to allow issues to be resolved by placing the JIRA directives in the body of the commit message. --- docs/SubmittingPatches | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches index d65e62bbb8..e839ff128d 100644 --- a/docs/SubmittingPatches +++ b/docs/SubmittingPatches @@ -76,21 +76,21 @@ message might look like this: > > After appropriate amounts of frobbing have been done, a new variable > `frobbing_done` is set in the caller's channel. +> +> FS-XXXX --resolve -Patches related to JIRA issues +Patches Related to JIRA Issues ------------------------------ -If your patch is related to an JIRA issue, you should add its name -(i.e. FS-555) to your commit message. You can also use some JIRA -directives, like '--resolve'. For example, if your patch fixes some -error reported by case FS-555, just add the following line somewhere -in your commit message: +When your patch is related to an issue logged in JIRA, add the +identifier for the issue (e.g. FS-XXXX) to the body of your commit +message at the beginning of a line, typically the last line or just +before "Signed-off-by:" and "Thanks-to:" lines. This helps our JIRA +bot do useful things by relating the commit to the issue. -> FS-555 --resolve - -or modify the subject: - -> FS-555 --resolve Add frobinator support to mod_sofia +If you believe your patch resolves the issue in question, follow the +issue number with a space and the "--resolve" directive as in the +example above. Where to Go for Help -------------------- From 85c986c8b4a5cad99e591c7b4e2ea590b5f19141 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 10:54:46 -0500 Subject: [PATCH 152/203] mod_skinny: add minimal handling of MeetMe button to send to a conference creation extension --- .../mod_skinny/conf/skinny_profiles/internal.xml | 1 + src/mod/endpoints/mod_skinny/mod_skinny.c | 9 +++++++++ src/mod/endpoints/mod_skinny/mod_skinny.h | 1 + src/mod/endpoints/mod_skinny/skinny_api.c | 1 + src/mod/endpoints/mod_skinny/skinny_server.c | 6 +++++- src/mod/endpoints/mod_skinny/skinny_tables.c | 2 +- src/mod/endpoints/mod_skinny/skinny_tables.h | 2 +- 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml b/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml index 39ce60fe4a..74cb86701b 100644 --- a/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml +++ b/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml @@ -14,6 +14,7 @@ + diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index dc83c47294..18b0f3c3f5 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -171,6 +171,7 @@ switch_status_t skinny_profile_dump(const skinny_profile_t *profile, switch_stre stream->write_function(stream, "Listener-Threads \t%d\n", profile->listener_threads); stream->write_function(stream, "Ext-Voicemail \t%s\n", profile->ext_voicemail); stream->write_function(stream, "Ext-Redial \t%s\n", profile->ext_redial); + stream->write_function(stream, "Ext-MeetMe \t%s\n", profile->ext_meetme); stream->write_function(stream, "%s\n", line); return SWITCH_STATUS_SUCCESS; @@ -1864,6 +1865,10 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c if (!profile->ext_redial || strcmp(val, profile->ext_redial)) { profile->ext_redial = switch_core_strdup(profile->pool, val); } + } else if (!strcasecmp(var, "ext-meetme")) { + if (!profile->ext_meetme || strcmp(val, profile->ext_meetme)) { + profile->ext_meetme = switch_core_strdup(profile->pool, val); + } } else { return SWITCH_STATUS_FALSE; } @@ -1956,6 +1961,10 @@ static switch_status_t load_skinny_config(void) skinny_profile_set(profile, "ext-redial", "redial"); } + if (!profile->ext_meetme) { + skinny_profile_set(profile, "ext-meetme", "conference"); + } + if (profile->port == 0) { profile->port = 2000; } diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index d8ed1b03bf..39faed4388 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -117,6 +117,7 @@ struct skinny_profile { /* extensions */ char *ext_voicemail; char *ext_redial; + char *ext_meetme; /* db */ char *dbname; char *odbc_dsn; diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c index 604b8509f7..94318c8de0 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.c +++ b/src/mod/endpoints/mod_skinny/skinny_api.c @@ -233,6 +233,7 @@ static switch_status_t skinny_api_list_settings(const char *line, const char *cu switch_console_push_match(&my_matches, "auto-restart"); switch_console_push_match(&my_matches, "ext-voicemail"); switch_console_push_match(&my_matches, "ext-redial"); + switch_console_push_match(&my_matches, "ext-meetme"); if (my_matches) { *matches = my_matches; diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 88db5b5347..a38005cdf6 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -76,7 +76,7 @@ uint32_t soft_key_template_default_events[] = { SOFTKEY_CONF, SOFTKEY_PARK, SOFTKEY_JOIN, - SOFTKEY_MEETMECONF, + SOFTKEY_MEETME, SOFTKEY_CALLPICKUP, SOFTKEY_GRPCALLPICKUP, SOFTKEY_DND, @@ -1928,6 +1928,10 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn } } break; + case SOFTKEY_MEETME: + skinny_create_incoming_session(listener, &line_instance, &session); + skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_meetme, '\0', 0); + break; default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown SoftKeyEvent type: %d.\n", request->data.soft_key_event.event); diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index 9f04f8cd63..ea29918cbb 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -239,7 +239,7 @@ SKINNY_DECLARE_STR2ID(skinny_str2button, SKINNY_BUTTONS, -1) {SOFTKEY_CONF, "SoftkeyConf"}, {SOFTKEY_PARK, "SoftkeyPark"}, {SOFTKEY_JOIN, "SoftkeyJoin"}, - {SOFTKEY_MEETMECONF, "SoftkeyMeetmeconfrm"}, + {SOFTKEY_MEETME, "SoftkeyMeetme"}, {SOFTKEY_CALLPICKUP, "SoftkeyCallpickup"}, {SOFTKEY_GRPCALLPICKUP, "SoftkeyGrpcallpickup"}, {SOFTKEY_DND, "SoftkeyDnd"}, diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index 1e35a7d208..647837f212 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -192,7 +192,7 @@ enum skinny_soft_key_event { SOFTKEY_CONF = 0x0D, SOFTKEY_PARK = 0x0E, SOFTKEY_JOIN = 0x0F, - SOFTKEY_MEETMECONF = 0x10, + SOFTKEY_MEETME = 0x10, SOFTKEY_CALLPICKUP = 0x11, SOFTKEY_GRPCALLPICKUP = 0x12, SOFTKEY_DND = 0x13, From d9905fa72b0c4851354b31e691774dc4cda8fec7 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 11:21:40 -0500 Subject: [PATCH 153/203] make default conf example work properly based on FS-5335 feedback/testing --- src/mod/endpoints/mod_skinny/conf/dialplan/skinny-patterns.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_skinny/conf/dialplan/skinny-patterns.xml b/src/mod/endpoints/mod_skinny/conf/dialplan/skinny-patterns.xml index b37d8eed82..69419f36c2 100644 --- a/src/mod/endpoints/mod_skinny/conf/dialplan/skinny-patterns.xml +++ b/src/mod/endpoints/mod_skinny/conf/dialplan/skinny-patterns.xml @@ -15,7 +15,7 @@ - + From e20dd10b59107ebe98a8378a2902de3525fb5744 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 13:53:29 -0500 Subject: [PATCH 154/203] mod_skinny: implement per device setting of ext- extensions --- .../conf/directory/default/skinny-example.xml | 7 ++++-- src/mod/endpoints/mod_skinny/mod_skinny.h | 9 +++++++ src/mod/endpoints/mod_skinny/skinny_server.c | 24 +++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml b/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml index 357eb72f12..8b8fad5812 100644 --- a/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml +++ b/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml @@ -2,8 +2,11 @@ diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 39faed4388..7c9dcdb314 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -35,6 +35,12 @@ #include +/*****************************************************************************/ +/* UTILITY MACROS */ +/*****************************************************************************/ +#define empty_null(a) ((a)?(a):NULL) +#define empty_null2(a,b) ((a)?(a):empty_null(b)) + /*****************************************************************************/ /* LOGGING FUNCTIONS */ /*****************************************************************************/ @@ -183,6 +189,9 @@ struct listener { uint32_t flags; time_t expire_time; struct listener *next; + char *ext_voicemail; + char *ext_redial; + char *ext_meetme; }; typedef struct listener listener_t; diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index a38005cdf6..b6aea308cd 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1034,6 +1034,18 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r strncpy(listener->firmware_version, value, 16); } else if (!strcasecmp(name, "skinny-soft-key-set-set")) { listener->soft_key_set_set = switch_core_strdup(profile->pool, value); + } else if (!strcasecmp(name, "ext-voicemail")) { + if (!listener->ext_voicemail || strcmp(value,listener->ext_voicemail)) { + listener->ext_voicemail = switch_core_strdup(profile->pool, value); + } + } else if (!strcasecmp(name, "ext-redial")) { + if (!listener->ext_redial || strcmp(value,listener->ext_redial)) { + listener->ext_redial = switch_core_strdup(profile->pool, value); + } + } else if (!strcasecmp(name, "ext-meetme")) { + if (!listener->ext_meetme || strcmp(value,listener->ext_meetme)) { + listener->ext_meetme = switch_core_strdup(profile->pool, value); + } } } } @@ -1267,7 +1279,8 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess switch(request->data.stimulus.instance_type) { case SKINNY_BUTTON_LAST_NUMBER_REDIAL: skinny_create_incoming_session(listener, &line_instance, &session); - skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_redial, '\0', 0); + skinny_session_process_dest(session, listener, line_instance, + empty_null2(listener->ext_redial,listener->profile->ext_redial), '\0', 0); break; case SKINNY_BUTTON_SPEED_DIAL: skinny_speed_dial_get(listener, request->data.stimulus.instance, &button_speed_dial); @@ -1296,7 +1309,8 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess break; case SKINNY_BUTTON_VOICEMAIL: skinny_create_incoming_session(listener, &line_instance, &session); - skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_voicemail, '\0', 0); + skinny_session_process_dest(session, listener, line_instance, + empty_null2(listener->ext_voicemail, listener->profile->ext_voicemail), '\0', 0); break; case SKINNY_BUTTON_LINE: @@ -1870,7 +1884,8 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn switch(request->data.soft_key_event.event) { case SOFTKEY_REDIAL: status = skinny_create_incoming_session(listener, &line_instance, &session); - skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_redial, '\0', 0); + skinny_session_process_dest(session, listener, line_instance, + empty_null2(listener->ext_redial,listener->profile->ext_redial), '\0', 0); break; case SOFTKEY_NEWCALL: status = skinny_create_incoming_session(listener, &line_instance, &session); @@ -1930,7 +1945,8 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn break; case SOFTKEY_MEETME: skinny_create_incoming_session(listener, &line_instance, &session); - skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_meetme, '\0', 0); + skinny_session_process_dest(session, listener, line_instance, + empty_null2(listener->ext_meetme, listener->profile->ext_meetme), '\0', 0); break; default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, From 1e3bfef390add3eb4f902b102fd74e8d1b6d0846 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 14:12:03 -0500 Subject: [PATCH 155/203] FS-5662 --resolve implement call pickup group functionality in mod_skinny. Currently treats callPickup and grpCallPickup identically, may revisit when I find out more about what's different between the two --- .../conf/directory/default/skinny-example.xml | 8 ++++++++ src/mod/endpoints/mod_skinny/mod_skinny.c | 9 +++++++++ src/mod/endpoints/mod_skinny/mod_skinny.h | 2 ++ src/mod/endpoints/mod_skinny/skinny_api.c | 1 + src/mod/endpoints/mod_skinny/skinny_server.c | 10 ++++++++++ 5 files changed, 30 insertions(+) diff --git a/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml b/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml index 8b8fad5812..c51b5ce9cf 100644 --- a/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml +++ b/src/mod/endpoints/mod_skinny/conf/directory/default/skinny-example.xml @@ -8,6 +8,14 @@ --> + + + + diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 18b0f3c3f5..ab4398a898 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -172,6 +172,7 @@ switch_status_t skinny_profile_dump(const skinny_profile_t *profile, switch_stre stream->write_function(stream, "Ext-Voicemail \t%s\n", profile->ext_voicemail); stream->write_function(stream, "Ext-Redial \t%s\n", profile->ext_redial); stream->write_function(stream, "Ext-MeetMe \t%s\n", profile->ext_meetme); + stream->write_function(stream, "Ext-PickUp \t%s\n", profile->ext_pickup); stream->write_function(stream, "%s\n", line); return SWITCH_STATUS_SUCCESS; @@ -1869,6 +1870,10 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c if (!profile->ext_meetme || strcmp(val, profile->ext_meetme)) { profile->ext_meetme = switch_core_strdup(profile->pool, val); } + } else if (!strcasecmp(var, "ext-pickup")) { + if (!profile->ext_pickup || strcmp(val, profile->ext_pickup)) { + profile->ext_pickup = switch_core_strdup(profile->pool, val); + } } else { return SWITCH_STATUS_FALSE; } @@ -1965,6 +1970,10 @@ static switch_status_t load_skinny_config(void) skinny_profile_set(profile, "ext-meetme", "conference"); } + if (!profile->ext_pickup) { + skinny_profile_set(profile, "ext-pickup", "pickup"); + } + if (profile->port == 0) { profile->port = 2000; } diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 7c9dcdb314..df876d0894 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -124,6 +124,7 @@ struct skinny_profile { char *ext_voicemail; char *ext_redial; char *ext_meetme; + char *ext_pickup; /* db */ char *dbname; char *odbc_dsn; @@ -192,6 +193,7 @@ struct listener { char *ext_voicemail; char *ext_redial; char *ext_meetme; + char *ext_pickup; }; typedef struct listener listener_t; diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c index 94318c8de0..db9338b000 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.c +++ b/src/mod/endpoints/mod_skinny/skinny_api.c @@ -234,6 +234,7 @@ static switch_status_t skinny_api_list_settings(const char *line, const char *cu switch_console_push_match(&my_matches, "ext-voicemail"); switch_console_push_match(&my_matches, "ext-redial"); switch_console_push_match(&my_matches, "ext-meetme"); + switch_console_push_match(&my_matches, "ext-pickup"); if (my_matches) { *matches = my_matches; diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index b6aea308cd..a1189b87f3 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1046,6 +1046,10 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r if (!listener->ext_meetme || strcmp(value,listener->ext_meetme)) { listener->ext_meetme = switch_core_strdup(profile->pool, value); } + } else if (!strcasecmp(name, "ext-pickup")) { + if (!listener->ext_pickup || strcmp(value,listener->ext_pickup)) { + listener->ext_pickup = switch_core_strdup(profile->pool, value); + } } } } @@ -1948,6 +1952,12 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn skinny_session_process_dest(session, listener, line_instance, empty_null2(listener->ext_meetme, listener->profile->ext_meetme), '\0', 0); break; + case SOFTKEY_CALLPICKUP: + case SOFTKEY_GRPCALLPICKUP: + skinny_create_incoming_session(listener, &line_instance, &session); + skinny_session_process_dest(session, listener, line_instance, + empty_null2(listener->ext_pickup, listener->profile->ext_pickup), '\0', 0); + break; default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown SoftKeyEvent type: %d.\n", request->data.soft_key_event.event); From 36726ee0ef0c8892cf122a503ce91bb3c030dfae Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 21:11:56 -0500 Subject: [PATCH 156/203] mod_skinny work on FS-5632 - first pass --- .../endpoints/mod_skinny/skinny_protocol.c | 260 ++++++++++-------- .../endpoints/mod_skinny/skinny_protocol.h | 19 +- src/mod/endpoints/mod_skinny/skinny_server.c | 88 +++--- 3 files changed, 198 insertions(+), 169 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 677c703b39..2de3b87e27 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -463,16 +463,15 @@ switch_status_t perform_send_keep_alive_ack(listener_t *listener, const char *file, const char *func, int line) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12); - message->type = KEEP_ALIVE_ACK_MESSAGE; - message->length = 4; + + skinny_create_empty_message(message, KEEP_ALIVE_ACK_MESSAGE); if ( listener->profile->debug >= 10 ) { skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Sending Keep Alive Ack%s\n", ""); } - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_register_ack(listener_t *listener, @@ -484,9 +483,9 @@ switch_status_t perform_send_register_ack(listener_t *listener, char *reserved2) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.reg_ack)); - message->type = REGISTER_ACK_MESSAGE; - message->length = 4 + sizeof(message->data.reg_ack); + + skinny_create_message(message, REGISTER_ACK_MESSAGE, reg_ack); + message->data.reg_ack.keep_alive = keep_alive; strncpy(message->data.reg_ack.date_format, date_format, 6); strncpy(message->data.reg_ack.reserved, reserved, 2); @@ -497,7 +496,7 @@ switch_status_t perform_send_register_ack(listener_t *listener, "Sending Register Ack with Keep Alive (%d), Date Format (%s), Secondary Keep Alive (%d)\n", keep_alive, date_format, secondary_keep_alive); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_speed_dial_stat_res(listener_t *listener, @@ -507,9 +506,8 @@ switch_status_t perform_send_speed_dial_stat_res(listener_t *listener, char *speed_label) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.speed_dial_res)); - message->type = SPEED_DIAL_STAT_RES_MESSAGE; - message->length = 4 + sizeof(message->data.speed_dial_res); + + skinny_create_message(message, SPEED_DIAL_STAT_RES_MESSAGE, speed_dial_res); message->data.speed_dial_res.number = number; strncpy(message->data.speed_dial_res.line, speed_line, 24); @@ -519,7 +517,7 @@ switch_status_t perform_send_speed_dial_stat_res(listener_t *listener, "Sending Speed Dial Stat Res with Number (%d), Line (%s), Label (%s)\n", number, speed_line, speed_label); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_start_tone(listener_t *listener, @@ -530,9 +528,9 @@ switch_status_t perform_send_start_tone(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.start_tone)); - message->type = START_TONE_MESSAGE; - message->length = 4 + sizeof(message->data.start_tone); + + skinny_create_message(message, START_TONE_MESSAGE, start_tone); + message->data.start_tone.tone = tone; message->data.start_tone.reserved = reserved; message->data.start_tone.line_instance = line_instance; @@ -542,7 +540,7 @@ switch_status_t perform_send_start_tone(listener_t *listener, "Sending Start Tone with Tone (%s), Line Instance (%d), Call ID (%d)\n", skinny_tone2str(tone), line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_stop_tone(listener_t *listener, @@ -551,16 +549,16 @@ switch_status_t perform_send_stop_tone(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.stop_tone)); - message->type = STOP_TONE_MESSAGE; - message->length = 4 + sizeof(message->data.stop_tone); + + skinny_create_message(message, STOP_TONE_MESSAGE, stop_tone); + message->data.stop_tone.line_instance = line_instance; message->data.stop_tone.call_id = call_id; skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Sending Stop Tone with Line Instance (%d), Call ID (%d)\n", line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_set_ringer(listener_t *listener, @@ -571,9 +569,9 @@ switch_status_t perform_send_set_ringer(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.ringer)); - message->type = SET_RINGER_MESSAGE; - message->length = 4 + sizeof(message->data.ringer); + + skinny_create_message(message, SET_RINGER_MESSAGE, ringer); + message->data.ringer.ring_type = ring_type; message->data.ringer.ring_mode = ring_mode; message->data.ringer.line_instance = line_instance; @@ -583,7 +581,7 @@ switch_status_t perform_send_set_ringer(listener_t *listener, "Sending SetRinger with Ring Type (%s), Mode (%s), Line Instance (%d), Call ID (%d)\n", skinny_ring_type2str(ring_type), skinny_ring_mode2str(ring_mode), line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_set_lamp(listener_t *listener, @@ -593,9 +591,9 @@ switch_status_t perform_send_set_lamp(listener_t *listener, uint32_t mode) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.lamp)); - message->type = SET_LAMP_MESSAGE; - message->length = 4 + sizeof(message->data.lamp); + + skinny_create_message(message, SET_LAMP_MESSAGE, lamp); + message->data.lamp.stimulus = stimulus; message->data.lamp.stimulus_instance = stimulus_instance; message->data.lamp.mode = mode; @@ -604,7 +602,7 @@ switch_status_t perform_send_set_lamp(listener_t *listener, "Sending Set Lamp with Stimulus (%s), Stimulus Instance (%d), Mode (%s)\n", skinny_button2str(stimulus), stimulus_instance, skinny_lamp_mode2str(mode)); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_set_speaker_mode(listener_t *listener, @@ -612,15 +610,15 @@ switch_status_t perform_send_set_speaker_mode(listener_t *listener, uint32_t mode) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.speaker_mode)); - message->type = SET_SPEAKER_MODE_MESSAGE; - message->length = 4 + sizeof(message->data.speaker_mode); + + skinny_create_message(message, SET_SPEAKER_MODE_MESSAGE, speaker_mode); + message->data.speaker_mode.mode = mode; skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Sending Set Speaker Mode with Mode (%s)\n", skinny_speaker_mode2str(mode)); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_srvreq_response(listener_t *listener, @@ -629,9 +627,7 @@ switch_status_t perform_send_srvreq_response(listener_t *listener, { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.serv_res_mess)); - message->type = SERVER_RESPONSE_MESSAGE; - message->length = 4 + sizeof(message->data.serv_res_mess); + skinny_create_message(message, SERVER_RESPONSE_MESSAGE, serv_res_mess); message->data.serv_res_mess.serverListenPort[0] = port; switch_inet_pton(AF_INET,ip, &message->data.serv_res_mess.serverIpAddr[0]); @@ -640,7 +636,7 @@ switch_status_t perform_send_srvreq_response(listener_t *listener, skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Sending Server Request Response with IP (%s) and Port (%d)\n", ip, port); - return skinny_send_reply(listener, message); + return skinny_send_reply(listener, message, SWITCH_TRUE); } switch_status_t perform_send_start_media_transmission(listener_t *listener, @@ -657,9 +653,9 @@ switch_status_t perform_send_start_media_transmission(listener_t *listener, uint32_t g723_bitrate) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.start_media)); - message->type = START_MEDIA_TRANSMISSION_MESSAGE; - message->length = 4 + sizeof(message->data.start_media); + + skinny_create_message(message, START_MEDIA_TRANSMISSION_MESSAGE, start_media); + message->data.start_media.conference_id = conference_id; message->data.start_media.pass_thru_party_id = pass_thru_party_id; message->data.start_media.remote_ip = remote_ip; @@ -676,7 +672,7 @@ switch_status_t perform_send_start_media_transmission(listener_t *listener, "Send Start Media Transmission with Conf ID(%d), Passthrough Party ID (%d), ...\n", conference_id, pass_thru_party_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_stop_media_transmission(listener_t *listener, @@ -686,9 +682,9 @@ switch_status_t perform_send_stop_media_transmission(listener_t *listener, uint32_t conference_id2) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.stop_media)); - message->type = STOP_MEDIA_TRANSMISSION_MESSAGE; - message->length = 4 + sizeof(message->data.stop_media); + + skinny_create_message(message, STOP_MEDIA_TRANSMISSION_MESSAGE, stop_media); + message->data.stop_media.conference_id = conference_id; message->data.stop_media.pass_thru_party_id = pass_thru_party_id; message->data.stop_media.conference_id2 = conference_id2; @@ -698,7 +694,7 @@ switch_status_t perform_send_stop_media_transmission(listener_t *listener, "Send Stop Media Transmission with Conf ID (%d), Passthrough Party ID (%d), Conf ID2 (%d)\n", conference_id, pass_thru_party_id, conference_id2); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_call_info(listener_t *listener, @@ -725,9 +721,9 @@ switch_status_t perform_send_call_info(listener_t *listener, uint32_t party_pi_restriction_bits) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.call_info)); - message->type = CALL_INFO_MESSAGE; - message->length = 4 + sizeof(message->data.call_info); + + skinny_create_message(message, CALL_INFO_MESSAGE, call_info); + strncpy(message->data.call_info.calling_party_name, calling_party_name, 40); strncpy(message->data.call_info.calling_party, calling_party, 24); strncpy(message->data.call_info.called_party_name, called_party_name, 40); @@ -752,7 +748,7 @@ switch_status_t perform_send_call_info(listener_t *listener, skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Call Info with Line Instance (%d)...\n", line_instance); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_define_time_date(listener_t *listener, @@ -768,9 +764,9 @@ switch_status_t perform_send_define_time_date(listener_t *listener, uint32_t timestamp) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.define_time_date)); - message->type = DEFINE_TIME_DATE_MESSAGE; - message->length = 4+sizeof(message->data.define_time_date); + + skinny_create_message(message, DEFINE_TIME_DATE_MESSAGE, define_time_date); + message->data.define_time_date.year = year; message->data.define_time_date.month = month; message->data.define_time_date.day_of_week = day_of_week; @@ -785,7 +781,7 @@ switch_status_t perform_send_define_time_date(listener_t *listener, "Send Define Time Date with %.4d-%.2d-%.2d %.2d:%.2d:%.2d.%d, Timestamp (%d), DOW (%d)\n", year, month, day, hour, minute, seconds, milliseconds, timestamp, day_of_week); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_define_current_time_date(listener_t *listener, @@ -812,14 +808,13 @@ switch_status_t perform_send_capabilities_req(listener_t *listener, const char *file, const char *func, int line) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12); - message->type = CAPABILITIES_REQ_MESSAGE; - message->length = 4; + + skinny_create_empty_message(message, CAPABILITIES_REQ_MESSAGE); skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Capabilities Req%s\n", ""); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_version(listener_t *listener, @@ -827,15 +822,15 @@ switch_status_t perform_send_version(listener_t *listener, char *version) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.version)); - message->type = VERSION_MESSAGE; - message->length = 4+ sizeof(message->data.version); + + skinny_create_message(message, VERSION_MESSAGE, version); + strncpy(message->data.version.version, version, 16); skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Version with Version(%s)\n", version); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_register_reject(listener_t *listener, @@ -843,15 +838,15 @@ switch_status_t perform_send_register_reject(listener_t *listener, char *error) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.reg_rej)); - message->type = REGISTER_REJECT_MESSAGE; - message->length = 4 + sizeof(message->data.reg_rej); + + skinny_create_message(message, REGISTER_REJECT_MESSAGE, reg_rej); + strncpy(message->data.reg_rej.error, error, 33); skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Register Reject with Error (%s)\n", error); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_open_receive_channel(listener_t *listener, @@ -866,9 +861,9 @@ switch_status_t perform_send_open_receive_channel(listener_t *listener, uint32_t reserved[10]) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.open_receive_channel)); - message->type = OPEN_RECEIVE_CHANNEL_MESSAGE; - message->length = 4 + sizeof(message->data.open_receive_channel); + + skinny_create_message(message, OPEN_RECEIVE_CHANNEL_MESSAGE, open_receive_channel); + message->data.open_receive_channel.conference_id = conference_id; message->data.open_receive_channel.pass_thru_party_id = pass_thru_party_id; message->data.open_receive_channel.ms_per_packet = ms_per_packet; @@ -892,7 +887,7 @@ switch_status_t perform_send_open_receive_channel(listener_t *listener, skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Open Receive Channel with Conf ID (%d), ...\n", conference_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_close_receive_channel(listener_t *listener, @@ -902,9 +897,9 @@ switch_status_t perform_send_close_receive_channel(listener_t *listener, uint32_t conference_id2) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.close_receive_channel)); - message->type = CLOSE_RECEIVE_CHANNEL_MESSAGE; - message->length = 4 + sizeof(message->data.close_receive_channel); + + skinny_create_message(message, CLOSE_RECEIVE_CHANNEL_MESSAGE, close_receive_channel); + message->data.close_receive_channel.conference_id = conference_id; message->data.close_receive_channel.pass_thru_party_id = pass_thru_party_id; message->data.close_receive_channel.conference_id2 = conference_id2; @@ -912,7 +907,7 @@ switch_status_t perform_send_close_receive_channel(listener_t *listener, skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Close Receive Channel with Conf ID (%d), ...\n", conference_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_select_soft_keys(listener_t *listener, @@ -923,9 +918,9 @@ switch_status_t perform_send_select_soft_keys(listener_t *listener, uint32_t valid_key_mask) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.select_soft_keys)); - message->type = SELECT_SOFT_KEYS_MESSAGE; - message->length = 4 + sizeof(message->data.select_soft_keys); + + skinny_create_message(message, SELECT_SOFT_KEYS_MESSAGE, select_soft_keys); + message->data.select_soft_keys.line_instance = line_instance; message->data.select_soft_keys.call_id = call_id; message->data.select_soft_keys.soft_key_set = soft_key_set; @@ -935,7 +930,7 @@ switch_status_t perform_send_select_soft_keys(listener_t *listener, "Send Select Soft Keys with Line Instance (%d), Call ID (%d), Soft Key Set (%d), Valid Key Mask (%x)\n", line_instance, call_id, soft_key_set, valid_key_mask); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_call_state(listener_t *listener, @@ -945,9 +940,9 @@ switch_status_t perform_send_call_state(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.call_state)); - message->type = CALL_STATE_MESSAGE; - message->length = 4 + sizeof(message->data.call_state); + + skinny_create_message(message, CALL_STATE_MESSAGE, call_state); + message->data.call_state.call_state = call_state; message->data.call_state.line_instance = line_instance; message->data.call_state.call_id = call_id; @@ -956,7 +951,7 @@ switch_status_t perform_send_call_state(listener_t *listener, "Send Call State with State (%s), Line Instance (%d), Call ID (%d)\n", skinny_call_state2str(call_state), line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_display_prompt_status(listener_t *listener, @@ -969,9 +964,8 @@ switch_status_t perform_send_display_prompt_status(listener_t *listener, skinny_message_t *message; char *tmp; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.display_prompt_status)); - message->type = DISPLAY_PROMPT_STATUS_MESSAGE; - message->length = 4 + sizeof(message->data.display_prompt_status); + skinny_create_message(message, DISPLAY_PROMPT_STATUS_MESSAGE, display_prompt_status); + message->data.display_prompt_status.timeout = timeout; strncpy(message->data.display_prompt_status.display, display, 32); message->data.display_prompt_status.line_instance = line_instance; @@ -985,7 +979,7 @@ switch_status_t perform_send_display_prompt_status(listener_t *listener, switch_safe_free(tmp); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_display_prompt_status_textid(listener_t *listener, @@ -997,9 +991,9 @@ switch_status_t perform_send_display_prompt_status_textid(listener_t *listener, { skinny_message_t *message; char *label; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.display_prompt_status)); - message->type = DISPLAY_PROMPT_STATUS_MESSAGE; - message->length = 4 + sizeof(message->data.display_prompt_status); + + skinny_create_message(message, DISPLAY_PROMPT_STATUS_MESSAGE, display_prompt_status); + message->data.display_prompt_status.timeout = timeout; label = skinny_textid2raw(display_textid); @@ -1013,7 +1007,7 @@ switch_status_t perform_send_display_prompt_status_textid(listener_t *listener, "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n", timeout, skinny_textid2str(display_textid), line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_clear_prompt_status(listener_t *listener, @@ -1022,9 +1016,9 @@ switch_status_t perform_send_clear_prompt_status(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.clear_prompt_status)); - message->type = CLEAR_PROMPT_STATUS_MESSAGE; - message->length = 4 + sizeof(message->data.clear_prompt_status); + + skinny_create_message(message, CLEAR_PROMPT_STATUS_MESSAGE, clear_prompt_status); + message->data.clear_prompt_status.line_instance = line_instance; message->data.clear_prompt_status.call_id = call_id; @@ -1032,7 +1026,7 @@ switch_status_t perform_send_clear_prompt_status(listener_t *listener, "Send Clear Prompt Status with Line Instance (%d), Call ID (%d)\n", line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_activate_call_plane(listener_t *listener, @@ -1040,15 +1034,15 @@ switch_status_t perform_send_activate_call_plane(listener_t *listener, uint32_t line_instance) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.activate_call_plane)); - message->type = ACTIVATE_CALL_PLANE_MESSAGE; - message->length = 4 + sizeof(message->data.activate_call_plane); + + skinny_create_message(message, ACTIVATE_CALL_PLANE_MESSAGE, activate_call_plane); + message->data.activate_call_plane.line_instance = line_instance; skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Activate Call Plane with Line Instance (%d)\n", line_instance); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_back_space_request(listener_t *listener, @@ -1057,9 +1051,9 @@ switch_status_t perform_send_back_space_request(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.back_space_req)); - message->type = BACK_SPACE_REQ_MESSAGE; - message->length = 4 + sizeof(message->data.back_space_req); + + skinny_create_message(message, BACK_SPACE_REQ_MESSAGE, back_space_req); + message->data.back_space_req.line_instance = line_instance; message->data.back_space_req.call_id = call_id; @@ -1067,7 +1061,7 @@ switch_status_t perform_send_back_space_request(listener_t *listener, "Send Back Space Request with Line Instance (%d), Call ID (%d)\n", line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } @@ -1078,9 +1072,9 @@ switch_status_t perform_send_dialed_number(listener_t *listener, uint32_t call_id) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.dialed_number)); - message->type = DIALED_NUMBER_MESSAGE; - message->length = 4 + sizeof(message->data.dialed_number); + + skinny_create_message(message, DIALED_NUMBER_MESSAGE, dialed_number); + strncpy(message->data.dialed_number.called_party, called_party, 24); message->data.dialed_number.line_instance = line_instance; message->data.dialed_number.call_id = call_id; @@ -1089,7 +1083,7 @@ switch_status_t perform_send_dialed_number(listener_t *listener, "Send Dialed Number with Number (%s), Line Instance (%d), Call ID (%d)\n", called_party, line_instance, call_id); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_display_pri_notify(listener_t *listener, @@ -1099,9 +1093,9 @@ switch_status_t perform_send_display_pri_notify(listener_t *listener, char *notify) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.display_pri_notify)); - message->type = DISPLAY_PRI_NOTIFY_MESSAGE; - message->length = 4 + sizeof(message->data.display_pri_notify); + + skinny_create_message(message, DISPLAY_PRI_NOTIFY_MESSAGE, display_pri_notify); + message->data.display_pri_notify.message_timeout = message_timeout; message->data.display_pri_notify.priority = priority; strncpy(message->data.display_pri_notify.notify, notify, 32); @@ -1110,7 +1104,7 @@ switch_status_t perform_send_display_pri_notify(listener_t *listener, "Send Display Pri Notify with Timeout (%d), Priority (%d), Message (%s)\n", message_timeout, priority, notify); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } @@ -1119,15 +1113,15 @@ switch_status_t perform_send_reset(listener_t *listener, uint32_t reset_type) { skinny_message_t *message; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.reset)); - message->type = RESET_MESSAGE; - message->length = 4 + sizeof(message->data.reset); + + skinny_create_message(message, RESET_MESSAGE, reset); + message->data.reset.reset_type = reset_type; skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Reset with Type (%s)\n", skinny_device_reset_type2str(reset_type)); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_data(listener_t *listener, @@ -1142,13 +1136,17 @@ switch_status_t perform_send_data(listener_t *listener, { skinny_message_t *message; switch_assert(data_length == strlen(data)); + /* data_length should be a multiple of 4 */ if ((data_length % 4) != 0) { data_length = (data_length / 4 + 1) * 4; } - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.data)+data_length-1); + + /* This one needs explicit allocation */ + message = calloc(12+sizeof(message->data.data)+data_length-1, 1); message->type = message_type; message->length = 4 + sizeof(message->data.data)+data_length-1; + message->data.data.application_id = application_id; message->data.data.line_instance = line_instance; message->data.data.call_id = call_id; @@ -1159,7 +1157,7 @@ switch_status_t perform_send_data(listener_t *listener, skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, "Send Data with Data Length (%d)\n", data_length); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } switch_status_t perform_send_extended_data(listener_t *listener, @@ -1179,13 +1177,17 @@ switch_status_t perform_send_extended_data(listener_t *listener, { skinny_message_t *message; switch_assert(data_length == strlen(data)); + /* data_length should be a multiple of 4 */ if ((data_length % 4) != 0) { data_length = (data_length / 4 + 1) * 4; } - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.extended_data)+data_length-1); + + /* This one needs explicit allocation */ + message = calloc(12+sizeof(message->data.extended_data)+data_length-1, 1); message->type = message_type; message->length = 4 + sizeof(message->data.extended_data)+data_length-1; + message->data.extended_data.application_id = application_id; message->data.extended_data.line_instance = line_instance; message->data.extended_data.call_id = call_id; @@ -1202,32 +1204,45 @@ switch_status_t perform_send_extended_data(listener_t *listener, "Send Extended Data with Application ID (%d), Line Instance (%d), Call ID (%d), ...\n", application_id, line_instance, call_id ); - return skinny_send_reply_quiet(listener, message); + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } -switch_status_t skinny_perform_send_reply_quiet(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply) +switch_status_t skinny_perform_send_reply_quiet(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply, + switch_bool_t discard) { char *ptr; switch_size_t len; + switch_status_t res; + switch_assert(reply != NULL); + len = reply->length+8; ptr = (char *) reply; if (listener_is_ready(listener)) { - return switch_socket_send(listener->sock, ptr, &len); + res = switch_socket_send(listener->sock, ptr, &len); + + if ( discard ) { switch_safe_free(reply); } + return res; } else { skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_WARNING, "Not sending %s (type=%x,length=%d) while not ready.\n", skinny_message_type2str(reply->type), reply->type, reply->length); + + if ( discard ) { switch_safe_free(reply); } return SWITCH_STATUS_FALSE; } } -switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply) +switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply, + switch_bool_t discard) { char *ptr; switch_size_t len; + switch_status_t res; + switch_assert(reply != NULL); + len = reply->length+8; ptr = (char *) reply; @@ -1237,11 +1252,16 @@ switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file "Sending %s (type=%x,length=%d).\n", skinny_message_type2str(reply->type), reply->type, reply->length); } - return switch_socket_send(listener->sock, ptr, &len); + res = switch_socket_send(listener->sock, ptr, &len); + + if ( discard ) { switch_safe_free(reply); } + return res; } else { skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_WARNING, "Not sending %s (type=%x,length=%d) while not ready.\n", skinny_message_type2str(reply->type), reply->type, reply->length); + + if ( discard ) { switch_safe_free(reply); } return SWITCH_STATUS_FALSE; } } diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 2fe1336aa6..43b2502e81 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -87,6 +87,17 @@ char* skinny_codec2string(skinny_codecs skinnycodec); /* SKINNY MESSAGE DATA */ /*****************************************************************************/ +#define skinny_create_message(message,msgtype,field) \ + message = calloc(12 + sizeof(message->data.field), 1); \ + message->type = msgtype; \ + message->length = 4 + sizeof(message->data.field) + +#define skinny_create_empty_message(message,msgtype) \ + message = calloc(12, 1); \ + message->type = msgtype; \ + message->length = 4 + + /* KeepAliveMessage */ #define KEEP_ALIVE_MESSAGE 0x0000 @@ -955,11 +966,11 @@ void skinny_speed_dial_get(listener_t *listener, uint32_t instance, struct speed void skinny_service_url_get(listener_t *listener, uint32_t instance, struct service_url_stat_res_message **button); void skinny_feature_get(listener_t *listener, uint32_t instance, struct feature_stat_res_message **button); -switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply); -#define skinny_send_reply(listener, reply) skinny_perform_send_reply(listener, __FILE__, __SWITCH_FUNC__, __LINE__, reply) +switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply, switch_bool_t discard); +#define skinny_send_reply(listener, reply, discard) skinny_perform_send_reply(listener, __FILE__, __SWITCH_FUNC__, __LINE__, reply, discard) -switch_status_t skinny_perform_send_reply_quiet(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply); -#define skinny_send_reply_quiet(listener, reply) skinny_perform_send_reply_quiet(listener, __FILE__, __SWITCH_FUNC__, __LINE__, reply) +switch_status_t skinny_perform_send_reply_quiet(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply, switch_bool_t discard); +#define skinny_send_reply_quiet(listener, reply, discard) skinny_perform_send_reply_quiet(listener, __FILE__, __SWITCH_FUNC__, __LINE__, reply, discard) switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request); diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index a1189b87f3..193b26a36f 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -58,8 +58,6 @@ uint32_t soft_key_template_default_textids[] = { SKINNY_TEXTID_IDIVERT }; -#define TEXT_ID_LEN 20 - uint32_t soft_key_template_default_events[] = { SOFTKEY_REDIAL, SOFTKEY_NEWCALL, @@ -1440,15 +1438,13 @@ switch_status_t skinny_handle_forward_stat_req_message(listener_t *listener, ski skinny_check_data_length(request, sizeof(request->data.forward_stat_req)); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.forward_stat)); - message->type = FORWARD_STAT_MESSAGE; - message->length = 4 + sizeof(message->data.forward_stat); + skinny_create_message(message, FORWARD_STAT_MESSAGE, forward_stat); message->data.forward_stat.line_instance = request->data.forward_stat_req.line_instance; skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Forward Stat Req Message with Line Instance (%d)\n", request->data.forward_stat_req.line_instance); - skinny_send_reply_quiet(listener, message); + skinny_send_reply_quiet(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -1475,15 +1471,13 @@ switch_status_t skinny_handle_line_stat_request(listener_t *listener, skinny_mes skinny_check_data_length(request, sizeof(request->data.line_req)); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.line_res)); - message->type = LINE_STAT_RES_MESSAGE; - message->length = 4 + sizeof(message->data.line_res); + skinny_create_message(message, LINE_STAT_RES_MESSAGE, line_res); skinny_line_get(listener, request->data.line_req.number, &button); memcpy(&message->data.line_res, button, sizeof(struct line_stat_res_message)); - skinny_send_reply(listener, message); + skinny_send_reply(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -1521,9 +1515,7 @@ switch_status_t skinny_handle_config_stat_request(listener_t *listener, skinny_m profile = listener->profile; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.config_res)); - message->type = CONFIG_STAT_RES_MESSAGE; - message->length = 4 + sizeof(message->data.config_res); + skinny_create_message(message, CONFIG_STAT_RES_MESSAGE, config_res); if ((sql = switch_mprintf( "SELECT name, user_id, instance, '' AS user_name, '' AS server_name, " @@ -1540,7 +1532,7 @@ switch_status_t skinny_handle_config_stat_request(listener_t *listener, skinny_m skinny_execute_sql_callback(profile, profile->sql_mutex, sql, skinny_config_stat_res_callback, message); switch_safe_free(sql); } - skinny_send_reply(listener, message); + skinny_send_reply(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -1591,9 +1583,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin profile = listener->profile; - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.button_template)); - message->type = BUTTON_TEMPLATE_RES_MESSAGE; - message->length = 4 + sizeof(message->data.button_template); + skinny_create_message(message, BUTTON_TEMPLATE_RES_MESSAGE, button_template); message->data.button_template.button_offset = 0; message->data.button_template.button_count = 0; @@ -1636,9 +1626,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin } } - - - return skinny_send_reply(listener, message);; + return skinny_send_reply(listener, message, SWITCH_TRUE); } switch_status_t skinny_handle_version_request(listener_t *listener, skinny_message_t *request) @@ -1855,7 +1843,7 @@ switch_status_t skinny_handle_soft_key_set_request(listener_t *listener, skinny_ skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Set Request with Set (%s)\n", "default"); } if (message) { - skinny_send_reply(listener, message); + skinny_send_reply_quiet(listener, message, SWITCH_FALSE); } else { skinny_log_l(listener, SWITCH_LOG_ERROR, "Profile %s doesn't have a default .\n", listener->profile->name); @@ -1979,14 +1967,13 @@ switch_status_t skinny_handle_unregister(listener_t *listener, skinny_message_t skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_UNREGISTER); switch_event_fire(&event); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.unregister_ack)); - message->type = UNREGISTER_ACK_MESSAGE; - message->length = 4 + sizeof(message->data.unregister_ack); + skinny_create_message(message, UNREGISTER_ACK_MESSAGE, unregister_ack); + message->data.unregister_ack.unregister_status = 0; /* OK */ skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Unregister with Status (%d)\n", message->data.unregister_ack.unregister_status); - skinny_send_reply_quiet(listener, message); + skinny_send_reply_quiet(listener, message, SWITCH_TRUE); /* Close socket */ switch_clear_flag_locked(listener, LFLAG_RUNNING); @@ -2005,18 +1992,15 @@ switch_status_t skinny_handle_soft_key_template_request(listener_t *listener, sk switch_assert(listener->profile); switch_assert(listener->device_name); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.soft_key_template)); - message->type = SOFT_KEY_TEMPLATE_RES_MESSAGE; - message->length = 4 + sizeof(message->data.soft_key_template); + skinny_create_message(message, SOFT_KEY_TEMPLATE_RES_MESSAGE, soft_key_template); message->data.soft_key_template.soft_key_offset = 0; message->data.soft_key_template.soft_key_count = 21; message->data.soft_key_template.total_soft_key_count = 21; - memset(message->data.soft_key_template.soft_key, 0, sizeof(message->data.soft_key_template)); - for (i=0; i< TEXT_ID_LEN; i++) { + for (i=0; i < sizeof(soft_key_template_default_textids)/4; i++) { char *label = skinny_textid2raw(soft_key_template_default_textids[i]); - strcpy(message->data.soft_key_template.soft_key[i].soft_key_label, skinny_textid2raw(soft_key_template_default_textids[i])); + strncpy(message->data.soft_key_template.soft_key[i].soft_key_label, label, sizeof(message->data.soft_key_template.soft_key[i].soft_key_label)); switch_safe_free(label); message->data.soft_key_template.soft_key[i].soft_key_event = soft_key_template_default_events[i]; @@ -2024,7 +2008,7 @@ switch_status_t skinny_handle_soft_key_template_request(listener_t *listener, sk skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Template Request with Default Template\n"); - skinny_send_reply_quiet(listener, message); + skinny_send_reply_quiet(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -2077,12 +2061,16 @@ switch_status_t skinny_handle_data_message(listener_t *listener, skinny_message_ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Call-Id", "%d", request->data.data.call_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Transaction-Id", "%d", request->data.data.transaction_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Data-Length", "%d", request->data.data.data_length); - /* Ensure that the body is null-terminated */ + tmp = malloc(request->data.data.data_length + 1); memcpy(tmp, request->data.data.data, request->data.data.data_length); + + /* Ensure that the body is null-terminated */ tmp[request->data.data.data_length] = '\0'; switch_event_add_body(event, "%s", tmp); + switch_safe_free(tmp); + switch_event_fire(&event); return SWITCH_STATUS_SUCCESS; @@ -2095,15 +2083,13 @@ switch_status_t skinny_handle_service_url_stat_request(listener_t *listener, ski skinny_check_data_length(request, sizeof(request->data.service_url_req)); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.service_url_res)); - message->type = SERVICE_URL_STAT_RES_MESSAGE; - message->length = 4 + sizeof(message->data.service_url_res); + skinny_create_message(message, SERVICE_URL_STAT_RES_MESSAGE, service_url_res); skinny_service_url_get(listener, request->data.service_url_req.service_url_index, &button); memcpy(&message->data.service_url_res, button, sizeof(struct service_url_stat_res_message)); - skinny_send_reply(listener, message); + skinny_send_reply(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -2115,15 +2101,13 @@ switch_status_t skinny_handle_feature_stat_request(listener_t *listener, skinny_ skinny_check_data_length(request, sizeof(request->data.feature_req)); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.feature_res)); - message->type = FEATURE_STAT_RES_MESSAGE; - message->length = 4 + sizeof(message->data.feature_res); + skinny_create_message(message, FEATURE_STAT_RES_MESSAGE, feature_res); skinny_feature_get(listener, request->data.feature_req.feature_index, &button); memcpy(&message->data.feature_res, button, sizeof(struct feature_stat_res_message)); - skinny_send_reply(listener, message); + skinny_send_reply(listener, message, SWITCH_TRUE); return SWITCH_STATUS_SUCCESS; } @@ -2149,32 +2133,46 @@ switch_status_t skinny_handle_extended_data_message(listener_t *listener, skinny switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Conference-Id", "%d", request->data.extended_data.conference_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-App-Instance-Id", "%d", request->data.extended_data.app_instance_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Routing-Id", "%d", request->data.extended_data.routing_id); - /* Ensure that the body is null-terminated */ + tmp = malloc(request->data.data.data_length + 1); memcpy(tmp, request->data.data.data, request->data.data.data_length); + + /* Ensure that the body is null-terminated */ tmp[request->data.data.data_length] = '\0'; switch_event_add_body(event, "%s", tmp); + switch_safe_free(tmp); switch_event_fire(&event); return SWITCH_STATUS_SUCCESS; } + switch_status_t skinny_handle_dialed_phone_book_message(listener_t *listener, skinny_message_t *request) { skinny_message_t *message; skinny_check_data_length(request, sizeof(request->data.dialed_phone_book)); - message = switch_core_alloc(listener->pool, 12+sizeof(message->data.dialed_phone_book_ack)); - message->type = DIALED_PHONE_BOOK_ACK_MESSAGE; - message->length = 4 + sizeof(message->data.dialed_phone_book_ack); + skinny_create_message(message, DIALED_PHONE_BOOK_ACK_MESSAGE, dialed_phone_book_ack); + message->data.dialed_phone_book_ack.number_index = request->data.dialed_phone_book.number_index; message->data.dialed_phone_book_ack.line_instance = request->data.dialed_phone_book.line_instance; message->data.dialed_phone_book_ack.unknown = request->data.dialed_phone_book.unknown; message->data.dialed_phone_book_ack.unknown2 = 0; +#if 0 + /* Not sure why this isn't being sent at this point, need to investigate */ + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Sending Handle Dialed Phone Book Ack Message with Number Index (%d), Line Instance (%d)\n", + request->data.dialed_phone_book.number_index, request->data.dialed_phone_book.line_instance); + + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); +#else + switch_safe_free(message); return SWITCH_STATUS_SUCCESS; +#endif } + switch_status_t skinny_handle_accessory_status_message(listener_t *listener, skinny_message_t *request) { char *sql; From fa2530306f5d9d98eb79d75a4d73a30dd250ab57 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 2 Aug 2013 21:25:51 -0500 Subject: [PATCH 157/203] mod_skinny work on FS-5632 - few more cases --- src/mod/endpoints/mod_skinny/mod_skinny.c | 4 +++- src/mod/endpoints/mod_skinny/skinny_protocol.c | 10 +++++++++- src/mod/endpoints/mod_skinny/skinny_server.c | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index ab4398a898..13a94810f8 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1604,9 +1604,11 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) if (skinny_handle_request(listener, request) != SWITCH_STATUS_SUCCESS) { switch_clear_flag_locked(listener, LFLAG_RUNNING); + switch_safe_free(request); break; + } else { + switch_safe_free(request); } - } remove_listener(listener); diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 2de3b87e27..ce756da34a 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -110,7 +110,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) char *ptr; switch_status_t status = SWITCH_STATUS_SUCCESS; - request = switch_core_alloc(listener->pool, SKINNY_MESSAGE_MAXSIZE); + request = calloc(SKINNY_MESSAGE_MAXSIZE,1); if (!request) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate memory.\n"); @@ -122,6 +122,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) while (listener_is_ready(listener)) { uint8_t do_sleep = 1; if (listener->expire_time && listener->expire_time < switch_epoch_time_now(NULL)) { + switch_safe_free(request); return SWITCH_STATUS_TIMEOUT; } if(bytes < SKINNY_MESSAGE_FIELD_SIZE) { @@ -135,6 +136,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) status = switch_socket_recv(listener->sock, ptr, &mlen); if (listener->expire_time && listener->expire_time < switch_epoch_time_now(NULL)) { + switch_safe_free(request); return SWITCH_STATUS_TIMEOUT; } @@ -143,6 +145,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) } if (!switch_status_is_timeup(status) && !SWITCH_STATUS_IS_BREAK(status) && (status != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Socket break with status=%d.\n", status); + switch_safe_free(request); return SWITCH_STATUS_FALSE; } @@ -162,17 +165,20 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Skinny client sent invalid data. Length should be greater than 4 but got %d.\n", request->length); + switch_safe_free(request); return SWITCH_STATUS_FALSE; } if(request->length + 2*SKINNY_MESSAGE_FIELD_SIZE > SKINNY_MESSAGE_MAXSIZE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Skinny client sent too huge data. Got %d which is above threshold %d.\n", request->length, SKINNY_MESSAGE_MAXSIZE - 2*SKINNY_MESSAGE_FIELD_SIZE); + switch_safe_free(request); return SWITCH_STATUS_FALSE; } if(bytes >= request->length + 2*SKINNY_MESSAGE_FIELD_SIZE) { /* Message body */ *req = request; + /* Do not free here, caller needs to do it */ return SWITCH_STATUS_SUCCESS; } } @@ -181,6 +187,8 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req) switch_cond_next(); } } + + switch_safe_free(request); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 193b26a36f..dff09844e7 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1687,7 +1687,11 @@ switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny } i = 0; pos = 0; - codec_string = switch_core_alloc(listener->pool, string_len+1); + codec_string = calloc(string_len+1,1); + if ( !codec_string ) { + skinny_log_l_msg(listener, SWITCH_LOG_ERROR, "Unable to allocate memory for codec string.\n"); + return SWITCH_STATUS_FALSE; + } for (string_pos = 0; string_pos < string_len; string_pos++) { char *codec = codec_order[i]; switch_assert(i < n); @@ -1709,6 +1713,7 @@ switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny switch_safe_free(sql); } skinny_log_l(listener, SWITCH_LOG_DEBUG, "Codecs %s supported.\n", codec_string); + switch_safe_free(codec_string); return SWITCH_STATUS_SUCCESS; } From 03dc7082b20b08bdf0681dd670f8561819f01d27 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 3 Aug 2013 18:49:55 +0500 Subject: [PATCH 158/203] FS-5664 --resolve --- src/switch_core_sqldb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 262aa14d15..510da35699 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -393,6 +393,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h const char *db_name = NULL; const char *odbc_user = NULL; const char *odbc_pass = NULL; + const char *db_type = NULL; while(runtime.max_db_handles && sql_manager.total_handles >= runtime.max_db_handles && sql_manager.total_used_handles >= sql_manager.total_handles) { if (!waiting++) { @@ -416,12 +417,14 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h db_name = connection_options->pgsql_options.dsn; odbc_user = NULL; odbc_pass = NULL; + db_type = "pgsql"; } case SCDB_TYPE_ODBC: { db_name = connection_options->odbc_options.dsn; odbc_user = connection_options->odbc_options.user; odbc_pass = connection_options->odbc_options.pass; + db_type = "odbc"; } break; case SCDB_TYPE_CORE_DB: @@ -429,6 +432,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h db_name = connection_options->core_db_options.db_path; odbc_user = NULL; odbc_pass = NULL; + db_type = "core_db"; } break; } @@ -438,9 +442,9 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h } if (odbc_user || odbc_pass) { - snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\";user=\"%s\";pass=\"%s\"", db_name, odbc_user, odbc_pass); + snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\";type=\"%s\"user=\"%s\";pass=\"%s\"", db_name, db_type, odbc_user, odbc_pass); } else { - snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\"", db_name); + snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\",type=\"%s\"", db_name, db_type); } snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line); snprintf(thread_str, sizeof(thread_str) - 1, "thread=\"%lu\"", (unsigned long) (intptr_t) self); From 92a99c4141710d08fb8de2b26d3ca4c6af2a0427 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 29 Jul 2013 20:04:32 +0800 Subject: [PATCH 159/203] add ws --- src/mod/xml_int/mod_xml_rpc/ws.c | 771 +++++++++++++++++++++++++++++++ src/mod/xml_int/mod_xml_rpc/ws.h | 99 ++++ 2 files changed, 870 insertions(+) create mode 100644 src/mod/xml_int/mod_xml_rpc/ws.c create mode 100644 src/mod/xml_int/mod_xml_rpc/ws.h diff --git a/src/mod/xml_int/mod_xml_rpc/ws.c b/src/mod/xml_int/mod_xml_rpc/ws.c new file mode 100644 index 0000000000..35fb4c0f22 --- /dev/null +++ b/src/mod/xml_int/mod_xml_rpc/ws.c @@ -0,0 +1,771 @@ +#include "ws.h" +#include + +#ifndef _MSC_VER +#include +#endif + +#define SHA1_HASH_SIZE 20 +struct globals_s globals; + +#ifndef WSS_STANDALONE + +void init_ssl(void) +{ + SSL_library_init(); +} +void deinit_ssl(void) +{ + return; +} + +#else +static unsigned long pthreads_thread_id(void); +static void pthreads_locking_callback(int mode, int type, const char *file, int line); + +static pthread_mutex_t *lock_cs; +static long *lock_count; + + + +static void thread_setup(void) +{ + int i; + + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); + + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_count[i] = 0; + pthread_mutex_init(&(lock_cs[i]), NULL); + } + + CRYPTO_set_id_callback(pthreads_thread_id); + CRYPTO_set_locking_callback(pthreads_locking_callback); +} + +static void thread_cleanup(void) +{ + int i; + + CRYPTO_set_locking_callback(NULL); + + for (i=0; i buflen - 1) { + cplen = buflen -1; + } else { + cplen = len; + } + + strncpy(buf, v, cplen); + *(buf+cplen) = '\0'; + return 1; + } + + } + } + return 0; +} + +static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen) +{ + int y=0,bytes=0; + size_t x=0; + unsigned int b=0,l=0; + + if(olen) { + } + + for(x=0;x= 6) { + out[bytes++] = c64[(b>>(l-=6))%64]; + if(++y!=72) { + continue; + } + //out[bytes++] = '\n'; + y=0; + } + } + + if (l > 0) { + out[bytes++] = c64[((b%16)<<(6-l))%64]; + } + if (l != 0) while (l < 6) { + out[bytes++] = '=', l += 2; + } + + return 0; +} + +#ifdef NO_OPENSSL +static void sha1_digest(char *digest, unsigned char *in) +{ + SHA1Context sha; + char *p; + int x; + + + SHA1Init(&sha); + SHA1Update(&sha, in, strlen(in)); + SHA1Final(&sha, digest); +} +#else + +static void sha1_digest(unsigned char *digest, char *in) +{ + SHA_CTX sha; + + SHA1_Init(&sha); + SHA1_Update(&sha, in, strlen(in)); + SHA1_Final(digest, &sha); + +} + +#endif + +int ws_handshake(wsh_t *wsh) +{ + char key[256] = ""; + char version[5] = ""; + char proto[256] = ""; + char uri[256] = ""; + char input[256] = ""; + unsigned char output[SHA1_HASH_SIZE] = ""; + char b64[256] = ""; + char respond[512] = ""; + issize_t bytes; + char *p, *e = 0; + + if (wsh->sock == ws_sock_invalid) { + return -3; + } + + while((bytes = ws_raw_read(wsh, wsh->buffer + wsh->datalen, wsh->buflen - wsh->datalen)) > 0) { + wsh->datalen += bytes; + if (strstr(wsh->buffer, "\r\n\r\n") || strstr(wsh->buffer, "\n\n")) { + break; + } + } + + if (bytes > sizeof(wsh->buffer)) { + goto err; + } + + *(wsh->buffer+bytes) = '\0'; + + if (strncasecmp(wsh->buffer, "GET ", 4)) { + goto err; + } + + p = wsh->buffer + 4; + + e = strchr(p, ' '); + if (!e) { + goto err; + } + + strncpy(uri, p, e-p); + + cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key)); + cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version)); + cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto)); + + if (!*key) { + goto err; + } + + snprintf(input, sizeof(input), "%s%s", key, WEBSOCKET_GUID); + sha1_digest(output, input); + b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64)); + + snprintf(respond, sizeof(respond), + "HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Accept: %s\r\n" + "Sec-WebSocket-Protocol: %s\r\n\r\n", + b64, + proto); + + + ws_raw_write(wsh, respond, strlen(respond)); + wsh->handshake = 1; + + return 0; + + err: + + snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n" + "Sec-WebSocket-Version: 13\r\n\r\n"); + + //printf("ERR:\n%s\n", respond); + + + ws_raw_write(wsh, respond, strlen(respond)); + + ws_close(wsh, WS_NONE); + + return -1; + +} + +issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes) +{ + issize_t r; + int x = 0; + + if (wsh->ssl) { + do { + r = SSL_read(wsh->ssl, data, bytes); +#ifndef _MSC_VER + if (x++) usleep(10000); +#else + if (x++) Sleep(10); +#endif + } while (r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_READ && x < 100); + + return r; + } + + do { + r = recv(wsh->sock, data, bytes, 0); +#ifndef _MSC_VER + if (x++) usleep(10000); +#else + if (x++) Sleep(10); +#endif + } while (r == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK || + errno == 35 || errno == 730035 || errno == 2 || errno == 60) && x < 100); + + if (x >= 100) { + r = -1; + } + + return r; +} + +issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes) +{ + size_t r; + + if (wsh->ssl) { + do { + r = SSL_write(wsh->ssl, data, bytes); + } while (r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_WRITE); + + return r; + } + + do { + r = send(wsh->sock, data, bytes, 0); + } while (r == -1 && (errno == EAGAIN || errno == EINTR)); + + //if (r<0) { + //printf("wRITE FAIL: %s\n", strerror(errno)); + //} + + return r; +} + +#ifdef _MSC_VER +static int setup_socket(ws_socket_t sock) +{ + unsigned long v = 1; + + if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR) { + return -1; + } + + return 0; + +} + +static int restore_socket(ws_socket_t sock) +{ + unsigned long v = 0; + + if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR) { + return -1; + } + + return 0; + +} + +#else + +static int setup_socket(ws_socket_t sock) +{ + int flags = fcntl(sock, F_GETFL, 0); + return fcntl(sock, F_SETFL, flags | O_NONBLOCK); +} + +static int restore_socket(ws_socket_t sock) +{ + int flags = fcntl(sock, F_GETFL, 0); + + flags &= ~O_NONBLOCK; + + return fcntl(sock, F_SETFL, flags); + +} + +#endif + + + +int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) +{ + memset(wsh, 0, sizeof(*wsh)); + wsh->sock = sock; + + if (!ssl_ctx) { + ssl_ctx = globals.ssl_ctx; + } + + if (close_sock) { + wsh->close_sock = 1; + } + + wsh->buflen = sizeof(wsh->buffer); + wsh->secure = ssl_ctx ? 1 : 0; + + setup_socket(sock); + + if (wsh->secure) { + int code; + int sanity = 500; + + wsh->ssl = SSL_new(ssl_ctx); + assert(wsh->ssl); + + SSL_set_fd(wsh->ssl, wsh->sock); + + do { + code = SSL_accept(wsh->ssl); + + if (code == 1) { + break; + } + + if (code == 0) { + return -1; + } + + if (code < 0) { + if (code == -1 && SSL_get_error(wsh->ssl, code) != SSL_ERROR_WANT_READ) { + return -1; + } + } +#ifndef _MSC_VER + usleep(10000); +#else + Sleep(10); +#endif + + } while (--sanity > 0); + + if (!sanity) { + return -1; + } + + } + + while (!wsh->down && !wsh->handshake) { + int r = ws_handshake(wsh); + + if (r < 0) { + wsh->down = 1; + return -1; + } + } + + if (wsh->down) { + return -1; + } + + return 0; +} + +void ws_destroy(wsh_t *wsh) +{ + + if (!wsh) { + return; + } + + if (!wsh->down) { + ws_close(wsh, WS_NONE); + } + + if (wsh->down > 1) { + return; + } + + wsh->down = 2; + + if (wsh->ssl) { + int code; + do { + code = SSL_shutdown(wsh->ssl); + } while (code == -1 && SSL_get_error(wsh->ssl, code) == SSL_ERROR_WANT_READ); + + SSL_free(wsh->ssl); + wsh->ssl = NULL; + } +} + +issize_t ws_close(wsh_t *wsh, int16_t reason) +{ + + if (wsh->down) { + return -1; + } + + wsh->down = 1; + + if (reason && wsh->sock != ws_sock_invalid) { + uint16_t *u16; + uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0}; + + u16 = (uint16_t *) &fr[2]; + *u16 = htons((int16_t)reason); + ws_raw_write(wsh, fr, 4); + } + + restore_socket(wsh->sock); + + if (wsh->close_sock) { + close(wsh->sock); + } + + wsh->sock = ws_sock_invalid; + + return reason * -1; + +} + +issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data) +{ + + issize_t need = 2; + char *maskp; + + again: + need = 2; + maskp = NULL; + *data = NULL; + + if (wsh->down) { + return -1; + } + + if (!wsh->handshake) { + return ws_close(wsh, WS_PROTO_ERR); + } + + if ((wsh->datalen = ws_raw_read(wsh, wsh->buffer, 14)) < need) { + if ((wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 14 - wsh->datalen)) < need) { + /* too small - protocol err */ + return ws_close(wsh, WS_PROTO_ERR); + } + } + + *oc = *wsh->buffer & 0xf; + + switch(*oc) { + case WSOC_CLOSE: + { + wsh->plen = wsh->buffer[1] & 0x7f; + *data = (uint8_t *) &wsh->buffer[2]; + return ws_close(wsh, 1000); + } + break; + case WSOC_CONTINUATION: + case WSOC_TEXT: + case WSOC_BINARY: + case WSOC_PING: + case WSOC_PONG: + { + //int fin = (wsh->buffer[0] >> 7) & 1; + int mask = (wsh->buffer[1] >> 7) & 1; + + if (mask) { + need += 4; + + if (need > wsh->datalen) { + /* too small - protocol err */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_PROTO_ERR); + } + } + + wsh->plen = wsh->buffer[1] & 0x7f; + wsh->payload = &wsh->buffer[2]; + + if (wsh->plen == 127) { + uint64_t *u64; + + need += 8; + + if (need > wsh->datalen) { + /* too small - protocol err */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_PROTO_ERR); + } + + u64 = (uint64_t *) wsh->payload; + wsh->payload += 8; + + wsh->plen = ntohl((u_long)*u64); + + } else if (wsh->plen == 126) { + uint16_t *u16; + + need += 2; + + if (need > wsh->datalen) { + /* too small - protocol err */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_PROTO_ERR); + } + + u16 = (uint16_t *) wsh->payload; + wsh->payload += 2; + wsh->plen = ntohs(*u16); + } + + if (mask) { + maskp = (char *)wsh->payload; + wsh->payload += 4; + } + + need = (wsh->plen - (wsh->datalen - need)); + + if ((need + wsh->datalen) > (issize_t)wsh->buflen) { + /* too big - Ain't nobody got time fo' dat */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_DATA_TOO_BIG); + } + + wsh->rplen = wsh->plen - need; + + while(need) { + issize_t r = ws_raw_read(wsh, wsh->payload + wsh->rplen, need); + + if (r < 1) { + /* invalid read - protocol err .. */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_PROTO_ERR); + } + + wsh->datalen += r; + wsh->rplen += r; + need -= r; + } + + if (mask && maskp) { + issize_t i; + + for (i = 0; i < wsh->datalen; i++) { + wsh->payload[i] ^= maskp[i % 4]; + } + } + + + if (*oc == WSOC_PING) { + ws_write_frame(wsh, WSOC_PONG, wsh->payload, wsh->rplen); + goto again; + } + + + *(wsh->payload+wsh->rplen) = '\0'; + *data = (uint8_t *)wsh->payload; + + //printf("READ[%ld][%d]-----------------------------:\n[%s]\n-------------------------------\n", wsh->rplen, *oc, (char *)*data); + + + return wsh->rplen; + } + break; + default: + { + /* invalid op code - protocol err .. */ + *oc = WSOC_CLOSE; + return ws_close(wsh, WS_PROTO_ERR); + } + break; + } +} + +issize_t ws_feed_buf(wsh_t *wsh, void *data, size_t bytes) +{ + + if (bytes + wsh->wdatalen > wsh->buflen) { + return -1; + } + + memcpy(wsh->wbuffer + wsh->wdatalen, data, bytes); + + wsh->wdatalen += bytes; + + return bytes; +} + +issize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc) +{ + issize_t r = 0; + + if (!wsh->wdatalen) { + return -1; + } + + r = ws_write_frame(wsh, oc, wsh->wbuffer, wsh->wdatalen); + + wsh->wdatalen = 0; + + return r; +} + + +issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes) +{ + uint8_t hdr[14] = { 0 }; + size_t hlen = 2; + + if (wsh->down) { + return -1; + } + + //printf("WRITE[%ld]-----------------------------:\n[%s]\n-----------------------------------\n", bytes, (char *) data); + + hdr[0] = (uint8_t)(oc | 0x80); + + if (bytes < 126) { + hdr[1] = (uint8_t)bytes; + } else if (bytes < 0x10000) { + uint16_t *u16; + + hdr[1] = 126; + hlen += 2; + + u16 = (uint16_t *) &hdr[2]; + *u16 = htons((uint16_t) bytes); + + } else { + uint64_t *u64; + + hdr[1] = 127; + hlen += 8; + + u64 = (uint64_t *) &hdr[2]; + *u64 = htonl(bytes); + } + + if (ws_raw_write(wsh, (void *) &hdr[0], hlen) != (issize_t)hlen) { + return -1; + } + + if (ws_raw_write(wsh, data, bytes) != (issize_t)bytes) { + return -2; + } + + return bytes; +} + + diff --git a/src/mod/xml_int/mod_xml_rpc/ws.h b/src/mod/xml_int/mod_xml_rpc/ws.h new file mode 100644 index 0000000000..81368158b3 --- /dev/null +++ b/src/mod/xml_int/mod_xml_rpc/ws.h @@ -0,0 +1,99 @@ +#ifndef _WS_H +#define _WS_H + +//#define WSS_STANDALONE 1 + +#define WEBSOCKET_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" +#define B64BUFFLEN 1024 + +#include +#ifndef _MSC_VER +#include +#include +#include +#else +#pragma warning(disable:4996) +#endif +#include +#include +#include +#include +#include +#include +#include +#include +//#include "sha1.h" +#include +#include + + +struct globals_s { + const SSL_METHOD *ssl_method; + SSL_CTX *ssl_ctx; + char cert[512]; + char key[512]; +}; + +extern struct globals_s globals; + +typedef int ws_socket_t; +#define ws_sock_invalid -1 + + +typedef enum { + WS_NONE = 0, + WS_NORMAL = 1000, + WS_PROTO_ERR = 1002, + WS_DATA_TOO_BIG = 1009 +} ws_cause_t; + +typedef enum { + WSOC_CONTINUATION = 0x0, + WSOC_TEXT = 0x1, + WSOC_BINARY = 0x2, + WSOC_CLOSE = 0x8, + WSOC_PING = 0x9, + WSOC_PONG = 0xA +} ws_opcode_t; + +typedef struct wsh_s { + ws_socket_t sock; + char buffer[65536]; + char wbuffer[65536]; + size_t buflen; + issize_t datalen; + issize_t wdatalen; + char *payload; + issize_t plen; + issize_t rplen; + SSL *ssl; + int handshake; + uint8_t down; + int secure; + uint8_t close_sock; +} wsh_t; + +issize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc); +issize_t ws_feed_buf(wsh_t *wsh, void *data, size_t bytes); + + +issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes); +issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes); +issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data); +issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes); +int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock); +issize_t ws_close(wsh_t *wsh, int16_t reason); +void ws_destroy(wsh_t *wsh); +void init_ssl(void); +void deinit_ssl(void); + + +#ifndef _MSC_VER +static inline uint64_t get_unaligned_uint64(const void *p) +{ + const struct { uint64_t d; } __attribute__((packed)) *pp = p; + return pp->d; +} +#endif + +#endif From fb4c5e6fe88efb2aeb42b362c35cbbe0c5008fa3 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 29 Jul 2013 23:06:12 +0800 Subject: [PATCH 160/203] make websocket work with abyss --- src/mod/xml_int/mod_xml_rpc/Makefile | 4 +- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 175 +++++++++++++++++++++- src/mod/xml_int/mod_xml_rpc/ws.c | 120 +++++++-------- src/mod/xml_int/mod_xml_rpc/ws.h | 9 +- 4 files changed, 245 insertions(+), 63 deletions(-) diff --git a/src/mod/xml_int/mod_xml_rpc/Makefile b/src/mod/xml_int/mod_xml_rpc/Makefile index cfc0276204..f0585dc324 100644 --- a/src/mod/xml_int/mod_xml_rpc/Makefile +++ b/src/mod/xml_int/mod_xml_rpc/Makefile @@ -60,10 +60,12 @@ $(XMLRPC_DIR)/src/xmlrpc_server_abyss.o\ $(XMLRPC_DIR)/src/xmlrpc_server_cgi.o\ $(XMLRPC_DIR)/src/xmlrpc_string.o\ $(XMLRPC_DIR)/src/xmlrpc_struct.o\ -$(XMLRPC_DIR)/lib/expat/xmltok/xmltok.o +$(XMLRPC_DIR)/lib/expat/xmltok/xmltok.o\ +ws.o LOCAL_CFLAGS = -w -I$(XMLRPC_DIR)/lib/expat/xmlparse -I$(XMLRPC_DIR)/lib/expat/xmltok -I$(XMLRPC_DIR) -I$(XMLRPC_DIR)/include LOCAL_CFLAGS+= -I$(XMLRPC_DIR)/lib/abyss/src -I$(XMLRPC_DIR)/lib/util/include -D_THREAD -D__EXTENSIONS__ +LOCAL_CFLAGS+= -I. -I../../../../libs/sofia-sip/libsofia-sip-ua/su include $(BASE)/build/modmake.rules diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index d25009f8fb..9b791b6c53 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -26,6 +26,7 @@ * Anthony Minessale II * John Wehle * Garmt Boekholt + * Seven Du * * mod_xml_rpc.c -- XML RPC * @@ -69,6 +70,7 @@ #include <../lib/abyss/src/token.h> #include <../lib/abyss/src/http.h> #include <../lib/abyss/src/session.h> +#include "ws.h" SWITCH_MODULE_LOAD_FUNCTION(mod_xml_rpc_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown); @@ -87,6 +89,7 @@ static struct { switch_bool_t virtual_host; TServer abyssServer; xmlrpc_registry *registryP; + switch_bool_t enable_websocket; } globals; SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_realm, globals.realm); @@ -126,6 +129,8 @@ static switch_status_t do_config(void) default_domain = val; } else if (!strcasecmp(var, "virtual-host")) { globals.virtual_host = switch_true(val); + } else if (!strcasecmp(var, "enable-websocket")) { + globals.enable_websocket = switch_true(val); } } } @@ -541,11 +546,160 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) return rval; } +void stop_hook_event_handler(switch_event_t *event) { + char *json; + wsh_t *wsh = (TSession *)event->bind_user_data; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "got websocket::stophook, closing\n"); + wsh->down++; +} + +void event_handler(switch_event_t *event) { + char *json; + wsh_t *wsh = (TSession *)event->bind_user_data; + switch_event_serialize_json(event, &json); + ws_write_frame(wsh, WSOC_TEXT, json, strlen(json)); + free(json); +} + +#define MAX_EVENT_BIND_SLOTS SWITCH_EVENT_ALL + +abyss_bool websocket_hook(TSession *r) +{ + wsh_t wsh; + int ret; + int i; + ws_opcode_t opcode; + uint8_t *data; + switch_event_node_t *nodes[MAX_EVENT_BIND_SLOTS]; + int node_count = 0; + char *p; + char *key = TableFind(&r->requestHeaderFields, "sec-websocket-key"); + char *version = TableFind(&r->requestHeaderFields, "sec-websocket-version"); + char *proto = TableFind(&r->requestHeaderFields, "sec-websocket-protocol"); + char *upgrade = TableFind(&r->requestHeaderFields, "connection"); + + if (!key || !version || !proto || !upgrade) return FALSE; + if (strncasecmp(upgrade, "Upgrade", 7) || strncasecmp(proto, "websocket", 9)) return FALSE; + + for (i = 0; i < r->requestHeaderFields.size; ++i) { + TTableItem * const fieldP = &r->requestHeaderFields.item[i]; + const char * const fieldValue = fieldP->value; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "headers %s: %s\n", fieldP->name, fieldValue); + } + + ret = ws_init(&wsh, r, NULL, 0); + if (ret != 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "websocket error %d\n", ret); + return FALSE; + } + + while(!wsh.down && !wsh.handshake) { + ret = ws_handshake_kvp(&wsh, key, version, proto); + if (ret < 0) wsh.down = 1; + } + + if (ret != 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "handshake error %d\n", ret); + return FALSE; + } + + if (switch_event_bind_removable("websocket", SWITCH_EVENT_CUSTOM, "websocket::stophook", stop_hook_event_handler, &wsh, &nodes[node_count++]) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't bind!\n"); + node_count--; + } + + while (!wsh.down) { + int bytes = ws_read_frame(&wsh, &opcode, &data); + + if (bytes < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d %s\n", opcode, (char *)data); + switch_yield(1000); + continue; + } + + switch (opcode) { + case WSOC_CLOSE: + ws_close(&wsh, 1000); + break; + case WSOC_CONTINUATION: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "continue\n"); + continue; + case WSOC_TEXT: + p = data; + if (!p) continue; + if (!strncasecmp(data, "event ", 6)) { + switch_event_types_t type; + char *subclass; + + if (node_count == MAX_EVENT_BIND_SLOTS - 1) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot subscribe more than %d events\n", node_count); + continue; + } + p += 6; + if (p = strchr(p, ' ')) p++; + if (!strncasecmp(p, "json ", 5)) { + p += 5; + } else if (!strncasecmp(p, "xml ", 4)) { + p += 4; + } else if (!strncasecmp(p, "plain ", 6)) { + p += 6; + } + if (!*p) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "missing event type in [%s]\n", data); + break; + } else { + } + if (subclass = strchr(p, ' ')) { + *subclass++ = '\0'; + if (!*subclass) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing subclass\n"); + continue; + } + } else { + subclass = SWITCH_EVENT_SUBCLASS_ANY; + } + + if (switch_name_event(p, &type) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown event %s\n", p); + continue; + } + + if (switch_event_bind_removable("websocket", type, subclass, event_handler, &wsh, &nodes[node_count++]) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't bind!\n"); + node_count--; + continue; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bind %s\n", data); + } + + } + break; + default: + break; + } + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "wsh.down = %d, node_count = %d\n", wsh.down, node_count); + + switch_yield(2000); + while (--node_count >= 0) switch_event_unbind(&nodes[node_count]); + + return FALSE; +} + abyss_bool auth_hook(TSession * r) { char *domain_name, *e; abyss_bool ret = FALSE; + if (globals.enable_websocket && !strncmp(r->requestInfo.uri, "/socket", 7)) { + // Chrome has no Authorization support yet + // https://code.google.com/p/chromium/issues/detail?id=123862 + return websocket_hook(r); + } + if (!strncmp(r->requestInfo.uri, "/domains/", 9)) { domain_name = strdup(r->requestInfo.uri + 9); switch_assert(domain_name); @@ -1059,7 +1213,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime) ServerAddHandler(&globals.abyssServer, auth_hook); ServerSetKeepaliveTimeout(&globals.abyssServer, 5); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting HTTP Port %d, DocRoot [%s]\n", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting HTTP Port %d, DocRoot [%s]%s\n", + globals.port, SWITCH_GLOBAL_dirs.htdocs_dir, globals.enable_websocket ? " with websocket." : ""); ServerRun(&globals.abyssServer); switch_yield(1000000); @@ -1069,10 +1224,28 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime) return SWITCH_STATUS_TERM; } +void stop_all_websockets() +{ + switch_event_t *event; + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "websocket::stophook") != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to create event!\n"); + } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "stop", "now"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "stopping all websockets ...\n"); + if (switch_event_fire(&event) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to fire the event!\n"); + switch_event_destroy(&event); + return false; + } +} + /* upon module unload */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown) { + /* Cann't find a way to stop the websockets, use this for a workaround before finding the real one that works */ + stop_all_websockets(); + /* this makes the worker thread (ServerRun) stop */ ServerTerminate(&globals.abyssServer); diff --git a/src/mod/xml_int/mod_xml_rpc/ws.c b/src/mod/xml_int/mod_xml_rpc/ws.c index 35fb4c0f22..1ef76e3cc9 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.c +++ b/src/mod/xml_int/mod_xml_rpc/ws.c @@ -218,11 +218,8 @@ static void sha1_digest(unsigned char *digest, char *in) #endif -int ws_handshake(wsh_t *wsh) +int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto) { - char key[256] = ""; - char version[5] = ""; - char proto[256] = ""; char uri[256] = ""; char input[256] = ""; unsigned char output[SHA1_HASH_SIZE] = ""; @@ -231,44 +228,14 @@ int ws_handshake(wsh_t *wsh) issize_t bytes; char *p, *e = 0; - if (wsh->sock == ws_sock_invalid) { + if (!wsh->tsession) { return -3; } - while((bytes = ws_raw_read(wsh, wsh->buffer + wsh->datalen, wsh->buflen - wsh->datalen)) > 0) { - wsh->datalen += bytes; - if (strstr(wsh->buffer, "\r\n\r\n") || strstr(wsh->buffer, "\n\n")) { - break; - } - } - - if (bytes > sizeof(wsh->buffer)) { + if (!*key || !*version || !*proto) { goto err; } - *(wsh->buffer+bytes) = '\0'; - - if (strncasecmp(wsh->buffer, "GET ", 4)) { - goto err; - } - - p = wsh->buffer + 4; - - e = strchr(p, ' '); - if (!e) { - goto err; - } - - strncpy(uri, p, e-p); - - cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key)); - cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version)); - cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto)); - - if (!*key) { - goto err; - } - snprintf(input, sizeof(input), "%s%s", key, WEBSOCKET_GUID); sha1_digest(output, input); b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64)); @@ -282,7 +249,6 @@ int ws_handshake(wsh_t *wsh) b64, proto); - ws_raw_write(wsh, respond, strlen(respond)); wsh->handshake = 1; @@ -308,7 +274,9 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes) { issize_t r; int x = 0; + TConn *conn = wsh->tsession->connP; +#if 0 if (wsh->ssl) { do { r = SSL_read(wsh->ssl, data, bytes); @@ -321,21 +289,50 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes) return r; } - - do { - r = recv(wsh->sock, data, bytes, 0); -#ifndef _MSC_VER - if (x++) usleep(10000); -#else - if (x++) Sleep(10); #endif - } while (r == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK || - errno == 35 || errno == 730035 || errno == 2 || errno == 60) && x < 100); - - if (x >= 100) { - r = -1; + + if (!wsh->handshake) { + r = wsh->tsession->connP->buffersize; + memcpy(data, conn->buffer.b, r); + printf("%s\n", conn->buffer.t); + ConnReadInit(conn); + return r; + } else { + const char *readError = NULL; + + // printf(" pos=%d size=%d need=%d\n", conn->bufferpos, conn->buffersize, bytes); + + r = conn->buffersize - conn->bufferpos; + + if (r < 0) { + printf("348 Read Error %d!\n", r); + return 0; + } else if (r == 0) { + ConnRead(conn, 2, NULL, NULL, &readError); + + if (readError) { + // printf("354 Read Error %s\n", readError); + xmlrpc_strfree(readError); + return 0; + } + + r = conn->buffersize - conn->bufferpos; + } + + if (r <= bytes) { + memcpy(data, conn->buffer.b + conn->bufferpos, r); + // ConnReadInit(conn); + conn->bufferpos = conn->buffersize; + ConnReadInit(conn); + return r; + } else { + memcpy(data, conn->buffer.b + conn->bufferpos, bytes); + conn->bufferpos += bytes; + return bytes; + } + } - + return r; } @@ -351,9 +348,11 @@ issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes) return r; } - do { - r = send(wsh->sock, data, bytes, 0); - } while (r == -1 && (errno == EAGAIN || errno == EINTR)); + if (ConnWrite(wsh->tsession->connP, data, bytes)) { + return bytes; + } else { + return 0; + } //if (r<0) { //printf("wRITE FAIL: %s\n", strerror(errno)); @@ -408,11 +407,10 @@ static int restore_socket(ws_socket_t sock) #endif - -int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) +int ws_init(wsh_t *wsh, ws_tsession_t *tsession, SSL_CTX *ssl_ctx, int close_sock) { memset(wsh, 0, sizeof(*wsh)); - wsh->sock = sock; + wsh->tsession = tsession; if (!ssl_ctx) { ssl_ctx = globals.ssl_ctx; @@ -425,7 +423,7 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) wsh->buflen = sizeof(wsh->buffer); wsh->secure = ssl_ctx ? 1 : 0; - setup_socket(sock); + // setup_socket(sock); if (wsh->secure) { int code; @@ -466,6 +464,7 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) } +/* while (!wsh->down && !wsh->handshake) { int r = ws_handshake(wsh); @@ -474,6 +473,7 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) return -1; } } +*/ if (wsh->down) { return -1; @@ -560,8 +560,10 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data) } if ((wsh->datalen = ws_raw_read(wsh, wsh->buffer, 14)) < need) { - if ((wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 14 - wsh->datalen)) < need) { - /* too small - protocol err */ + while (!wsh->down && (wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 14 - wsh->datalen)) < need) ; + + if (0 && (wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 14 - wsh->datalen)) < need) { + /* too small - protocol err */ return ws_close(wsh, WS_PROTO_ERR); } } diff --git a/src/mod/xml_int/mod_xml_rpc/ws.h b/src/mod/xml_int/mod_xml_rpc/ws.h index 81368158b3..06fd3b2594 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.h +++ b/src/mod/xml_int/mod_xml_rpc/ws.h @@ -25,7 +25,10 @@ //#include "sha1.h" #include #include +#include <../lib/abyss/src/session.h> +#include <../lib/abyss/src/conn.h> +typedef TSession ws_tsession_t; struct globals_s { const SSL_METHOD *ssl_method; @@ -34,7 +37,7 @@ struct globals_s { char key[512]; }; -extern struct globals_s globals; +// extern struct globals_s globals; typedef int ws_socket_t; #define ws_sock_invalid -1 @@ -71,6 +74,7 @@ typedef struct wsh_s { uint8_t down; int secure; uint8_t close_sock; + ws_tsession_t *tsession; } wsh_t; issize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc); @@ -81,11 +85,12 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes); issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes); issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data); issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes); -int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock); +int ws_init(wsh_t *wsh, ws_tsession_t *tsession, SSL_CTX *ssl_ctx, int close_sock); issize_t ws_close(wsh_t *wsh, int16_t reason); void ws_destroy(wsh_t *wsh); void init_ssl(void); void deinit_ssl(void); +int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto); #ifndef _MSC_VER From 5b5b23116451004b093259e694365848aa4f9b0b Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 29 Jul 2013 23:59:06 +0800 Subject: [PATCH 161/203] add settings disabled by default The new websocket stuff breaks windows build so please fix, thanks --- .../xml_int/mod_xml_rpc/conf/autoload_configs/xml_rpc.conf.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mod/xml_int/mod_xml_rpc/conf/autoload_configs/xml_rpc.conf.xml b/src/mod/xml_int/mod_xml_rpc/conf/autoload_configs/xml_rpc.conf.xml index 714a909907..b5f0bc317c 100644 --- a/src/mod/xml_int/mod_xml_rpc/conf/autoload_configs/xml_rpc.conf.xml +++ b/src/mod/xml_int/mod_xml_rpc/conf/autoload_configs/xml_rpc.conf.xml @@ -6,5 +6,7 @@ + + From 7d48b0b3cc1223692d53c34f87383131aea76e0b Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 31 Jul 2013 15:34:20 +0800 Subject: [PATCH 162/203] cleanup code, less dependency --- src/mod/xml_int/mod_xml_rpc/Makefile | 2 +- src/mod/xml_int/mod_xml_rpc/ws.c | 1 - src/mod/xml_int/mod_xml_rpc/ws.h | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mod/xml_int/mod_xml_rpc/Makefile b/src/mod/xml_int/mod_xml_rpc/Makefile index f0585dc324..bc7e4c1de4 100644 --- a/src/mod/xml_int/mod_xml_rpc/Makefile +++ b/src/mod/xml_int/mod_xml_rpc/Makefile @@ -65,7 +65,7 @@ ws.o LOCAL_CFLAGS = -w -I$(XMLRPC_DIR)/lib/expat/xmlparse -I$(XMLRPC_DIR)/lib/expat/xmltok -I$(XMLRPC_DIR) -I$(XMLRPC_DIR)/include LOCAL_CFLAGS+= -I$(XMLRPC_DIR)/lib/abyss/src -I$(XMLRPC_DIR)/lib/util/include -D_THREAD -D__EXTENSIONS__ -LOCAL_CFLAGS+= -I. -I../../../../libs/sofia-sip/libsofia-sip-ua/su +LOCAL_CFLAGS+= -I. include $(BASE)/build/modmake.rules diff --git a/src/mod/xml_int/mod_xml_rpc/ws.c b/src/mod/xml_int/mod_xml_rpc/ws.c index 1ef76e3cc9..40829ffe40 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.c +++ b/src/mod/xml_int/mod_xml_rpc/ws.c @@ -1,5 +1,4 @@ #include "ws.h" -#include #ifndef _MSC_VER #include diff --git a/src/mod/xml_int/mod_xml_rpc/ws.h b/src/mod/xml_int/mod_xml_rpc/ws.h index 06fd3b2594..f5cb5e820a 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.h +++ b/src/mod/xml_int/mod_xml_rpc/ws.h @@ -11,24 +11,24 @@ #include #include #include +#include #else #pragma warning(disable:4996) +#define snprintf _snprintf #endif #include -#include #include #include #include #include #include #include -//#include "sha1.h" #include -#include #include <../lib/abyss/src/session.h> #include <../lib/abyss/src/conn.h> typedef TSession ws_tsession_t; +typedef int issize_t; struct globals_s { const SSL_METHOD *ssl_method; From 2fa9e676518ab35c56f2b171aae01398f7498bbe Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 31 Jul 2013 16:19:58 +0800 Subject: [PATCH 163/203] trying to fix windows build --- .../mod_xml_rpc/mod_xml_rpc.2010.vcxproj | 14 +++++++++----- .../mod_xml_rpc/mod_xml_rpc.2012.vcxproj | 18 ++++++++++++++---- src/mod/xml_int/mod_xml_rpc/ws.h | 1 - 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj index f95e975efe..6420eb41e5 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj @@ -66,7 +66,7 @@ - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -83,7 +83,7 @@ X64 - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -98,7 +98,7 @@ - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -115,7 +115,7 @@ X64 - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -130,6 +130,7 @@ + @@ -149,7 +150,10 @@ false + + + - \ No newline at end of file + diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj index 1a65b391e0..af3305a50c 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj @@ -70,7 +70,7 @@ - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -87,7 +87,7 @@ X64 - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -102,7 +102,7 @@ - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -119,7 +119,7 @@ X64 - $(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) ABYSS_WIN32;%(PreprocessorDefinitions) @@ -134,8 +134,15 @@ + + + {d331904d-a00a-4694-a5a3-fcff64ab5dbe} + + + {b4b62169-5ad4-4559-8707-3d933ac5db39} + {d2396dd7-7d38-473a-abb7-6f96d65ae1b9} @@ -153,6 +160,9 @@ false + + + diff --git a/src/mod/xml_int/mod_xml_rpc/ws.h b/src/mod/xml_int/mod_xml_rpc/ws.h index f5cb5e820a..09dfd282da 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.h +++ b/src/mod/xml_int/mod_xml_rpc/ws.h @@ -11,7 +11,6 @@ #include #include #include -#include #else #pragma warning(disable:4996) #define snprintf _snprintf From 3aaab08cc650d2c0b7e5dbe3f7a74a289074051d Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 31 Jul 2013 16:27:56 +0800 Subject: [PATCH 164/203] more cleanup --- src/mod/xml_int/mod_xml_rpc/ws.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mod/xml_int/mod_xml_rpc/ws.c b/src/mod/xml_int/mod_xml_rpc/ws.c index 40829ffe40..a9a31c2b8b 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.c +++ b/src/mod/xml_int/mod_xml_rpc/ws.c @@ -219,13 +219,10 @@ static void sha1_digest(unsigned char *digest, char *in) int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto) { - char uri[256] = ""; char input[256] = ""; unsigned char output[SHA1_HASH_SIZE] = ""; char b64[256] = ""; char respond[512] = ""; - issize_t bytes; - char *p, *e = 0; if (!wsh->tsession) { return -3; @@ -258,9 +255,6 @@ int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto) snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n" "Sec-WebSocket-Version: 13\r\n\r\n"); - //printf("ERR:\n%s\n", respond); - - ws_raw_write(wsh, respond, strlen(respond)); ws_close(wsh, WS_NONE); From 7b2ed3405e8c16f3ee68809f5316577b19935c61 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Wed, 31 Jul 2013 21:45:18 -0500 Subject: [PATCH 165/203] FS-5655 try this --- .../src/msvc/make_cielab_luts.2010.vcxproj | 2 +- .../src/msvc/make_cielab_luts.2012.vcxproj | 2 +- .../msvc/make_math_fixed_tables.2010.vcxproj | 2 +- .../msvc/make_math_fixed_tables.2012.vcxproj | 2 +- .../mod_xml_rpc/mod_xml_rpc.2010.vcxproj | 324 +++++++++--------- .../mod_xml_rpc/mod_xml_rpc.2012.vcxproj | 6 + 6 files changed, 175 insertions(+), 163 deletions(-) diff --git a/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj b/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj index 282cc186cf..de83ac7306 100644 --- a/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj +++ b/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj @@ -27,7 +27,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_cielab_luts\$(Configuration)\ false diff --git a/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj b/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj index 881c035554..d7c54ca97f 100644 --- a/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj +++ b/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj @@ -28,7 +28,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_cielab_luts\$(Configuration)\ false diff --git a/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj b/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj index a71f70e556..61465917f1 100644 --- a/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj +++ b/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj @@ -27,7 +27,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_math_fixed_tables\$(Configuration)\ false diff --git a/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj b/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj index 610bb28625..ab6b648bcb 100644 --- a/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj +++ b/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj @@ -28,7 +28,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_math_fixed_tables\$(Configuration)\ false diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj index 6420eb41e5..76e7eb0b29 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2010.vcxproj @@ -1,159 +1,165 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mod_xml_rpc - {CBEC7225-0C21-4DA8-978E-1F158F8AD950} - mod_xml_rpc - Win32Proj - - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) - ABYSS_WIN32;%(PreprocessorDefinitions) - - - - - ..\..\..\..\libs\xmlrpc\lib;..\..\..\..\libs\xmlrpc\lib\abyss\src\$(OutDir);..\..\..\..\libs\apr-util\xml\expat\lib\LibD;%(AdditionalLibraryDirectories) - false - - - - - - - X64 - - - $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) - ABYSS_WIN32;%(PreprocessorDefinitions) - - - - - %(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) - ABYSS_WIN32;%(PreprocessorDefinitions) - - - - - ..\..\..\..\libs\xmlrpc\lib;..\..\..\..\libs\xmlrpc\lib\abyss\src\$(OutDir);..\..\..\..\libs\apr-util\xml\expat\lib\LibR;%(AdditionalLibraryDirectories) - false - - - - - - - X64 - - - $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) - ABYSS_WIN32;%(PreprocessorDefinitions) - - - - - %(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - - - - - {d2396dd7-7d38-473a-abb7-6f96d65ae1b9} - - - {0d108721-eae8-4baf-8102-d8960ec93647} - - - {cee544a9-0303-44c2-8ece-efa7d7bcbbba} - - - {b535402e-38d2-4d54-8360-423acbd17192} - - - {202d7a4e-760d-4d0e-afa1-d7459ced30ff} - false - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_xml_rpc + {CBEC7225-0C21-4DA8-978E-1F158F8AD950} + mod_xml_rpc + Win32Proj + + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + ABYSS_WIN32;%(PreprocessorDefinitions) + + + + + ..\..\..\..\libs\xmlrpc\lib;..\..\..\..\libs\xmlrpc\lib\abyss\src\$(OutDir);..\..\..\..\libs\apr-util\xml\expat\lib\LibD;%(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + ABYSS_WIN32;%(PreprocessorDefinitions) + + + + + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + ABYSS_WIN32;%(PreprocessorDefinitions) + + + + + ..\..\..\..\libs\xmlrpc\lib;..\..\..\..\libs\xmlrpc\lib\abyss\src\$(OutDir);..\..\..\..\libs\apr-util\xml\expat\lib\LibR;%(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + $(SolutionDir)libs\openssl-1.0.1c\include;$(SolutionDir)libs\xmlrpc-c\include;$(SolutionDir)libs\xmlrpc-c\lib\abyss\src;$(SolutionDir)libs\xmlrpc-c\lib\util\include;%(AdditionalIncludeDirectories) + ABYSS_WIN32;%(PreprocessorDefinitions) + + + + + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + + + + + {d331904d-a00a-4694-a5a3-fcff64ab5dbe} + + + {b4b62169-5ad4-4559-8707-3d933ac5db39} + + + {d2396dd7-7d38-473a-abb7-6f96d65ae1b9} + + + {0d108721-eae8-4baf-8102-d8960ec93647} + + + {cee544a9-0303-44c2-8ece-efa7d7bcbbba} + + + {b535402e-38d2-4d54-8360-423acbd17192} + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + + + + \ No newline at end of file diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj index af3305a50c..afd6d9f0c5 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj @@ -137,6 +137,12 @@ + + {d331904d-a00a-4694-a5a3-fcff64ab5dbe} + + + {b4b62169-5ad4-4559-8707-3d933ac5db39} + {d331904d-a00a-4694-a5a3-fcff64ab5dbe} From c5abe3ed27fd986aa9f033499f73ea79b37ec8c6 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Thu, 1 Aug 2013 13:29:51 -0500 Subject: [PATCH 166/203] mod_xml_rpc revert extra stuff --- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj index afd6d9f0c5..af3305a50c 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.2012.vcxproj @@ -137,12 +137,6 @@ - - {d331904d-a00a-4694-a5a3-fcff64ab5dbe} - - - {b4b62169-5ad4-4559-8707-3d933ac5db39} - {d331904d-a00a-4694-a5a3-fcff64ab5dbe} From d7290246be878a286d1a8bd60467864389bc5478 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 5 Aug 2013 23:27:16 +0800 Subject: [PATCH 167/203] FS-5655 --resolve msvc has so many versions, makes it complicated --- Freeswitch.2010.express.sln | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Freeswitch.2010.express.sln b/Freeswitch.2010.express.sln index 4749470674..6b7c5fde3b 100644 --- a/Freeswitch.2010.express.sln +++ b/Freeswitch.2010.express.sln @@ -38,6 +38,11 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_console", "src\mod\loggers\mod_console\mod_console.2010.vcxproj", "{1C453396-D912-4213-89FD-9B489162B7B5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_rpc", "src\mod\xml_int\mod_xml_rpc\mod_xml_rpc.2010.vcxproj", "{CBEC7225-0C21-4DA8-978E-1F158F8AD950}" + ProjectSection(ProjectDependencies) = postProject + {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} = {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} + {329A6FA0-0FCC-4435-A950-E670AEFA9838} = {329A6FA0-0FCC-4435-A950-E670AEFA9838} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_rss", "src\mod\applications\mod_rss\mod_rss.2010.vcxproj", "{B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4}" EndProject @@ -221,6 +226,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libs\spandsp\src\libspandsp.2010.vcxproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" ProjectSection(ProjectDependencies) = postProject {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspeex", "libs\speex\win32\VS2008\libspeex\libspeex.vcxproj", "{E972C52F-9E85-4D65-B19C-031E511E9DB4}" @@ -338,6 +344,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gennmtab", "libs\win32\xmlr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_math_fixed_tables", "libs\spandsp\src\msvc\make_math_fixed_tables.2010.vcxproj", "{9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2010.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -2067,6 +2075,15 @@ Global {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|Win32.Build.0 = All|Win32 {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|x64.ActiveCfg = All|Win32 {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.ActiveCfg = All|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 9d9844ec460324628c5148c0375e70c20ba08a12 Mon Sep 17 00:00:00 2001 From: Ben Langfeld Date: Tue, 6 Aug 2013 11:03:01 -0300 Subject: [PATCH 168/203] mod_rayo: Commands executed against a dead call should return item-not-found --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index a110cdb703..7baaf5f46f 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -1424,7 +1424,7 @@ void rayo_call_send(struct rayo_actor *call, struct rayo_message *msg) if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, session not found\n", RAYO_JID(call)); if (!msg->is_reply) { - RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(iq, STANZA_ERROR_SERVICE_UNAVAILABLE)); + RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(iq, STANZA_ERROR_ITEM_NOT_FOUND)); } return; } From 86ea09c9e31c45cea72e3a421f61e603e27a300e Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 6 Aug 2013 11:05:35 -0400 Subject: [PATCH 169/203] FS-5669 --resolve mod_rayo: return error if is missing in --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 3 ++- .../mod_rayo/rayo_output_component.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 7baaf5f46f..6370d88048 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -3688,7 +3688,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) "" "0123456789*#]]>" ""); - + rayo_add_cmd_alias("output_bad", + ""); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/rayo_output_component.c b/src/mod/event_handlers/mod_rayo/rayo_output_component.c index 82fd0aa8b2..f92d994a64 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_output_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_output_component.c @@ -126,12 +126,19 @@ static iks *start_call_output_component(struct rayo_actor *call, struct rayo_mes switch_core_session_t *session = (switch_core_session_t *)session_data; struct rayo_component *output_component = NULL; iks *output = iks_find(iq, "output"); + iks *document = NULL; /* validate output attributes */ if (!VALIDATE_RAYO_OUTPUT(output)) { return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); } + /* check if exists */ + document = iks_find(output, "document"); + if (!document) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + output_component = create_output_component(call, RAT_CALL_COMPONENT, output, iks_find_attrib(iq, "from")); return start_call_output(output_component, session, output, iq); } @@ -144,6 +151,7 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m iks *iq = msg->payload; struct rayo_component *component = NULL; iks *output = iks_find(iq, "output"); + iks *document = NULL; switch_stream_handle_t stream = { 0 }; /* validate output attributes */ @@ -151,6 +159,12 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); } + /* check if exists */ + document = iks_find(output, "document"); + if (!document) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + component = create_output_component(mixer, RAT_MIXER_COMPONENT, output, iks_find_attrib(iq, "from")); /* build conference command */ From fe5e8241c055ec204b1aeb4ebdd81152907361cd Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 6 Aug 2013 14:52:56 -0400 Subject: [PATCH 170/203] mod_rayo: fix crash on originate error --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 6370d88048..3aa255f833 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -1907,6 +1907,7 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void * char *dial_to_dup = NULL; const char *dial_from = iks_find_attrib(dial, "from"); const char *dial_timeout_ms = iks_find_attrib(dial, "timeout"); + const char *uuid = NULL; struct dial_gateway *gateway = NULL; struct rayo_call *call = NULL; switch_stream_handle_t stream = { 0 }; @@ -1917,6 +1918,7 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void * call->dcp_jid = switch_core_strdup(RAYO_POOL(call), dcp_jid); call->dial_id = iks_find_attrib(iq, "id"); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_INFO, "%s has control of call\n", dcp_jid); + uuid = switch_core_strdup(dtdata->pool, rayo_call_get_uuid(call)); /* set rayo channel variables so channel originate event can be identified as coming from Rayo */ stream.write_function(&stream, "{origination_uuid=%s,rayo_dcp_jid=%s,rayo_call_jid=%s", @@ -2016,19 +2018,17 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void * /* response will be sent when originate event is received- otherwise error is returned */ if (switch_api_execute("originate", stream.data, NULL, &api_stream) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_DEBUG, "Got originate result: %s\n", (char *)api_stream.data); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got originate result: %s\n", (char *)api_stream.data); /* check for failure */ if (strncmp("+OK", api_stream.data, strlen("+OK"))) { - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_INFO, "Failed to originate call\n"); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_INFO, "Failed to originate call\n"); if (call->dial_id) { /* map failure reason to iq error */ if (!strncmp("-ERR DESTINATION_OUT_OF_ORDER", api_stream.data, strlen("-ERR DESTINATION_OUT_OF_ORDER"))) { /* this -ERR is received when out of sessions */ response = iks_new_error(iq, STANZA_ERROR_RESOURCE_CONSTRAINT); - } else { - response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, api_stream.data); } } } From d57282489ab191857c6aa23dab1ab0fd202b83c5 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 6 Aug 2013 15:30:22 -0400 Subject: [PATCH 171/203] FS-5668 --resolve mod_rayo: offer from/to do not match SIP --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 3aa255f833..79d2179053 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -2728,12 +2728,35 @@ static iks *rayo_create_offer(struct rayo_call *call, switch_core_session_t *ses switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); iks *presence = iks_new("presence"); iks *offer = iks_insert(presence, "offer"); + const char *val; iks_insert_attrib(presence, "from", RAYO_JID(call)); - iks_insert_attrib(offer, "from", profile->caller_id_number); - iks_insert_attrib(offer, "to", profile->destination_number); iks_insert_attrib(offer, "xmlns", RAYO_NS); + if ((val = switch_channel_get_variable(channel, "sip_from_uri"))) { + /* is a SIP call - pass the URI */ + if (!strchr(val, ':')) { + iks_insert_attrib_printf(offer, "from", "sip:%s", val); + } else { + iks_insert_attrib(offer, "from", val); + } + } else { + /* pass caller ID */ + iks_insert_attrib(offer, "from", profile->caller_id_number); + } + + if ((val = switch_channel_get_variable(channel, "sip_to_uri"))) { + /* is a SIP call - pass the URI */ + if (!strchr(val, ':')) { + iks_insert_attrib_printf(offer, "to", "sip:%s", val); + } else { + iks_insert_attrib(offer, "to", val); + } + } else { + /* pass dialed number */ + iks_insert_attrib(offer, "to", profile->destination_number); + } + /* add signaling headers */ { switch_event_header_t *var; From 22ab34c507ae746dc5c44f91789ba66e3cd4bc28 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 6 Aug 2013 16:21:22 -0400 Subject: [PATCH 172/203] FS-5679 --resolve mod_rayo: SIP 180 doesn't result in ringing event --- src/mod/event_handlers/mod_rayo/mod_rayo.c | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 79d2179053..6798f70f06 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -129,6 +129,8 @@ struct rayo_call { const char *dial_id; /** channel destroy event */ switch_event_t *end_event; + /** True if ringing event sent to client */ + int ringing_sent; }; /** @@ -1031,6 +1033,7 @@ static struct rayo_call *rayo_call_init(struct rayo_call *call, switch_memory_po call->dcp_jid = ""; call->idle_start_time = switch_micro_time_now(); call->joined = 0; + call->ringing_sent = 0; switch_core_hash_init(&call->pcps, pool); switch_safe_free(call_jid); @@ -2550,13 +2553,21 @@ static void on_call_answer_event(struct rayo_client *rclient, switch_event_t *ev */ static void on_call_ringing_event(struct rayo_client *rclient, switch_event_t *event) { - struct rayo_call *call = RAYO_CALL_LOCATE(switch_event_get_header(event, "Unique-ID")); - if (call) { - iks *revent = iks_new_presence("ringing", RAYO_NS, - switch_event_get_header(event, "variable_rayo_call_jid"), - switch_event_get_header(event, "variable_rayo_dcp_jid")); - RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); - RAYO_UNLOCK(call); + const char *call_direction = switch_event_get_header(event, "Call-Direction"); + if (call_direction && !strcmp(call_direction, "outbound")) { + struct rayo_call *call = RAYO_CALL_LOCATE(switch_event_get_header(event, "Unique-ID")); + if (call) { + switch_mutex_lock(RAYO_ACTOR(call)->mutex); + if (!call->ringing_sent) { + iks *revent = iks_new_presence("ringing", RAYO_NS, + switch_event_get_header(event, "variable_rayo_call_jid"), + switch_event_get_header(event, "variable_rayo_dcp_jid")); + call->ringing_sent = 1; + RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); + RAYO_UNLOCK(call); + } + switch_mutex_unlock(RAYO_ACTOR(call)->mutex); + } } } @@ -2651,6 +2662,7 @@ static void rayo_client_handle_event(struct rayo_client *rclient, switch_event_t case SWITCH_EVENT_CHANNEL_ORIGINATE: on_call_originate_event(rclient, event); break; + case SWITCH_EVENT_CHANNEL_PROGRESS: case SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA: on_call_ringing_event(rclient, event); break; @@ -3598,6 +3610,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) switch_event_bind(modname, SWITCH_EVENT_CHANNEL_ORIGINATE, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA, NULL, route_call_event, NULL); + switch_event_bind(modname, SWITCH_EVENT_CHANNEL_PROGRESS, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_ANSWER, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_BRIDGE, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_UNBRIDGE, NULL, route_call_event, NULL); From 05444a6ebd9ec882723fea0a611be9f2d030e633 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 7 Aug 2013 21:22:26 +0500 Subject: [PATCH 173/203] FS-5661 --resolve --- src/include/switch_scheduler.h | 1 + src/mod/applications/mod_commands/mod_commands.c | 6 ++++-- src/mod/applications/mod_dptools/mod_dptools.c | 4 +++- src/switch_scheduler.c | 11 +++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/include/switch_scheduler.h b/src/include/switch_scheduler.h index 8d9bd9ca1a..59997a006d 100644 --- a/src/include/switch_scheduler.h +++ b/src/include/switch_scheduler.h @@ -43,6 +43,7 @@ SWITCH_BEGIN_EXTERN_C int64_t created; int64_t runtime; uint32_t cmd_id; + uint32_t repeat; char *group; void *cmd_arg; uint32_t task_id; diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index ef91f36a8d..fc74c3dd65 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -3164,7 +3164,7 @@ SWITCH_STANDARD_API(uuid_broadcast_function) return SWITCH_STATUS_SUCCESS; } -#define SCHED_BROADCAST_SYNTAX "[+] + + + + + diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml index 0cb46d7992..248fd47ccf 100644 --- a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml +++ b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml @@ -11,6 +11,11 @@ + + + + + diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.c b/src/mod/event_handlers/mod_rayo/iks_helpers.c index 0b5616a1f3..30d9d215a5 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.c +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.c @@ -216,6 +216,17 @@ double iks_find_decimal_attrib(iks *xml, const char *attrib) return atof(iks_find_attrib_soft(xml, attrib)); } +/** + * Get attribute character value of node + * @param xml the XML node to search + * @param attrib the Attribute name + * @return the attribute value + */ +char iks_find_char_attrib(iks *xml, const char *attrib) +{ + return iks_find_attrib_soft(xml, attrib)[0]; +} + /** * Convert iksemel XML node type to string * @param type the XML node type @@ -392,6 +403,54 @@ int iks_attrib_is_decimal_between_zero_and_one(const char *value) return SWITCH_FALSE; } +/** + * Validate dtmf digit + * @param value + * @return SWITCH_TRUE if 0-9,a,b,c,d,A,B,C,D,*,# + */ +int iks_attrib_is_dtmf_digit(const char *value) +{ + if (value && *value && strlen(value) == 1) { + switch (*value) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'a': + case 'B': + case 'b': + case 'C': + case 'c': + case 'D': + case 'd': + case '*': + case '#': + return SWITCH_TRUE; + } + } + return SWITCH_FALSE; +} + +/** + * @param fn to evaluate attribute + * @param attrib to evaluate + * @return true if not set or is valid + */ +int validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib) +{ + if (!attrib || !*attrib) { + return SWITCH_TRUE; + } + return fn(attrib); +} + #define IKS_SHA256_HEX_DIGEST_LENGTH ((SHA256_DIGEST_LENGTH * 2) + 1) /** diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.h b/src/mod/event_handlers/mod_rayo/iks_helpers.h index 90a5ca688d..3a7bae02e7 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.h +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.h @@ -63,6 +63,7 @@ extern const char *iks_find_attrib_soft(iks *xml, const char *attrib); extern const char *iks_find_attrib_default(iks *xml, const char *attrib, const char *def); extern int iks_find_bool_attrib(iks *xml, const char *attrib); extern int iks_find_int_attrib(iks *xml, const char *attrib); +extern char iks_find_char_attrib(iks *xml, const char *attrib); extern double iks_find_decimal_attrib(iks *xml, const char *attrib); extern const char *iks_node_type_to_string(int type); extern const char *iks_net_error_to_string(int err); @@ -73,9 +74,12 @@ extern char *iks_server_dialback_key(const char *secret, const char *receiving_s /** A function to validate attribute value */ typedef int (*iks_attrib_validation_function)(const char *); +extern int validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib); + #define ELEMENT_DECL(name) extern int VALIDATE_##name(iks *node); #define ELEMENT(name) int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0; #define ATTRIB(name, def, rule) result &= iks_attrib_is_##rule(iks_find_attrib_default(node, #name, #def)); +#define OPTIONAL_ATTRIB(name, def, rule) result &= validate_optional_attrib(iks_attrib_is_##rule, iks_find_attrib_default(node, #name, #def)); #define STRING_ATTRIB(name, def, rule) result &= value_matches(iks_find_attrib_default(node, #name, #def), rule); #define ELEMENT_END return result; } @@ -87,6 +91,7 @@ extern int iks_attrib_is_positive(const char *value); extern int iks_attrib_is_positive_or_neg_one(const char *value); extern int iks_attrib_is_any(const char *value); extern int iks_attrib_is_decimal_between_zero_and_one(const char *value); +extern int iks_attrib_is_dtmf_digit(const char *value); #endif diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index fffffe31eb..69f8b2271b 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -3737,6 +3737,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) "" ""); + rayo_add_cmd_alias("prompt_barge_mrcp", "" + "

Please press a digit.

]]>
" + "" + "" + "0123456789]]>" + "" + "
"); + rayo_add_cmd_alias("prompt_no_barge", "" "

Please press a digit.

]]>
" "" @@ -3800,6 +3808,34 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) ""); rayo_add_cmd_alias("unjoin", ""); + rayo_add_cmd_alias("input_voice_yesno_unimrcp", + "" + "" + "yesno]]>"); +rayo_add_cmd_alias("input_voice_yesno_unimrcp_timeout", + "" + "" + "yesno]]>"); + rayo_add_cmd_alias("input_voice_yesno_pocketsphinx", + "" + "" + "yesno]]>"); + rayo_add_cmd_alias("input_voice_yesno_default", + "" + "" + "yesno]]>"); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.c b/src/mod/event_handlers/mod_rayo/rayo_components.c index 54e241d036..d8a8854f52 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.c +++ b/src/mod/event_handlers/mod_rayo/rayo_components.c @@ -227,15 +227,10 @@ void rayo_component_api_execute_async(struct rayo_component *component, const ch */ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { - rayo_input_component_load(); - rayo_output_component_load(module_interface, pool); - rayo_prompt_component_load(); - rayo_record_component_load(pool, config_file); - - if (rayo_input_component_load() != SWITCH_STATUS_SUCCESS || - rayo_output_component_load(module_interface, pool) != SWITCH_STATUS_SUCCESS || - rayo_prompt_component_load() != SWITCH_STATUS_SUCCESS || - rayo_record_component_load(pool, config_file) != SWITCH_STATUS_SUCCESS) { + if (rayo_input_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || + rayo_output_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || + rayo_prompt_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || + rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_TERM; } return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.h b/src/mod/event_handlers/mod_rayo/rayo_components.h index 71891ea3d6..6e93dfbc43 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.h +++ b/src/mod/event_handlers/mod_rayo/rayo_components.h @@ -54,10 +54,10 @@ #define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS extern switch_status_t rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); -extern switch_status_t rayo_input_component_load(void); -extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool); -extern switch_status_t rayo_prompt_component_load(void); -extern switch_status_t rayo_record_component_load(switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_components_shutdown(void); extern switch_status_t rayo_input_component_shutdown(void); diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.c b/src/mod/event_handlers/mod_rayo/rayo_elements.c index 89e31c7d66..34577a9492 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.c +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.c @@ -33,7 +33,7 @@ */ ELEMENT(RAYO_INPUT) STRING_ATTRIB(mode, any, "any,dtmf,voice") - ATTRIB(terminator,, any) + OPTIONAL_ATTRIB(terminator,, dtmf_digit) ATTRIB(recognizer,, any) ATTRIB(language, en-US, any) ATTRIB(initial-timeout, -1, positive_or_neg_one) diff --git a/src/mod/event_handlers/mod_rayo/rayo_input_component.c b/src/mod/event_handlers/mod_rayo/rayo_input_component.c index 9e10d1b7a5..3bf3b6dfb6 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_input_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_input_component.c @@ -45,6 +45,8 @@ struct input_handler; static struct { /** grammar parser */ struct srgs_parser *parser; + /** default recognizer to use if none specified */ + const char *default_recognizer; } globals; /** @@ -57,8 +59,8 @@ struct input_component { int speech_mode; /** Number of collected digits */ int num_digits; - /** Terminating digits */ - int term_digit_mask; + /** Terminating digit */ + char term_digit; /** The collected digits */ char digits[MAX_DTMF + 1]; /** grammar to match */ @@ -70,7 +72,9 @@ struct input_component { /** maximum silence allowed */ int max_silence; /** minimum speech detection confidence */ - int min_confidence; + double min_confidence; + /** sensitivity to background noise */ + double sensitivity; /** timeout after first digit is received */ int inter_digit_timeout; /** stop flag */ @@ -79,6 +83,10 @@ struct input_component { int start_timers; /** true if event fired for first digit / start of speech */ int barge_event; + /** optional language to use */ + const char *language; + /** optional recognizer to use */ + const char *recognizer; /** global data */ struct input_handler *handler; }; @@ -91,77 +99,24 @@ struct input_component { struct input_handler { /** media bug to monitor frames / control input lifecycle */ switch_media_bug_t *bug; - /** active input component - TODO multiple inputs */ - struct input_component *component; + /** active voice input component */ + struct input_component *voice_component; + /** active dtmf input component */ + struct input_component *dtmf_component; /** synchronizes media bug and dtmf callbacks */ switch_mutex_t *mutex; + /** last recognizer used */ + const char *last_recognizer; }; /** - * @return digit mask + * @param digit1 to match + * @param digit2 to match + * @return true if matching */ -static int get_digit_mask(char digit) +static int digit_test(char digit1, char digit2) { - switch(digit) { - case '0': return 1; - case '1': return 1 << 1; - case '2': return 1 << 2; - case '3': return 1 << 3; - case '4': return 1 << 4; - case '5': return 1 << 5; - case '6': return 1 << 6; - case '7': return 1 << 7; - case '8': return 1 << 8; - case '9': return 1 << 9; - case 'A': - case 'a': return 1 << 10; - case 'B': - case 'b': return 1 << 11; - case 'C': - case 'c': return 1 << 12; - case 'D': - case 'd': return 1 << 13; - case '#': return 1 << 14; - case '*': return 1 << 15; - } - return 0; -} - -/** - * @param digit_mask to check - * @param digit to look for - * @return true if set - */ -static int digit_mask_test(int digit_mask, char digit) -{ - return digit_mask & get_digit_mask(digit); -} - -/** - * @param digit_mask to set digit in - * @param digit to set - * @return the digit mask with the set digit - */ -static int digit_mask_set(int digit_mask, char digit) -{ - return digit_mask | get_digit_mask(digit); -} - -/** - * @param digit_mask to set digits in - * @param digits to add to mask - * @return the digit mask with the set digits - */ -static int digit_mask_set_from_digits(int digit_mask, const char *digits) -{ - if (!zstr(digits)) { - int digits_len = strlen(digits); - int i; - for (i = 0; i < digits_len; i++) { - digit_mask = digit_mask_set(digit_mask, digits[i]); - } - } - return digit_mask; + return digit1 && digit2 && tolower(digit1) == tolower(digit2); } /** @@ -205,15 +160,14 @@ static switch_status_t input_component_on_dtmf(switch_core_session_t *session, c switch_mutex_lock(handler->mutex); - component = handler->component; + component = handler->dtmf_component; /* additional paranoia check */ if (!component) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Received DTMF without active input component\n"); switch_mutex_unlock(handler->mutex); return SWITCH_STATUS_SUCCESS; } - is_term_digit = digit_mask_test(component->term_digit_mask, dtmf->digit); + is_term_digit = digit_test(component->term_digit, dtmf->digit); if (!is_term_digit) { component->digits[component->num_digits] = dtmf->digit; @@ -247,7 +201,7 @@ static switch_status_t input_component_on_dtmf(switch_core_session_t *session, c } case SMT_NO_MATCH: { /* notify of no-match and remove input component */ - handler->component = NULL; + handler->dtmf_component = NULL; switch_core_media_bug_remove(session, &handler->bug); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NO MATCH = %s\n", component->digits); rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); @@ -256,7 +210,7 @@ static switch_status_t input_component_on_dtmf(switch_core_session_t *session, c case SMT_MATCH_END: { iks *result = nlsml_create_dtmf_match(component->digits); /* notify of match and remove input component */ - handler->component = NULL; + handler->dtmf_component = NULL; switch_core_media_bug_remove(session, &handler->bug); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits); send_match_event(RAYO_COMPONENT(component), result); @@ -279,7 +233,7 @@ static switch_bool_t input_component_bug_callback(switch_media_bug_t *bug, void struct input_component *component; switch_mutex_lock(handler->mutex); - component = handler->component; + component = handler->dtmf_component; switch(type) { case SWITCH_ABC_TYPE_INIT: { @@ -294,7 +248,7 @@ static switch_bool_t input_component_bug_callback(switch_media_bug_t *bug, void int elapsed_ms = (switch_micro_time_now() - component->last_digit_time) / 1000; if (component->num_digits && component->inter_digit_timeout > 0 && elapsed_ms > component->inter_digit_timeout) { enum srgs_match_type match; - handler->component = NULL; + handler->dtmf_component = NULL; switch_core_media_bug_set_flag(bug, SMBF_PRUNE); /* we got some input, check for match */ @@ -310,7 +264,7 @@ static switch_bool_t input_component_bug_callback(switch_media_bug_t *bug, void rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); } } else if (!component->num_digits && component->initial_timeout > 0 && elapsed_ms > component->initial_timeout) { - handler->component = NULL; + handler->dtmf_component = NULL; switch_core_media_bug_set_flag(bug, SMBF_PRUNE); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "initial-timeout\n"); rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOINPUT); @@ -323,10 +277,10 @@ static switch_bool_t input_component_bug_callback(switch_media_bug_t *bug, void /* check for hangup */ if (component) { if (component->stop) { - handler->component = NULL; + handler->dtmf_component = NULL; rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); } else { - handler->component = NULL; + handler->dtmf_component = NULL; rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP); } } @@ -396,34 +350,53 @@ static iks *start_call_input(struct input_component *component, switch_core_sess handler = switch_core_session_alloc(session, sizeof(*handler)); switch_mutex_init(&handler->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); switch_channel_set_private(switch_core_session_get_channel(session), RAYO_INPUT_COMPONENT_PRIVATE_VAR, handler); + handler->last_recognizer = ""; } - handler->component = component; + + /* TODO break up this function by mode... dtmf/voice/fax/etc */ + component->speech_mode = strcmp(iks_find_attrib_soft(input, "mode"), "dtmf"); + if (component->speech_mode && handler->voice_component) { + /* don't allow multi voice input */ + return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple voice input is not allowed"); + } + if (!component->speech_mode && handler->dtmf_component) { + /* don't allow multi dtmf input */ + return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple dtmf input is not allowed"); + } + + if (component->speech_mode) { + handler->voice_component = component; + } else { + handler->dtmf_component = component; + } + + component->grammar = NULL; component->num_digits = 0; component->digits[0] = '\0'; component->stop = 0; - component->speech_mode = 0; component->initial_timeout = iks_find_int_attrib(input, "initial-timeout"); component->inter_digit_timeout = iks_find_int_attrib(input, "inter-digit-timeout"); component->max_silence = iks_find_int_attrib(input, "max-silence"); - component->min_confidence = (int)ceil(iks_find_decimal_attrib(input, "min-confidence") * 100.0); + component->min_confidence = iks_find_decimal_attrib(input, "min-confidence"); + component->sensitivity = iks_find_decimal_attrib(input, "sensitivity"); component->barge_event = iks_find_bool_attrib(input, "barge-event"); component->start_timers = iks_find_bool_attrib(input, "start-timers"); - /* TODO this should just be a single digit terminator? */ - component->term_digit_mask = digit_mask_set_from_digits(0, iks_find_attrib_soft(input, "terminator")); - /* TODO recognizer ignored */ - /* TODO language ignored */ + component->term_digit = iks_find_char_attrib(input, "terminator"); + component->recognizer = iks_find_attrib(input, "recognizer"); + component->language = iks_find_attrib(input, "language"); component->handler = handler; - /* parse the grammar */ - if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); - RAYO_UNLOCK(component); - RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); - } - /* is this voice or dtmf srgs grammar? */ - if (!strcasecmp("dtmf", iks_find_attrib_soft(input, "mode"))) { + if (!component->speech_mode) { + + /* parse the grammar */ + if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); + } + component->last_digit_time = switch_micro_time_now(); /* acknowledge command */ @@ -431,38 +404,124 @@ static iks *start_call_input(struct input_component *component, switch_core_sess /* start dtmf input detection */ if (switch_core_media_bug_add(session, "rayo_input_component", NULL, input_component_bug_callback, handler, 0, SMBF_READ_REPLACE, &handler->bug) != SWITCH_STATUS_SUCCESS) { + handler->dtmf_component = NULL; rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); } } else { - char *grammar = NULL; - const char *jsgf_path; - component->speech_mode = 1; - jsgf_path = srgs_grammar_to_jsgf_file(component->grammar, SWITCH_GLOBAL_dirs.grammar_dir, "gram"); - if (!jsgf_path) { + switch_stream_handle_t grammar = { 0 }; + SWITCH_STANDARD_STREAM(grammar); + + if (zstr(component->recognizer)) { + component->recognizer = globals.default_recognizer; + } + + /* if recognition engine is different, we can't handle this request */ + if (!zstr(handler->last_recognizer) && strcmp(component->recognizer, handler->last_recognizer)) { + handler->voice_component = NULL; RAYO_UNLOCK(component); RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Grammar error"); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Must use the same recognizer for the entire call"); + } + handler->last_recognizer = switch_core_session_strdup(session, component->recognizer); + + if (!strcmp(component->recognizer, "pocketsphinx")) { + const char *jsgf_path; + + /* transform SRGS grammar to JSGF */ + if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); + handler->voice_component = NULL; + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); + } + jsgf_path = srgs_grammar_to_jsgf_file(component->grammar, SWITCH_GLOBAL_dirs.grammar_dir, "gram"); + if (!jsgf_path) { + handler->voice_component = NULL; + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Grammar conversion to JSGF error"); + } + + /* build pocketsphinx grammar string */ + grammar.write_function(&grammar, + "{start-input-timers=%s,no-input-timeout=%d,speech-timeout=%d,confidence-threshold=%d}%s", + component->start_timers ? "true" : "false", + component->initial_timeout, + component->max_silence, + (int)ceil(component->min_confidence * 100.0), + jsgf_path); + } else if (!strncmp(component->recognizer, "unimrcp", strlen("unimrcp"))) { + /* send inline grammar to unimrcp */ + grammar.write_function(&grammar, "{start-input-timers=%s,confidence-threshold=%f,sensitivity-level=%f", + component->start_timers ? "true" : "false", + component->min_confidence, + component->sensitivity); + + if (component->initial_timeout > 0) { + grammar.write_function(&grammar, ",no-input-timeout=%d", + component->initial_timeout); + } + + if (component->max_silence > 0) { + grammar.write_function(&grammar, ",speech-complete-timeout=%d,speech-incomplete-timeout=%d", + component->max_silence, + component->max_silence); + } + + if (!zstr(component->language)) { + grammar.write_function(&grammar, ",speech-language=%s", component->language); + } + + if (!strcmp(iks_find_attrib_soft(input, "mode"), "any")) { + /* set dtmf params */ + if (component->inter_digit_timeout > 0) { + grammar.write_function(&grammar, ",dtmf-interdigit-timeout=%d", component->inter_digit_timeout); + } + if (component->term_digit) { + grammar.write_function(&grammar, ",dtmf-term-char=%c", component->term_digit); + } + } + + grammar.write_function(&grammar, "}inline:%s", iks_find_cdata(input, "grammar")); + } else { + /* passthrough to unknown ASR module */ + grammar.write_function(&grammar, "%s", iks_find_cdata(input, "grammar")); } /* acknowledge command */ rayo_component_send_start(RAYO_COMPONENT(component), iq); - /* TODO configurable speech detection - different engines, grammar passthrough, dtmf handled by recognizer */ - grammar = switch_mprintf("{no-input-timeout=%s,speech-timeout=%s,start-input-timers=%s,confidence-threshold=%d}%s", - component->initial_timeout, component->max_silence, - component->start_timers ? "true" : "false", - component->min_confidence, jsgf_path); /* start speech detection */ switch_channel_set_variable(switch_core_session_get_channel(session), "fire_asr_events", "true"); - if (switch_ivr_detect_speech(session, "pocketsphinx", grammar, "mod_rayo_grammar", "", NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_detect_speech(session, component->recognizer, grammar.data, "mod_rayo_grammar", "", NULL) != SWITCH_STATUS_SUCCESS) { + handler->voice_component = NULL; rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); } - switch_safe_free(grammar); + switch_safe_free(grammar.data); } return NULL; } +/** + * Create input component id for session. + * @param session requesting component + * @param input request + * @return the ID + */ +static char *create_input_component_id(switch_core_session_t *session, iks *input) +{ + const char *mode = "unk"; + if (input) { + mode = iks_find_attrib_soft(input, "mode"); + if (!strcmp(mode, "any")) { + mode = "voice"; + } + } + return switch_core_session_sprintf(session, "%s-input-%s", switch_core_session_get_uuid(session), mode); +} + /** * Start execution of input component */ @@ -470,10 +529,10 @@ static iks *start_call_input_component(struct rayo_actor *call, struct rayo_mess { iks *iq = msg->payload; switch_core_session_t *session = (switch_core_session_t *)session_data; - char *component_id = switch_mprintf("%s-input", switch_core_session_get_uuid(session)); + iks *input = iks_find(iq, "input"); + char *component_id = create_input_component_id(session, input); switch_memory_pool_t *pool = NULL; struct input_component *input_component = NULL; - iks *input = iks_find(iq, "input"); const char *error = NULL; if (!validate_call_input(input, &error)) { @@ -484,7 +543,6 @@ static iks *start_call_input_component(struct rayo_actor *call, struct rayo_mess switch_core_new_memory_pool(&pool); input_component = switch_core_alloc(pool, sizeof(*input_component)); rayo_component_init(RAYO_COMPONENT(input_component), pool, RAT_CALL_COMPONENT, "input", component_id, call, iks_find_attrib(iq, "from")); - switch_safe_free(component_id); /* start input */ return start_call_input(input_component, session, iks_find(iq, "input"), iq, NULL, 0); @@ -530,7 +588,6 @@ static iks *start_timers_call_input_component(struct rayo_actor *component, stru switch_mutex_lock(input_component->handler->mutex); if (input_component->speech_mode) { switch_ivr_detect_speech_start_input_timers(session); - rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); } else { input_component->last_digit_time = switch_micro_time_now(); input_component->start_timers = 1; @@ -549,53 +606,63 @@ static void on_detected_speech_event(switch_event_t *event) { const char *speech_type = switch_event_get_header(event, "Speech-Type"); char *event_str = NULL; + const char *uuid = switch_event_get_header(event, "Unique-ID"); switch_event_serialize(event, &event_str, SWITCH_FALSE); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", event_str); - if (!speech_type) { + if (!speech_type || !uuid) { return; } + if (!strcasecmp("detected-speech", speech_type)) { - const char *uuid = switch_event_get_header(event, "Unique-ID"); - char *component_id = switch_mprintf("%s-input", uuid); + char *component_id = switch_mprintf("%s-input-voice", uuid); struct rayo_component *component = RAYO_COMPONENT_LOCATE(component_id); + switch_safe_free(component_id); if (component) { const char *result = switch_event_get_body(event); switch_mutex_lock(INPUT_COMPONENT(component)->handler->mutex); - INPUT_COMPONENT(component)->handler->component = NULL; + INPUT_COMPONENT(component)->handler->voice_component = NULL; switch_mutex_unlock(INPUT_COMPONENT(component)->handler->mutex); if (zstr(result)) { rayo_component_send_complete(component, INPUT_NOMATCH); } else { - enum nlsml_match_type match_type = nlsml_parse(result, uuid); - switch (match_type) { - case NMT_NOINPUT: + if (strchr(result, '<')) { + /* got an XML result */ + enum nlsml_match_type match_type = nlsml_parse(result, uuid); + switch (match_type) { + case NMT_NOINPUT: + rayo_component_send_complete(component, INPUT_NOINPUT); + break; + case NMT_MATCH: { + iks *result_xml = nlsml_normalize(result); + send_match_event(RAYO_COMPONENT(component), result_xml); + iks_delete(result_xml); + break; + } + case NMT_BAD_XML: + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_WARNING, "Failed to parse NLSML result: %s!\n", result); + rayo_component_send_complete(component, INPUT_NOMATCH); + break; + case NMT_NOMATCH: + rayo_component_send_complete(component, INPUT_NOMATCH); + break; + default: + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_CRIT, "Unknown NLSML match type: %i, %s!\n", match_type, result); + rayo_component_send_complete(component, INPUT_NOMATCH); + break; + } + } else if (strstr(result, "002")) { + /* Completion-Cause: 002 no-input-timeout */ rayo_component_send_complete(component, INPUT_NOINPUT); - break; - case NMT_MATCH: { - iks *result_xml = nlsml_normalize(result); - send_match_event(RAYO_COMPONENT(component), result_xml); - iks_delete(result_xml); - break; - } - case NMT_BAD_XML: - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_WARNING, "Failed to parse NLSML result: %s!\n", result); + } else { + /* assume no match */ rayo_component_send_complete(component, INPUT_NOMATCH); - break; - case NMT_NOMATCH: - rayo_component_send_complete(component, INPUT_NOMATCH); - break; - default: - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_CRIT, "Unknown NLSML match type: %i, %s!\n", match_type, result); - rayo_component_send_complete(component, INPUT_NOMATCH); - break; } } RAYO_UNLOCK(component); } } else if (!strcasecmp("begin-speaking", speech_type)) { - const char *uuid = switch_event_get_header(event, "Unique-ID"); - char *component_id = switch_mprintf("%s-input", uuid); + char *component_id = switch_mprintf("%s-input-voice", uuid); struct rayo_component *component = RAYO_COMPONENT_LOCATE(component_id); switch_safe_free(component_id); if (component && INPUT_COMPONENT(component)->barge_event) { @@ -603,14 +670,13 @@ static void on_detected_speech_event(switch_event_t *event) } RAYO_UNLOCK(component); } else if (!strcasecmp("closed", speech_type)) { - const char *uuid = switch_event_get_header(event, "Unique-ID"); - char *component_id = switch_mprintf("%s-input", uuid); + char *component_id = switch_mprintf("%s-input-voice", uuid); struct rayo_component *component = RAYO_COMPONENT_LOCATE(component_id); switch_safe_free(component_id); if (component) { char *channel_state = switch_event_get_header(event, "Channel-State"); switch_mutex_lock(INPUT_COMPONENT(component)->handler->mutex); - INPUT_COMPONENT(component)->handler->component = NULL; + INPUT_COMPONENT(component)->handler->voice_component = NULL; switch_mutex_unlock(INPUT_COMPONENT(component)->handler->mutex); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Recognizer closed\n"); if (channel_state && !strcmp("CS_HANGUP", channel_state)) { @@ -625,12 +691,63 @@ static void on_detected_speech_event(switch_event_t *event) switch_safe_free(event_str); } +/** + * Process module XML configuration + * @param pool memory pool to allocate from + * @param config_file to use + * @return SWITCH_STATUS_SUCCESS on successful configuration + */ +static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_file) +{ + switch_xml_t cfg, xml; + + /* set defaults */ + globals.default_recognizer = "pocketsphinx"; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Configuring module\n"); + if (!(xml = switch_xml_open_cfg(config_file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", config_file); + return SWITCH_STATUS_TERM; + } + + /* get params */ + { + switch_xml_t settings = switch_xml_child(cfg, "input"); + if (settings) { + switch_xml_t param; + for (param = switch_xml_child(settings, "param"); param; param = param->next) { + const char *var = switch_xml_attr_soft(param, "name"); + const char *val = switch_xml_attr_soft(param, "value"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param: %s = %s\n", var, val); + if (!strcasecmp(var, "default-recognizer")) { + if (!zstr(val)) { + globals.default_recognizer = switch_core_strdup(pool, val); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var); + } + } + } + } + + switch_xml_free(xml); + + return SWITCH_STATUS_SUCCESS; +} + /** * Initialize input component + * @param module_interface + * @param pool memory pool to allocate from + * @param config_file to use * @return SWITCH_STATUS_SUCCESS if successful */ -switch_status_t rayo_input_component_load(void) +switch_status_t rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { + if (do_config(pool, config_file) != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_TERM; + } + srgs_init(); nlsml_init(); diff --git a/src/mod/event_handlers/mod_rayo/rayo_output_component.c b/src/mod/event_handlers/mod_rayo/rayo_output_component.c index f92d994a64..e85a12cece 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_output_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_output_component.c @@ -1092,9 +1092,12 @@ static char *fileman_supported_formats[] = { "fileman", NULL }; /** * Initialize output component + * @param module_interface + * @param pool memory pool to allocate from + * @param config_file to use * @return SWITCH_STATUS_SUCCESS if successful */ -switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) +switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { switch_api_interface_t *api_interface; switch_file_interface_t *file_interface; diff --git a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c index 47dbc46df3..f48e7d02d2 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c @@ -620,9 +620,12 @@ static iks *forward_output_component_request(struct rayo_actor *prompt, struct r /** * Initialize prompt component + * @param module_interface + * @param pool memory pool to allocate from + * @param config_file to use * @return SWITCH_STATUS_SUCCESS if successful */ -switch_status_t rayo_prompt_component_load(void) +switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { /* Prompt is a convenience component that wraps and */ rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_PROMPT_NS":prompt", start_call_prompt_component); diff --git a/src/mod/event_handlers/mod_rayo/rayo_record_component.c b/src/mod/event_handlers/mod_rayo/rayo_record_component.c index 2db5b30771..601d8cb3aa 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_record_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_record_component.c @@ -479,11 +479,12 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_ /** * Initialize record component + * @param module_interface * @param pool memory pool to allocate from * @param config_file to use * @return SWITCH_STATUS_SUCCESS if successful */ -switch_status_t rayo_record_component_load(switch_memory_pool_t *pool, const char *config_file) +switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { if (do_config(pool, config_file) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_TERM; diff --git a/src/mod/event_handlers/mod_rayo/test_iks/main.c b/src/mod/event_handlers/mod_rayo/test_iks/main.c index 699f40267e..09a368dc4b 100644 --- a/src/mod/event_handlers/mod_rayo/test_iks/main.c +++ b/src/mod/event_handlers/mod_rayo/test_iks/main.c @@ -145,6 +145,27 @@ static void test_dialback_key(void) ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL)); } +static void test_validate_dtmf(void) +{ + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("1")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("A")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("a")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("D")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("d")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("*")); + ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("#")); + ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("E")); + ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit(NULL)); + ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("")); + ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("11")); + ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "A")); + ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "1")); + ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "Z")); + ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "11")); + ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, NULL)); + ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "")); +} + /** * main program */ @@ -159,5 +180,6 @@ int main(int argc, char **argv) TEST(test_rayo_test_srgs); TEST(test_iks_helper_value_matches); TEST(test_dialback_key); + TEST(test_validate_dtmf); return 0; } From a8f2e684670c9d3b8139930abcb0509f5c4589fd Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Wed, 14 Aug 2013 10:06:18 -0400 Subject: [PATCH 200/203] mod_unimrcp: add example config for Vestec --- conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml diff --git a/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml new file mode 100644 index 0000000000..cbde87ca5a --- /dev/null +++ b/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + From 6726059e472a74aac0c7280558a1a56e9446d1d7 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 14 Aug 2013 09:05:14 -0500 Subject: [PATCH 201/203] FS-5694 --resolve --- src/mod/applications/mod_voicemail/mod_voicemail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 41f7cef5d6..e7d4da79ca 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -2876,7 +2876,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, update_mwi(profile, myid, domain_name, myfolder, MWI_REASON_NEW); } - if (send_mail && !zstr(vm_email) && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) { + if (send_mail && (!zstr(vm_email) || !zstr(vm_notify_email)) && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) { switch_event_t *event; char *from; char *body; From a29b2c2f7f9e47685ed485dc95c0c949f24cc9e8 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 14 Aug 2013 09:49:48 -0500 Subject: [PATCH 202/203] FS-5648 --resolve --- src/mod/endpoints/mod_sofia/sofia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 4faea7ac42..c98417f374 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -8582,6 +8582,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia profile_dup_clean(displayname, tech_pvt->caller_profile->caller_id_name, tech_pvt->caller_profile->pool); profile_dup_clean(from_user, tech_pvt->caller_profile->caller_id_number, tech_pvt->caller_profile->pool); profile_dup_clean(network_ip, tech_pvt->caller_profile->network_addr, tech_pvt->caller_profile->pool); + profile_dup_clean(from_user, tech_pvt->caller_profile->ani, tech_pvt->caller_profile->pool); profile_dup_clean(aniii, tech_pvt->caller_profile->aniii, tech_pvt->caller_profile->pool); profile_dup_clean(context, tech_pvt->caller_profile->context, tech_pvt->caller_profile->pool); profile_dup_clean(destination_number, tech_pvt->caller_profile->destination_number, tech_pvt->caller_profile->pool); From b0371ee702751970d649f7b73b4b526289148404 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 14 Aug 2013 21:00:08 +0500 Subject: [PATCH 203/203] FS-5701 --resolve --- src/switch_ivr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index f424a4668b..6cfdca4dad 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2905,6 +2905,12 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3 interval = read_impl.microseconds_per_packet / 1000; //samples = switch_samples_per_packet(read_impl.samples_per_second, interval); + if (delay_ms < interval * 2) { + delay_ms = interval * 2; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Minimum possible delay for this codec (%d) has been chosen\n", delay_ms); + } + + qlen = delay_ms / (interval) / 2; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen); jb = stfu_n_init(qlen, qlen, read_impl.samples_per_packet, read_impl.samples_per_second, 0);