Blob Blame Raw
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Wed, 10 Aug 2011 17:30:51 +0400
Subject: [PATCH] Use additional auth field - Sip-Source-IP-Address

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

diff --git a/aaa/aaa_avp.h b/aaa/aaa_avp.h
index 08a3131e9..2c215f740 100644
--- a/aaa/aaa_avp.h
+++ b/aaa/aaa_avp.h
@@ -56,7 +56,8 @@
 #define	A_TIME_STAMP					28
 #define	A_SIP_CALL_ID					29
 #define	A_SIP_REQUEST_HASH				30
-#define	A_MAX						31
+#define	A_SIP_SOURCE_IP_ADDRESS				31
+#define	A_MAX						32
 
 #define	V_STATUS_START			0
 #define	V_STATUS_STOP			1
diff --git a/modules/auth_aaa/authaaa_mod.c b/modules/auth_aaa/authaaa_mod.c
index 5b230cf58..bc1ea8603 100644
--- a/modules/auth_aaa/authaaa_mod.c
+++ b/modules/auth_aaa/authaaa_mod.c
@@ -139,6 +139,7 @@ static int mod_init(void)
 	memset(vals, 0, sizeof(vals));
 	attrs[A_SERVICE_TYPE].name			= "Service-Type";
 	attrs[A_SIP_URI_USER].name			= "Sip-URI-User";
+	attrs[A_SIP_SOURCE_IP_ADDRESS].name			= "Sip-Source-IP-Address";
 	attrs[A_DIGEST_RESPONSE].name		= "Digest-Response";
 	attrs[A_DIGEST_ALGORITHM].name		= "Digest-Algorithm";
 	attrs[A_DIGEST_BODY_DIGEST].name	= "Digest-Body-Digest";
diff --git a/modules/auth_aaa/sterman.c b/modules/auth_aaa/sterman.c
index 92df9b9bd..a0fa42aa1 100644
--- a/modules/auth_aaa/sterman.c
+++ b/modules/auth_aaa/sterman.c
@@ -87,6 +87,7 @@ int aaa_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _method,
 	uint32_t service;
 	str method, user, user_name;
 	str *ruri;
+	str ip;
 
 	send = received = NULL;
 
@@ -229,6 +230,14 @@ int aaa_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _method,
 		goto err;
 	}
 
+	/* Add SIP source IP address as a check item */
+	ip.s = ip_addr2a(&_msg->rcv.src_ip);
+	ip.len = strlen(ip.s);
+	if (proto.avp_add(conn, send, &attrs[A_SIP_SOURCE_IP_ADDRESS], ip.s,ip.len,0)) {
+		LM_ERR("unable to add Sip-URI-User attribute\n");
+		goto err;
+	}
+
 	/* Add CALL-ID in Acct-Session-Id Attribute */
 	if ( _msg->callid==NULL &&
 		(parse_headers(_msg, HDR_CALLID_F, 0)==-1 || _msg->callid==NULL)  ) {