From e1cf97802618c935ddd9ed80353cac39e4def8f4 Mon Sep 17 00:00:00 2001 From: TeoV Date: Fri, 10 Jul 2020 11:52:01 +0300 Subject: [PATCH 1/2] Rename from ResourceMessage to ResourceAllocation --- apier/v1/sessions_process_event_it_test.go | 8 ++++---- packages/debian/changelog | 1 + sessions/sessions.go | 24 +++++++++++----------- sessions/sessions_test.go | 4 ++-- utils/consts.go | 1 - 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apier/v1/sessions_process_event_it_test.go b/apier/v1/sessions_process_event_it_test.go index 89aeaca21..4e64bd6a3 100644 --- a/apier/v1/sessions_process_event_it_test.go +++ b/apier/v1/sessions_process_event_it_test.go @@ -175,8 +175,8 @@ func testSSv1ItProcessEventAuth(t *testing.T) { if rply.MaxUsage != authUsage { t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) } - if *rply.ResourceMessage == utils.EmptyString { - t.Errorf("Unexpected ResourceMessage: %s", *rply.ResourceMessage) + if *rply.ResourceAllocation == utils.EmptyString { + t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation) } eSplrs := &engine.SortedSuppliers{ ProfileID: "SPL_ACNT_1001", @@ -259,8 +259,8 @@ func testSSv1ItProcessEventInitiateSession(t *testing.T) { if rply.MaxUsage != initUsage { t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) } - if *rply.ResourceMessage != "RES_ACNT_1001" { - t.Errorf("Unexpected ResourceMessage: %s", *rply.ResourceMessage) + if *rply.ResourceAllocation != "RES_ACNT_1001" { + t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation) } eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, diff --git a/packages/debian/changelog b/packages/debian/changelog index 9f5deade1..bfcf39c2e 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -10,6 +10,7 @@ cgrates (0.10.2~dev) UNRELEASED; urgency=medium * [SessionS] Use correctly SessionTTLUsage when calculate end usage in case of terminate session from ttl mechanism * [RSRParsers] Removed attribute sistem from RSRParser * [RSRParsers] Added grave accent(`) char as a delimiter to not split tge RSR value + * [SessionS] Rename from ResourceMessage to ResourceAllocation -- DanB Tue, 12 May 2020 13:08:15 +0300 diff --git a/sessions/sessions.go b/sessions/sessions.go index ccf7c4aee..80fe24917 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -2932,13 +2932,13 @@ type V1ProcessEventArgs struct { // V1ProcessEventReply is the reply for the ProcessEvent API type V1ProcessEventReply struct { - MaxUsage time.Duration - ResourceMessage *string - Attributes *engine.AttrSProcessEventReply - Suppliers *engine.SortedSuppliers - ThresholdIDs *[]string - StatQueueIDs *[]string - getMaxUsage bool + MaxUsage time.Duration + ResourceAllocation *string + Attributes *engine.AttrSProcessEventReply + Suppliers *engine.SortedSuppliers + ThresholdIDs *[]string + StatQueueIDs *[]string + getMaxUsage bool } // SetMaxUsageNeeded used by agent that use the reply as NavigableMapper @@ -2956,8 +2956,8 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap() utils.NavigableMap2 { if v1Rply.getMaxUsage { cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage) } - if v1Rply.ResourceMessage != nil { - cgrReply[utils.CapResourceMessage] = utils.NewNMData(*v1Rply.ResourceMessage) + if v1Rply.ResourceAllocation != nil { + cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation) } if v1Rply.Attributes != nil { attrs := make(utils.NavigableMap2) @@ -3071,21 +3071,21 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.ClientConnector, attrRU, &resMessage); err != nil { return utils.NewErrResourceS(err) } - rply.ResourceMessage = &resMessage + rply.ResourceAllocation = &resMessage } if resourceFlagsWithParams.HasKey(utils.MetaAllocate) { if err = sS.connMgr.Call(sS.cgrCfg.SessionSCfg().ResSConns, nil, utils.ResourceSv1AllocateResources, attrRU, &resMessage); err != nil { return utils.NewErrResourceS(err) } - rply.ResourceMessage = &resMessage + rply.ResourceAllocation = &resMessage } if resourceFlagsWithParams.HasKey(utils.MetaRelease) { if err = sS.connMgr.Call(sS.cgrCfg.SessionSCfg().ResSConns, nil, utils.ResourceSv1ReleaseResources, attrRU, &resMessage); err != nil { return utils.NewErrResourceS(err) } - rply.ResourceMessage = &resMessage + rply.ResourceAllocation = &resMessage } } } diff --git a/sessions/sessions_test.go b/sessions/sessions_test.go index 3402a2971..b4243e4e7 100644 --- a/sessions/sessions_test.go +++ b/sessions/sessions_test.go @@ -1336,8 +1336,8 @@ func TestV1ProcessEventReplyAsNavigableMap(t *testing.T) { t.Errorf("Expecting \n%+v\n, received: \n%+v", expected, rply) } //resource message check - v1per.ResourceMessage = utils.StringPointer("Resource") - expected[utils.CapResourceMessage] = utils.NewNMData("Resource") + v1per.ResourceAllocation = utils.StringPointer("Resource") + expected[utils.CapResourceAllocation] = utils.NewNMData("Resource") if rply := v1per.AsNavigableMap(); !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting \n%+v\n, received: \n%+v", expected, rply) } diff --git a/utils/consts.go b/utils/consts.go index 476390b6f..3972ba9f3 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -807,7 +807,6 @@ const ( MetaDurationSeconds = "*duration_seconds" MetaDurationNanoseconds = "*duration_nanoseconds" CapAttributes = "Attributes" - CapResourceMessage = "ResourceMessage" CapResourceAllocation = "ResourceAllocation" CapMaxUsage = "MaxUsage" CapSuppliers = "Suppliers" From 115a9a1b7cb8d935b768947ddf30ab8e1b3e3e38 Mon Sep 17 00:00:00 2001 From: TeoV Date: Fri, 10 Jul 2020 15:25:09 +0300 Subject: [PATCH 2/2] Correctly populate max usage from Agents SessionSv1.ProcessEvent + added test --- agents/diam_it_test.go | 89 +++++++++++++++++ agents/diamagent.go | 5 +- agents/dnsagent.go | 5 +- agents/httpagent.go | 5 +- agents/radagent.go | 5 +- .../samples/diamagent_internal/voice.json | 99 +++++++++++++++++++ data/conf/samples/diamagent_mongo/voice.json | 99 +++++++++++++++++++ data/conf/samples/diamagent_mysql/voice.json | 99 +++++++++++++++++++ .../samples/diamsctpagent_internal/voice.json | 99 +++++++++++++++++++ .../samples/diamsctpagent_mongo/voice.json | 99 +++++++++++++++++++ .../samples/diamsctpagent_mysql/voice.json | 99 +++++++++++++++++++ .../samples/dispatchers/diamagent/voice.json | 99 +++++++++++++++++++ packages/debian/changelog | 1 + 13 files changed, 791 insertions(+), 12 deletions(-) diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index e2199d57e..d140ac761 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -57,6 +57,7 @@ var ( testDiamItApierRpcConn, testDiamItTPFromFolder, testDiamItDryRun, + testDiamItCCRAuth, testDiamItCCRInit, testDiamItCCRInitWithForceDuration, testDiamItCCRUpdate, @@ -551,6 +552,94 @@ func testDiamItDryRunMaxConn(t *testing.T) { } } +func testDiamItCCRAuth(t *testing.T) { + m := diam.NewRequest(diam.CreditControl, 4, nil) + m.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("bb97be2b9f37c2be9614fff71c8b1d08b1acbff8")) + m.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("192.168.1.1")) + m.NewAVP(avp.OriginRealm, avp.Mbit, 0, datatype.DiameterIdentity("cgrates.org")) + m.NewAVP(avp.AuthApplicationID, avp.Mbit, 0, datatype.Unsigned32(4)) + m.NewAVP(avp.CCRequestType, avp.Mbit, 0, datatype.Enumerated(1)) + m.NewAVP(avp.CCRequestNumber, avp.Mbit, 0, datatype.Unsigned32(0)) + m.NewAVP(avp.DestinationHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA")) + m.NewAVP(avp.DestinationRealm, avp.Mbit, 0, datatype.DiameterIdentity("cgrates.org")) + m.NewAVP(avp.ServiceContextID, avp.Mbit, 0, datatype.UTF8String("EventVoice@DiamItCCRAuth")) + m.NewAVP(avp.EventTimestamp, avp.Mbit, 0, datatype.Time(time.Date(2018, 10, 4, 14, 42, 20, 0, time.UTC))) + m.NewAVP(avp.SubscriptionID, avp.Mbit, 0, &diam.GroupedAVP{ + AVP: []*diam.AVP{ + diam.NewAVP(450, avp.Mbit, 0, datatype.Enumerated(0)), // Subscription-Id-Type + diam.NewAVP(444, avp.Mbit, 0, datatype.UTF8String("1006")), // Subscription-Id-Data + }}) + m.NewAVP(avp.ServiceIdentifier, avp.Mbit, 0, datatype.Unsigned32(0)) + m.NewAVP(avp.RequestedServiceUnit, avp.Mbit, 0, &diam.GroupedAVP{ + AVP: []*diam.AVP{ + diam.NewAVP(420, avp.Mbit, 0, datatype.Unsigned32(300))}}) + m.NewAVP(avp.UsedServiceUnit, avp.Mbit, 0, &diam.GroupedAVP{ + AVP: []*diam.AVP{ + diam.NewAVP(420, avp.Mbit, 0, datatype.Unsigned32(0))}}) + m.NewAVP(873, avp.Mbit, 10415, &diam.GroupedAVP{ + AVP: []*diam.AVP{ + diam.NewAVP(20300, avp.Mbit, 2011, &diam.GroupedAVP{ // IN-Information + AVP: []*diam.AVP{ + diam.NewAVP(831, avp.Mbit, 10415, datatype.UTF8String("1006")), // Calling-Party-Address + diam.NewAVP(832, avp.Mbit, 10415, datatype.UTF8String("1002")), // Called-Party-Address + diam.NewAVP(20327, avp.Mbit, 2011, datatype.UTF8String("1002")), // Real-Called-Number + diam.NewAVP(20339, avp.Mbit, 2011, datatype.Unsigned32(0)), // Charge-Flow-Type + diam.NewAVP(20302, avp.Mbit, 2011, datatype.UTF8String("")), // Calling-Vlr-Number + diam.NewAVP(20303, avp.Mbit, 2011, datatype.UTF8String("")), // Calling-CellID-Or-SAI + diam.NewAVP(20313, avp.Mbit, 2011, datatype.OctetString("")), // Bearer-Capability + diam.NewAVP(20321, avp.Mbit, 2011, datatype.UTF8String("bb97be2b9f37c2be9614fff71c8b1d08b1acbff8")), // Call-Reference-Number + diam.NewAVP(20322, avp.Mbit, 2011, datatype.UTF8String("")), // MSC-Address + diam.NewAVP(20324, avp.Mbit, 2011, datatype.Unsigned32(0)), // Time-Zone + diam.NewAVP(20385, avp.Mbit, 2011, datatype.UTF8String("")), // Called-Party-NP + diam.NewAVP(20386, avp.Mbit, 2011, datatype.UTF8String("")), // SSP-Time + }, + }), + }}) + // ============================================ + // prevent nil pointer dereference + // ============================================ + if diamClnt == nil { + t.Fatal("Diameter client should not be nil") + } + if diamClnt.conn == nil { + t.Fatal("Diameter connection should not be nil") + } + if m == nil { + t.Fatal("The mesage to diameter should not be nil") + } + // ============================================ + if err := diamClnt.SendMessage(m); err != nil { + t.Error(err) + } + msg := diamClnt.ReceivedMessage(rplyTimeout) + if msg == nil { + t.Fatal("No message returned") + } + // Result-Code + eVal := "2001" + if avps, err := msg.FindAVPsWithPath([]interface{}{"Result-Code"}, dict.UndefinedVendorID); err != nil { + t.Error(err) + } else if len(avps) == 0 { + t.Error("Missing AVP") + } else if val, err := diamAVPAsString(avps[0]); err != nil { + t.Error(err) + } else if val != eVal { + t.Errorf("expecting: %s, received: <%s>", eVal, val) + } + // Result-Code + eVal = "300" // 5 mins of session + if avps, err := msg.FindAVPsWithPath([]interface{}{"Granted-Service-Unit", "CC-Time"}, + dict.UndefinedVendorID); err != nil { + t.Error(err) + } else if len(avps) == 0 { + t.Error("Missing AVP") + } else if val, err := diamAVPAsString(avps[0]); err != nil { + t.Error(err) + } else if val != eVal { + t.Errorf("expecting: %s, received: <%s>", eVal, val) + } +} + func testDiamItCCRInit(t *testing.T) { m := diam.NewRequest(diam.CreditControl, 4, nil) m.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("bb97be2b9f37c2be9614fff71c8b1d08b1acbff8")) diff --git a/agents/diamagent.go b/agents/diamagent.go index 1c077d684..758612dc5 100644 --- a/agents/diamagent.go +++ b/agents/diamagent.go @@ -388,9 +388,8 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, ArgDispatcher: cgrArgs.ArgDispatcher, Paginator: *cgrArgs.SupplierPaginator, } - needMaxUsage := reqProcessor.Flags.HasKey(utils.MetaAuth) || - reqProcessor.Flags.HasKey(utils.MetaInit) || - reqProcessor.Flags.HasKey(utils.MetaUpdate) + needMaxUsage := utils.IsSliceMember([]string{utils.MetaAuthorize, utils.MetaInitiate, utils.MetaUpdate}, + reqProcessor.Flags.ParamsSlice(utils.MetaRALs)[0]) rply := new(sessions.V1ProcessEventReply) err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1ProcessEvent, evArgs, rply) diff --git a/agents/dnsagent.go b/agents/dnsagent.go index c480b2fbd..a5ffa9b8e 100644 --- a/agents/dnsagent.go +++ b/agents/dnsagent.go @@ -314,9 +314,8 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, ArgDispatcher: cgrArgs.ArgDispatcher, Paginator: *cgrArgs.SupplierPaginator, } - needMaxUsage := reqProcessor.Flags.HasKey(utils.MetaAuth) || - reqProcessor.Flags.HasKey(utils.MetaInit) || - reqProcessor.Flags.HasKey(utils.MetaUpdate) + needMaxUsage := utils.IsSliceMember([]string{utils.MetaAuthorize, utils.MetaInitiate, utils.MetaUpdate}, + reqProcessor.Flags.ParamsSlice(utils.MetaRALs)[0]) rply := new(sessions.V1ProcessEventReply) err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessEvent, diff --git a/agents/httpagent.go b/agents/httpagent.go index c5fd75e52..72b9f1718 100644 --- a/agents/httpagent.go +++ b/agents/httpagent.go @@ -244,9 +244,8 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, ArgDispatcher: cgrArgs.ArgDispatcher, Paginator: *cgrArgs.SupplierPaginator, } - needMaxUsage := reqProcessor.Flags.HasKey(utils.MetaAuth) || - reqProcessor.Flags.HasKey(utils.MetaInit) || - reqProcessor.Flags.HasKey(utils.MetaUpdate) + needMaxUsage := utils.IsSliceMember([]string{utils.MetaAuthorize, utils.MetaInitiate, utils.MetaUpdate}, + reqProcessor.Flags.ParamsSlice(utils.MetaRALs)[0]) rply := new(sessions.V1ProcessEventReply) err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1ProcessEvent, evArgs, rply) diff --git a/agents/radagent.go b/agents/radagent.go index 8b9a4e46a..42d4c2810 100644 --- a/agents/radagent.go +++ b/agents/radagent.go @@ -284,9 +284,8 @@ func (ra *RadiusAgent) processRequest(reqProcessor *config.RequestProcessor, ArgDispatcher: cgrArgs.ArgDispatcher, Paginator: *cgrArgs.SupplierPaginator, } - needMaxUsage := reqProcessor.Flags.HasKey(utils.MetaAuth) || - reqProcessor.Flags.HasKey(utils.MetaInit) || - reqProcessor.Flags.HasKey(utils.MetaUpdate) + needMaxUsage := utils.IsSliceMember([]string{utils.MetaAuthorize, utils.MetaInitiate, utils.MetaUpdate}, + reqProcessor.Flags.ParamsSlice(utils.MetaRALs)[0]) rply := new(sessions.V1ProcessEventReply) err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessEvent, evArgs, rply) diff --git a/data/conf/samples/diamagent_internal/voice.json b/data/conf/samples/diamagent_internal/voice.json index 91de9c026..3b1f0d6d0 100644 --- a/data/conf/samples/diamagent_internal/voice.json +++ b/data/conf/samples/diamagent_internal/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInitForceDuration", "filters": [ diff --git a/data/conf/samples/diamagent_mongo/voice.json b/data/conf/samples/diamagent_mongo/voice.json index 91de9c026..3b1f0d6d0 100644 --- a/data/conf/samples/diamagent_mongo/voice.json +++ b/data/conf/samples/diamagent_mongo/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInitForceDuration", "filters": [ diff --git a/data/conf/samples/diamagent_mysql/voice.json b/data/conf/samples/diamagent_mysql/voice.json index 91de9c026..8d9fef127 100644 --- a/data/conf/samples/diamagent_mysql/voice.json +++ b/data/conf/samples/diamagent_mysql/voice.json @@ -102,6 +102,105 @@ }, ], }, + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": [ diff --git a/data/conf/samples/diamsctpagent_internal/voice.json b/data/conf/samples/diamsctpagent_internal/voice.json index 76656c74b..400d32aac 100755 --- a/data/conf/samples/diamsctpagent_internal/voice.json +++ b/data/conf/samples/diamsctpagent_internal/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/diamsctpagent_mongo/voice.json b/data/conf/samples/diamsctpagent_mongo/voice.json index 76656c74b..400d32aac 100755 --- a/data/conf/samples/diamsctpagent_mongo/voice.json +++ b/data/conf/samples/diamsctpagent_mongo/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/diamsctpagent_mysql/voice.json b/data/conf/samples/diamsctpagent_mysql/voice.json index 76656c74b..400d32aac 100755 --- a/data/conf/samples/diamsctpagent_mysql/voice.json +++ b/data/conf/samples/diamsctpagent_mysql/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/dispatchers/diamagent/voice.json b/data/conf/samples/dispatchers/diamagent/voice.json index bffbe9fbf..bbd070ee2 100644 --- a/data/conf/samples/dispatchers/diamagent/voice.json +++ b/data/conf/samples/dispatchers/diamagent/voice.json @@ -3,6 +3,105 @@ "diameter_agent": { "request_processors": [ + { + "id": "VoiceEventAuth", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*string:~*req.Service-Context-Id:EventVoice@DiamItCCRAuth" + ], + "flags": ["*event", "*rals:*authorize", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/packages/debian/changelog b/packages/debian/changelog index bfcf39c2e..8cfcd688f 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -11,6 +11,7 @@ cgrates (0.10.2~dev) UNRELEASED; urgency=medium * [RSRParsers] Removed attribute sistem from RSRParser * [RSRParsers] Added grave accent(`) char as a delimiter to not split tge RSR value * [SessionS] Rename from ResourceMessage to ResourceAllocation + * [AgentS] Correctly verify flags for setting max usage in ProcessEvent -- DanB Tue, 12 May 2020 13:08:15 +0300