Module: sip-router
Branch: master
Commit: 2e821613a2fac7b3a6b7ec28a314b462f18f5bc2
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2e82161…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Thu Oct 9 11:57:56 2014 +0200
modules/ims_qos: Added feature to Rx_reg check if session has been opened before acting
on termination
When Rx signalling session is terminated only remove user from user loc if rx signalling
session was successfully opened
---
modules/ims_qos/cdpeventprocessor.c | 37 ++++++++++++++++++----------------
modules/ims_qos/rx_aar.c | 27 ++++++++++++++++++++++--
modules/ims_qos/rx_authdata.c | 2 +
modules/ims_qos/rx_authdata.h | 1 +
4 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/modules/ims_qos/cdpeventprocessor.c b/modules/ims_qos/cdpeventprocessor.c
index 409009e..1cf322e 100644
--- a/modules/ims_qos/cdpeventprocessor.c
+++ b/modules/ims_qos/cdpeventprocessor.c
@@ -230,23 +230,26 @@ void cdp_cb_event_process() {
LM_DBG("This is a subscription to signalling bearer
session");
//instead of removing the contact from usrloc_pcscf we just change
the state of the contact to TERMINATE_PENDING_NOTIFY
//pcscf_registrar sees this, sends a SIP PUBLISH and on SIP NOTIFY
the contact is deleted
-
- if (ul.register_udomain(p_session_data->domain.s, &domain)
- < 0) {
- LM_DBG("Unable to register usrloc
domain....aborting\n");
- return;
- }
- ul.lock_udomain(domain, &p_session_data->registration_aor);
- if (ul.get_pcontact(domain,
&p_session_data->registration_aor,
- &pcontact) != 0) {
- LM_DBG("no contact found for terminated Rx reg session.....
ignoring\n");
- } else {
- LM_DBG("Updating contact [%.*s] after Rx reg session
terminated, setting state to PCONTACT_DEREG_PENDING_PUBLISH\n", pcontact->aor.len,
pcontact->aor.s);
- ci.reg_state = PCONTACT_DEREG_PENDING_PUBLISH;
- ci.num_service_routes = 0;
- ul.update_pcontact(domain, &ci, pcontact);
- }
- ul.unlock_udomain(domain, &p_session_data->registration_aor);
+ //note we only send SIP PUBLISH if the session has been successfully opened
+
+ if(p_session_data->session_has_been_opened) {
+ if (ul.register_udomain(p_session_data->domain.s, &domain)
+ < 0) {
+ LM_DBG("Unable to register usrloc domain....aborting\n");
+ return;
+ }
+ ul.lock_udomain(domain, &p_session_data->registration_aor);
+ if (ul.get_pcontact(domain, &p_session_data->registration_aor,
+ &pcontact) != 0) {
+ LM_DBG("no contact found for terminated Rx reg session.....
ignoring\n");
+ } else {
+ LM_DBG("Updating contact [%.*s] after Rx reg session terminated, setting
state to PCONTACT_DEREG_PENDING_PUBLISH\n", pcontact->aor.len,
pcontact->aor.s);
+ ci.reg_state = PCONTACT_DEREG_PENDING_PUBLISH;
+ ci.num_service_routes = 0;
+ ul.update_pcontact(domain, &ci, pcontact);
+ }
+ ul.unlock_udomain(domain, &p_session_data->registration_aor);
+ }
} else {
LM_DBG("This is a media bearer session session");
diff --git a/modules/ims_qos/rx_aar.c b/modules/ims_qos/rx_aar.c
index 028d6cd..c3482fc 100644
--- a/modules/ims_qos/rx_aar.c
+++ b/modules/ims_qos/rx_aar.c
@@ -94,7 +94,7 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa,
long elaps
struct cell *t = 0;
unsigned int cdp_result;
int result = CSCF_RETURN_ERROR;
-
+
LM_DBG("Received AAR callback\n");
saved_transaction_t* data = (saved_transaction_t*) param;
@@ -135,9 +135,9 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa,
long elaps
if (cdp_result >= 2000 && cdp_result < 3000) {
LM_DBG("Success, received code: [%i] from PCRF for AAR request\n",
cdp_result);
-
- LM_DBG("Auth session ID [%.*s]", aaa->sessionId->data.len,
aaa->sessionId->data.s);
+ LM_DBG("Auth session ID [%.*s]", aaa->sessionId->data.len,
aaa->sessionId->data.s);
+
if(!data->aar_update) {
LM_DBG("This is an AAA response to an initial AAR");
str * passed_rx_session_id = shm_malloc(sizeof (struct _str));
@@ -181,6 +181,8 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage
*aaa, long e
struct pcontact_info ci;
udomain_t* domain_t;
int finalReply = 0;
+ AAASession *auth = 0;
+ rx_authsessiondata_t* p_session_data = 0;
int result = CSCF_RETURN_ERROR;
LM_DBG("Received AAR callback\n");
@@ -245,6 +247,25 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage
*aaa, long e
create_return_code(result);
goto done;
}
+ //need to set Rx auth data to say this session has been successfully opened
+ //This is used elsewhere to prevent acting on termination events when the session has
not been opened
+ //getting auth session
+ auth = cdpb.AAAGetAuthSession(aaa->sessionId->data);
+ if (!auth) {
+ LM_DBG("Could not get Auth Session for session id: [%.*s]\n",
aaa->sessionId->data.len, aaa->sessionId->data.s);
+ goto error;
+ }
+ //getting session data
+ p_session_data = (rx_authsessiondata_t*) auth->u.auth.generic_data;
+ if (!p_session_data) {
+ LM_DBG("Could not get session data on Auth Session for session id:
[%.*s]\n", aaa->sessionId->data.len, aaa->sessionId->data.s);
+ if (auth) cdpb.AAASessionsUnlock(auth->hash);
+ goto error;
+ }
+ p_session_data->session_has_been_opened = 1;
+ if (auth) cdpb.AAASessionsUnlock(auth->hash);
+
+
LM_DBG("Success, received code: [%i] from PCRF for AAR request (contact:
[%.*s]), (auth session id: %.*s)\n",
cdp_result, local_data->contact.len, local_data->contact.s,
local_data->auth_session_id.len, local_data->auth_session_id.s);
diff --git a/modules/ims_qos/rx_authdata.c b/modules/ims_qos/rx_authdata.c
index 1de9b40..86e8fca 100644
--- a/modules/ims_qos/rx_authdata.c
+++ b/modules/ims_qos/rx_authdata.c
@@ -81,6 +81,8 @@ int create_new_regsessiondata(str* domain, str* aor,
rx_authsessiondata_t** sess
p_session_data->subscribed_to_signaling_path_status = 1;
p_session_data->must_terminate_dialog = 0; /*irrelevent for reg session data
this will always be 0 */
+ p_session_data->session_has_been_opened = 0; /*0 has not been opened 1 has been
opened*/
+
char* p = (char*)(p_session_data + 1);
p_session_data->domain.s = p;
memcpy(p, domain->s, domain->len);
diff --git a/modules/ims_qos/rx_authdata.h b/modules/ims_qos/rx_authdata.h
index 3332997..2264664 100644
--- a/modules/ims_qos/rx_authdata.h
+++ b/modules/ims_qos/rx_authdata.h
@@ -84,6 +84,7 @@ typedef struct rx_authsessiondata {
int ip_version;
//for registration session
int subscribed_to_signaling_path_status; // 0 not subscribed 1 is subscribed
+ int session_has_been_opened; // 0 has not been opened 1 has been opened
str domain; //the domain the registration aor belongs to (for registration)
str registration_aor; //the aor if this rx session is a subscription to signalling
status
int must_terminate_dialog; //0 means when this session terminates it must not
terminate the relevant dialog, 1 means it must terminate the dialog