Переглянути джерело

uac(k): exported functions for auth

- added prototypes and structures to .h
Daniel-Constantin Mierla 15 роки тому
батько
коміт
7ea6f7c5bc
4 змінених файлів з 37 додано та 32 видалено
  1. 8 7
      modules_k/uac/auth.c
  2. 29 0
      modules_k/uac/auth.h
  3. 0 8
      modules_k/uac/auth_alg.h
  4. 0 17
      modules_k/uac/auth_hdr.h

+ 8 - 7
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,

+ 29 - 0
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

+ 0 - 8
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,

+ 0 - 17
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,