[sr-dev] git:master: modules/auth: new flag 16 to add stale= true to challenge response

Juha Heinanen jh at tutpro.com
Sat May 28 10:45:37 CEST 2011


Module: sip-router
Branch: master
Commit: b63f14b1fd5042b3b605794d6bb18a4030e573ed
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b63f14b1fd5042b3b605794d6bb18a4030e573ed

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Sat May 28 11:43:41 2011 +0300

modules/auth: new flag 16 to add stale=true to challenge response

---

 modules/auth/README            |    2 ++
 modules/auth/auth_mod.c        |   10 ++++++++--
 modules/auth/doc/functions.xml |    9 +++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/auth/README b/modules/auth/README
index 0c34aa8..04d7594 100644
--- a/modules/auth/README
+++ b/modules/auth/README
@@ -539,6 +539,7 @@ if (www_authenticate("realm", "subscriber)) {
           + 4 - do not send '500 Internal Server Error' reply
             automatically in failure cases (error code is returned to
             config)
+          + 16 - build challenge header with stale=true
 
    This function can be used from REQUEST_ROUTE.
 
@@ -607,6 +608,7 @@ if (!proxy_authenticate("$fd", "subscriber)) {
           + 2 - build challenge header with no qop and add it to avp
           + 4 - build challenge header with qop=auth and add it to avp
           + 8 - build challenge header with qop=auth-int and add it to avp
+          + 16 - build challenge header with stale=true
 
    When challenge header is built and stored in avp, append_to_reply() and
    sl reply functions can be used to send appropriate SIP reply to
diff --git a/modules/auth/auth_mod.c b/modules/auth/auth_mod.c
index c44fb96..a28c2ba 100644
--- a/modules/auth/auth_mod.c
+++ b/modules/auth/auth_mod.c
@@ -635,7 +635,7 @@ static int auth_send_reply(struct sip_msg *msg, int code, char *reason,
  */
 int auth_challenge(struct sip_msg *msg, str *realm, int flags, int hftype)
 {
-	int ret;
+    int ret, stale;
     str hf = {0, 0};
 	struct qp *qop = NULL;
 
@@ -646,7 +646,13 @@ int auth_challenge(struct sip_msg *msg, str *realm, int flags, int hftype)
 	} else if(flags&1) {
 		qop = &auth_qauth;
 	}
-	if (get_challenge_hf(msg, 0, realm, NULL, NULL, qop, hftype, &hf) < 0) {
+	if (flags & 16) {
+	    stale = 1;
+	} else {
+	    stale = 0;
+	}
+	if (get_challenge_hf(msg, stale, realm, NULL, NULL, qop, hftype, &hf)
+	    < 0) {
 		ERR("Error while creating challenge\n");
 		ret = -2;
 		goto error;
diff --git a/modules/auth/doc/functions.xml b/modules/auth/doc/functions.xml
index f452529..d328def 100644
--- a/modules/auth/doc/functions.xml
+++ b/modules/auth/doc/functions.xml
@@ -81,6 +81,10 @@ if (www_authenticate("realm", "subscriber)) {
 					Server Error' reply automatically in failure cases
 					(error code is returned to config)</para>
 			</listitem>
+			<listitem>
+				<para><emphasis>16</emphasis> - build challenge header with
+					stale=true</para>
+			</listitem>
 			</itemizedlist>
 		</listitem>
 		</itemizedlist>
@@ -214,6 +218,11 @@ if (!proxy_authenticate("$fd", "subscriber)) {
 				<para><emphasis>8</emphasis> - build challenge header with
 					qop=auth-int and add it to avp</para>
 			</listitem>
+			<listitem>
+				<para><emphasis>16</emphasis> - build challenge header with
+					stale=true</para>
+			</listitem>
+
 			</itemizedlist>
 		</listitem>
 		</itemizedlist>




More information about the sr-dev mailing list