diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj b/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj index cbb404c20f..468ca02836 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj +++ b/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj @@ -142,7 +142,6 @@ - diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index d37c728cb9..82e59420ae 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -34,7 +34,6 @@ #include "skinny_protocol.h" #include "skinny_server.h" #include "skinny_tables.h" -#include "skinny_labels.h" #include "skinny_api.h" SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load); @@ -103,6 +102,44 @@ static char active_lines_sql[] = " call_state INTEGER\n" ");\n"; +/*****************************************************************************/ +/* TEXT FUNCTIONS */ +/*****************************************************************************/ +char *skinny_expand_textid(const char *str) +{ + char *tmp; + int i; + + /* Look for \200, if found, next character indicates string id */ + char match = (char) 128; + + tmp = switch_mprintf(""); + + if (zstr(str)) { + return tmp; + } + + for (i=0; idevice_name, listener->device_instance, line_instance, call_id, + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Line %d, Call %d Change State to %s (%d)\n", + line_instance, call_id, skinny_call_state2str(call_state), call_state); } @@ -620,6 +658,7 @@ int channel_on_routing_callback(void *pArg, int argc, char **argv, char **column { struct channel_on_routing_helper *helper = pArg; listener_t *listener = NULL; + char *label; char *device_name = argv[0]; uint32_t device_instance = atoi(argv[1]); @@ -654,8 +693,11 @@ int channel_on_routing_callback(void *pArg, int argc, char **argv, char **column send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON); skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY); send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, SKINNY_KEY_SET_IN_USE_HINT, 0xffff); - send_display_prompt_status(listener, 0, SKINNY_DISP_IN_USE_REMOTE, - line_instance, helper->tech_pvt->call_id); + + label = skinny_textid2raw(SKINNY_TEXTID_IN_USE_REMOTE); + send_display_prompt_status(listener, 0, label, line_instance, helper->tech_pvt->call_id); + switch_safe_free(label); + skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); } } @@ -751,6 +793,7 @@ int channel_on_hangup_callback(void *pArg, int argc, char **argv, char **columnN { struct channel_on_hangup_helper *helper = pArg; listener_t *listener = NULL; + char *label; char *device_name = argv[0]; uint32_t device_instance = atoi(argv[1]); @@ -782,11 +825,15 @@ int channel_on_hangup_callback(void *pArg, int argc, char **argv, char **columnN case SWITCH_CAUSE_UNALLOCATED_NUMBER: send_start_tone(listener, SKINNY_TONE_REORDER, 0, line_instance, call_id); skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); - send_display_prompt_status(listener, 0, SKINNY_DISP_UNKNOWN_NUMBER, line_instance, call_id); + label = skinny_textid2raw(SKINNY_TEXTID_UNKNOWN_NUMBER); + send_display_prompt_status(listener, 0, label, line_instance, call_id); + switch_safe_free(label); break; case SWITCH_CAUSE_USER_BUSY: send_start_tone(listener, SKINNY_TONE_BUSYTONE, 0, line_instance, call_id); - send_display_prompt_status(listener, 0, SKINNY_DISP_BUSY, line_instance, call_id); + label = skinny_textid2raw(SKINNY_TEXTID_BUSY); + send_display_prompt_status(listener, 0, label, line_instance, call_id); + switch_safe_free(label); break; case SWITCH_CAUSE_NORMAL_CLEARING: send_clear_prompt_status(listener, line_instance, call_id); @@ -1431,11 +1478,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) switch_socket_timeout_set(listener->sock, 5000000); #endif if (listener->profile->debug > 0) { - if (zstr(listener->remote_ip)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open\n"); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open from %s:%d\n", listener->remote_ip, listener->remote_port); - } + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Connection Open\n"); } switch_set_flag_locked(listener, LFLAG_RUNNING); @@ -1449,8 +1492,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) if (status != SWITCH_STATUS_SUCCESS) { switch(status) { case SWITCH_STATUS_TIMEOUT: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Communication Time Out with %s:%d.\n", - listener->remote_ip, listener->remote_port); + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Time Out\n"); if(listener->expire_time < switch_epoch_time_now(NULL)) { switch_event_t *event = NULL; @@ -1460,8 +1502,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) } break; default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Communication Error with %s:%d.\n", - listener->remote_ip, listener->remote_port); + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Error\n"); } switch_clear_flag_locked(listener, LFLAG_RUNNING); break; @@ -1484,8 +1525,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) remove_listener(listener); if (listener->profile->debug > 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Communication Complete with %s:%d.\n", - listener->remote_ip, listener->remote_port); + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Complete\n"); } switch_thread_rwlock_wrlock(listener->rwlock); @@ -1498,8 +1538,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) switch_thread_rwlock_unlock(listener->rwlock); if (listener->profile->debug > 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Communication Closed with %s:%d.\n", - listener->remote_ip, listener->remote_port); + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Closed\n"); } if(destroy_pool == 0) { @@ -2009,8 +2048,7 @@ static void skinny_user_to_device_event_handler(switch_event_t *event) data); break; default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Incorrect message type %s (%d).\n", skinny_message_type2str(message_type), message_type); + skinny_log_l(listener, SWITCH_LOG_WARNING, "Incorrect message type %s (%d).\n", skinny_message_type2str(message_type), message_type); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, @@ -2102,8 +2140,13 @@ int skinny_message_waiting_event_handler_callback(void *pArg, int argc, char **a if (listener) { if (helper->yn == SWITCH_TRUE) { char buffer[32]; + char *label; send_set_lamp(listener, SKINNY_BUTTON_VOICEMAIL, 0, SKINNY_LAMP_ON); - sprintf(buffer, "%s: (%d/%d urgents)", SKINNY_DISP_YOU_HAVE_VOICEMAIL, helper->total_new_messages, helper->total_new_urgent_messages); + + label = skinny_textid2raw(SKINNY_TEXTID_YOU_HAVE_VOICEMAIL); + sprintf(buffer, "%s: (%d/%d urgents)", label, helper->total_new_messages, helper->total_new_urgent_messages); + switch_safe_free(label); + send_display_pri_notify(listener, 5, 10, buffer); } else { send_set_lamp(listener, SKINNY_BUTTON_VOICEMAIL, 0, SKINNY_LAMP_OFF); @@ -2206,6 +2249,7 @@ static void skinny_trap_event_handler(switch_event_t *event) } } + /*****************************************************************************/ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) { diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 12926268d9..e6d8583fdd 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -35,6 +35,32 @@ #include +/*****************************************************************************/ +/* LOGGING FUNCTIONS */ +/*****************************************************************************/ +#define skinny_undef_str(x) (zstr(x) ? "_undef_" : x) + +#define skinny_log_l(listener, level, _fmt, ...) switch_log_printf(SWITCH_CHANNEL_LOG, level, \ + "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ + listener->remote_port, __VA_ARGS__) + +#define skinny_log_l_msg(listener, level, _fmt) switch_log_printf(SWITCH_CHANNEL_LOG, level, \ + "[%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_l_ffl(listener, file, func, line, level, _fmt, ...) switch_log_printf( \ + SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level, \ + "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ + listener->remote_port, __VA_ARGS__) + +#define skinny_log_ls(listener, session, level, _fmt, ...) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, \ + "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ + listener->remote_port, __VA_ARGS__) + +#define skinny_log_ls_msg(listener, session, level, _fmt) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, \ + "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ + listener->remote_port) + /*****************************************************************************/ /* MODULE TYPES */ /*****************************************************************************/ @@ -274,6 +300,12 @@ switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); /*****************************************************************************/ switch_endpoint_interface_t *skinny_get_endpoint_interface(); +/*****************************************************************************/ +/* TEXT FUNCTIONS */ +/*****************************************************************************/ +#define skinny_textid2raw(label) (label > 0 ? switch_mprintf("\200%c", label) : switch_mprintf("")) +char *skinny_expand_textid(const char *str); + #endif /* _MOD_SKINNY_H */ /* For Emacs: diff --git a/src/mod/endpoints/mod_skinny/mod_skinny_2008.vcproj b/src/mod/endpoints/mod_skinny/mod_skinny_2008.vcproj index f052ce0fcd..fbf3482f7d 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny_2008.vcproj +++ b/src/mod/endpoints/mod_skinny/mod_skinny_2008.vcproj @@ -311,10 +311,6 @@ RelativePath=".\skinny_api.h" > - - diff --git a/src/mod/endpoints/mod_skinny/mod_skinny_2010.vcxproj b/src/mod/endpoints/mod_skinny/mod_skinny_2010.vcxproj index 440e2d500d..afacad5b6e 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny_2010.vcxproj +++ b/src/mod/endpoints/mod_skinny/mod_skinny_2010.vcxproj @@ -138,7 +138,6 @@ - diff --git a/src/mod/endpoints/mod_skinny/skinny_labels.h b/src/mod/endpoints/mod_skinny/skinny_labels.h deleted file mode 100644 index 3e495c1bd5..0000000000 --- a/src/mod/endpoints/mod_skinny/skinny_labels.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2010, Mathieu Parent - * - * 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 FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * - * The Initial Developer of the Original Code is - * Mathieu Parent - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Mathieu Parent - * - * Based on chan-sccp-b (file src/sccp_labels.h) - * - * skinny_labels.h -- Skinny Call Control Protocol (SCCP) Endpoint Module - * - */ -#ifndef _SKINNY_LABELS_H -#define _SKINNY_LABELS_H - -#define SKINNY_DISP_EMPTY "" -#define SKINNY_DISP_REDIAL "\200\1" -#define SKINNY_DISP_NEWCALL "\200\2" -#define SKINNY_DISP_HOLD "\200\3" -#define SKINNY_DISP_TRANSFER "\200\4" -#define SKINNY_DISP_CFWDALL "\200\5" -#define SKINNY_DISP_CFWDBUSY "\200\6" -#define SKINNY_DISP_CFWDNOANSWER "\200\7" -#define SKINNY_DISP_BACKSPACE "\200\10" -#define SKINNY_DISP_ENDCALL "\200\11" -#define SKINNY_DISP_RESUME "\200\12" -#define SKINNY_DISP_ANSWER "\200\13" -#define SKINNY_DISP_INFO "\200\14" -#define SKINNY_DISP_CONFRM "\200\15" -#define SKINNY_DISP_PARK "\200\16" -#define SKINNY_DISP_JOIN "\200\17" -#define SKINNY_DISP_MEETME "\200\20" -#define SKINNY_DISP_CALLPICKUP "\200\21" -#define SKINNY_DISP_GRPCALLPICKUP "\200\22" -#define SKINNY_DISP_YOUR_CURRENT_OPTIONS "\200\23" -#define SKINNY_DISP_OFF_HOOK "\200\24" -#define SKINNY_DISP_ON_HOOK "\200\25" -#define SKINNY_DISP_RING_OUT "\200\26" -#define SKINNY_DISP_FROM "\200\27" -#define SKINNY_DISP_CONNECTED "\200\30" -#define SKINNY_DISP_BUSY "\200\31" -#define SKINNY_DISP_LINE_IN_USE "\200\32" -#define SKINNY_DISP_CALL_WAITING "\200\33" -#define SKINNY_DISP_CALL_TRANSFER "\200\34" -#define SKINNY_DISP_CALL_PARK "\200\35" -#define SKINNY_DISP_CALL_PROCEED "\200\36" -#define SKINNY_DISP_IN_USE_REMOTE "\200\37" -#define SKINNY_DISP_ENTER_NUMBER "\200\40" -#define SKINNY_DISP_CALL_PARK_AT "\200\41" -#define SKINNY_DISP_PRIMARY_ONLY "\200\42" -#define SKINNY_DISP_TEMP_FAIL "\200\43" -#define SKINNY_DISP_YOU_HAVE_VOICEMAIL "\200\44" -#define SKINNY_DISP_FORWARDED_TO "\200\45" -#define SKINNY_DISP_CAN_NOT_COMPLETE_CONFERENCE "\200\46" -#define SKINNY_DISP_NO_CONFERENCE_BRIDGE "\200\47" -#define SKINNY_DISP_CAN_NOT_HOLD_PRIMARY_CONTROL "\200\50" -#define SKINNY_DISP_INVALID_CONFERENCE_PARTICIPANT "\200\51" -#define SKINNY_DISP_IN_CONFERENCE_ALREADY "\200\52" -#define SKINNY_DISP_NO_PARTICIPANT_INFO "\200\53" -#define SKINNY_DISP_EXCEED_MAXIMUM_PARTIES "\200\54" -#define SKINNY_DISP_KEY_IS_NOT_ACTIVE "\200\55" -#define SKINNY_DISP_ERROR_NO_LICENSE "\200\56" -#define SKINNY_DISP_ERROR_DBCONFIG "\200\57" -#define SKINNY_DISP_ERROR_DATABASE "\200\60" -#define SKINNY_DISP_ERROR_PASS_LIMIT "\200\61" -#define SKINNY_DISP_ERROR_UNKNOWN "\200\62" -#define SKINNY_DISP_ERROR_MISMATCH "\200\63" -#define SKINNY_DISP_CONFERENCE "\200\64" -#define SKINNY_DISP_PARK_NUMBER "\200\65" -#define SKINNY_DISP_PRIVATE "\200\66" -#define SKINNY_DISP_NOT_ENOUGH_BANDWIDTH "\200\67" -#define SKINNY_DISP_UNKNOWN_NUMBER "\200\70" -#define SKINNY_DISP_RMLSTC "\200\71" -#define SKINNY_DISP_VOICEMAIL "\200\72" -#define SKINNY_DISP_IMMDIV "\200\73" -#define SKINNY_DISP_INTRCPT "\200\74" -#define SKINNY_DISP_SETWTCH "\200\75" -#define SKINNY_DISP_TRNSFVM "\200\76" -#define SKINNY_DISP_DND "\200\77" -#define SKINNY_DISP_DIVALL "\200\100" -#define SKINNY_DISP_CALLBACK "\200\101" -#define SKINNY_DISP_NETWORK_CONGESTION_REROUTING "\200\102" -#define SKINNY_DISP_BARGE "\200\103" -#define SKINNY_DISP_FAILED_TO_SETUP_BARGE "\200\104" -#define SKINNY_DISP_ANOTHER_BARGE_EXISTS "\200\105" -#define SKINNY_DISP_INCOMPATIBLE_DEVICE_TYPE "\200\106" -#define SKINNY_DISP_NO_PARK_NUMBER_AVAILABLE "\200\107" -#define SKINNY_DISP_CALLPARK_REVERSION "\200\110" -#define SKINNY_DISP_SERVICE_IS_NOT_ACTIVE "\200\111" -#define SKINNY_DISP_HIGH_TRAFFIC_TRY_AGAIN_LATER "\200\112" -#define SKINNY_DISP_QRT "\200\113" -#define SKINNY_DISP_MCID "\200\114" -#define SKINNY_DISP_DIRTRFR "\200\115" -#define SKINNY_DISP_SELECT "\200\116" -#define SKINNY_DISP_CONFLIST "\200\117" -#define SKINNY_DISP_IDIVERT "\200\120" -#define SKINNY_DISP_CBARGE "\200\121" -#define SKINNY_DISP_CAN_NOT_COMPLETE_TRANSFER "\200\122" -#define SKINNY_DISP_CAN_NOT_JOIN_CALLS "\200\123" -#define SKINNY_DISP_MCID_SUCCESSFUL "\200\124" -#define SKINNY_DISP_NUMBER_NOT_CONFIGURED "\200\125" -#define SKINNY_DISP_SECURITY_ERROR "\200\126" -#define SKINNY_DISP_VIDEO_BANDWIDTH_UNAVAILABLE "\200\127" -#define SKINNY_DISP_VIDMODE "\200\130" -#define SKINNY_DISP_MAX_CALL_DURATION_TIMEOUT "\200\131" -#define SKINNY_DISP_MAX_HOLD_DURATION_TIMEOUT "\200\132" -#define SKINNY_DISP_OPICKUP "\200\133" -#define SKINNY_DISP_EXTERNAL_TRANSFER_RESTRICTED "\200\141" -#define SKINNY_DISP_MAC_ADDRESS "\200\145" -#define SKINNY_DISP_HOST_NAME "\200\146" -#define SKINNY_DISP_DOMAIN_NAME "\200\147" -#define SKINNY_DISP_IP_ADDRESS "\200\150" -#define SKINNY_DISP_SUBNET_MASK "\200\151" -#define SKINNY_DISP_TFTP_SERVER_1 "\200\152" -#define SKINNY_DISP_DEFAULT_ROUTER_1 "\200\153" -#define SKINNY_DISP_DEFAULT_ROUTER_2 "\200\154" -#define SKINNY_DISP_DEFAULT_ROUTER_3 "\200\155" -#define SKINNY_DISP_DEFAULT_ROUTER_4 "\200\156" -#define SKINNY_DISP_DEFAULT_ROUTER_5 "\200\157" -#define SKINNY_DISP_DNS_SERVER_1 "\200\160" -#define SKINNY_DISP_DNS_SERVER_2 "\200\161" -#define SKINNY_DISP_DNS_SERVER_3 "\200\162" -#define SKINNY_DISP_DNS_SERVER_4 "\200\163" -#define SKINNY_DISP_DNS_SERVER_5 "\200\164" -#define SKINNY_DISP_OPERATIONAL_VLAN_ID "\200\165" -#define SKINNY_DISP_ADMIN_VLAN_ID "\200\166" -#define SKINNY_DISP_CALL_MANAGER_1 "\200\167" -#define SKINNY_DISP_CALL_MANAGER_2 "\200\170" -#define SKINNY_DISP_CALL_MANAGER_3 "\200\171" -#define SKINNY_DISP_CALL_MANAGER_4 "\200\172" -#define SKINNY_DISP_CALL_MANAGER_5 "\200\173" -#define SKINNY_DISP_INFORMATION_URL "\200\174" -#define SKINNY_DISP_DIRECTORIES_URL "\200\175" -#define SKINNY_DISP_MESSAGES_URL "\200\176" -#define SKINNY_DISP_SERVICES_URL "\200\177" - -#endif /* _SKINNY_LABELS_H */ - -/* 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: - */ diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 1dab0f1c60..7fd0f2bbd4 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -33,7 +33,6 @@ #include "mod_skinny.h" #include "skinny_protocol.h" #include "skinny_tables.h" -#include "skinny_labels.h" /*****************************************************************************/ /* SKINNY FUNCTIONS */ @@ -460,7 +459,24 @@ void skinny_feature_get(listener_t *listener, uint32_t instance, struct feature_ /*****************************************************************************/ /* SKINNY MESSAGE SENDER */ /*****************************************************************************/ -switch_status_t send_register_ack(listener_t *listener, +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; + + 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); +} + +switch_status_t perform_send_register_ack(listener_t *listener, + const char *file, const char *func, int line, uint32_t keep_alive, char *date_format, char *reserved, @@ -476,10 +492,38 @@ switch_status_t send_register_ack(listener_t *listener, strncpy(message->data.reg_ack.reserved, reserved, 2); message->data.reg_ack.secondary_keep_alive = keep_alive; strncpy(message->data.reg_ack.reserved2, reserved2, 4); - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_start_tone(listener_t *listener, +switch_status_t perform_send_speed_dial_stat_res(listener_t *listener, + const char *file, const char *func, int line, + uint32_t number, + char *speed_line, + 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); + + message->data.speed_dial_res.number = number; + strncpy(message->data.speed_dial_res.line, speed_line, 24); + strncpy(message->data.speed_dial_res.label, speed_label, 40); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); +} + +switch_status_t perform_send_start_tone(listener_t *listener, + const char *file, const char *func, int line, uint32_t tone, uint32_t reserved, uint32_t line_instance, @@ -493,10 +537,16 @@ switch_status_t send_start_tone(listener_t *listener, message->data.start_tone.reserved = reserved; message->data.start_tone.line_instance = line_instance; message->data.start_tone.call_id = call_id; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_stop_tone(listener_t *listener, +switch_status_t perform_send_stop_tone(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id) { @@ -506,10 +556,15 @@ switch_status_t send_stop_tone(listener_t *listener, message->length = 4 + sizeof(message->data.stop_tone); message->data.stop_tone.line_instance = line_instance; message->data.stop_tone.call_id = call_id; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_set_ringer(listener_t *listener, +switch_status_t perform_send_set_ringer(listener_t *listener, + const char *file, const char *func, int line, uint32_t ring_type, uint32_t ring_mode, uint32_t line_instance, @@ -523,10 +578,16 @@ switch_status_t send_set_ringer(listener_t *listener, message->data.ringer.ring_mode = ring_mode; message->data.ringer.line_instance = line_instance; message->data.ringer.call_id = call_id; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_set_lamp(listener_t *listener, +switch_status_t perform_send_set_lamp(listener_t *listener, + const char *file, const char *func, int line, uint32_t stimulus, uint32_t stimulus_instance, uint32_t mode) @@ -538,10 +599,16 @@ switch_status_t send_set_lamp(listener_t *listener, message->data.lamp.stimulus = stimulus; message->data.lamp.stimulus_instance = stimulus_instance; message->data.lamp.mode = mode; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_set_speaker_mode(listener_t *listener, +switch_status_t perform_send_set_speaker_mode(listener_t *listener, + const char *file, const char *func, int line, uint32_t mode) { skinny_message_t *message; @@ -549,10 +616,15 @@ switch_status_t send_set_speaker_mode(listener_t *listener, message->type = SET_SPEAKER_MODE_MESSAGE; message->length = 4 + sizeof(message->data.speaker_mode); message->data.speaker_mode.mode = mode; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_start_media_transmission(listener_t *listener, +switch_status_t perform_send_start_media_transmission(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t remote_ip, @@ -579,10 +651,16 @@ switch_status_t send_start_media_transmission(listener_t *listener, message->data.start_media.max_frames_per_packet = max_frames_per_packet; message->data.start_media.g723_bitrate = g723_bitrate; /* ... */ - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_stop_media_transmission(listener_t *listener, +switch_status_t perform_send_stop_media_transmission(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t conference_id2) @@ -595,10 +673,16 @@ switch_status_t send_stop_media_transmission(listener_t *listener, message->data.stop_media.pass_thru_party_id = pass_thru_party_id; message->data.stop_media.conference_id2 = conference_id2; /* ... */ - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t skinny_send_call_info(listener_t *listener, +switch_status_t perform_send_call_info(listener_t *listener, + const char *file, const char *func, int line, const char *calling_party_name, const char *calling_party, const char *called_party_name, @@ -644,10 +728,15 @@ switch_status_t skinny_send_call_info(listener_t *listener, message->data.call_info.call_instance = call_instance; message->data.call_info.call_security_status = call_security_status; message->data.call_info.party_pi_restriction_bits = party_pi_restriction_bits; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_define_time_date(listener_t *listener, +switch_status_t perform_send_define_time_date(listener_t *listener, + const char *file, const char *func, int line, uint32_t year, uint32_t month, uint32_t day_of_week, /* monday = 1 */ @@ -671,15 +760,22 @@ switch_status_t send_define_time_date(listener_t *listener, message->data.define_time_date.seconds = seconds; message->data.define_time_date.milliseconds = milliseconds; message->data.define_time_date.timestamp = timestamp; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_define_current_time_date(listener_t *listener) +switch_status_t perform_send_define_current_time_date(listener_t *listener, + const char *file, const char *func, int line) { switch_time_t ts; switch_time_exp_t tm; ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); + return send_define_time_date(listener, tm.tm_year + 1900, tm.tm_mon + 1, @@ -692,16 +788,22 @@ switch_status_t send_define_current_time_date(listener_t *listener) ts / 1000000); } -switch_status_t send_capabilities_req(listener_t *listener) +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; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Send Capabilities Req%s\n", ""); + + return skinny_send_reply_quiet(listener, message); } -switch_status_t send_version(listener_t *listener, +switch_status_t perform_send_version(listener_t *listener, + const char *file, const char *func, int line, char *version) { skinny_message_t *message; @@ -709,10 +811,15 @@ switch_status_t send_version(listener_t *listener, message->type = VERSION_MESSAGE; message->length = 4+ sizeof(message->data.version); strncpy(message->data.version.version, version, 16); - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_register_reject(listener_t *listener, +switch_status_t perform_send_register_reject(listener_t *listener, + const char *file, const char *func, int line, char *error) { skinny_message_t *message; @@ -720,10 +827,15 @@ switch_status_t send_register_reject(listener_t *listener, message->type = REGISTER_REJECT_MESSAGE; message->length = 4 + sizeof(message->data.reg_rej); strncpy(message->data.reg_rej.error, error, 33); - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_open_receive_channel(listener_t *listener, +switch_status_t perform_send_open_receive_channel(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t ms_per_packet, @@ -756,10 +868,15 @@ switch_status_t send_open_receive_channel(listener_t *listener, message->data.open_receive_channel.reserved[8] = reserved[8]; message->data.open_receive_channel.reserved[9] = reserved[9]; */ - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_close_receive_channel(listener_t *listener, +switch_status_t perform_send_close_receive_channel(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t conference_id2) @@ -771,10 +888,15 @@ switch_status_t send_close_receive_channel(listener_t *listener, 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; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_select_soft_keys(listener_t *listener, +switch_status_t perform_send_select_soft_keys(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id, uint32_t soft_key_set, @@ -788,10 +910,16 @@ switch_status_t send_select_soft_keys(listener_t *listener, message->data.select_soft_keys.call_id = call_id; message->data.select_soft_keys.soft_key_set = soft_key_set; message->data.select_soft_keys.valid_key_mask = valid_key_mask; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_call_state(listener_t *listener, +switch_status_t perform_send_call_state(listener_t *listener, + const char *file, const char *func, int line, uint32_t call_state, uint32_t line_instance, uint32_t call_id) @@ -803,16 +931,24 @@ switch_status_t send_call_state(listener_t *listener, message->data.call_state.call_state = call_state; message->data.call_state.line_instance = line_instance; message->data.call_state.call_id = call_id; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_display_prompt_status(listener_t *listener, +switch_status_t perform_send_display_prompt_status(listener_t *listener, + const char *file, const char *func, int line, uint32_t timeout, const char *display, uint32_t line_instance, uint32_t call_id) { 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); @@ -820,10 +956,48 @@ switch_status_t send_display_prompt_status(listener_t *listener, strncpy(message->data.display_prompt_status.display, display, 32); message->data.display_prompt_status.line_instance = line_instance; message->data.display_prompt_status.call_id = call_id; - return skinny_send_reply(listener, message); + + tmp = skinny_expand_textid(display); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n", + timeout, tmp, line_instance, call_id); + + switch_safe_free(tmp); + + return skinny_send_reply_quiet(listener, message); } -switch_status_t send_clear_prompt_status(listener_t *listener, +switch_status_t perform_send_display_prompt_status_textid(listener_t *listener, + const char *file, const char *func, int line, + uint32_t timeout, + uint32_t display_textid, + uint32_t line_instance, + uint32_t call_id) +{ + 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); + message->data.display_prompt_status.timeout = timeout; + + label = skinny_textid2raw(display_textid); + strncpy(message->data.display_prompt_status.display, label, 32); + switch_safe_free(label); + + message->data.display_prompt_status.line_instance = line_instance; + message->data.display_prompt_status.call_id = call_id; + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); +} + +switch_status_t perform_send_clear_prompt_status(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id) { @@ -833,10 +1007,16 @@ switch_status_t send_clear_prompt_status(listener_t *listener, message->length = 4 + sizeof(message->data.clear_prompt_status); message->data.clear_prompt_status.line_instance = line_instance; message->data.clear_prompt_status.call_id = call_id; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Send Clear Prompt Status with Line Instance (%d), Call ID (%d)\n", + line_instance, call_id); + + return skinny_send_reply_quiet(listener, message); } -switch_status_t send_activate_call_plane(listener_t *listener, +switch_status_t perform_send_activate_call_plane(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance) { skinny_message_t *message; @@ -844,10 +1024,15 @@ switch_status_t send_activate_call_plane(listener_t *listener, message->type = ACTIVATE_CALL_PLANE_MESSAGE; message->length = 4 + sizeof(message->data.activate_call_plane); message->data.activate_call_plane.line_instance = line_instance; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_back_space_request(listener_t *listener, +switch_status_t perform_send_back_space_request(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id) { @@ -857,11 +1042,17 @@ switch_status_t send_back_space_request(listener_t *listener, message->length = 4 + sizeof(message->data.back_space_req); message->data.back_space_req.line_instance = line_instance; message->data.back_space_req.call_id = call_id; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Send Back Space Request with Line Instance (%d), Call ID (%d)\n", + line_instance, call_id); + + return skinny_send_reply_quiet(listener, message); } -switch_status_t send_dialed_number(listener_t *listener, +switch_status_t perform_send_dialed_number(listener_t *listener, + const char *file, const char *func, int line, char called_party[24], uint32_t line_instance, uint32_t call_id) @@ -873,10 +1064,16 @@ switch_status_t send_dialed_number(listener_t *listener, 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; - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); } -switch_status_t send_display_pri_notify(listener_t *listener, +switch_status_t perform_send_display_pri_notify(listener_t *listener, + const char *file, const char *func, int line, uint32_t message_timeout, uint32_t priority, char *notify) @@ -888,21 +1085,34 @@ switch_status_t send_display_pri_notify(listener_t *listener, 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); - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Send Display Pri Notify with Timeout (%d), Priority (%d), Message (%s)\n", + message_timeout, priority, notify); + + return skinny_send_reply_quiet(listener, message); } -switch_status_t send_reset(listener_t *listener, uint32_t reset_type) +switch_status_t perform_send_reset(listener_t *listener, + const char *file, const char *func, int line, + 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); message->data.reset.reset_type = reset_type; - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_data(listener_t *listener, uint32_t message_type, +switch_status_t perform_send_data(listener_t *listener, + const char *file, const char *func, int line, + uint32_t message_type, uint32_t application_id, uint32_t line_instance, uint32_t call_id, @@ -925,10 +1135,16 @@ switch_status_t send_data(listener_t *listener, uint32_t message_type, message->data.data.transaction_id = transaction_id; message->data.data.data_length = data_length; strncpy(message->data.data.data, data, data_length); - return skinny_send_reply(listener, message); + + 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); } -switch_status_t send_extended_data(listener_t *listener, uint32_t message_type, +switch_status_t perform_send_extended_data(listener_t *listener, + const char *file, const char *func, int line, + uint32_t message_type, uint32_t application_id, uint32_t line_instance, uint32_t call_id, @@ -961,7 +1177,30 @@ switch_status_t send_extended_data(listener_t *listener, uint32_t message_type, message->data.extended_data.app_instance_id = app_instance_id; message->data.extended_data.routing_id = routing_id; strncpy(message->data.extended_data.data, data, data_length); - return skinny_send_reply(listener, message); + + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "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); +} + +switch_status_t skinny_perform_send_reply_quiet(listener_t *listener, const char *file, const char *func, int line, skinny_message_t *reply) +{ + char *ptr; + switch_size_t len; + switch_assert(reply != NULL); + len = reply->length+8; + ptr = (char *) reply; + + if (listener_is_ready(listener)) { + return switch_socket_send(listener->sock, ptr, &len); + } 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); + 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) @@ -974,17 +1213,15 @@ switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file if (listener_is_ready(listener)) { if (listener->profile->debug >= 10 || reply->type != KEEP_ALIVE_ACK_MESSAGE) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, - "Sending %s (type=%x,length=%d) to %s:%d at %s:%d.\n", - skinny_message_type2str(reply->type), reply->type, reply->length, - listener->device_name, listener->device_instance, listener->remote_ip, listener->remote_port); + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Sending %s (type=%x,length=%d).\n", + skinny_message_type2str(reply->type), reply->type, reply->length); } return switch_socket_send(listener->sock, ptr, &len); } else { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, - "Not sending %s (type=%x,length=%d) to %s:%d while not ready.\n", - skinny_message_type2str(reply->type), reply->type, reply->length, - listener->device_name, listener->device_instance); + 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); 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 da79df8b7e..16a8767c8e 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -789,37 +789,70 @@ void skinny_feature_get(listener_t *listener, uint32_t instance, struct feature_ 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_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_handle_request(listener_t *listener, skinny_message_t *request); /*****************************************************************************/ /* SKINNY MESSAGE HELPER */ /*****************************************************************************/ -switch_status_t send_register_ack(listener_t *listener, +switch_status_t perform_send_keep_alive_ack(listener_t *listener, + const char *file, const char *func, int line); +#define send_keep_alive_ack(listener) perform_send_keep_alive_ack(listener, __FILE__, __SWITCH_FUNC__, __LINE__); + +switch_status_t perform_send_register_ack(listener_t *listener, + const char *file, const char *func, int line, uint32_t keep_alive, char *date_format, char *reserved, uint32_t secondary_keep_alive, char *reserved2); -switch_status_t send_start_tone(listener_t *listener, +#define send_register_ack(listener, ...) perform_send_register_ack(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_speed_dial_stat_res(listener_t *listener, + const char *file, const char *func, int line, + uint32_t number, + char *speed_line, + char *speed_label); +#define send_speed_dial_stat_res(listener, ...) perform_send_speed_dial_stat_res(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_start_tone(listener_t *listener, + const char *file, const char *func, int line, uint32_t tone, uint32_t reserved, uint32_t line_instance, uint32_t call_id); -switch_status_t send_stop_tone(listener_t *listener, +#define send_start_tone(listener, ...) perform_send_start_tone(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_stop_tone(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id); -switch_status_t send_set_ringer(listener_t *listener, +#define send_stop_tone(listener, ...) perform_send_stop_tone(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_set_ringer(listener_t *listener, + const char *file, const char *func, int line, uint32_t ring_type, uint32_t ring_mode, uint32_t line_instance, uint32_t call_id); -switch_status_t send_set_lamp(listener_t *listener, +#define send_set_ringer(listener, ...) perform_send_set_ringer(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_set_lamp(listener_t *listener, + const char *file, const char *func, int line, uint32_t stimulus, uint32_t stimulus_instance, uint32_t mode); -switch_status_t send_set_speaker_mode(listener_t *listener, +#define send_set_lamp(listener, ...) perform_send_set_lamp(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_set_speaker_mode(listener_t *listener, + const char *file, const char *func, int line, uint32_t mode); -switch_status_t send_start_media_transmission(listener_t *listener, +#define send_set_speaker_mode(listener, ...) perform_send_set_speaker_mode(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, uint32_t pass_thru_party_id, uint32_t remote_ip, @@ -830,11 +863,17 @@ switch_status_t send_start_media_transmission(listener_t *listener, uint32_t silence_suppression, uint16_t max_frames_per_packet, uint32_t g723_bitrate); -switch_status_t send_stop_media_transmission(listener_t *listener, +#define send_start_media_transmission(listener,...) perform_send_start_media_transmission(listener,__FILE__, __SWITCH_FUNC__, __LINE__,__VA_ARGS__) + +switch_status_t perform_send_stop_media_transmission(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t conference_id2); -switch_status_t skinny_send_call_info(listener_t *listener, +#define send_stop_media_transmission(listener, ...) perform_send_stop_media_transmission(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_call_info(listener_t *listener, + const char *file, const char *func, int line, const char *calling_party_name, const char *calling_party, const char *called_party_name, @@ -855,7 +894,10 @@ switch_status_t skinny_send_call_info(listener_t *listener, uint32_t call_instance, uint32_t call_security_status, uint32_t party_pi_restriction_bits); -switch_status_t send_define_time_date(listener_t *listener, +#define send_call_info(listener, ...) perform_send_call_info(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_define_time_date(listener_t *listener, + const char *file, const char *func, int line, uint32_t year, uint32_t month, uint32_t day_of_week, /* monday = 1 */ @@ -865,13 +907,28 @@ switch_status_t send_define_time_date(listener_t *listener, uint32_t seconds, uint32_t milliseconds, uint32_t timestamp); -switch_status_t send_define_current_time_date(listener_t *listener); -switch_status_t send_version(listener_t *listener, +#define send_define_time_date(listener, ...) perform_send_define_time_date(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_define_current_time_date(listener_t *listener, + const char *file, const char *func, int line); +#define send_define_current_time_date(listener) perform_send_define_current_time_date(listener, __FILE__, __SWITCH_FUNC__, __LINE__) + +switch_status_t perform_send_version(listener_t *listener, + const char *file, const char *func, int line, char *version); -switch_status_t send_capabilities_req(listener_t *listener); -switch_status_t send_register_reject(listener_t *listener, +#define send_version(listener, ...) perform_send_version(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_capabilities_req(listener_t *listener, + const char *file, const char *func, int line); +#define send_capabilities_req(listener) perform_send_capabilities_req(listener, __FILE__, __SWITCH_FUNC__, __LINE__) + +switch_status_t perform_send_register_reject(listener_t *listener, + const char *file, const char *func, int line, char *error); -switch_status_t send_open_receive_channel(listener_t *listener, +#define send_register_reject(listener, ...) perform_send_register_reject(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_open_receive_channel(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t ms_per_packet, @@ -880,52 +937,96 @@ switch_status_t send_open_receive_channel(listener_t *listener, uint32_t g723_bitrate, uint32_t conference_id2, uint32_t reserved[10]); -switch_status_t send_close_receive_channel(listener_t *listener, +#define send_open_receive_channel(listener, ...) perform_send_open_receive_channel(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_close_receive_channel(listener_t *listener, + const char *file, const char *func, int line, uint32_t conference_id, uint32_t pass_thru_party_id, uint32_t conference_id2); -switch_status_t send_select_soft_keys(listener_t *listener, +#define send_close_receive_channel(listener, ...) perform_send_close_receive_channel(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_select_soft_keys(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id, uint32_t soft_key_set, uint32_t valid_key_mask); -switch_status_t send_call_state(listener_t *listener, +#define send_select_soft_keys(listener, ...) perform_send_select_soft_keys(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_call_state(listener_t *listener, + const char *file, const char *func, int line, uint32_t call_state, uint32_t line_instance, uint32_t call_id); -switch_status_t send_display_prompt_status(listener_t *listener, +#define send_call_state(listener, ...) perform_send_call_state(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_display_prompt_status(listener_t *listener, + const char *file, const char *func, int line, uint32_t timeout, const char *display, uint32_t line_instance, uint32_t call_id); -switch_status_t send_clear_prompt_status(listener_t *listener, +#define send_display_prompt_status(listener, ...) perform_send_display_prompt_status(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_display_prompt_status_textid(listener_t *listener, + const char *file, const char *func, int line, + uint32_t timeout, + uint32_t display_textid, uint32_t line_instance, uint32_t call_id); -switch_status_t send_activate_call_plane(listener_t *listener, +#define send_display_prompt_status_textid(listener, ...) perform_send_display_prompt_status_textid(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_clear_prompt_status(listener_t *listener, + const char *file, const char *func, int line, + uint32_t line_instance, + uint32_t call_id); +#define send_clear_prompt_status(listener, ...) perform_send_clear_prompt_status(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_activate_call_plane(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance); -switch_status_t send_back_space_request(listener_t *listener, +#define send_activate_call_plane(listener, ...) perform_send_activate_call_plane(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_back_space_request(listener_t *listener, + const char *file, const char *func, int line, uint32_t line_instance, uint32_t call_id); -switch_status_t send_dialed_number(listener_t *listener, +#define send_back_space_request(listener, ...) perform_send_back_space_request(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_dialed_number(listener_t *listener, + const char *file, const char *func, int line, char called_party[24], uint32_t line_instance, uint32_t call_id); -switch_status_t send_display_pri_notify(listener_t *listener, +#define send_dialed_number(listener, ...) perform_send_dialed_number(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_display_pri_notify(listener_t *listener, + const char *file, const char *func, int line, uint32_t message_timeout, uint32_t priority, char *notify); -switch_status_t send_reset(listener_t *listener, - uint32_t reset_type); +#define send_display_pri_notify(listener, ...) perform_send_display_pri_notify(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) -switch_status_t send_data(listener_t *listener, uint32_t message_type, +switch_status_t perform_send_reset(listener_t *listener, + const char *file, const char *func, int line, + uint32_t reset_type); +#define send_reset(listener, ...) perform_send_reset(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + +switch_status_t perform_send_data(listener_t *listener, + const char *file, const char *func, int line, + uint32_t message_type, uint32_t application_id, uint32_t line_instance, uint32_t call_id, uint32_t transaction_id, uint32_t data_length, const char *data); +#define send_data(listener, ...) perform_send_data(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) -switch_status_t send_extended_data(listener_t *listener, uint32_t message_type, +switch_status_t perform_send_extended_data(listener_t *listener, + const char *file, const char *func, int line, + uint32_t message_type, uint32_t application_id, uint32_t line_instance, uint32_t call_id, @@ -937,6 +1038,7 @@ switch_status_t send_extended_data(listener_t *listener, uint32_t message_type, uint32_t app_instance_id, uint32_t routing_id, const char *data); +#define send_extended_data(listener, ...) perform_send_extended_data(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) #endif /* _SKINNY_PROTOCOL_H */ diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index f5f7e5f5bc..8904c3cf59 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -33,30 +33,52 @@ #include "mod_skinny.h" #include "skinny_protocol.h" #include "skinny_tables.h" -#include "skinny_labels.h" #include "skinny_server.h" -struct soft_key_template_definition soft_key_template_default[] = { - { SKINNY_DISP_REDIAL, SOFTKEY_REDIAL }, - { SKINNY_DISP_NEWCALL, SOFTKEY_NEWCALL }, - { SKINNY_DISP_HOLD, SOFTKEY_HOLD }, - { SKINNY_DISP_TRANSFER, SOFTKEY_TRANSFER }, - { SKINNY_DISP_CFWDALL, SOFTKEY_CFWDALL }, - { SKINNY_DISP_CFWDBUSY, SOFTKEY_CFWDBUSY }, - { SKINNY_DISP_CFWDNOANSWER, SOFTKEY_CFWDNOANSWER }, - { SKINNY_DISP_BACKSPACE, SOFTKEY_BACKSPACE }, - { SKINNY_DISP_ENDCALL, SOFTKEY_ENDCALL }, - { SKINNY_DISP_RESUME, SOFTKEY_RESUME }, - { SKINNY_DISP_ANSWER, SOFTKEY_ANSWER }, - { SKINNY_DISP_INFO, SOFTKEY_INFO }, - { SKINNY_DISP_CONFRM, SOFTKEY_CONFRM }, - { SKINNY_DISP_PARK, SOFTKEY_PARK }, - { SKINNY_DISP_JOIN, SOFTKEY_JOIN }, - { SKINNY_DISP_MEETME, SOFTKEY_MEETMECONFRM }, - { SKINNY_DISP_CALLPICKUP, SOFTKEY_CALLPICKUP }, - { SKINNY_DISP_GRPCALLPICKUP, SOFTKEY_GRPCALLPICKUP }, - { SKINNY_DISP_DND, SOFTKEY_DND }, - { SKINNY_DISP_IDIVERT, SOFTKEY_IDIVERT }, +uint32_t soft_key_template_default_textids[] = { + SKINNY_TEXTID_REDIAL, + SKINNY_TEXTID_NEWCALL, + SKINNY_TEXTID_HOLD, + SKINNY_TEXTID_TRANSFER, + SKINNY_TEXTID_CFWDALL, + SKINNY_TEXTID_CFWDBUSY, + SKINNY_TEXTID_CFWDNOANSWER, + SKINNY_TEXTID_BACKSPACE, + SKINNY_TEXTID_ENDCALL, + SKINNY_TEXTID_RESUME, + SKINNY_TEXTID_ANSWER, + SKINNY_TEXTID_INFO, + SKINNY_TEXTID_CONF, + SKINNY_TEXTID_PARK, + SKINNY_TEXTID_JOIN, + SKINNY_TEXTID_MEETME, + SKINNY_TEXTID_CALLPICKUP, + SKINNY_TEXTID_GRPCALLPICKUP, + SKINNY_TEXTID_DND, + SKINNY_TEXTID_IDIVERT +}; + +uint32_t soft_key_template_default_events[] = { + SOFTKEY_REDIAL, + SOFTKEY_NEWCALL, + SOFTKEY_HOLD, + SOFTKEY_TRANSFER, + SOFTKEY_CFWDALL, + SOFTKEY_CFWDBUSY, + SOFTKEY_CFWDNOANSWER, + SOFTKEY_BACKSPACE, + SOFTKEY_ENDCALL, + SOFTKEY_RESUME, + SOFTKEY_ANSWER, + SOFTKEY_INFO, + SOFTKEY_CONF, + SOFTKEY_PARK, + SOFTKEY_JOIN, + SOFTKEY_MEETMECONF, + SOFTKEY_CALLPICKUP, + SOFTKEY_GRPCALLPICKUP, + SOFTKEY_DND, + SOFTKEY_IDIVERT }; /*****************************************************************************/ @@ -91,20 +113,18 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l skinny_line_get(listener, *line_instance_p, &button); if (!button || !button->shortname) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Line %d not found on device %s %d\n", - *line_instance_p, listener->device_name, listener->device_instance); + skinny_log_l(listener, SWITCH_LOG_CRIT, "Line %d not found on device\n", *line_instance_p); goto error; } if (!(nsession = switch_core_session_request(skinny_get_endpoint_interface(), SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n"); + skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Error Creating Session\n"); goto error; } if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(nsession, sizeof(*tech_pvt)))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(nsession), SWITCH_LOG_CRIT, - "Error Creating Session private object\n"); + skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT, "Error Creating Session private object\n"); goto error; } @@ -119,13 +139,11 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l switch_channel_set_name(channel, name); if (switch_core_session_thread_launch(nsession) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(nsession), SWITCH_LOG_CRIT, - "Error Creating Session thread\n"); + skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT, "Error Creating Session thread\n"); goto error; } if (switch_core_session_read_lock(nsession) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(nsession), SWITCH_LOG_CRIT, - "Error Locking Session\n"); + skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT, "Error Locking Session\n"); goto error; } /* First create the caller profile in the patterns Dialplan */ @@ -136,8 +154,7 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l "skinny" /* modname */, listener->profile->patterns_context, "")) != 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(nsession), SWITCH_LOG_CRIT, - "Error Creating Session caller profile\n"); + skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT, "Error Creating Session caller profile\n"); goto error; } @@ -161,14 +178,15 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l send_set_lamp(listener, SKINNY_BUTTON_LINE, *line_instance_p, SKINNY_LAMP_ON); skinny_line_set_state(listener, *line_instance_p, tech_pvt->call_id, SKINNY_OFF_HOOK); send_select_soft_keys(listener, *line_instance_p, tech_pvt->call_id, SKINNY_KEY_SET_OFF_HOOK, 0xffff); - send_display_prompt_status(listener, 0, SKINNY_DISP_ENTER_NUMBER, - *line_instance_p, tech_pvt->call_id); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_ENTER_NUMBER, *line_instance_p, tech_pvt->call_id); + send_activate_call_plane(listener, *line_instance_p); if (switch_channel_get_state(channel) == CS_NEW) { switch_channel_set_state(channel, CS_HIBERNATE); } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(nsession), SWITCH_LOG_CRIT, - "Wow! this channel should be in CS_NEW state, but it is not!\n"); + skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT, + "Wow! this channel should be in CS_NEW state, but it is not!\n"); } goto done; @@ -347,7 +365,7 @@ switch_status_t skinny_session_send_call_info(switch_core_session_t *session, li } else { call_type = SKINNY_OUTBOUND_CALL; } - skinny_send_call_info(listener, + send_call_info(listener, caller_party_name, /* char calling_party_name[40], */ caller_party_number, /* char calling_party[24], */ called_party_name, /* char called_party_name[40], */ @@ -499,6 +517,7 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN { struct skinny_ring_lines_helper *helper = pArg; char *tmp; + char *label; char *device_name = argv[0]; uint32_t device_instance = atoi(argv[1]); @@ -529,6 +548,10 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN helper->lines_count++; switch_channel_set_variable(channel, "effective_callee_id_number", value); switch_channel_set_variable(channel, "effective_callee_id_name", caller_name); + + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Ring Lines Callback with Callee Number (%s), Caller Name (%s), Dest Number (%s)\n", + value, caller_name, helper->tech_pvt->caller_profile->destination_number); + if (helper->remote_session) { switch_core_session_message_t msg = { 0 }; msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY; @@ -545,10 +568,14 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_RING_IN); send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, SKINNY_KEY_SET_RING_IN, 0xffff); - if ((tmp = switch_mprintf("%s%s", SKINNY_DISP_FROM, helper->tech_pvt->caller_profile->destination_number))) { + + label = skinny_textid2raw(SKINNY_TEXTID_FROM); + if ((tmp = switch_mprintf("%s%s", label, helper->tech_pvt->caller_profile->destination_number))) { send_display_prompt_status(listener, 0, tmp, line_instance, helper->tech_pvt->call_id); switch_safe_free(tmp); } + switch_safe_free(label); + if ((tmp = switch_mprintf("\005\000\000\000%s", helper->tech_pvt->caller_profile->destination_number))) { send_display_pri_notify(listener, 10 /* message_timeout */, 5 /* priority */, tmp); switch_safe_free(tmp); @@ -600,7 +627,9 @@ switch_status_t skinny_session_ring_out(switch_core_session_t *session, listener send_start_tone(listener, SKINNY_TONE_ALERT, 0, line_instance, tech_pvt->call_id); skinny_line_set_state(listener, line_instance, tech_pvt->call_id, SKINNY_RING_OUT); send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_RING_OUT, 0xffff); - send_display_prompt_status(listener, 0, SKINNY_DISP_RING_OUT, line_instance, tech_pvt->call_id); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_RING_OUT, line_instance, tech_pvt->call_id); + skinny_session_send_call_info(session, listener, line_instance); return SWITCH_STATUS_SUCCESS; @@ -642,12 +671,17 @@ int skinny_session_answer_callback(void *pArg, int argc, char **argv, char **col && (device_instance == helper->listener->device_instance) && (line_instance == helper->line_instance)) {/* the answering line */ /* nothing */ + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Session Answer Callback - matched helper\n"); } else { + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Session Answer Callback\n"); + send_define_current_time_date(listener); send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON); skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY); send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, 10, 0x0002); - send_display_prompt_status(listener, 0, SKINNY_DISP_IN_USE_REMOTE, line_instance, helper->tech_pvt->call_id); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_IN_USE_REMOTE, line_instance, helper->tech_pvt->call_id); + send_set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id); } } @@ -716,11 +750,8 @@ switch_status_t skinny_session_start_media(switch_core_session_t *session, liste skinny_line_set_state(listener, line_instance, tech_pvt->call_id, SKINNY_CONNECTED); send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_CONNECTED, 0xffff); - send_display_prompt_status(listener, - 0, - SKINNY_DISP_CONNECTED, - line_instance, - tech_pvt->call_id); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_CONNECTED, line_instance, tech_pvt->call_id); } skinny_session_send_call_info(session, listener, line_instance); @@ -744,8 +775,9 @@ switch_status_t skinny_session_hold_line(switch_core_session_t *session, listene send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_WINK); skinny_line_set_state(listener, line_instance, tech_pvt->call_id, SKINNY_HOLD); send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_ON_HOLD, 0xffff); - send_display_prompt_status(listener, 0, SKINNY_DISP_HOLD, - line_instance, tech_pvt->call_id); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_HOLD, line_instance, tech_pvt->call_id); + skinny_session_send_call_info(tech_pvt->session, listener, line_instance); send_set_speaker_mode(listener, SKINNY_SPEAKER_OFF); send_set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, tech_pvt->call_id); @@ -907,13 +939,10 @@ switch_status_t skinny_hold_active_calls(listener_t *listener) /*****************************************************************************/ switch_status_t skinny_handle_keep_alive_message(listener_t *listener, skinny_message_t *request) { - skinny_message_t *message; - - message = switch_core_alloc(listener->pool, 12); - message->type = KEEP_ALIVE_ACK_MESSAGE; - message->length = 4; keepalive_listener(listener, NULL); - skinny_send_reply(listener, message); + + send_keep_alive_ack(listener); + return SWITCH_STATUS_SUCCESS; } @@ -1220,6 +1249,9 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess call_id = request->data.stimulus.call_id; } + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received stimulus message of type (%s)\n", + skinny_button2str(request->data.stimulus.instance_type)); + switch(request->data.stimulus.instance_type) { case SKINNY_BUTTON_LAST_NUMBER_REDIAL: skinny_create_incoming_session(listener, &line_instance, &session); @@ -1384,27 +1416,24 @@ switch_status_t skinny_handle_forward_stat_req_message(listener_t *listener, ski message->data.forward_stat.line_instance = request->data.forward_stat_req.line_instance; - skinny_send_reply(listener, message); + 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); return SWITCH_STATUS_SUCCESS; } switch_status_t skinny_handle_speed_dial_stat_request(listener_t *listener, skinny_message_t *request) { - skinny_message_t *message; struct speed_dial_stat_res_message *button = NULL; skinny_check_data_length(request, sizeof(request->data.speed_dial_req)); - 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_log_l(listener, SWITCH_LOG_DEBUG, "Handle Speed Dial Stat Request for Number (%d)\n", request->data.speed_dial_req.number); skinny_speed_dial_get(listener, request->data.speed_dial_req.number, &button); - memcpy(&message->data.speed_dial_res, button, sizeof(struct speed_dial_stat_res_message)); - - skinny_send_reply(listener, message); + send_speed_dial_stat_res(listener, request->data.speed_dial_req.number, button->line, button->label); return SWITCH_STATUS_SUCCESS; } @@ -1661,8 +1690,7 @@ switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny 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); + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Codecs %s supported.\n", codec_string); return SWITCH_STATUS_SUCCESS; } @@ -1672,10 +1700,10 @@ switch_status_t skinny_handle_alarm(listener_t *listener, skinny_message_t *requ skinny_check_data_length(request, sizeof(request->data.alarm)); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Received alarm: Severity=%d, DisplayMessage=%s, Param1=%d, Param2=%d.\n", - request->data.alarm.alarm_severity, request->data.alarm.display_message, - request->data.alarm.alarm_param1, request->data.alarm.alarm_param2); + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received alarm: Severity=%d, DisplayMessage=%s, Param1=%d, Param2=%d.\n", + request->data.alarm.alarm_severity, request->data.alarm.display_message, + request->data.alarm.alarm_param1, request->data.alarm.alarm_param2); + /* skinny::alarm event */ skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_ALARM); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-Alarm-Severity", "%d", request->data.alarm.alarm_severity); @@ -1774,9 +1802,8 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON); } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Unable to find session for device %s:%d (call id=%d).\n", - listener->device_name, listener->device_instance, request->data.open_receive_channel_ack.pass_thru_party_id); + skinny_log_l(listener, SWITCH_LOG_WARNING, "Unable to find session for call id=%d.\n", + request->data.open_receive_channel_ack.pass_thru_party_id); } end: if(session) { @@ -1791,15 +1818,17 @@ switch_status_t skinny_handle_soft_key_set_request(listener_t *listener, skinny_ if (listener->soft_key_set_set) { message = switch_core_hash_find(listener->profile->soft_key_set_sets_hash, listener->soft_key_set_set); + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Set Request with Set (%s)\n", listener->soft_key_set_set); } if (!message) { message = switch_core_hash_find(listener->profile->soft_key_set_sets_hash, "default"); + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Set Request with Set (%s)\n", "default"); } if (message) { skinny_send_reply(listener, message); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Profile %s doesn't have a default .\n", listener->profile->name); + skinny_log_l(listener, SWITCH_LOG_ERROR, "Profile %s doesn't have a default .\n", + listener->profile->name); } /* Init the states */ @@ -1823,6 +1852,9 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn call_id = request->data.soft_key_event.call_id; } + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Soft Key Event (%s) with Line Instance (%d), Call ID (%d)\n", + skinny_soft_key_event2str(request->data.soft_key_event.event), line_instance, call_id); + switch(request->data.soft_key_event.event) { case SOFTKEY_REDIAL: status = skinny_create_incoming_session(listener, &line_instance, &session); @@ -1909,7 +1941,10 @@ switch_status_t skinny_handle_unregister(listener_t *listener, skinny_message_t message->type = UNREGISTER_ACK_MESSAGE; message->length = 4 + sizeof(message->data.unregister_ack); message->data.unregister_ack.unregister_status = 0; /* OK */ - skinny_send_reply(listener, message); + + 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); /* Close socket */ switch_clear_flag_locked(listener, LFLAG_RUNNING); @@ -1919,6 +1954,7 @@ switch_status_t skinny_handle_unregister(listener_t *listener, skinny_message_t switch_status_t skinny_handle_soft_key_template_request(listener_t *listener, skinny_message_t *request) { + int i; skinny_message_t *message; switch_assert(listener->profile); @@ -1932,11 +1968,18 @@ switch_status_t skinny_handle_soft_key_template_request(listener_t *listener, sk message->data.soft_key_template.soft_key_count = 21; message->data.soft_key_template.total_soft_key_count = 21; - memcpy(message->data.soft_key_template.soft_key, - soft_key_template_default, - sizeof(soft_key_template_default)); + memset(message->data.soft_key_template.soft_key, 0, sizeof(message->data.soft_key_template)); + for (i=0; idata.soft_key_template.soft_key[i].soft_key_label, skinny_textid2raw(soft_key_template_default_textids[i])); + switch_safe_free(label); - skinny_send_reply(listener, message); + message->data.soft_key_template.soft_key[i].soft_key_event = soft_key_template_default_events[i]; + } + + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Template Request with Default Template\n"); + + skinny_send_reply_quiet(listener, message); return SWITCH_STATUS_SUCCESS; } @@ -1957,6 +2000,9 @@ switch_status_t skinny_headset_status_message(listener_t *listener, skinny_messa switch_safe_free(sql); } + skinny_log_l(listener, SWITCH_LOG_DEBUG, "Update headset accessory status (%s)\n", + skinny_accessory_state2str(request->data.headset_status.mode)); + return SWITCH_STATUS_SUCCESS; } @@ -1964,6 +2010,8 @@ switch_status_t skinny_handle_register_available_lines_message(listener_t *liste { skinny_check_data_length(request, sizeof(request->data.reg_lines)); + skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Handle Register Available Lines\n"); + /* Do nothing */ return SWITCH_STATUS_SUCCESS; } @@ -2132,8 +2180,7 @@ switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t * switch_event_t *event = NULL; char *tmp = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Received XML alarm.\n"); + skinny_log_l(listener, SWITCH_LOG_INFO, "Received XML alarm (length=%d).\n", request->length); /* skinny::xml_alarm event */ skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_XML_ALARM); /* Ensure that the body is null-terminated */ @@ -2150,9 +2197,8 @@ switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t * switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request) { if (listener->profile->debug >= 10 || request->type != KEEP_ALIVE_MESSAGE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Received %s (type=%x,length=%d) from %s:%d at %s:%d.\n", skinny_message_type2str(request->type), request->type, request->length, - listener->device_name, listener->device_instance, listener->remote_ip, listener->remote_port); + 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) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index f5ce877f27..8dd9ddd988 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -43,7 +43,7 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {STIMULUS_MESSAGE, "StimulusMessage"}, {OFF_HOOK_MESSAGE, "OffHookMessage"}, {ON_HOOK_MESSAGE, "OnHookMessage"}, - { FORWARD_STAT_REQ_MESSAGE, "ForwardStatReqMessage"}, + {FORWARD_STAT_REQ_MESSAGE, "ForwardStatReqMessage"}, {SPEED_DIAL_STAT_REQ_MESSAGE, "SpeedDialStatReqMessage"}, {LINE_STAT_REQ_MESSAGE, "LineStatReqMessage"}, {CONFIG_STAT_REQ_MESSAGE, "ConfigStatReqMessage"}, @@ -132,6 +132,19 @@ SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1) SKINNY_DECLARE_ID2STR(skinny_device_type2str, SKINNY_DEVICE_TYPES, "UnknownDeviceType") SKINNY_DECLARE_STR2ID(skinny_str2device_type, SKINNY_DEVICE_TYPES, -1) + struct skinny_table SKINNY_TONS[] = { + {SKINNY_TONE_SILENCE, "Silence"}, + {SKINNY_TONE_DIALTONE, "DialTone"}, + {SKINNY_TONE_BUSYTONE, "BusyTone"}, + {SKINNY_TONE_ALERT, "Alert"}, + {SKINNY_TONE_REORDER, "Reorder"}, + {SKINNY_TONE_CALLWAITTONE, "CallWaitTone"}, + {SKINNY_TONE_NOTONE, "NoTone"}, + {0, NULL} + }; + SKINNY_DECLARE_ID2STR(skinny_tone2str, SKINNY_TONS, "UnknownTone") +SKINNY_DECLARE_STR2ID(skinny_str2tone, SKINNY_TONS, -1) + struct skinny_table SKINNY_RING_TYPES[] = { {SKINNY_RING_OFF, "RingOff"}, {SKINNY_RING_INSIDE, "RingInside"}, @@ -179,10 +192,10 @@ SKINNY_DECLARE_STR2ID(skinny_str2button, SKINNY_BUTTONS, -1) {SOFTKEY_RESUME, "SoftkeyResume"}, {SOFTKEY_ANSWER , "SoftkeyAnswer"}, {SOFTKEY_INFO, "SoftkeyInfo"}, - {SOFTKEY_CONFRM, "SoftkeyConfrm"}, + {SOFTKEY_CONF, "SoftkeyConf"}, {SOFTKEY_PARK, "SoftkeyPark"}, {SOFTKEY_JOIN, "SoftkeyJoin"}, - {SOFTKEY_MEETMECONFRM, "SoftkeyMeetmeconfrm"}, + {SOFTKEY_MEETMECONF, "SoftkeyMeetmeconfrm"}, {SOFTKEY_CALLPICKUP, "SoftkeyCallpickup"}, {SOFTKEY_GRPCALLPICKUP, "SoftkeyGrpcallpickup"}, {SOFTKEY_DND, "SoftkeyDnd"}, @@ -275,6 +288,132 @@ SKINNY_DECLARE_STR2ID(skinny_str2accessory_type, SKINNY_ACCESSORY_TYPES, -1) SKINNY_DECLARE_ID2STR(skinny_accessory_state2str, SKINNY_ACCESSORY_STATES, "AccessoryStateUnknown") SKINNY_DECLARE_STR2ID(skinny_str2accessory_state, SKINNY_ACCESSORY_STATES, -1) + struct skinny_table SKINNY_TEXTIDS[] = { + {SKINNY_TEXTID_EMPTY, "Empty"}, + {SKINNY_TEXTID_REDIAL, "Redial"}, + {SKINNY_TEXTID_NEWCALL, "Newcall"}, + {SKINNY_TEXTID_HOLD, "Hold"}, + {SKINNY_TEXTID_TRANSFER, "Transfer"}, + {SKINNY_TEXTID_CFWDALL, "Cfwdall"}, + {SKINNY_TEXTID_CFWDBUSY, "Cfwdbusy"}, + {SKINNY_TEXTID_CFWDNOANSWER, "Cfwdnoanswer"}, + {SKINNY_TEXTID_BACKSPACE, "Backspace"}, + {SKINNY_TEXTID_ENDCALL, "Endcall"}, + {SKINNY_TEXTID_RESUME, "Resume"}, + {SKINNY_TEXTID_ANSWER, "Answer"}, + {SKINNY_TEXTID_INFO, "Info"}, + {SKINNY_TEXTID_CONF, "Conf"}, + {SKINNY_TEXTID_PARK, "Park"}, + {SKINNY_TEXTID_JOIN, "Join"}, + {SKINNY_TEXTID_MEETME, "Meetme"}, + {SKINNY_TEXTID_CALLPICKUP, "Callpickup"}, + {SKINNY_TEXTID_GRPCALLPICKUP, "Grpcallpickup"}, + {SKINNY_TEXTID_YOUR_CURRENT_OPTIONS, "Your Current Options"}, + {SKINNY_TEXTID_OFF_HOOK, "Off Hook"}, + {SKINNY_TEXTID_ON_HOOK, "On Hook"}, + {SKINNY_TEXTID_RING_OUT, "Ring Out"}, + {SKINNY_TEXTID_FROM, "From"}, + {SKINNY_TEXTID_CONNECTED, "Connected"}, + {SKINNY_TEXTID_BUSY, "Busy"}, + {SKINNY_TEXTID_LINE_IN_USE, "Line In Use"}, + {SKINNY_TEXTID_CALL_WAITING, "Call Waiting"}, + {SKINNY_TEXTID_CALL_TRANSFER, "Call Transfer"}, + {SKINNY_TEXTID_CALL_PARK, "Call Park"}, + {SKINNY_TEXTID_CALL_PROCEED, "Call Proceed"}, + {SKINNY_TEXTID_IN_USE_REMOTE, "In Use Remote"}, + {SKINNY_TEXTID_ENTER_NUMBER, "Enter Number"}, + {SKINNY_TEXTID_CALL_PARK_AT, "Call Park At"}, + {SKINNY_TEXTID_PRIMARY_ONLY, "Primary Only"}, + {SKINNY_TEXTID_TEMP_FAIL, "Temp Fail"}, + {SKINNY_TEXTID_YOU_HAVE_VOICEMAIL, "You Have Voicemail"}, + {SKINNY_TEXTID_FORWARDED_TO, "Forwarded To"}, + {SKINNY_TEXTID_CAN_NOT_COMPLETE_CONFERENCE, "Can Not Complete Conference"}, + {SKINNY_TEXTID_NO_CONFERENCE_BRIDGE, "No Conference Bridge"}, + {SKINNY_TEXTID_CAN_NOT_HOLD_PRIMARY_CONTROL, "Can Not Hold Primary Control"}, + {SKINNY_TEXTID_INVALID_CONFERENCE_PARTICIPANT, "Invalid Conference Participant"}, + {SKINNY_TEXTID_IN_CONFERENCE_ALREADY, "In Conference Already"}, + {SKINNY_TEXTID_NO_PARTICIPANT_INFO, "No Participant Info"}, + {SKINNY_TEXTID_EXCEED_MAXIMUM_PARTIES, "Exceed Maximum Parties"}, + {SKINNY_TEXTID_KEY_IS_NOT_ACTIVE, "Key Is Not Active"}, + {SKINNY_TEXTID_ERROR_NO_LICENSE, "Error No License"}, + {SKINNY_TEXTID_ERROR_DBCONFIG, "Error Dbconfig"}, + {SKINNY_TEXTID_ERROR_DATABASE, "Error Database"}, + {SKINNY_TEXTID_ERROR_PASS_LIMIT, "Error Pass Limit"}, + {SKINNY_TEXTID_ERROR_UNKNOWN, "Error Unknown"}, + {SKINNY_TEXTID_ERROR_MISMATCH, "Error Mismatch"}, + {SKINNY_TEXTID_CONFERENCE, "Conference"}, + {SKINNY_TEXTID_PARK_NUMBER, "Park Number"}, + {SKINNY_TEXTID_PRIVATE, "Private"}, + {SKINNY_TEXTID_NOT_ENOUGH_BANDWIDTH, "Not Enough Bandwidth"}, + {SKINNY_TEXTID_UNKNOWN_NUMBER, "Unknown Number"}, + {SKINNY_TEXTID_RMLSTC, "Rmlstc"}, + {SKINNY_TEXTID_VOICEMAIL, "Voicemail"}, + {SKINNY_TEXTID_IMMDIV, "Immdiv"}, + {SKINNY_TEXTID_INTRCPT, "Intrcpt"}, + {SKINNY_TEXTID_SETWTCH, "Setwtch"}, + {SKINNY_TEXTID_TRNSFVM, "Trnsfvm"}, + {SKINNY_TEXTID_DND, "Dnd"}, + {SKINNY_TEXTID_DIVALL, "Divall"}, + {SKINNY_TEXTID_CALLBACK, "Callback"}, + {SKINNY_TEXTID_NETWORK_CONGESTION_REROUTING, "Network Congestion Rerouting"}, + {SKINNY_TEXTID_BARGE, "Barge"}, + {SKINNY_TEXTID_FAILED_TO_SETUP_BARGE, "Failed To Setup Barge"}, + {SKINNY_TEXTID_ANOTHER_BARGE_EXISTS, "Another Barge Exists"}, + {SKINNY_TEXTID_INCOMPATIBLE_DEVICE_TYPE, "Incompatible Device Type"}, + {SKINNY_TEXTID_NO_PARK_NUMBER_AVAILABLE, "No Park Number Available"}, + {SKINNY_TEXTID_CALLPARK_REVERSION, "Callpark Reversion"}, + {SKINNY_TEXTID_SERVICE_IS_NOT_ACTIVE, "Service Is Not Active"}, + {SKINNY_TEXTID_HIGH_TRAFFIC_TRY_AGAIN_LATER, "High Traffic Try Again Later"}, + {SKINNY_TEXTID_QRT, "Qrt"}, + {SKINNY_TEXTID_MCID, "Mcid"}, + {SKINNY_TEXTID_DIRTRFR, "Dirtrfr"}, + {SKINNY_TEXTID_SELECT, "Select"}, + {SKINNY_TEXTID_CONFLIST, "Conflist"}, + {SKINNY_TEXTID_IDIVERT, "Idivert"}, + {SKINNY_TEXTID_CBARGE, "Cbarge"}, + {SKINNY_TEXTID_CAN_NOT_COMPLETE_TRANSFER, "Can Not Complete Transfer"}, + {SKINNY_TEXTID_CAN_NOT_JOIN_CALLS, "Can Not Join Calls"}, + {SKINNY_TEXTID_MCID_SUCCESSFUL, "Mcid Successful"}, + {SKINNY_TEXTID_NUMBER_NOT_CONFIGURED, "Number Not Configured"}, + {SKINNY_TEXTID_SECURITY_ERROR, "Security Error"}, + {SKINNY_TEXTID_VIDEO_BANDWIDTH_UNAVAILABLE, "Video Bandwidth Unavailable"}, + {SKINNY_TEXTID_VIDMODE, "Vidmode"}, + {SKINNY_TEXTID_MAX_CALL_DURATION_TIMEOUT, "Max Call Duration Timeout"}, + {SKINNY_TEXTID_MAX_HOLD_DURATION_TIMEOUT, "Max Hold Duration Timeout"}, + {SKINNY_TEXTID_OPICKUP, "Opickup"}, + {SKINNY_TEXTID_EXTERNAL_TRANSFER_RESTRICTED, "External Transfer Restricted"}, + {SKINNY_TEXTID_MAC_ADDRESS, "Mac Address"}, + {SKINNY_TEXTID_HOST_NAME, "Host Name"}, + {SKINNY_TEXTID_DOMAIN_NAME, "Domain Name"}, + {SKINNY_TEXTID_IP_ADDRESS, "Ip Address"}, + {SKINNY_TEXTID_SUBNET_MASK, "Subnet Mask"}, + {SKINNY_TEXTID_TFTP_SERVER_1, "Tftp Server 1"}, + {SKINNY_TEXTID_DEFAULT_ROUTER_1, "Default Router 1"}, + {SKINNY_TEXTID_DEFAULT_ROUTER_2, "Default Router 2"}, + {SKINNY_TEXTID_DEFAULT_ROUTER_3, "Default Router 3"}, + {SKINNY_TEXTID_DEFAULT_ROUTER_4, "Default Router 4"}, + {SKINNY_TEXTID_DEFAULT_ROUTER_5, "Default Router 5"}, + {SKINNY_TEXTID_DNS_SERVER_1, "Dns Server 1"}, + {SKINNY_TEXTID_DNS_SERVER_2, "Dns Server 2"}, + {SKINNY_TEXTID_DNS_SERVER_3, "Dns Server 3"}, + {SKINNY_TEXTID_DNS_SERVER_4, "Dns Server 4"}, + {SKINNY_TEXTID_DNS_SERVER_5, "Dns Server 5"}, + {SKINNY_TEXTID_OPERATIONAL_VLAN_ID, "Operational Vlan Id"}, + {SKINNY_TEXTID_ADMIN_VLAN_ID, "Admin Vlan Id"}, + {SKINNY_TEXTID_CALL_MANAGER_1, "Call Manager 1"}, + {SKINNY_TEXTID_CALL_MANAGER_2, "Call Manager 2"}, + {SKINNY_TEXTID_CALL_MANAGER_3, "Call Manager 3"}, + {SKINNY_TEXTID_CALL_MANAGER_4, "Call Manager 4"}, + {SKINNY_TEXTID_CALL_MANAGER_5, "Call Manager 5"}, + {SKINNY_TEXTID_INFORMATION_URL, "Information Url"}, + {SKINNY_TEXTID_DIRECTORIES_URL, "Directories Url"}, + {SKINNY_TEXTID_MESSAGES_URL, "Messages Url"}, + {SKINNY_TEXTID_SERVICES_URL, "Services Url"}, + {0, NULL} + }; + SKINNY_DECLARE_ID2STR(skinny_textid2str, SKINNY_TEXTIDS, "Unknown") +SKINNY_DECLARE_STR2ID(skinny_str2textid, SKINNY_TEXTIDS, -1) + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index 502c0b5eb6..40d02fa501 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -106,6 +106,10 @@ enum skinny_tone { SKINNY_TONE_CALLWAITTONE = 0x2D, SKINNY_TONE_NOTONE = 0x7F, }; +extern struct skinny_table SKINNY_TONES[9]; +const char *skinny_tone2str(uint32_t id); +uint32_t skinny_str2tone(const char *str); +#define SKINNY_PUSH_TONES SKINNY_DECLARE_PUSH_MATCH(SKINNY_TONES) enum skinny_ring_type { SKINNY_RING_OFF = 1, @@ -185,10 +189,10 @@ enum skinny_soft_key_event { SOFTKEY_RESUME = 0x0A, SOFTKEY_ANSWER = 0x0B, SOFTKEY_INFO = 0x0C, - SOFTKEY_CONFRM = 0x0D, + SOFTKEY_CONF = 0x0D, SOFTKEY_PARK = 0x0E, SOFTKEY_JOIN = 0x0F, - SOFTKEY_MEETMECONFRM = 0x10, + SOFTKEY_MEETMECONF = 0x10, SOFTKEY_CALLPICKUP = 0x11, SOFTKEY_GRPCALLPICKUP = 0x12, SOFTKEY_DND = 0x13, @@ -269,6 +273,134 @@ const char *skinny_accessory_state2str(uint32_t id); uint32_t skinny_str2accessory_state(const char *str); #define SKINNY_PUSH_ACCESSORY_STATES SKINNY_DECLARE_PUSH_MATCH(SKINNY_ACCESSORY_STATES) +enum skinny_label { + SKINNY_TEXTID_EMPTY = 0, + SKINNY_TEXTID_REDIAL = 1, + SKINNY_TEXTID_NEWCALL = 2, + SKINNY_TEXTID_HOLD = 3, + SKINNY_TEXTID_TRANSFER = 4, + SKINNY_TEXTID_CFWDALL = 5, + SKINNY_TEXTID_CFWDBUSY = 6, + SKINNY_TEXTID_CFWDNOANSWER = 7, + SKINNY_TEXTID_BACKSPACE = 8, + SKINNY_TEXTID_ENDCALL = 9, + SKINNY_TEXTID_RESUME = 10, + SKINNY_TEXTID_ANSWER = 11, + SKINNY_TEXTID_INFO = 12, + SKINNY_TEXTID_CONF = 13, + SKINNY_TEXTID_PARK = 14, + SKINNY_TEXTID_JOIN = 15, + SKINNY_TEXTID_MEETME = 16, + SKINNY_TEXTID_CALLPICKUP = 17, + SKINNY_TEXTID_GRPCALLPICKUP = 18, + SKINNY_TEXTID_YOUR_CURRENT_OPTIONS = 19, + SKINNY_TEXTID_OFF_HOOK = 20, + SKINNY_TEXTID_ON_HOOK = 21, + SKINNY_TEXTID_RING_OUT = 22, + SKINNY_TEXTID_FROM = 23, + SKINNY_TEXTID_CONNECTED = 24, + SKINNY_TEXTID_BUSY = 25, + SKINNY_TEXTID_LINE_IN_USE = 26, + SKINNY_TEXTID_CALL_WAITING = 27, + SKINNY_TEXTID_CALL_TRANSFER = 28, + SKINNY_TEXTID_CALL_PARK = 29, + SKINNY_TEXTID_CALL_PROCEED = 30, + SKINNY_TEXTID_IN_USE_REMOTE = 31, + SKINNY_TEXTID_ENTER_NUMBER = 32, + SKINNY_TEXTID_CALL_PARK_AT = 33, + SKINNY_TEXTID_PRIMARY_ONLY = 34, + SKINNY_TEXTID_TEMP_FAIL = 35, + SKINNY_TEXTID_YOU_HAVE_VOICEMAIL = 36, + SKINNY_TEXTID_FORWARDED_TO = 37, + SKINNY_TEXTID_CAN_NOT_COMPLETE_CONFERENCE = 38, + SKINNY_TEXTID_NO_CONFERENCE_BRIDGE = 39, + SKINNY_TEXTID_CAN_NOT_HOLD_PRIMARY_CONTROL = 40, + SKINNY_TEXTID_INVALID_CONFERENCE_PARTICIPANT = 41, + SKINNY_TEXTID_IN_CONFERENCE_ALREADY = 42, + SKINNY_TEXTID_NO_PARTICIPANT_INFO = 43, + SKINNY_TEXTID_EXCEED_MAXIMUM_PARTIES = 44, + SKINNY_TEXTID_KEY_IS_NOT_ACTIVE = 45, + SKINNY_TEXTID_ERROR_NO_LICENSE = 46, + SKINNY_TEXTID_ERROR_DBCONFIG = 47, + SKINNY_TEXTID_ERROR_DATABASE = 48, + SKINNY_TEXTID_ERROR_PASS_LIMIT = 49, + SKINNY_TEXTID_ERROR_UNKNOWN = 50, + SKINNY_TEXTID_ERROR_MISMATCH = 51, + SKINNY_TEXTID_CONFERENCE = 52, + SKINNY_TEXTID_PARK_NUMBER = 53, + SKINNY_TEXTID_PRIVATE = 54, + SKINNY_TEXTID_NOT_ENOUGH_BANDWIDTH = 55, + SKINNY_TEXTID_UNKNOWN_NUMBER = 56, + SKINNY_TEXTID_RMLSTC = 57, + SKINNY_TEXTID_VOICEMAIL = 58, + SKINNY_TEXTID_IMMDIV = 59, + SKINNY_TEXTID_INTRCPT = 60, + SKINNY_TEXTID_SETWTCH = 61, + SKINNY_TEXTID_TRNSFVM = 62, + SKINNY_TEXTID_DND = 63, + SKINNY_TEXTID_DIVALL = 64, + SKINNY_TEXTID_CALLBACK = 65, + SKINNY_TEXTID_NETWORK_CONGESTION_REROUTING = 66, + SKINNY_TEXTID_BARGE = 67, + SKINNY_TEXTID_FAILED_TO_SETUP_BARGE = 68, + SKINNY_TEXTID_ANOTHER_BARGE_EXISTS = 69, + SKINNY_TEXTID_INCOMPATIBLE_DEVICE_TYPE = 70, + SKINNY_TEXTID_NO_PARK_NUMBER_AVAILABLE = 71, + SKINNY_TEXTID_CALLPARK_REVERSION = 72, + SKINNY_TEXTID_SERVICE_IS_NOT_ACTIVE = 73, + SKINNY_TEXTID_HIGH_TRAFFIC_TRY_AGAIN_LATER = 74, + SKINNY_TEXTID_QRT = 75, + SKINNY_TEXTID_MCID = 76, + SKINNY_TEXTID_DIRTRFR = 77, + SKINNY_TEXTID_SELECT = 78, + SKINNY_TEXTID_CONFLIST = 79, + SKINNY_TEXTID_IDIVERT = 80, + SKINNY_TEXTID_CBARGE = 81, + SKINNY_TEXTID_CAN_NOT_COMPLETE_TRANSFER = 82, + SKINNY_TEXTID_CAN_NOT_JOIN_CALLS = 83, + SKINNY_TEXTID_MCID_SUCCESSFUL = 84, + SKINNY_TEXTID_NUMBER_NOT_CONFIGURED = 85, + SKINNY_TEXTID_SECURITY_ERROR = 86, + SKINNY_TEXTID_VIDEO_BANDWIDTH_UNAVAILABLE = 87, + SKINNY_TEXTID_VIDMODE = 88, + SKINNY_TEXTID_MAX_CALL_DURATION_TIMEOUT = 89, + SKINNY_TEXTID_MAX_HOLD_DURATION_TIMEOUT = 90, + SKINNY_TEXTID_OPICKUP = 91, + SKINNY_TEXTID_EXTERNAL_TRANSFER_RESTRICTED = 97, + SKINNY_TEXTID_MAC_ADDRESS = 101, + SKINNY_TEXTID_HOST_NAME = 102, + SKINNY_TEXTID_DOMAIN_NAME = 103, + SKINNY_TEXTID_IP_ADDRESS = 104, + SKINNY_TEXTID_SUBNET_MASK = 105, + SKINNY_TEXTID_TFTP_SERVER_1 = 106, + SKINNY_TEXTID_DEFAULT_ROUTER_1 = 107, + SKINNY_TEXTID_DEFAULT_ROUTER_2 = 108, + SKINNY_TEXTID_DEFAULT_ROUTER_3 = 109, + SKINNY_TEXTID_DEFAULT_ROUTER_4 = 110, + SKINNY_TEXTID_DEFAULT_ROUTER_5 = 111, + SKINNY_TEXTID_DNS_SERVER_1 = 112, + SKINNY_TEXTID_DNS_SERVER_2 = 113, + SKINNY_TEXTID_DNS_SERVER_3 = 114, + SKINNY_TEXTID_DNS_SERVER_4 = 115, + SKINNY_TEXTID_DNS_SERVER_5 = 116, + SKINNY_TEXTID_OPERATIONAL_VLAN_ID = 117, + SKINNY_TEXTID_ADMIN_VLAN_ID = 118, + SKINNY_TEXTID_CALL_MANAGER_1 = 119, + SKINNY_TEXTID_CALL_MANAGER_2 = 120, + SKINNY_TEXTID_CALL_MANAGER_3 = 121, + SKINNY_TEXTID_CALL_MANAGER_4 = 122, + SKINNY_TEXTID_CALL_MANAGER_5 = 123, + SKINNY_TEXTID_INFORMATION_URL = 124, + SKINNY_TEXTID_DIRECTORIES_URL = 125, + SKINNY_TEXTID_MESSAGES_URL = 126, + SKINNY_TEXTID_SERVICES_URL = 127 +}; +extern struct skinny_table SKINNY_TEXTIDS[128]; +const char *skinny_textid2str(uint32_t id); +uint32_t skinny_str2textid(const char *str); +#define SKINNY_PUSH_TEXTIDS SKINNY_DECLARE_PUSH_MATCH(SKINNY_TEXTIDS) + + #endif /* _SKINNY_TABLES_H */ /* For Emacs: diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index ca49a3203f..1497df5155 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -39,7 +39,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown); SWITCH_MODULE_DEFINITION(mod_local_stream, mod_local_stream_load, mod_local_stream_shutdown, NULL); -static void launch_streams(const char *name); +static int launch_streams(const char *name); static void launch_thread(const char *name, const char *path, switch_xml_t directory); static const char *global_cf = "local_stream.conf"; @@ -663,25 +663,31 @@ static void launch_thread(const char *name, const char *path, switch_xml_t direc switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool); } -static void launch_streams(const char *name) +static int launch_streams(const char *name) { switch_xml_t cfg, xml, directory; + int x = 0; if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); - abort(); + return 0; } + if (zstr(name)) { for (directory = switch_xml_child(cfg, "directory"); directory; directory = directory->next) { char *name = (char *) switch_xml_attr(directory, "name"); char *path = (char *) switch_xml_attr(directory, "path"); launch_thread(name, path, directory); + x++; } } else if ((directory = switch_xml_find_child(cfg, "directory", "name", name))) { char *path = (char *) switch_xml_attr(directory, "path"); launch_thread(name, path, directory); + x++; } switch_xml_free(xml); + + return x; } static void event_handler(switch_event_t *event) @@ -882,6 +888,7 @@ SWITCH_STANDARD_API(start_local_stream_function) char *mycmd = NULL, *argv[8] = { 0 }; char *local_stream_name = NULL; int argc = 0; + int ok = 0; if (zstr(cmd)) { goto usage; @@ -906,10 +913,10 @@ SWITCH_STANDARD_API(start_local_stream_function) goto done; } - launch_streams(local_stream_name); - stream->write_function(stream, "+OK stream: %s", local_stream_name); - - goto done; + if ((ok = launch_streams(local_stream_name))) { + stream->write_function(stream, "+OK stream: %s", local_stream_name); + goto done; + } usage: stream->write_function(stream, "-USAGE: %s\n", START_LOCAL_STREAM_SYNTAX); @@ -967,8 +974,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load) { switch_api_interface_t *commands_api_interface; switch_file_interface_t *file_interface; + supported_formats[0] = "local_stream"; + + memset(&globals, 0, sizeof(globals)); + switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool); + switch_core_hash_init(&globals.source_hash, pool); + if (!launch_streams(NULL)) { + return SWITCH_STATUS_GENERR; + } + *module_interface = switch_loadable_module_create_module_interface(pool, modname); file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); file_interface->interface_name = modname; @@ -981,10 +997,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n"); } - memset(&globals, 0, sizeof(globals)); - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool); - switch_core_hash_init(&globals.source_hash, pool); - launch_streams(NULL); + SWITCH_ADD_API(commands_api_interface, "hup_local_stream", "Skip to next file in local_stream", hup_local_stream_function, RELOAD_LOCAL_STREAM_SYNTAX); SWITCH_ADD_API(commands_api_interface, "reload_local_stream", "Reloads a local_stream", reload_local_stream_function, RELOAD_LOCAL_STREAM_SYNTAX); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index be5c4975d4..e3671beb51 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1523,36 +1523,41 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses state = switch_channel_get_state(caller_channel); - if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) && !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) { + switch_call_cause_t cause = switch_channel_get_cause(peer_channel); + const char *hup = switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE); + int explicit = 0; + + if (cause == SWITCH_CAUSE_NONE) { + cause = SWITCH_CAUSE_NORMAL_CLEARING; + } + + if (hup) { + explicit = !strcasecmp(hup, "explicit"); + } + + if (cause && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) { + switch_channel_handle_cause(caller_channel, cause); + } + + if (explicit) { + if (switch_channel_test_flag(peer_channel, CF_INTERCEPTED)) { + switch_channel_set_flag(peer_channel, CF_INTERCEPT); + } + switch_channel_hangup(caller_channel, cause); + } + if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) || (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) { - switch_call_cause_t cause = switch_channel_get_cause(peer_channel); - - if (cause && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) { - switch_channel_handle_cause(caller_channel, cause); - } - + if (!switch_channel_test_flag(caller_channel, CF_TRANSFER)) { if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) { switch_ivr_park_session(session); } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) { transfer_after_bridge(session, var); } else { - const char *hup = switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE); - int explicit = 0; - - if (hup) { - explicit = !strcasecmp(hup, "explicit"); - } - - if (explicit || (switch_channel_test_flag(peer_channel, CF_ANSWERED) && switch_true(hup))) { - switch_call_cause_t cause = switch_channel_get_cause(peer_channel); - if (cause == SWITCH_CAUSE_NONE) { - cause = SWITCH_CAUSE_NORMAL_CLEARING; - } - + if ((switch_channel_test_flag(peer_channel, CF_ANSWERED) && switch_true(hup))) { if (switch_channel_test_flag(peer_channel, CF_INTERCEPTED)) { switch_channel_set_flag(peer_channel, CF_INTERCEPT); }