[sr-dev] git:master: uac(k): exported functions for auth

Daniel-Constantin Mierla miconda at gmail.com
Sun Jan 24 22:00:55 CET 2010


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Jan 24 19:49:21 2010 +0100

uac(k): exported functions for auth

- added prototypes and structures to .h

---

 modules_k/uac/auth.c     |   15 ++++++++-------
 modules_k/uac/auth.h     |   29 +++++++++++++++++++++++++++++
 modules_k/uac/auth_alg.h |    8 --------
 modules_k/uac/auth_hdr.h |   17 -----------------
 4 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/modules_k/uac/auth.c b/modules_k/uac/auth.c
index ba0e3fc..69cbe96 100644
--- a/modules_k/uac/auth.c
+++ b/modules_k/uac/auth.c
@@ -201,8 +201,7 @@ void destroy_credentials(void)
 }
 
 
-static inline struct hdr_field *get_autenticate_hdr(struct sip_msg *rpl,
-																int rpl_code)
+struct hdr_field *get_autenticate_hdr(struct sip_msg *rpl, int rpl_code)
 {
 	struct hdr_field *hdr;
 	str hdr_name;
@@ -288,8 +287,9 @@ static inline struct uac_credential *get_avp_credential(struct sip_msg *msg,
 }
 
 
-static inline void do_uac_auth(struct sip_msg *req, str *uri,
-		struct uac_credential *crd, struct authenticate_body *auth,
+void do_uac_auth(str *method, str *uri,
+		struct uac_credential *crd,
+		struct authenticate_body *auth,
 		HASHHEX response)
 {
 	HASHHEX ha1;
@@ -303,7 +303,7 @@ static inline void do_uac_auth(struct sip_msg *req, str *uri,
 
 		/* do authentication */
 		uac_calc_HA1( crd, auth, &cnonce, ha1);
-		uac_calc_HA2( &req->first_line.u.request.method, uri,
+		uac_calc_HA2( method, uri,
 			auth, 0/*hentity*/, ha2 );
 
 		uac_calc_response( ha1, ha2, auth, &nc, &cnonce, response);
@@ -312,7 +312,7 @@ static inline void do_uac_auth(struct sip_msg *req, str *uri,
 	} else {
 		/* do authentication */
 		uac_calc_HA1( crd, auth, 0/*cnonce*/, ha1);
-		uac_calc_HA2( &req->first_line.u.request.method, uri,
+		uac_calc_HA2( method, uri,
 			auth, 0/*hentity*/, ha2 );
 
 		uac_calc_response( ha1, ha2, auth, 0/*nc*/, 0/*cnonce*/, response);
@@ -444,7 +444,8 @@ int uac_auth( struct sip_msg *msg)
 	}
 
 	/* do authentication */
-	do_uac_auth( msg, &t->uac[branch].uri, crd, &auth, response);
+	do_uac_auth( &msg->first_line.u.request.method,
+			&t->uac[branch].uri, crd, &auth, response);
 
 	/* build the authorization header */
 	new_hdr = build_authorization_hdr( code, &t->uac[branch].uri,
diff --git a/modules_k/uac/auth.h b/modules_k/uac/auth.h
index 0d24c8d..672abae 100644
--- a/modules_k/uac/auth.h
+++ b/modules_k/uac/auth.h
@@ -38,6 +38,28 @@ struct uac_credential {
 	struct uac_credential *next;
 };
 
+struct authenticate_body {
+	int flags;
+	str realm;
+	str domain;
+	str nonce;
+	str opaque;
+	str qop;
+	str *nc;
+	str *cnonce;
+};
+
+#define AUTHENTICATE_MD5         (1<<0)
+#define AUTHENTICATE_MD5SESS     (1<<1)
+#define AUTHENTICATE_STALE       (1<<2)
+#define QOP_AUTH                 (1<<3)
+#define QOP_AUTH_INT             (1<<4)
+
+#define HASHLEN 16
+typedef char HASH[HASHLEN];
+
+#define HASHHEXLEN 32
+typedef char HASHHEX[HASHHEXLEN+1];
 
 int has_credentials(void);
 
@@ -45,6 +67,13 @@ int add_credential( unsigned int type, void *val);
 
 void destroy_credentials(void);
 
+struct hdr_field *get_autenticate_hdr(struct sip_msg *rpl, int rpl_code);
+
 int uac_auth( struct sip_msg *msg);
 
+void do_uac_auth(str *method, str *uri,
+		struct uac_credential *crd,
+		struct authenticate_body *auth,
+		HASHHEX response);
+
 #endif
diff --git a/modules_k/uac/auth_alg.h b/modules_k/uac/auth_alg.h
index 99269df..d88c654 100644
--- a/modules_k/uac/auth_alg.h
+++ b/modules_k/uac/auth_alg.h
@@ -31,17 +31,9 @@
 
 #include "../../str.h"
 
-#include "auth_hdr.h"
 #include "auth.h"
 
 
-#define HASHLEN 16
-typedef char HASH[HASHLEN];
-
-
-#define HASHHEXLEN 32
-typedef char HASHHEX[HASHHEXLEN+1];
-
 void uac_calc_HA1( struct uac_credential *crd,
 		struct authenticate_body *auth,
 		str* cnonce,
diff --git a/modules_k/uac/auth_hdr.h b/modules_k/uac/auth_hdr.h
index 73e5c52..8ead2b8 100644
--- a/modules_k/uac/auth_hdr.h
+++ b/modules_k/uac/auth_hdr.h
@@ -33,23 +33,6 @@
 
 #include "auth.h"
 
-struct authenticate_body {
-	int flags;
-	str realm;
-	str domain;
-	str nonce;
-	str opaque;
-	str qop;
-	str *nc;
-	str *cnonce;
-};
-
-#define AUTHENTICATE_MD5         (1<<0)
-#define AUTHENTICATE_MD5SESS     (1<<1)
-#define AUTHENTICATE_STALE       (1<<2)
-#define QOP_AUTH                 (1<<3)
-#define QOP_AUTH_INT             (1<<4)
-
 int parse_authenticate_body( str *body, struct authenticate_body *auth);
 
 str* build_authorization_hdr(int code, str *uri,




More information about the sr-dev mailing list