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_outbound_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_outbound_authenticator_digest.c')
-rw-r--r-- | res/res_pjsip_outbound_authenticator_digest.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/res/res_pjsip_outbound_authenticator_digest.c b/res/res_pjsip_outbound_authenticator_digest.c index e7e77dbd5..1e411f1c5 100644 --- a/res/res_pjsip_outbound_authenticator_digest.c +++ b/res/res_pjsip_outbound_authenticator_digest.c @@ -50,15 +50,16 @@ static pjsip_www_authenticate_hdr *get_auth_header(pjsip_rx_data *challenge) { } static int set_outbound_authentication_credentials(pjsip_auth_clt_sess *auth_sess, - const struct ast_sip_auth_array *array, pjsip_rx_data *challenge) + const struct ast_sip_auth_vector *auth_vector, pjsip_rx_data *challenge) { - struct ast_sip_auth **auths = ast_alloca(array->num * sizeof(*auths)); - pjsip_cred_info *auth_creds = ast_alloca(array->num * sizeof(*auth_creds)); + size_t auth_size = AST_VECTOR_SIZE(auth_vector); + struct ast_sip_auth **auths = ast_alloca(auth_size * sizeof(*auths)); + pjsip_cred_info *auth_creds = ast_alloca(auth_size * sizeof(*auth_creds)); pjsip_www_authenticate_hdr *auth_hdr = NULL; int res = 0; int i; - if (ast_sip_retrieve_auths(array, auths)) { + if (ast_sip_retrieve_auths(auth_vector, auths)) { res = -1; goto cleanup; } @@ -70,7 +71,7 @@ static int set_outbound_authentication_credentials(pjsip_auth_clt_sess *auth_ses goto cleanup; } - for (i = 0; i < array->num; ++i) { + for (i = 0; i < auth_size; ++i) { if (ast_strlen_zero(auths[i]->realm)) { auth_creds[i].realm = auth_hdr->challenge.common.realm; } else { @@ -93,14 +94,14 @@ static int set_outbound_authentication_credentials(pjsip_auth_clt_sess *auth_ses } } - pjsip_auth_clt_set_credentials(auth_sess, array->num, auth_creds); + pjsip_auth_clt_set_credentials(auth_sess, auth_size, auth_creds); cleanup: - ast_sip_cleanup_auths(auths, array->num); + ast_sip_cleanup_auths(auths, auth_size); return res; } -static int digest_create_request_with_auth(const struct ast_sip_auth_array *auths, pjsip_rx_data *challenge, +static int digest_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_transaction *tsx, pjsip_tx_data **new_request) { pjsip_auth_clt_sess auth_sess; |