Diameter - setting correct result code based on maxusage

65 views
Skip to first unread message

Anthony Somerset

unread,
Jan 11, 2019, 2:07:20 AM1/11/19
to CGRateS
Hi There

i am attempting to return the correct result code (and granted service units too) based on the max usage, below is my current attempts at making it work:

        "request_processors": [
           {
               "id": "VoiceInit",
               "filters": ["*string:*vars.*cmd:CCR", "*string:*req.CC-Request-Type:1"],
               "flags": ["*initiate", "*accounts", "*attributes", "*log"],
               "request_fields":[
                   {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
                   {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.Service-Information.IMS-Information.User-Session-Id", "mandatory": true},
                   {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", "value": "~*req.Origin-Host", "mandatory": true},
                   {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"},
                   {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
                   {"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
                   {"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
                   {"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.Service-Information.IMS-Information.Called-Party-Address:s/^tel:(.*)/$1/", "mandatory": true},
                   {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
                   {"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.Multiple-Services-Credit-Control.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
                   {"tag": "SubscriberID", "field_id": "SubscriberId", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
               ],
               "reply_fields":[
                   {"tag": "SessionId", "field_id": "Session-Id", "type": "*composed",
                        "value": "~*req.Session-Id", "mandatory": true},
                   {"tag": "ResultCode",  "filters": ["*rsr::~*cgrep.Error(!^$)"],
                        "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
                   {"tag": "ResultCode",  "filters": ["*gt:*cgrep.MaxUsage{*duration_seconds}:0"],
                        "field_id": "Result-Code", "type": "*constant", "value": "2001"},
                   {"tag": "ResultCode",  "filters": ["*lte:*cgrep.MaxUsage{*duration_seconds}:0"],
                        "field_id": "Result-Code", "type": "*constant", "value": "5031"},
                   {"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed",
                        "value": "~*vars.OriginHost", "mandatory": true},
                   {"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed",
                        "value": "~*vars.OriginRealm", "mandatory": true},
                   {"tag": "AuthApplicationId", "field_id": "Auth-Application-Id", "type": "*composed",
                       "value": "~*vars.*appid", "mandatory": true},
                   {"tag": "CCRequestType", "field_id": "CC-Request-Type", "type": "*composed",
                        "value": "~*req.CC-Request-Type", "mandatory": true},
                   {"tag": "CCRequestNumber", "field_id": "CC-Request-Number", "type": "*composed",
                        "value": "~*req.CC-Request-Number", "mandatory": true},
                   {"tag": "GrantedUnits", "field_id": "Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Time", "type": "*constant",
                        "value": "30"},
                   {"tag": "GrantedUnits", "filters": ["*gte:*cgrep.MaxUsage{*duration_seconds}:0","*string:~*vars.RequestType:*prepaid"], "field_id": "Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Time", "type": "*composed",
                        "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},      
                    {"tag": "ServiceId",    "field_id": "Multiple-Services-Credit-Control.Service-Identifier", "type": "*constant",
                        "value": "0"},
                   {"tag": "RatingGroup",  "field_id": "Multiple-Services-Credit-Control.Rating-Group", "type": "*constant",
                        "value": "0"},              
               ],
           },

unfortunately the *lte and *gt seem to be not having any match ever - have i referenced the MaxUsage incorrectly or something here?


Teofil Voivozeanu

unread,
Jan 11, 2019, 2:40:46 AM1/11/19
to CGRateS
Hi Anthony,

When you compare max usage in the filter you shouldn't use the converter, just *gte:*cgrep.MaxUsage:0 

Thanks,
TeoV

Anthony Somerset

unread,
Jan 11, 2019, 3:03:24 AM1/11/19
to CGRateS
thanks, when i tried that i was getting incomparable errors:

what i finally got working was something like this:

                    {"tag": "ResultCode",  "filters": ["*gt:*cgrep.MaxUsage:0s"],
                        "field_id": "Result-Code", "type": "*constant", "value": "2001"},
                   {"tag": "ResultCode",  "filters": ["*lte:*cgrep.MaxUsage:0s"],
                        "field_id": "Result-Code", "type": "*constant", "value": "5031"},

same for setting the CC-Time field too

when i get chance i will submit a PR to update the voice example here: https://github.com/cgrates/cgrates/blob/master/data/conf/samples/diamagent/voice.json
Reply all
Reply to author
Forward
0 new messages