Asterisk - The Open Source Telephony Project
18.5.0
|
MySQL CDR backend. More...
#include "asterisk.h"
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/cli.h"
#include "asterisk/strings.h"
#include "asterisk/linkedlists.h"
#include "asterisk/threadstorage.h"
Go to the source code of this file.
Data Structures | |
struct | column |
struct | columns |
struct | unload_string |
struct | unload_strings |
Macros | |
#define | DATE_FORMAT "%Y-%m-%d %T" |
#define | MYSQL_PORT 3306 |
Functions | |
static void | __init_escape_buf (void) |
static void | __init_sql1_buf (void) |
static void | __init_sql2_buf (void) |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | configure_connection_charset (void) |
static void | free_strings (void) |
static char * | handle_cli_cdr_mysql_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | load_module (void) |
static int | my_connect_db (struct ast_config *cfg) |
static int | my_load_config_number (struct ast_config *cfg, const char *category, const char *variable, int *field, int def) |
static int | my_load_config_string (struct ast_config *cfg, const char *category, const char *variable, struct ast_str **field, const char *def) |
static int | my_load_module (int reload) |
static int | my_unload_module (int reload) |
static int | mysql_log (struct ast_cdr *cdr) |
static int | reload (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "MySQL CDR Backend" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .reload = reload, .requires = "cdr", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static int | calldate_compat = 0 |
static struct ast_cli_entry | cdr_mysql_status_cli [] |
static struct ast_str * | cdrzone = NULL |
static struct columns | columns = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static const char | config [] = "cdr_mysql.conf" |
static time_t | connect_time = 0 |
static int | connected = 0 |
static struct ast_str * | dbcharset = NULL |
static struct ast_str * | dbname = NULL |
static int | dbport = 0 |
static struct ast_str * | dbsock = NULL |
static struct ast_str * | dbtable = NULL |
static struct ast_str * | dbuser = NULL |
static const char | desc [] = "MySQL CDR Backend" |
static struct ast_threadstorage | escape_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_escape_buf , .custom_init = NULL , } |
static struct ast_str * | hostname = NULL |
static MYSQL | mysql = { { NULL }, } |
static ast_mutex_t | mysql_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static const char | name [] = "mysql" |
static struct ast_str * | password = NULL |
static int | records = 0 |
static struct ast_threadstorage | sql1_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_sql1_buf , .custom_init = NULL , } |
static struct ast_threadstorage | sql2_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_sql2_buf , .custom_init = NULL , } |
static struct ast_str * | ssl_ca = NULL |
static struct ast_str * | ssl_cert = NULL |
static struct ast_str * | ssl_key = NULL |
static int | timeout = 0 |
static int | totalrecords = 0 |
static struct unload_strings | unload_strings = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
MySQL CDR backend.
Definition in file cdr_mysql.c.
#define DATE_FORMAT "%Y-%m-%d %T" |
Definition at line 59 of file cdr_mysql.c.
Referenced by mysql_log().
#define MYSQL_PORT 3306 |
Definition at line 65 of file cdr_mysql.c.
Referenced by my_load_module().
|
static |
Definition at line 71 of file cdr_mysql.c.
|
static |
Definition at line 69 of file cdr_mysql.c.
|
static |
Definition at line 70 of file cdr_mysql.c.
|
static |
Definition at line 758 of file cdr_mysql.c.
|
static |
Definition at line 758 of file cdr_mysql.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 758 of file cdr_mysql.c.
|
static |
Definition at line 162 of file cdr_mysql.c.
References ast_log, ast_str_buffer(), ast_str_strlen(), dbcharset, LOG_WARNING, and mysql.
Referenced by my_connect_db(), and mysql_log().
|
static |
Definition at line 371 of file cdr_mysql.c.
References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and unload_string::str.
Referenced by my_load_module(), and my_unload_module().
|
static |
Definition at line 111 of file cdr_mysql.c.
References ast_cli_args::argc, ast_cli(), ast_cli_print_timestr_fromseconds(), ast_str_buffer(), ast_str_strlen(), buf, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, connect_time, connected, dbname, dbport, dbsock, dbtable, dbuser, ast_cli_args::fd, NULL, records, S_OR, status, totalrecords, and ast_cli_entry::usage.
|
static |
|
static |
Connect to MySQL. Initializes the connection.
Definition at line 466 of file cdr_mysql.c.
References ast_calloc, ast_debug, AST_LIST_INSERT_TAIL, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_str_buffer(), ast_str_strlen(), ast_strdupa, ast_strip(), ast_strlen_zero, ast_variable_browse(), ast_verb, column::cdrname, configure_connection_charset(), connect_time, connected, dbname, dbport, dbsock, dbtable, dbuser, unload_string::entry, item, column::list, LOG_ERROR, mysql, ast_variable::name, column::name, ast_variable::next, NULL, password, records, result, ssl_cert, ssl_key, column::staticvalue, timeout, column::type, ast_variable::value, and var.
Referenced by my_load_module().
|
static |
Definition at line 449 of file cdr_mysql.c.
References ast_variable_retrieve(), and tmp().
Referenced by my_load_module().
|
static |
Definition at line 423 of file cdr_mysql.c.
References ast_calloc, ast_free, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_str_create, ast_str_set(), ast_variable_retrieve(), unload_string::str, and tmp().
Referenced by my_load_module().
|
static |
Definition at line 597 of file cdr_mysql.c.
References ast_cdr_backend_unsuspend(), ast_cdr_register(), ast_cli_register_multiple, ast_config_destroy(), ast_config_load, ast_debug, ast_free, AST_LIST_REMOVE_HEAD, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_true(), ast_variable_browse(), calldate_compat, cdrzone, config, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, dbcharset, dbname, dbport, dbsock, dbtable, dbuser, desc, unload_string::entry, free_strings(), LOG_ERROR, LOG_WARNING, my_connect_db(), my_load_config_number(), my_load_config_string(), my_unload_module(), mysql_log(), MYSQL_PORT, name, ast_variable::name, ast_variable::next, password, S_OR, ssl_cert, ssl_key, timeout, ast_variable::value, and var.
Referenced by load_module(), and reload().
|
static |
Definition at line 383 of file cdr_mysql.c.
References ast_cdr_backend_suspend(), ast_cdr_unregister(), ast_cli_unregister_multiple(), ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, connected, dbport, unload_string::entry, free_strings(), column::list, mysql, name, and records.
Referenced by my_load_module(), and unload_module().
|
static |
Definition at line 172 of file cdr_mysql.c.
References ast_cdr::answer, AS_OR, ast_cdr_format_var(), ast_copy_string(), ast_debug, ast_localtime(), ast_log, ast_mutex_lock, ast_mutex_unlock, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_append(), ast_str_buffer(), ast_str_make_space, ast_str_set(), ast_str_strlen(), ast_str_thread_get(), ast_strdupa, ast_strftime(), ast_strlen_zero, ast_tvdiff_us(), ast_tvnow(), ast_tvzero(), calldate_compat, column::cdrname, cdrzone, configure_connection_charset(), connect_time, connected, DATE_FORMAT, dbname, dbport, dbsock, dbtable, dbuser, ast_cdr::end, unload_string::entry, error(), escape_buf, LOG_ERROR, mysql, mysql_lock, column::name, NULL, password, records, sql1_buf, sql2_buf, ssl_cert, ssl_key, ast_cdr::start, column::staticvalue, timeout, totalrecords, column::type, and value.
Referenced by my_load_module().
|
static |
Definition at line 741 of file cdr_mysql.c.
References AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_DEPRECATED, ast_mutex_lock, ast_mutex_unlock, ASTERISK_GPL_KEY, load_module(), my_load_module(), mysql_lock, and unload_module().
Referenced by ast_cel_backend_register(), ast_manager_event_blob_create(), do_reload(), load_module(), load_values_config(), ooh323_convert_hangupcause_h323ToAsterisk(), reload_module(), sip_options_synchronize(), sorcery_memory_cache_ami_stale_object(), sorcery_memory_cache_stale(), and unload_module().
|
static |
|
static |
Definition at line 758 of file cdr_mysql.c.
|
static |
Definition at line 758 of file cdr_mysql.c.
|
static |
Definition at line 87 of file cdr_mysql.c.
Referenced by my_load_module(), and mysql_log().
|
static |
Definition at line 158 of file cdr_mysql.c.
Definition at line 77 of file cdr_mysql.c.
Referenced by my_load_module(), and mysql_log().
|
static |
Referenced by display_results(), and realtime_sqlite3_require().
|
static |
Definition at line 75 of file cdr_mysql.c.
Referenced by my_load_module().
|
static |
Definition at line 83 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), my_connect_db(), and mysql_log().
|
static |
Definition at line 82 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), my_connect_db(), my_unload_module(), and mysql_log().
Definition at line 77 of file cdr_mysql.c.
Referenced by aMYSQL_connect(), configure_connection_charset(), and my_load_module().
Definition at line 77 of file cdr_mysql.c.
Referenced by aMYSQL_connect(), db_open(), handle_cli_cdr_mysql_status(), main(), my_connect_db(), my_load_module(), and mysql_log().
|
static |
Definition at line 81 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), my_connect_db(), my_load_module(), my_unload_module(), and mysql_log().
Definition at line 77 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), my_connect_db(), my_load_module(), and mysql_log().
Definition at line 77 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), my_connect_db(), my_load_module(), and mysql_log().
Definition at line 77 of file cdr_mysql.c.
Referenced by aMYSQL_connect(), handle_cli_cdr_mysql_status(), my_connect_db(), my_load_module(), and mysql_log().
|
static |
Definition at line 73 of file cdr_mysql.c.
Referenced by acf_retrieve_docs(), ast_tcptls_client_create(), ast_tcptls_client_start(), ast_tcptls_server_root(), AST_TEST_DEFINE(), au_rewrite(), au_seek(), au_tell(), check_header(), connect_to_host(), dump_cause(), idle_sched_init_pj_thread(), init_acf_query(), keepalive_transport_thread(), misdn_cfg_get_desc(), my_load_module(), ogg_vorbis_open(), ogg_vorbis_read(), ogg_vorbis_seek(), ogg_vorbis_tell(), pj_thread_register_check(), show_config_description(), sip_thread_start(), update_header(), and write_header().
|
static |
Definition at line 71 of file cdr_mysql.c.
Referenced by function_db_keys(), and mysql_log().
Definition at line 77 of file cdr_mysql.c.
Referenced by ast_remotecontrol(), asterisk_daemon(), cli_prompt(), iax2_register(), load_asterisk_conf(), netconsole(), set_destination(), sip_parse_host(), sip_parse_register_line(), and sip_subscribe_mwi().
|
static |
Definition at line 109 of file cdr_mysql.c.
Referenced by aMYSQL_connect(), aMYSQL_disconnect(), aMYSQL_nextresult(), aMYSQL_query(), configure_connection_charset(), my_connect_db(), my_unload_module(), and mysql_log().
|
static |
Definition at line 89 of file cdr_mysql.c.
Referenced by mysql_log(), and reload().
|
static |
Definition at line 74 of file cdr_mysql.c.
Referenced by __aco_option_register(), __allocate_taskprocessor(), __ast_channel_alloc_ap(), _sip_show_peers_one(), acf_curl_helper(), acf_curl_write(), aco_option_register_deprecated(), action_atxfer(), action_blind_transfer(), action_cancel_atxfer(), action_getvar(), action_originate(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), add_notify(), add_rlmi_resource(), adsi_load(), adsi_message(), advanced_options(), aelsub_exec(), alias_name_cb(), alloc_new_parking_lot(), ao2_container_check(), ao2_container_unregister(), aoc_amount_str(), ast_bridge_snapshot_create(), ast_cc_monitor_count(), ast_channel_by_name_cb(), ast_channel_hash_cb(), ast_channel_yank(), ast_codec_get(), ast_get_chan_applicationmap(), ast_include_rename(), ast_jb_read_conf(), ast_monitor_change_fname(), ast_monitor_start(), ast_register_thread(), ast_rtp_lookup_mime_multiple2(), ast_set_callerid(), ast_setstate(), ast_sip_auth_vector_destroy(), ast_sip_default_outbound_endpoint(), ast_sip_for_each_aor(), ast_sip_location_create_contact(), ast_sip_presence_xml_find_node_attr(), ast_sip_report_failed_acl(), ast_sip_report_invalid_endpoint(), ast_sip_retrieve_auths(), ast_sip_retrieve_auths_vector(), ast_sip_subscription_get_header(), ast_sockaddr_stringify_port(), ast_stream_codec_prefs_parse(), AST_TEST_DEFINE(), ast_var_name(), ast_variable_lists_match(), AST_VECTOR(), ast_websocket_add_protocol(), ast_websocket_remove_protocol(), ast_websocket_server_add_protocol(), ast_websocket_server_remove_protocol(), ast_websocket_sub_protocol_alloc(), ast_xml_doc_item_hash(), ast_xmldoc_build_documentation(), ast_xmldoc_regenerate_doc_item(), ast_xmpp_client_config_alloc(), blacklist_read(), bridge_hash_cb(), build_calendar(), build_config_docs(), build_rlmi_body(), build_topology(), cache_update(), caller_id_to_str(), callerid_read(), cc_generic_agent_init(), cdr_object_alloc(), cdr_object_get_by_name_cb(), cdr_object_select_all_by_name_cb(), change_monitor_action(), channel_hash(), channel_read_rtcp(), channel_snapshot_base_create(), channel_snapshot_caller_create(), channel_snapshot_connected_create(), channel_spy(), check_expr(), check_user_full(), cli_complete_registration(), cli_tps_ping(), cli_tps_reset_stats(), conference_bridge_hash_cb(), config_opt_cmp(), config_opt_hash(), config_option_destroy(), count_agents_cb(), destroy_pval(), dial_exec_full(), dialog_info_generate_body_content(), do_immediate_setup(), do_pause_or_unpause(), dtls_handler(), dump_ies(), dump_prov_ies(), endpoint_lookup(), fac2str(), fax_session_tab_complete(), find_calendar(), find_channel_parking_lot_name(), find_context(), find_macro(), find_option_cb(), find_user_realtime(), forward_message(), function_amiclient(), get_chan_by_ast_name(), get_cid_name(), get_codecs(), get_esc(), get_name_from_resource(), handle_cli_misdn_show_channels(), handle_cli_mobile_search(), handle_cli_status(), handle_cli_test_locales(), handle_manager_bridge_tech_suspend(), handle_manager_show_events(), handle_redirect(), handle_showchan(), handle_tcptls_connection(), headers_to_vars(), hook_callback(), iax2_codec_pref_string(), initial_notify_task(), is_registered_cb(), jb_debug_output(), jingle_endpoint_alloc(), jingle_endpoint_cmp(), jingle_endpoint_hash(), jingle_interpret_content(), jingle_interpret_google_transport(), jingle_request(), leave_voicemail(), load_config(), load_module(), lua_get_variable(), lua_get_variable_value(), lua_set_variable(), lua_set_variable_value(), match_agent(), media_info_cmp(), media_info_hash(), menu_hash_cb(), mgcp_call(), mgcp_hangup(), minivm_notify_exec(), misdn_cfg_get_config_string(), misdn_cfg_get_name(), misdn_hangup(), msg_to_json(), multi_object_blob_to_ami(), multi_user_event_to_json(), my_load_module(), my_unload_module(), ooh323_call(), ooh323_indicate(), originate_exec(), parking_lot_cfg_alloc(), party_id_write(), pbx_builtin_importvar(), pbx_builtin_setvar(), pbx_builtin_setvar_helper(), pbx_builtin_setvar_multiple(), peek_read(), phone_call(), phone_request(), play_message_callerid(), populate_cache(), print_bc_info(), protocol_hash_fn(), proxy_from_config(), publisher_start(), push_callinfo(), pvalAppCallSetAppName(), pvalCatchSetExtName(), pvalContextSetName(), pvalESwitchesAddSwitch(), pvalExtenSetName(), pvalLabelSetName(), pvalMacroCallSetMacroName(), pvalMacroSetName(), pvalSwitchesAddSwitch(), pvalVarDecSetVarname(), realtime_multi_mysql(), realtime_mysql(), realtime_peer_get_sippeer_helper(), record_serializer(), register_verify(), release_chan(), reload(), reload_module(), send_callinfo(), serialize_showchan(), set_hangup_source_and_cause(), set_message_vars_from_req(), set_var_handler(), setup_env(), show_config_description(), show_sounds_cb(), sip_acf_channel_read(), sip_msg_send(), sip_outbound_registration_perform(), sip_prepare_socket(), sip_prune_realtime(), sip_queue_hangup_cause(), skel_level_alloc(), skel_level_hash(), skinny_newcall(), sla_add_trunk_to_station(), sla_build_station(), sla_build_trunk(), sla_find_station(), sla_find_trunk(), softhangup_exec(), sorcery_config_open(), sorcery_destructor(), sorcery_field_default_handler(), sorcery_realtime_open(), start_monitor_action(), stasis_app_device_state_delete(), stasis_app_device_states_to_json(), state_alloc(), state_notify_build_xml(), statistics_show_subscription(), stop_monitor_action(), threadstorage_init(), tls_method_to_str(), tps_hash_cb(), transmit_registerrej(), transport_state2str(), tzload(), tzparse(), unistim_indicate(), unistim_new(), unload_dynamic_module(), unload_module(), update_call_counter(), update_connectedline(), user_hash_cb(), vars_to_headers(), vm_allocate_dh(), websocket_client_handshake_get_response(), wizard_apply_handler(), xmldoc_build_final_response(), xmldoc_build_list_responses(), xmpp_cli_create_collection(), xmpp_cli_create_leafnode(), xmpp_cli_delete_pubsub_node(), xmpp_cli_list_pubsub_nodes(), xmpp_cli_purge_pubsub_nodes(), and xpidf_allocate_body().
Definition at line 77 of file cdr_mysql.c.
Referenced by add_ice_to_sdp(), add_ice_to_stream(), ast_ari_config_init(), ast_http_get_auth(), ast_sip_initialize_sorcery_transport(), AST_TEST_DEFINE(), auth_exec(), authenticate(), authenticate_api_key(), fetch_access_token(), load_module(), manager_login(), my_connect_db(), my_load_module(), mysql_log(), rtp_ice_wrap_get_password(), and vm_authenticate().
|
static |
Definition at line 84 of file cdr_mysql.c.
Referenced by ast_dns_test_generate_result(), AST_TEST_DEFINE(), async_data_alloc(), dns_naptr_sort(), handle_cli_cdr_mysql_status(), invalid_record_test(), my_connect_db(), my_unload_module(), mysql_log(), nominal_test(), and off_nominal_test().
|
static |
Definition at line 69 of file cdr_mysql.c.
Referenced by mysql_log().
|
static |
Definition at line 70 of file cdr_mysql.c.
Referenced by mysql_log().
Definition at line 79 of file cdr_mysql.c.
Definition at line 79 of file cdr_mysql.c.
Referenced by my_connect_db(), my_load_module(), and mysql_log().
Definition at line 79 of file cdr_mysql.c.
Referenced by my_connect_db(), my_load_module(), and mysql_log().
|
static |
Definition at line 86 of file cdr_mysql.c.
Referenced by __analog_ss_thread(), __ast_pbx_run(), __init_manager(), _sip_tcp_helper_thread(), _skinny_message_set(), acf_jabberreceive_read(), action_timeout(), action_waitevent(), aMYSQL_connect(), analog_ss_thread(), ast_app_getdata(), ast_app_getdata_full(), ast_parked_call_payload_create(), ast_readstring_full(), ast_rtp_instance_set_hold_timeout(), ast_rtp_instance_set_timeout(), ast_serializer_pool_create(), ast_serializer_shutdown_group_join(), ast_smdi_md_message_wait(), ast_smdi_mwi_message_wait(), cache_lookup_internal(), cache_save(), cache_save_hint(), chan_pjsip_pvt_dtor(), check_rtp_timeout(), conf_load_config(), conf_run(), config_parse_variables(), control_dial_args_alloc(), dahdi_chan_conf_default(), destroy_all_channels(), dial_exec_full(), endpt_send_request(), fax_detect_attach(), find_cache(), generic_fax_exec(), handle_autohangup(), handle_getdata(), handle_getoption(), handle_speechrecognize(), httpd_helper_thread(), jb_debug_output(), launch_asyncagi(), manager_park(), mgcp_ss(), misdn_check_l2l1(), mp3_exec(), my_connect_db(), my_load_module(), mysql_log(), originate_exec(), page_exec(), parked_call_payload_from_parked_user(), pbx_builtin_waitdigit(), pbx_builtin_waitexten(), play_moh_exec(), read_exec(), read_mf_digits(), read_mf_exec(), read_sf_digits(), read_sf_exec(), readexten_exec(), rtcp_debug_test_addr(), rtp_check_timeout(), set_t38timeout(), sip_check_authtimeout(), sip_tcptls_read(), sla_process_timers(), softmix_mixing_loop(), speech_background(), timed_read(), transmit_audio(), transmit_t38(), wait_exec(), and waitfor_exec().
|
static |
Definition at line 85 of file cdr_mysql.c.
Referenced by handle_cli_cdr_mysql_status(), and mysql_log().
|
static |