indent run

This commit is contained in:
Anthony Minessale 2010-06-30 10:35:03 -05:00
parent 4f235af8b4
commit f2ea3ee315
5 changed files with 126 additions and 70 deletions

View File

@ -4553,6 +4553,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
if (switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY, sofia_glue_track_event_handler, NULL,
&mod_sofia_globals.recovery_node) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_GENERR;
}
if (switch_event_bind(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, general_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { if (switch_event_bind(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, general_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
@ -4647,6 +4653,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
switch_event_unbind(&mod_sofia_globals.roster_node); switch_event_unbind(&mod_sofia_globals.roster_node);
switch_event_unbind(&mod_sofia_globals.custom_node); switch_event_unbind(&mod_sofia_globals.custom_node);
switch_event_unbind(&mod_sofia_globals.mwi_node); switch_event_unbind(&mod_sofia_globals.mwi_node);
switch_event_unbind(&mod_sofia_globals.recovery_node);
switch_event_unbind_callback(general_event_handler); switch_event_unbind_callback(general_event_handler);
while (mod_sofia_globals.threads) { while (mod_sofia_globals.threads) {

View File

@ -83,6 +83,8 @@ typedef struct private_object private_object_t;
#define MY_EVENT_REINVITE "sofia::reinvite" #define MY_EVENT_REINVITE "sofia::reinvite"
#define MY_EVENT_GATEWAY_ADD "sofia::gateway_add" #define MY_EVENT_GATEWAY_ADD "sofia::gateway_add"
#define MY_EVENT_GATEWAY_DEL "sofia::gateway_delete" #define MY_EVENT_GATEWAY_DEL "sofia::gateway_delete"
#define MY_EVENT_RECOVERY "sofia::recovery"
#define MY_EVENT_RECOVERY_SEND "sofia::recovery_send"
#define MULTICAST_EVENT "multicast::event" #define MULTICAST_EVENT "multicast::event"
#define SOFIA_REPLACES_HEADER "_sofia_replaces_" #define SOFIA_REPLACES_HEADER "_sofia_replaces_"
@ -209,6 +211,7 @@ typedef enum {
PFLAG_PASS_CALLEE_ID, PFLAG_PASS_CALLEE_ID,
PFLAG_LOG_AUTH_FAIL, PFLAG_LOG_AUTH_FAIL,
PFLAG_TRACK_CALLS, PFLAG_TRACK_CALLS,
PFLAG_TRACK_CALLS_EVENTS,
PFLAG_DESTROY, PFLAG_DESTROY,
PFLAG_EXTENDED_INFO_PARSING, PFLAG_EXTENDED_INFO_PARSING,
PFLAG_T38_PASSTHRU, PFLAG_T38_PASSTHRU,
@ -295,6 +298,7 @@ struct mod_sofia_globals {
switch_event_node_t *roster_node; switch_event_node_t *roster_node;
switch_event_node_t *custom_node; switch_event_node_t *custom_node;
switch_event_node_t *mwi_node; switch_event_node_t *mwi_node;
switch_event_node_t *recovery_node;
int guess_mask; int guess_mask;
char guess_mask_str[16]; char guess_mask_str[16];
int debug_presence; int debug_presence;
@ -761,8 +765,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]); void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
tagi_t tags[]);
void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
tagi_t tags[]); tagi_t tags[]);
@ -792,6 +795,7 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
void event_handler(switch_event_t *event); void event_handler(switch_event_t *event);
void sofia_presence_event_handler(switch_event_t *event); void sofia_presence_event_handler(switch_event_t *event);
void sofia_presence_mwi_event_handler(switch_event_t *event); void sofia_presence_mwi_event_handler(switch_event_t *event);
void sofia_glue_track_event_handler(switch_event_t *event);
void sofia_presence_cancel(void); void sofia_presence_cancel(void);
switch_status_t config_sofia(int reload, char *profile_name); switch_status_t config_sofia(int reload, char *profile_name);
void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_regtype_t regtype, const char *realm, int stale); void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_regtype_t regtype, const char *realm, int stale);
@ -922,8 +926,7 @@ char *sofia_glue_strip_uri(const char *str);
int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip); int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip);
int sofia_glue_transport_has_tls(const sofia_transport_t tp); int sofia_glue_transport_has_tls(const sofia_transport_t tp);
const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name); const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name);
switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction);
switch_rtp_crypto_direction_t direction);
void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt); void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt);
switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt); switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt);
void sofia_presence_event_thread_start(void); void sofia_presence_event_thread_start(void);

