From ae596cccbcb89c9d66a6878421fd672201856f09 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Fri, 10 Sep 2021 16:12:12 +0300 Subject: [PATCH] cgrates: make MaxUsage optional for InitiateSession reply In newer versions of CGRateS, MaxUsage is no longer returned - this means that the session should be allowed without any duration limitation. --- modules/cgrates/cgrates_acc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/cgrates/cgrates_acc.c b/modules/cgrates/cgrates_acc.c index 8c0ba7da776..a1398c0d6ab 100644 --- a/modules/cgrates/cgrates_acc.c +++ b/modules/cgrates/cgrates_acc.c @@ -244,9 +244,10 @@ static int cgr_proc_start_acc_reply(struct cgr_conn *c, json_object *jobj, } /* we are only interested in the MaxUsage token */ if (!json_object_object_get_ex(jorig, "MaxUsage", &jobj)) { - LM_ERR("CGRateS did not return an MaxUsage in InitiateSession reply: %d %s\n", - json_object_get_type(jorig), json_object_to_json_string(jorig)); - return -4; + LM_DBG("CGRateS did not return an MaxUsage in InitiateSession reply: %d %s" + "- allow unlimited!\n", json_object_get_type(jorig), + json_object_to_json_string(jorig)); + return 1; } if (json_object_get_type(jobj) != json_type_int) { LM_ERR("CGRateS returned a non-int type for MaxUsage InitiateSession reply: %d %s\n", @@ -258,6 +259,10 @@ static int cgr_proc_start_acc_reply(struct cgr_conn *c, json_object *jobj, val.n = timeout / 1000000000; else val.n = timeout; + } else if (!jobj) { + LM_DBG("CGRateS did not return an MaxUsage in InitiateSession reply " + "- allow unlimited!\n"); + return 1; } else { if (json_object_get_type(jobj) != json_type_int) { LM_ERR("CGRateS returned a non-int type for InitiateSession reply: %d %s\n",