[asterisk-commits] mmichelson: branch group/pimp_my_sip r379965 - /team/group/pimp_my_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 22 18:24:19 CST 2013


Author: mmichelson
Date: Tue Jan 22 18:24:15 2013
New Revision: 379965

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379965
Log:
Fill in the add_digest_to_challenge method.


Modified:
    team/group/pimp_my_sip/res/res_sip.c

Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=379965&r1=379964&r2=379965
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Tue Jan 22 18:24:15 2013
@@ -126,17 +126,29 @@
 	return reg->get_authentication_credentials(endpoint, challenge);
 }
 
-static pjsip_auth_srv *challenge_data_to_auth_srv(struct ast_sip_digest_challenge_data *challenge)
-{
-	/* XXX stub. Needs to set the realm, username, and password.*/
-	return NULL;
-}
-
 void ast_sip_add_digest_to_challenge(struct ast_sip_digest_challenge_data *challenge, pjsip_tx_data *tdata)
 {
-	pjsip_auth_srv *auth_server = challenge_data_to_auth_srv(challenge);
-	/* XXX Just using NULL nonce, qop, and opaque. Change later */
-	pjsip_auth_srv_challenge(auth_server, NULL, NULL, NULL, PJ_FALSE, tdata);
+	pjsip_auth_srv auth_server;
+	pj_str_t realm;
+	pj_str_t nonce;
+	pj_str_t *nonce_ptr = NULL;
+	pj_str_t qop;
+	pj_str_t opaque;
+	pj_str_t *opaque_ptr = NULL;
+
+	pj_cstr(&realm, challenge->realm);
+	pj_cstr(&qop, "auth");
+	if (!ast_strlen_zero(challenge->opaque)) {
+		pj_cstr(&opaque, challenge->opaque);
+		opaque_ptr = &opaque;
+	}
+	if (!ast_strlen_zero(challenge->nonce)) {
+		pj_cstr(&nonce, challenge->nonce);
+		nonce_ptr = &nonce;
+	}
+
+	pjsip_auth_srv_init(tdata->pool, &auth_server, &realm, NULL, 0);
+	pjsip_auth_srv_challenge(&auth_server, &qop, nonce_ptr, opaque_ptr, PJ_FALSE, tdata);
 }
 
 enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)




More information about the asterisk-commits mailing list