From: Peter Lemenkov Date: Wed, 10 Aug 2011 17:30:51 +0400 Subject: [PATCH] Use additional auth field - Sip-Source-IP-Address Signed-off-by: Peter Lemenkov diff --git a/aaa/aaa_avp.h b/aaa/aaa_avp.h index 1211c26..6d95c72 100644 --- a/aaa/aaa_avp.h +++ b/aaa/aaa_avp.h @@ -58,7 +58,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 f63a485..c0a7235 100644 --- a/modules/auth_aaa/authaaa_mod.c +++ b/modules/auth_aaa/authaaa_mod.c @@ -126,6 +126,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 e10deec..702af71 100644 --- a/modules/auth_aaa/sterman.c +++ b/modules/auth_aaa/sterman.c @@ -89,6 +89,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; @@ -231,6 +232,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) ) {