diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-12-09 16:10:05 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-12-09 16:10:05 +0000 |
commit | b18ed67d16e60b0cfe25b5d3b5ff3b62a2b467dc (patch) | |
tree | 735c83ea3d113a37a2e7355c676e99b0d2668123 /res/res_pjsip_authenticator_digest.c | |
parent | 8042f4cdd2b650613898f9e7ddff0a052b8627f3 (diff) |
Switch PJSIP auth to use a vector.
Since Asterisk has a vector API now, places where arrays are manually
resized don't really make sense any more. Since the auth work in PJSIP
was freshly-written, it was easy to reform it to use a vector.
Review: https://reviewboard.asterisk.org/r/3044
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403499 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_authenticator_digest.c')
-rw-r--r-- | res/res_pjsip_authenticator_digest.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/res/res_pjsip_authenticator_digest.c b/res/res_pjsip_authenticator_digest.c index 30da26cfd..4a84a402a 100644 --- a/res/res_pjsip_authenticator_digest.c +++ b/res/res_pjsip_authenticator_digest.c @@ -41,7 +41,7 @@ AO2_GLOBAL_OBJ_STATIC(entity_id); */ static int digest_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) { - return endpoint->inbound_auths.num > 0; + return AST_VECTOR_SIZE(&endpoint->inbound_auths) > 0; } static void auth_store_cleanup(void *data) @@ -384,12 +384,15 @@ static enum ast_sip_check_auth_result digest_check_auth(struct ast_sip_endpoint enum ast_sip_check_auth_result res; int i; int failures = 0; + size_t auth_size; RAII_VAR(struct ast_sip_endpoint *, artificial_endpoint, ast_sip_get_artificial_endpoint(), ao2_cleanup); - auths = ast_alloca(endpoint->inbound_auths.num * sizeof(*auths)); - verify_res = ast_alloca(endpoint->inbound_auths.num * sizeof(*verify_res)); + auth_size = AST_VECTOR_SIZE(&endpoint->inbound_auths); + + auths = ast_alloca(auth_size * sizeof(*auths)); + verify_res = ast_alloca(auth_size * sizeof(*verify_res)); if (!auths) { return AST_SIP_AUTHENTICATION_ERROR; @@ -402,7 +405,7 @@ static enum ast_sip_check_auth_result digest_check_auth(struct ast_sip_endpoint goto cleanup; } - for (i = 0; i < endpoint->inbound_auths.num; ++i) { + for (i = 0; i < auth_size; ++i) { if (ast_strlen_zero(auths[i]->realm)) { ast_string_field_set(auths[i], realm, "asterisk"); } @@ -416,18 +419,18 @@ static enum ast_sip_check_auth_result digest_check_auth(struct ast_sip_endpoint } } - for (i = 0; i < endpoint->inbound_auths.num; ++i) { + for (i = 0; i < auth_size; ++i) { challenge(auths[i]->realm, tdata, rdata, verify_res[i] == AUTH_STALE); } - if (failures == endpoint->inbound_auths.num) { + if (failures == auth_size) { res = AST_SIP_AUTHENTICATION_FAILED; } else { res = AST_SIP_AUTHENTICATION_CHALLENGE; } cleanup: - ast_sip_cleanup_auths(auths, endpoint->inbound_auths.num); + ast_sip_cleanup_auths(auths, auth_size); return res; } |