From 054c645818979b83a436ef8a54ce7306ac84c4fa Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 24 May 2014 08:42:54 +0000 Subject: [PATCH] Show initial channel values with `show channels` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store some initial details about the channel separately so we can preserve them across e.g. transfers and display them with show channels. With this commit, we store the original caller ID (name and number) and IP address, and the call destination, dialplan, and context. FS-4296 --resolve Thanks-to: Mariusz Czułada --- src/switch_core_sqldb.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 6a49a4988c..31e835e760 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -2269,8 +2269,8 @@ static void core_event_handler(switch_event_t *event) break; } case SWITCH_EVENT_CHANNEL_CREATE: - new_sql() = switch_mprintf("insert into channels (uuid,direction,created,created_epoch, name,state,callstate,dialplan,context,hostname) " - "values('%q','%q','%q','%ld','%q','%q','%q','%q','%q','%q')", + new_sql() = switch_mprintf("insert into channels (uuid,direction,created,created_epoch, name,state,callstate,dialplan,context,hostname,initial_cid_name,initial_cid_num,initial_ip_addr,initial_dest,initial_dialplan,initial_context) " + "values('%q','%q','%q','%ld','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')", switch_event_get_header_nil(event, "unique-id"), switch_event_get_header_nil(event, "call-direction"), switch_event_get_header_nil(event, "event-date-local"), @@ -2279,7 +2279,13 @@ static void core_event_handler(switch_event_t *event) switch_event_get_header_nil(event, "channel-state"), switch_event_get_header_nil(event, "channel-call-state"), switch_event_get_header_nil(event, "caller-dialplan"), - switch_event_get_header_nil(event, "caller-context"), switch_core_get_switchname() + switch_event_get_header_nil(event, "caller-context"), switch_core_get_switchname(), + switch_event_get_header_nil(event, "caller-caller-id-name"), + switch_event_get_header_nil(event, "caller-caller-id-number"), + switch_event_get_header_nil(event, "caller-network-addr"), + switch_event_get_header_nil(event, "caller-destination-number"), + switch_event_get_header_nil(event, "caller-dialplan"), + switch_event_get_header_nil(event, "caller-context") ); break; case SWITCH_EVENT_CHANNEL_ANSWER: @@ -2666,7 +2672,13 @@ static char create_channels_sql[] = " callee_direction VARCHAR(5),\n" " call_uuid VARCHAR(256),\n" " sent_callee_name VARCHAR(1024),\n" - " sent_callee_num VARCHAR(256)\n" + " sent_callee_num VARCHAR(256),\n" + " initial_cid_name VARCHAR(1024),\n" + " initial_cid_num VARCHAR(256),\n" + " initial_ip_addr VARCHAR(256),\n" + " initial_dest VARCHAR(1024),\n" + " initial_dialplan VARCHAR(128),\n" + " initial_context VARCHAR(128)\n" ");\n"; static char create_calls_sql[] = @@ -3385,7 +3397,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_ char *err; int result = 0; - switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name from channels", "DROP TABLE channels", create_channels_sql); + switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name, initial_cid_name, initial_cid_num, initial_ip_addr, initial_dest, initial_dialplan, initial_context from channels", "DROP TABLE channels", create_channels_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select * from detailed_calls where sent_callee_name=''", "DROP VIEW detailed_calls", detailed_calls_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select * from basic_calls where sent_callee_name=''", "DROP VIEW basic_calls", basic_calls_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);