View File

@ -2949,8 +2949,13 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else { } else {
sofia_clear_pflag(profile, PFLAG_UUID_AS_CALLID); sofia_clear_pflag(profile, PFLAG_UUID_AS_CALLID);
} }
} else if (!strcasecmp(var, "track-calls") && switch_true(val)) { } else if (!strcasecmp(var, "track-calls")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_TRACK_CALLS); sofia_set_pflag(profile, PFLAG_TRACK_CALLS);
} else if (!strcasecmp(val, "events")) {
sofia_set_pflag(profile, PFLAG_TRACK_CALLS);
sofia_set_pflag(profile, PFLAG_TRACK_CALLS_EVENTS);
}
} else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact") && switch_true(val)) { } else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact") && switch_true(val)) {
sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT); sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
} else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) { } else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) {

View File

@ -4403,7 +4403,6 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
} }
switch_channel_set_variable(channel, "sip_invite_call_id", switch_channel_get_variable(channel, "sip_call_id")); switch_channel_set_variable(channel, "sip_invite_call_id", switch_channel_get_variable(channel, "sip_call_id"));
switch_channel_set_variable(channel, "sip_invite_cseq", switch_channel_get_variable(channel, "sip_cseq"));
if (switch_true(switch_channel_get_variable(channel, "sip_nat_detected"))) { if (switch_true(switch_channel_get_variable(channel, "sip_nat_detected"))) {
switch_channel_set_variable_printf(channel, "sip_route_uri", "sip:%s@%s:%s", switch_channel_set_variable_printf(channel, "sip_route_uri", "sip:%s@%s:%s",
@ -4575,9 +4574,28 @@ int sofia_glue_recover(switch_bool_t flush)
return r; return r;
} }
void sofia_glue_track_event_handler(switch_event_t *event)
{
char *sql, *buf = NULL;
char *profile_name = NULL;
switch_assert(event); // Just a sanity check
if ((buf = switch_event_get_header_nil(event, "sql")) && (profile_name = switch_event_get_header_nil(event, "profile_name"))) {
sofia_profile_t *profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", switch_event_get_header_nil(event, "Event-Calling-Function"));
if ((profile = sofia_glue_find_profile(profile_name))) {
sql = switch_mprintf("%s", buf);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sofia_glue_release_profile(profile);
}
}
return;
}
void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force) void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force)
{ {
char *sql; char *sql = NULL;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || (sofia_test_flag(tech_pvt, TFLAG_RECOVERING))) { if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || (sofia_test_flag(tech_pvt, TFLAG_RECOVERING))) {
@ -4585,6 +4603,7 @@ void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *se
} }
if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS) && (sofia_test_flag(tech_pvt, TFLAG_TRACKED) || force)) { if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS) && (sofia_test_flag(tech_pvt, TFLAG_TRACKED) || force)) {
switch_event_t *event = NULL;
if (force) { if (force) {
sql = switch_mprintf("delete from sip_recovery where uuid='%q'", switch_core_session_get_uuid(session)); sql = switch_mprintf("delete from sip_recovery where uuid='%q'", switch_core_session_get_uuid(session));
@ -4593,15 +4612,29 @@ void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *se
sql = switch_mprintf("delete from sip_recovery where runtime_uuid='%q' and uuid='%q'", sql = switch_mprintf("delete from sip_recovery where runtime_uuid='%q' and uuid='%q'",
switch_core_get_uuid(), switch_core_session_get_uuid(session)); switch_core_get_uuid(), switch_core_session_get_uuid(session));
} }
if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS_EVENTS)) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql);
switch_event_fire(&event);
}
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sofia_clear_flag(tech_pvt, TFLAG_TRACKED); sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
switch_safe_free(sql);
} }
} }
void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session) void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session)
{ {
switch_event_t *event;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_xml_t cdr = NULL;
char *xml_cdr_text = NULL;
char *sql = NULL;
if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
return; return;
@ -4611,27 +4644,34 @@ void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *sess
sofia_glue_tech_untrack(profile, session, SWITCH_TRUE); sofia_glue_tech_untrack(profile, session, SWITCH_TRUE);
} }
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
switch_xml_t cdr = NULL;
char *xml_cdr_text = NULL;
if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE); xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
switch_xml_free(cdr); switch_xml_free(cdr);
} }
if (xml_cdr_text) { if (xml_cdr_text) {
char *sql;
sql = switch_mprintf("insert into sip_recovery (runtime_uuid, profile_name, hostname, uuid, metadata) values ('%q','%q','%q','%q','%q')", sql = switch_mprintf("insert into sip_recovery (runtime_uuid, profile_name, hostname, uuid, metadata) values ('%q','%q','%q','%q','%q')",
switch_core_get_uuid(), profile->name, mod_sofia_globals.hostname, switch_core_session_get_uuid(session), xml_cdr_text); switch_core_get_uuid(), profile->name, mod_sofia_globals.hostname, switch_core_session_get_uuid(session), xml_cdr_text);
if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS_EVENTS)) {
switch_event_t *event = NULL;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql);
switch_event_fire(&event);
}
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
free(xml_cdr_text); free(xml_cdr_text);
sofia_set_flag(tech_pvt, TFLAG_TRACKED); sofia_set_flag(tech_pvt, TFLAG_TRACKED);
}
} }
switch_safe_free(sql);
} }
int sofia_glue_init_sql(sofia_profile_t *profile) int sofia_glue_init_sql(sofia_profile_t *profile)

