Quellcode durchsuchen

ims_charging: Properly check final_unit_action-flag for initial requests

If final_unit_action flag is set in initial ccr response, kamailio need to send terminate request after the granted time instead of sending an CCR-UPDATE request.

Patch by DileepNunna <[email protected]>

Closes Github #467 (Kamailio sending update ccr request instead of terminate request for initial ccr response having final_unit_action flag)
Carsten Bock vor 9 Jahren
Ursprung
Commit
581912f5ed

+ 4 - 0
modules/ims_charging/ims_ro.c

@@ -1255,6 +1255,10 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
     ssd->ro_session->event_type = pending;
     ssd->ro_session->event_type = pending;
     ssd->ro_session->reserved_secs = ro_cca_data->mscc->granted_service_unit->cc_time;
     ssd->ro_session->reserved_secs = ro_cca_data->mscc->granted_service_unit->cc_time;
     ssd->ro_session->valid_for = ro_cca_data->mscc->validity_time;
     ssd->ro_session->valid_for = ro_cca_data->mscc->validity_time;
+    ssd->ro_session->is_final_allocation = 0;
+
+    if (ro_cca_data->mscc->final_unit_action && (ro_cca_data->mscc->final_unit_action->action == 0))
+        ssd->ro_session->is_final_allocation = 1;
 
 
     Ro_free_CCA(ro_cca_data);
     Ro_free_CCA(ro_cca_data);
 
 

+ 1 - 0
modules/ims_charging/ro_session_hash.h

@@ -71,6 +71,7 @@ struct ro_session {
     str mac;
     str mac;
     int rating_group;
     int rating_group;
     int service_identifier;
     int service_identifier;
+    unsigned int is_final_allocation;
 };
 };
 
 
 /*! entries in the main ro_session table */
 /*! entries in the main ro_session table */

+ 13 - 0
modules/ims_charging/ro_timer.c

@@ -400,6 +400,19 @@ void ro_session_ontimeout(struct ro_tl *tl) {
     //		return;
     //		return;
     //	}
     //	}
 
 
+
+    if(ro_session->is_final_allocation) {
+        now = get_current_time_micro();
+        used_secs = now - ro_session->last_event_timestamp;
+        if((ro_session->reserved_secs - used_secs) > 0) {
+            update_ro_timer(&ro_session->ro_tl, (ro_session->reserved_secs - used_secs));
+            return;
+        }
+        else {
+            ro_session->event_type = no_more_credit;
+        }
+    }
+
     switch (ro_session->event_type) {
     switch (ro_session->event_type) {
         case answered:
         case answered:
             now = get_current_time_micro();
             now = get_current_time_micro();