diff options
-rw-r--r-- | addons/cdr_mysql.c | 35 | ||||
-rw-r--r-- | channels/chan_sip.c | 4 | ||||
-rw-r--r-- | funcs/func_channel.c | 7 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 4 |
4 files changed, 30 insertions, 20 deletions
diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c index c5cf10892..53ea92359 100644 --- a/addons/cdr_mysql.c +++ b/addons/cdr_mysql.c @@ -128,7 +128,7 @@ static char *handle_cli_cdr_mysql_status(struct ast_cli_entry *e, int cmd, struc else snprintf(status, 255, "Connected to %s@%s", ast_str_buffer(dbname), ast_str_buffer(hostname)); - if (!ast_strlen_zero(ast_str_buffer(dbuser))) + if (ast_str_strlen(dbuser)) snprintf(status2, 99, " with username %s", ast_str_buffer(dbuser)); if (ast_str_strlen(dbtable)) snprintf(status2, 99, " using table %s", ast_str_buffer(dbtable)); @@ -158,6 +158,16 @@ static struct ast_cli_entry cdr_mysql_status_cli[] = { AST_CLI_DEFINE(handle_cli_cdr_mysql_status, "Show connection status of cdr_mysql"), }; +static void configure_connection_charset(void) +{ + if (ast_str_strlen(dbcharset)) { + const char *charset = ast_str_buffer(dbcharset); + if (mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, charset)) { + ast_log(LOG_WARNING, "Failed to set connection charset. Data inserted might be invalid.\n"); + } + } +} + static int mysql_log(struct ast_cdr *cdr) { struct ast_str *sql1 = ast_str_thread_get(&sql1_buf, 1024), *sql2 = ast_str_thread_get(&sql2_buf, 1024); @@ -190,15 +200,13 @@ db_reconnect: if (ssl_ca || ssl_cert || ssl_key) { mysql_ssl_set(&mysql, ssl_key ? ast_str_buffer(ssl_key) : NULL, ssl_cert ? ast_str_buffer(ssl_cert) : NULL, ssl_ca ? ast_str_buffer(ssl_ca) : NULL, NULL, NULL); } + + configure_connection_charset(); + if (mysql_real_connect(&mysql, ast_str_buffer(hostname), ast_str_buffer(dbuser), ast_str_buffer(password), ast_str_buffer(dbname), dbport, dbsock && ast_str_strlen(dbsock) ? ast_str_buffer(dbsock) : NULL, ssl_ca ? CLIENT_SSL : 0)) { connected = 1; connect_time = time(NULL); records = 0; - if (dbcharset) { - ast_str_set(&sql1, 0, "SET NAMES '%s'", ast_str_buffer(dbcharset)); - mysql_real_query(&mysql, ast_str_buffer(sql1), ast_str_strlen(sql1)); - ast_debug(1, "SQL command as follows: %s\n", ast_str_buffer(sql1)); - } } else { ast_log(LOG_ERROR, "Cannot connect to database server %s: (%d) %s\n", ast_str_buffer(hostname), mysql_errno(&mysql), mysql_error(&mysql)); connected = 0; @@ -500,7 +508,7 @@ static int my_load_module(int reload) res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, ""); res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, ""); - res |= my_load_config_number(cfg, "global", "port", &dbport, 0); + res |= my_load_config_number(cfg, "global", "port", &dbport, MYSQL_PORT); res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0); res |= my_load_config_string(cfg, "global", "compat", &compat, "no"); res |= my_load_config_string(cfg, "global", "cdrzone", &cdrzone, ""); @@ -540,15 +548,16 @@ static int my_load_module(int reload) ast_debug(1, "Got hostname of %s\n", ast_str_buffer(hostname)); ast_debug(1, "Got port of %d\n", dbport); ast_debug(1, "Got a timeout of %d\n", timeout); - if (dbsock) + if (ast_str_strlen(dbsock)) { ast_debug(1, "Got sock file of %s\n", ast_str_buffer(dbsock)); + } ast_debug(1, "Got user of %s\n", ast_str_buffer(dbuser)); ast_debug(1, "Got dbname of %s\n", ast_str_buffer(dbname)); ast_debug(1, "Got password of %s\n", ast_str_buffer(password)); ast_debug(1, "%sunning in calldate compatibility mode\n", calldate_compat ? "R" : "Not r"); ast_debug(1, "Dates and times are localized to %s\n", S_OR(ast_str_buffer(cdrzone), "local timezone")); - if (dbcharset) { + if (ast_str_strlen(dbcharset)) { ast_debug(1, "Got DB charset of %s\n", ast_str_buffer(dbcharset)); } @@ -573,6 +582,9 @@ static int my_load_module(int reload) NULL, NULL); } temp = dbsock && ast_str_strlen(dbsock) ? ast_str_buffer(dbsock) : NULL; + + configure_connection_charset(); + if (!mysql_real_connect(&mysql, ast_str_buffer(hostname), ast_str_buffer(dbuser), ast_str_buffer(password), ast_str_buffer(dbname), dbport, temp, ssl_ca && ast_str_strlen(ssl_ca) ? CLIENT_SSL : 0)) { ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", ast_str_buffer(dbname), ast_str_buffer(hostname)); connected = 0; @@ -582,11 +594,6 @@ static int my_load_module(int reload) connected = 1; records = 0; connect_time = time(NULL); - if (dbcharset) { - snprintf(sqldesc, sizeof(sqldesc), "SET NAMES '%s'", ast_str_buffer(dbcharset)); - mysql_real_query(&mysql, sqldesc, strlen(sqldesc)); - ast_debug(1, "SQL command as follows: %s\n", sqldesc); - } /* Get table description */ snprintf(sqldesc, sizeof(sqldesc), "DESC %s", dbtable ? ast_str_buffer(dbtable) : "cdr"); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3ff84153d..ee2eee009 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11288,7 +11288,7 @@ static int process_sdp_a_ice(const char *a, struct sip_pvt *p, struct ast_rtp_in { struct ast_rtp_engine_ice *ice; int found = FALSE; - char ufrag[256], pwd[256], foundation[32], transport[4], address[46], cand_type[6], relay_address[46] = ""; + char ufrag[256], pwd[256], foundation[33], transport[4], address[46], cand_type[6], relay_address[46] = ""; struct ast_rtp_engine_ice_candidate candidate = { 0, }; unsigned int port, relay_port = 0; @@ -11302,7 +11302,7 @@ static int process_sdp_a_ice(const char *a, struct sip_pvt *p, struct ast_rtp_in } else if (sscanf(a, "ice-pwd: %255s", pwd) == 1) { ice->set_authentication(instance, NULL, pwd); found = TRUE; - } else if (sscanf(a, "candidate: %31s %30u %3s %30u %23s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, (unsigned *)&candidate.priority, + } else if (sscanf(a, "candidate: %32s %30u %3s %30u %23s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, (unsigned *)&candidate.priority, address, &port, cand_type, relay_address, &relay_port) >= 7) { if (rtcp_mux_offered && ast_test_flag(&p->flags[2], SIP_PAGE3_RTCP_MUX) && candidate.id > 1) { diff --git a/funcs/func_channel.c b/funcs/func_channel.c index 3005d31b1..793ea3f89 100644 --- a/funcs/func_channel.c +++ b/funcs/func_channel.c @@ -69,8 +69,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Gets or sets variables on the master channel </synopsis> <description> - <para>Allows access to the channel which created the current channel, if any. If the channel is already - a master channel, then accesses local channel variables.</para> + <para>Allows access to the oldest channel associated with the current + channel if it still exists. If the channel is the master channel or + the master channel no longer exists then access local channel variables + instead. In other words, the master channel is the channel identified by + the channel's linkedid.</para> </description> </function> <function name="CHANNEL" language="en_US"> diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 0fcd509fb..585202787 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -618,7 +618,7 @@ static void process_ice_attributes(struct ast_sip_session *session, struct ast_s /* Find all of the candidates */ for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) { - char foundation[32], transport[32], address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] = ""; + char foundation[33], transport[32], address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] = ""; unsigned int port, relay_port = 0; struct ast_rtp_engine_ice_candidate candidate = { 0, }; @@ -631,7 +631,7 @@ static void process_ice_attributes(struct ast_sip_session *session, struct ast_s ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value, sizeof(attr_value)); - if (sscanf(attr_value, "%31s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, + if (sscanf(attr_value, "%32s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, (unsigned *)&candidate.priority, address, &port, cand_type, relay_address, &relay_port) < 7) { /* Candidate did not parse properly */ continue; |