View File

@ -857,7 +857,8 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
} }
while (!sql_manager.event_db) { while (!sql_manager.event_db) {
if (switch_core_db_handle(&sql_manager.event_db) == SWITCH_STATUS_SUCCESS && sql_manager.event_db) break; if (switch_core_db_handle(&sql_manager.event_db) == SWITCH_STATUS_SUCCESS && sql_manager.event_db)
break;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error getting core db, Retrying\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error getting core db, Retrying\n");
switch_yield(500000); switch_yield(500000);
sanity--; sanity--;
@ -994,7 +995,8 @@ static void core_event_handler(switch_event_t *event)
if (id) { if (id) {
new_sql() = switch_mprintf("update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'", new_sql() = switch_mprintf("update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'",
switch_event_get_header_nil(event, "task-desc"), switch_event_get_header_nil(event, "task-desc"),
switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", id, switch_core_get_variable("hostname")); switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", id,
switch_core_get_variable("hostname"));
} }
} }
break; break;
@ -1097,8 +1099,7 @@ static void core_event_handler(switch_event_t *event)
{ {
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'", new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"), switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"), switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
switch_core_get_variable("hostname"));
} }
break; break;
@ -1330,10 +1331,10 @@ static char create_calls_sql[] =
" callee_chan_name VARCHAR(1024),\n" " callee_chan_name VARCHAR(1024),\n"
" callee_uuid VARCHAR(256),\n" " callee_uuid VARCHAR(256),\n"
" hostname VARCHAR(256)\n" " hostname VARCHAR(256)\n"
");\n" "create index eruuindex on calls (caller_uuid,hostname);\n" ");\n"
"create index eruuindex on calls (caller_uuid,hostname);\n"
"create index eeuuindex on calls (callee_uuid,hostname);\n" "create index eeuuindex on calls (callee_uuid,hostname);\n"
"create index eeuuindex2 on calls (call_uuid,hostname);\n" "create index eeuuindex2 on calls (call_uuid,hostname);\n";
;
static char create_interfaces_sql[] = static char create_interfaces_sql[] =
"CREATE TABLE interfaces (\n" "CREATE TABLE interfaces (\n"