b9a4805
From: Peter Lemenkov <lemenkov@gmail.com>
b9a4805
Date: Wed, 10 Aug 2011 17:30:51 +0400
fa3f242
Subject: [PATCH] Use additional auth field - Sip-Source-IP-Address
b9a4805
b9a4805
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
b9a4805
b9a4805
diff --git a/aaa/aaa_avp.h b/aaa/aaa_avp.h
aca7c2c
index 08a3131..2c215f7 100644
b9a4805
--- a/aaa/aaa_avp.h
b9a4805
+++ b/aaa/aaa_avp.h
aca7c2c
@@ -56,7 +56,8 @@
b9a4805
 #define	A_TIME_STAMP					28
b9a4805
 #define	A_SIP_CALL_ID					29
b9a4805
 #define	A_SIP_REQUEST_HASH				30
b9a4805
-#define	A_MAX						31
b9a4805
+#define	A_SIP_SOURCE_IP_ADDRESS				31
b9a4805
+#define	A_MAX						32
b9a4805
 
b9a4805
 #define	V_STATUS_START			0
b9a4805
 #define	V_STATUS_STOP			1
b9a4805
diff --git a/modules/auth_aaa/authaaa_mod.c b/modules/auth_aaa/authaaa_mod.c
aca7c2c
index 55b8cf5..33d5dc5 100644
b9a4805
--- a/modules/auth_aaa/authaaa_mod.c
b9a4805
+++ b/modules/auth_aaa/authaaa_mod.c
aca7c2c
@@ -137,6 +137,7 @@ static int mod_init(void)
b9a4805
 	memset(vals, 0, sizeof(vals));
b9a4805
 	attrs[A_SERVICE_TYPE].name			= "Service-Type";
b9a4805
 	attrs[A_SIP_URI_USER].name			= "Sip-URI-User";
b9a4805
+	attrs[A_SIP_SOURCE_IP_ADDRESS].name			= "Sip-Source-IP-Address";
b9a4805
 	attrs[A_DIGEST_RESPONSE].name		= "Digest-Response";
b9a4805
 	attrs[A_DIGEST_ALGORITHM].name		= "Digest-Algorithm";
b9a4805
 	attrs[A_DIGEST_BODY_DIGEST].name	= "Digest-Body-Digest";
b9a4805
diff --git a/modules/auth_aaa/sterman.c b/modules/auth_aaa/sterman.c
aca7c2c
index e65cd38..cdbd054 100644
b9a4805
--- a/modules/auth_aaa/sterman.c
b9a4805
+++ b/modules/auth_aaa/sterman.c
aca7c2c
@@ -87,6 +87,7 @@ int aaa_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _method,
b9a4805
 	uint32_t service;
b9a4805
 	str method, user, user_name;
b9a4805
 	str *ruri;
b9a4805
+	str ip;
b9a4805
 
b9a4805
 	send = received = NULL;
b9a4805
 
aca7c2c
@@ -229,6 +230,14 @@ int aaa_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _method,
b9a4805
 		goto err;
b9a4805
 	}
b9a4805
 
b9a4805
+	/* Add SIP source IP address as a check item */
b9a4805
+	ip.s = ip_addr2a(&_msg->rcv.src_ip);
b9a4805
+	ip.len = strlen(ip.s);
b9a4805
+	if (proto.avp_add(conn, send, &attrs[A_SIP_SOURCE_IP_ADDRESS], ip.s,ip.len,0)) {
b9a4805
+		LM_ERR("unable to add Sip-URI-User attribute\n");
b9a4805
+		goto err;
b9a4805
+	}
b9a4805
+
b9a4805
 	/* Add CALL-ID in Acct-Session-Id Attribute */
aa419c5
 	if ( _msg->callid==NULL &&
b9a4805
 		(parse_headers(_msg, HDR_CALLID_F, 0)==-1 || _msg->callid==NULL)  ) {