summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/res_pjsip/config_transport.c21
-rw-r--r--res/res_pjsip/pjsip_distributor.c26
-rw-r--r--res/res_rtp_asterisk.c14
3 files changed, 31 insertions, 30 deletions
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index dd7c7049d..20324ed9a 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -977,27 +977,22 @@ static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
/*! \brief Helper function which turns a cipher name into an identifier */
static pj_ssl_cipher cipher_name_to_id(const char *name)
{
- pj_ssl_cipher ciphers[100];
- pj_ssl_cipher id = 0;
+ pj_ssl_cipher ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
- int pos;
- const char *pos_name;
+ unsigned int pos;
if (pj_ssl_cipher_get_availables(ciphers, &cipher_num)) {
return 0;
}
for (pos = 0; pos < cipher_num; ++pos) {
- pos_name = pj_ssl_cipher_name(ciphers[pos]);
- if (!pos_name || strcmp(pos_name, name)) {
- continue;
+ const char *pos_name = pj_ssl_cipher_name(ciphers[pos]);
+ if (pos_name && !strcmp(pos_name, name)) {
+ return ciphers[pos];
}
-
- id = ciphers[pos];
- break;
}
- return id;
+ return 0;
}
/*!
@@ -1072,7 +1067,7 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
static void cipher_to_str(char **buf, const pj_ssl_cipher *ciphers, unsigned int cipher_num)
{
struct ast_str *str;
- int idx;
+ unsigned int idx;
str = ast_str_create(128);
if (!str) {
@@ -1106,7 +1101,7 @@ static int transport_tls_cipher_to_str(const void *obj, const intptr_t *args, ch
static char *handle_pjsip_list_ciphers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- pj_ssl_cipher ciphers[100];
+ pj_ssl_cipher ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
char *buf;
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index 33d4bced2..68a0cbcc2 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -690,7 +690,8 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
* the find without OBJ_UNLINK to prevent the unnecessary write lock, then unlink
* if needed.
*/
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
@@ -699,14 +700,14 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
endpoint = ast_sip_identify_endpoint(rdata);
if (endpoint) {
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
}
if (!endpoint) {
-
/* always use an artificial endpoint - per discussion no reason
to have "alwaysauthreject" as an option. It is felt using it
was a bug fix and it is not needed since we are not worried about
@@ -715,9 +716,10 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
endpoint = ast_sip_get_artificial_endpoint();
}
+ /* endpoint ref held by mod_data[] */
rdata->endpt_info.mod_data[endpoint_mod.id] = endpoint;
- if ((endpoint == artificial_endpoint) && !is_ack) {
+ if (endpoint == artificial_endpoint && !is_ack) {
char name[AST_UUID_STR_LEN] = "";
pjsip_uri *from = rdata->msg_info.from->uri;
@@ -726,17 +728,20 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
ast_copy_pj_str(name, &sip_from->user, sizeof(name));
}
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
check_endpoint(rdata, unid, name);
ao2_ref(unid, -1);
} else if (using_auth_username) {
ao2_wrlock(unidentified_requests);
- /* The check again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY | OBJ_NOLOCK))) {
+ /* Checking again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name,
+ OBJ_SEARCH_KEY | OBJ_NOLOCK);
+ if (unid) {
check_endpoint(rdata, unid, name);
} else {
- unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1, NULL,
- AO2_ALLOC_OPT_LOCK_RWLOCK);
+ unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1,
+ NULL, AO2_ALLOC_OPT_LOCK_RWLOCK);
if (!unid) {
ao2_unlock(unidentified_requests);
return PJ_TRUE;
@@ -860,7 +865,8 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata)
return PJ_TRUE;
case AST_SIP_AUTHENTICATION_SUCCESS:
/* See note in endpoint_lookup about not holding an unnecessary write lock */
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 4ac20d551..5579914af 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3947,15 +3947,15 @@ static void ast_rtp_change_source(struct ast_rtp_instance *instance)
if (rtp->lastts) {
/* We simply set this bit so that the next packet sent will have the marker bit turned on */
ast_set_flag(rtp, FLAG_NEED_MARKER_BIT);
+ }
- ast_debug(3, "Changing ssrc from %u to %u due to a source change\n", rtp->ssrc, ssrc);
+ ast_debug(3, "Changing ssrc from %u to %u due to a source change\n", rtp->ssrc, ssrc);
- if (srtp) {
- ast_debug(3, "Changing ssrc for SRTP from %u to %u\n", rtp->ssrc, ssrc);
- res_srtp->change_source(srtp, rtp->ssrc, ssrc);
- if (rtcp_srtp != srtp) {
- res_srtp->change_source(rtcp_srtp, rtp->ssrc, ssrc);
- }
+ if (srtp) {
+ ast_debug(3, "Changing ssrc for SRTP from %u to %u\n", rtp->ssrc, ssrc);
+ res_srtp->change_source(srtp, rtp->ssrc, ssrc);
+ if (rtcp_srtp != srtp) {
+ res_srtp->change_source(rtcp_srtp, rtp->ssrc, ssrc);
}
}