From 3074d017975cc4baefaa1500092b712e63ffbdb0 Mon Sep 17 00:00:00 2001 From: adragusin Date: Tue, 21 Jan 2020 17:54:43 +0200 Subject: [PATCH] updated IT tests in agents --- agents/diam_it_test.go | 53 +++++- agents/httpagent_it_test.go | 67 ++++--- agents/radagent_it_test.go | 21 ++- cmd/cgr-engine/cgr-engine.go | 10 +- .../samples/diamagent_internal/cgrates.json | 66 +++++++ .../data.json | 0 .../dryrun.json | 0 .../message.json | 0 .../simpa.json | 0 .../tests.json | 0 .../voice.json | 0 .../cgrates.json | 0 data/conf/samples/diamagent_mongo/data.json | 125 +++++++++++++ .../dryrun.json | 0 .../message.json | 0 data/conf/samples/diamagent_mongo/simpa.json | 28 +++ data/conf/samples/diamagent_mongo/tests.json | 46 +++++ .../voice.json | 0 .../conf/samples/diamagent_mysql/cgrates.json | 67 +++++++ data/conf/samples/diamagent_mysql/data.json | 125 +++++++++++++ data/conf/samples/diamagent_mysql/dryrun.json | 74 ++++++++ .../conf/samples/diamagent_mysql/message.json | 37 ++++ data/conf/samples/diamagent_mysql/simpa.json | 28 +++ data/conf/samples/diamagent_mysql/tests.json | 46 +++++ data/conf/samples/diamagent_mysql/voice.json | 103 +++++++++++ .../diamagentmaxconn_internal/cgrates.json | 77 ++++++++ .../cgrates.json | 0 .../diamagentmaxconn_mysql/cgrates.json | 77 ++++++++ .../diamsctpagent_internal/cgrates.json | 69 +++++++ .../data.json | 0 .../diamsctpagent_internal/dryrun.json | 74 ++++++++ .../diamsctpagent_internal/message.json | 37 ++++ .../simpa.json | 0 .../samples/diamsctpagent_internal/voice.json | 103 +++++++++++ .../cgrates.json | 0 .../samples/diamsctpagent_mongo/data.json | 125 +++++++++++++ .../samples/diamsctpagent_mongo/dryrun.json | 74 ++++++++ .../samples/diamsctpagent_mongo/message.json | 37 ++++ .../samples/diamsctpagent_mongo/simpa.json | 28 +++ .../samples/diamsctpagent_mongo/voice.json | 103 +++++++++++ .../samples/diamsctpagent_mysql/cgrates.json | 69 +++++++ .../samples/diamsctpagent_mysql/data.json | 125 +++++++++++++ .../samples/diamsctpagent_mysql/dryrun.json | 74 ++++++++ .../samples/diamsctpagent_mysql/message.json | 37 ++++ .../samples/diamsctpagent_mysql/simpa.json | 28 +++ .../samples/diamsctpagent_mysql/voice.json | 103 +++++++++++ .../samples/radagent_internal/cgrates.json | 160 +++++++++++++++++ .../radagent_internal_gob/cgrates.json | 168 ++++++++++++++++++ .../{radagent => radagent_mongo}/cgrates.json | 0 .../cgrates.json | 0 data/conf/samples/radagent_mysql/cgrates.json | 159 +++++++++++++++++ .../samples/radagent_mysql_gob/cgrates.json | 166 +++++++++++++++++ integration_test.sh | 17 +- 53 files changed, 2761 insertions(+), 45 deletions(-) create mode 100644 data/conf/samples/diamagent_internal/cgrates.json rename data/conf/samples/{diamagent => diamagent_internal}/data.json (100%) rename data/conf/samples/{diamagent => diamagent_internal}/dryrun.json (100%) rename data/conf/samples/{diamagent => diamagent_internal}/message.json (100%) rename data/conf/samples/{diamagent => diamagent_internal}/simpa.json (100%) rename data/conf/samples/{diamagent => diamagent_internal}/tests.json (100%) rename data/conf/samples/{diamagent => diamagent_internal}/voice.json (100%) rename data/conf/samples/{diamagent => diamagent_mongo}/cgrates.json (100%) create mode 100644 data/conf/samples/diamagent_mongo/data.json rename data/conf/samples/{diamsctpagent => diamagent_mongo}/dryrun.json (100%) mode change 100755 => 100644 rename data/conf/samples/{diamsctpagent => diamagent_mongo}/message.json (100%) mode change 100755 => 100644 create mode 100644 data/conf/samples/diamagent_mongo/simpa.json create mode 100644 data/conf/samples/diamagent_mongo/tests.json rename data/conf/samples/{diamsctpagent => diamagent_mongo}/voice.json (100%) mode change 100755 => 100644 create mode 100644 data/conf/samples/diamagent_mysql/cgrates.json create mode 100644 data/conf/samples/diamagent_mysql/data.json create mode 100644 data/conf/samples/diamagent_mysql/dryrun.json create mode 100644 data/conf/samples/diamagent_mysql/message.json create mode 100644 data/conf/samples/diamagent_mysql/simpa.json create mode 100644 data/conf/samples/diamagent_mysql/tests.json create mode 100644 data/conf/samples/diamagent_mysql/voice.json create mode 100755 data/conf/samples/diamagentmaxconn_internal/cgrates.json rename data/conf/samples/{diamagentmaxconn => diamagentmaxconn_mongo}/cgrates.json (100%) create mode 100755 data/conf/samples/diamagentmaxconn_mysql/cgrates.json create mode 100755 data/conf/samples/diamsctpagent_internal/cgrates.json rename data/conf/samples/{diamsctpagent => diamsctpagent_internal}/data.json (100%) create mode 100755 data/conf/samples/diamsctpagent_internal/dryrun.json create mode 100755 data/conf/samples/diamsctpagent_internal/message.json rename data/conf/samples/{diamsctpagent => diamsctpagent_internal}/simpa.json (100%) create mode 100755 data/conf/samples/diamsctpagent_internal/voice.json rename data/conf/samples/{diamsctpagent => diamsctpagent_mongo}/cgrates.json (100%) create mode 100755 data/conf/samples/diamsctpagent_mongo/data.json create mode 100755 data/conf/samples/diamsctpagent_mongo/dryrun.json create mode 100755 data/conf/samples/diamsctpagent_mongo/message.json create mode 100755 data/conf/samples/diamsctpagent_mongo/simpa.json create mode 100755 data/conf/samples/diamsctpagent_mongo/voice.json create mode 100755 data/conf/samples/diamsctpagent_mysql/cgrates.json create mode 100755 data/conf/samples/diamsctpagent_mysql/data.json create mode 100755 data/conf/samples/diamsctpagent_mysql/dryrun.json create mode 100755 data/conf/samples/diamsctpagent_mysql/message.json create mode 100755 data/conf/samples/diamsctpagent_mysql/simpa.json create mode 100755 data/conf/samples/diamsctpagent_mysql/voice.json create mode 100644 data/conf/samples/radagent_internal/cgrates.json create mode 100644 data/conf/samples/radagent_internal_gob/cgrates.json rename data/conf/samples/{radagent => radagent_mongo}/cgrates.json (100%) rename data/conf/samples/{radagent_gob => radagent_mongo_gob}/cgrates.json (100%) create mode 100644 data/conf/samples/radagent_mysql/cgrates.json create mode 100644 data/conf/samples/radagent_mysql_gob/cgrates.json diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index 3eff867f3..e594647ed 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -68,7 +68,18 @@ var ( // Test start here func TestDiamItTcp(t *testing.T) { engine.KillEngine(0) - diamConfigDIR = "diamagent" + switch *dbType { + case utils.MetaInternal: + diamConfigDIR = "diamagent_internal" + case utils.MetaSQL: + diamConfigDIR = "diamagent_mysql" + case utils.MetaMongo: + diamConfigDIR = "diamagent_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } for _, stest := range sTestsDiam { t.Run(diamConfigDIR, stest) } @@ -93,7 +104,18 @@ func TestDiamItDispatcher(t *testing.T) { func TestDiamItSctp(t *testing.T) { engine.KillEngine(0) - diamConfigDIR = "diamsctpagent" + switch *dbType { + case utils.MetaInternal: + diamConfigDIR = "diamsctpagent_internal" + case utils.MetaSQL: + diamConfigDIR = "diamsctpagent_mysql" + case utils.MetaMongo: + diamConfigDIR = "diamsctpagent_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } for _, stest := range sTestsDiam { t.Run(diamConfigDIR, stest) } @@ -101,7 +123,18 @@ func TestDiamItSctp(t *testing.T) { func TestDiamItMaxConn(t *testing.T) { engine.KillEngine(0) - diamConfigDIR = "diamagentmaxconn" + switch *dbType { + case utils.MetaInternal: + diamConfigDIR = "diamagentmaxconn_internal" + case utils.MetaSQL: + diamConfigDIR = "diamagentmaxconn_mysql" + case utils.MetaMongo: + diamConfigDIR = "diamagentmaxconn_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } for _, stest := range sTestsDiam[:7] { t.Run(diamConfigDIR, stest) } @@ -111,7 +144,19 @@ func TestDiamItMaxConn(t *testing.T) { func TestDiamItSessionDisconnect(t *testing.T) { engine.KillEngine(0) - diamConfigDIR = "diamagent" + switch *dbType { + case utils.MetaInternal: + diamConfigDIR = "diamagent_internal" + case utils.MetaSQL: + diamConfigDIR = "diamagent_mysql" + case utils.MetaMongo: + diamConfigDIR = "diamagent_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + for _, stest := range sTestsDiam[:7] { t.Run(diamConfigDIR, stest) } diff --git a/agents/httpagent_it_test.go b/agents/httpagent_it_test.go index 2d037696f..281bcf4b4 100644 --- a/agents/httpagent_it_test.go +++ b/agents/httpagent_it_test.go @@ -46,54 +46,65 @@ var ( httpC *http.Client // so we can cache the connection err error isTls bool + + sTestsHA = []func(t *testing.T){ + testHAitInitCfg, + testHAitHttp, + testHAitResetDB, + testHAitStartEngine, + testHAitApierRpcConn, + testHAitTPFromFolder, + testHAitAuthDryRun, + testHAitAuth1001, + testHAitCDRmtcall, + testHAitCDRmtcall2, + testHAitTextPlain, + testHAitStopEngine, + } ) -var sTestsHA = []func(t *testing.T){ - testHAitInitCfg, - testHAitHttp, - testHAitResetDB, - testHAitStartEngine, - testHAitApierRpcConn, - testHAitTPFromFolder, - testHAitAuthDryRun, - testHAitAuth1001, - testHAitCDRmtcall, - testHAitCDRmtcall2, - testHAitTextPlain, - testHAitStopEngine, -} - func TestHAit(t *testing.T) { - var configDir, configDirTls string switch *dbType { case utils.MetaInternal: - configDir = "httpagent_internal" - configDirTls = "httpagenttls_internal" + haCfgDIR = "httpagent_internal" case utils.MetaSQL: - configDir = "httpagent_mysql" - configDirTls = "httpagenttls_mysql" + haCfgDIR = "httpagent_mysql" case utils.MetaMongo: - configDir = "httpagent_mongo" - configDirTls = "httpagenttls_mongo" + haCfgDIR = "httpagent_mongo" case utils.MetaPostgres: t.SkipNow() default: t.Fatal("Unknown Database type") } if *encoding == utils.MetaGOB { - configDir += "_gob" - configDirTls += "_gob" + haCfgDIR += "_gob" } - //Run the tests without Tls isTls = false - haCfgDIR = configDir for _, stest := range sTestsHA { t.Run(haCfgDIR, stest) } + +} + +func TestHAitTls(t *testing.T) { + switch *dbType { + case utils.MetaInternal: + haCfgDIR = "httpagenttls_internal" + case utils.MetaSQL: + haCfgDIR = "httpagenttls_mysql" + case utils.MetaMongo: + haCfgDIR = "httpagenttls_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + if *encoding == utils.MetaGOB { + haCfgDIR += "_gob" + } //Run the tests with Tls isTls = true - haCfgDIR = configDirTls for _, stest := range sTestsHA { t.Run(haCfgDIR, stest) } @@ -290,7 +301,7 @@ func testHAitCDRmtcall(t *testing.T) { if cdrs[0].Usage != "3m5s" { // should be 1 but maxUsage returns rounded version t.Errorf("Unexpected CDR Usage received, cdr: %s ", utils.ToJSON(cdrs[0])) } - if cdrs[0].Cost != 0.2188 { + if utils.Round(cdrs[0].Cost, 4, utils.ROUNDING_MIDDLE) != 0.2188 { // sql have only 4 digits after decimal point t.Errorf("Unexpected CDR Cost received, cdr: %+v ", cdrs[0].Cost) } if cdrs[0].OriginHost != "127.0.0.1" { diff --git a/agents/radagent_it_test.go b/agents/radagent_it_test.go index b12dbcaef..aa81c7890 100644 --- a/agents/radagent_it_test.go +++ b/agents/radagent_it_test.go @@ -60,9 +60,23 @@ var ( // Test start here func TestRAit(t *testing.T) { engine.KillEngine(0) - raonfigDIR = "radagent" + switch *dbType { + case utils.MetaInternal: + raonfigDIR = "radagent_internal" + case utils.MetaSQL: + raonfigDIR = "radagent_mysql" + case utils.MetaMongo: + raonfigDIR = "radagent_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + if *encoding == utils.MetaGOB { + raonfigDIR += "_gob" + } for _, stest := range sTestsRadius { - t.Run(diamConfigDIR, stest) + t.Run(raonfigDIR, stest) } } @@ -85,9 +99,6 @@ func TestRAitDispatcher(t *testing.T) { func testRAitInitCfg(t *testing.T) { raCfgPath = path.Join(*dataDir, "conf", "samples", raonfigDIR) - if *encoding == utils.MetaGOB { - raCfgPath = path.Join(*dataDir, "conf", "samples", raonfigDIR+"_gob") - } // Init config first var err error raCfg, err = config.NewCGRConfigFromPath(raCfgPath) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 9f86338ff..9d09d0e81 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -385,7 +385,7 @@ func main() { } return } - if *pidFile != "" { + if *pidFile != utils.EmptyString { writePid() } if *singlecpu { @@ -395,16 +395,16 @@ func main() { exitChan := make(chan bool) go singnalHandler(exitChan) - if *memProfDir != "" { + if *memProfDir != utils.EmptyString { go memProfiling(*memProfDir, *memProfInterval, *memProfNrFiles, exitChan) } cpuProfChanStop := make(chan struct{}) cpuProfChanDone := make(chan struct{}) - if *cpuProfDir != "" { + if *cpuProfDir != utils.EmptyString { go cpuProfiling(*cpuProfDir, cpuProfChanStop, cpuProfChanDone, exitChan) } - if *scheduledShutdown != "" { + if *scheduledShutdown != utils.EmptyString { shutdownDur, err := utils.ParseDurationWithNanosecs(*scheduledShutdown) if err != nil { log.Fatal(err) @@ -422,7 +422,7 @@ func main() { log.Fatalf("Could not parse config: <%s>", err.Error()) return } - if *nodeID != "" { + if *nodeID != utils.EmptyString { cfg.GeneralCfg().NodeID = *nodeID } config.SetCgrConfig(cfg) // Share the config object diff --git a/data/conf/samples/diamagent_internal/cgrates.json b/data/conf/samples/diamagent_internal/cgrates.json new file mode 100644 index 000000000..006ef8e89 --- /dev/null +++ b/data/conf/samples/diamagent_internal/cgrates.json @@ -0,0 +1,66 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, + "default_tenant": "cgrates.com", +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "asr_template": "*asr", +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent/data.json b/data/conf/samples/diamagent_internal/data.json similarity index 100% rename from data/conf/samples/diamagent/data.json rename to data/conf/samples/diamagent_internal/data.json diff --git a/data/conf/samples/diamagent/dryrun.json b/data/conf/samples/diamagent_internal/dryrun.json similarity index 100% rename from data/conf/samples/diamagent/dryrun.json rename to data/conf/samples/diamagent_internal/dryrun.json diff --git a/data/conf/samples/diamagent/message.json b/data/conf/samples/diamagent_internal/message.json similarity index 100% rename from data/conf/samples/diamagent/message.json rename to data/conf/samples/diamagent_internal/message.json diff --git a/data/conf/samples/diamagent/simpa.json b/data/conf/samples/diamagent_internal/simpa.json similarity index 100% rename from data/conf/samples/diamagent/simpa.json rename to data/conf/samples/diamagent_internal/simpa.json diff --git a/data/conf/samples/diamagent/tests.json b/data/conf/samples/diamagent_internal/tests.json similarity index 100% rename from data/conf/samples/diamagent/tests.json rename to data/conf/samples/diamagent_internal/tests.json diff --git a/data/conf/samples/diamagent/voice.json b/data/conf/samples/diamagent_internal/voice.json similarity index 100% rename from data/conf/samples/diamagent/voice.json rename to data/conf/samples/diamagent_internal/voice.json diff --git a/data/conf/samples/diamagent/cgrates.json b/data/conf/samples/diamagent_mongo/cgrates.json similarity index 100% rename from data/conf/samples/diamagent/cgrates.json rename to data/conf/samples/diamagent_mongo/cgrates.json diff --git a/data/conf/samples/diamagent_mongo/data.json b/data/conf/samples/diamagent_mongo/data.json new file mode 100644 index 000000000..6b191ed7a --- /dev/null +++ b/data/conf/samples/diamagent_mongo/data.json @@ -0,0 +1,125 @@ + +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "data_init", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*initiate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_update_grp1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "_grp1"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*contant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + "continue": true, + }, + + { + "id": "data_update_grp2", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*constant", "value": "_grp2"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_terminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*terminate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginIDPrefix", "field_id": "OriginIDPrefix", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*handler", "handler_id": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets"}, + ], + }, + ] +} + +} diff --git a/data/conf/samples/diamsctpagent/dryrun.json b/data/conf/samples/diamagent_mongo/dryrun.json old mode 100755 new mode 100644 similarity index 100% rename from data/conf/samples/diamsctpagent/dryrun.json rename to data/conf/samples/diamagent_mongo/dryrun.json diff --git a/data/conf/samples/diamsctpagent/message.json b/data/conf/samples/diamagent_mongo/message.json old mode 100755 new mode 100644 similarity index 100% rename from data/conf/samples/diamsctpagent/message.json rename to data/conf/samples/diamagent_mongo/message.json diff --git a/data/conf/samples/diamagent_mongo/simpa.json b/data/conf/samples/diamagent_mongo/simpa.json new file mode 100644 index 000000000..ddc025359 --- /dev/null +++ b/data/conf/samples/diamagent_mongo/simpa.json @@ -0,0 +1,28 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "simpa_event", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:simpa"], + "flags": ["*message", "*accounts", "*log"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*generic"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*value_exponent", "mandatory": true, + "value": "~*req.Requested-Service-Unit.CC-Money.Unit-Value.Value-Digits;~*req.Requested-Service-Unit.CC-Money.Unit-Value.Exponent"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo/tests.json b/data/conf/samples/diamagent_mongo/tests.json new file mode 100644 index 000000000..cd751c6b1 --- /dev/null +++ b/data/conf/samples/diamagent_mongo/tests.json @@ -0,0 +1,46 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "TestSessionDisconnect", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:testSessionDisconnect"], + "flags": ["*initiate", "*accounts","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*variable", + "value": "~*req.Origin-Host", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", + "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "DebitInterval", "field_id": "CGRDebitInterval", + "type": "*constant", "value": "1s"}, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", + "filters": ["*gte:~*cgrep.MaxUsage:0s"], + "type": "*variable", "value": "~*cgrep.MaxUsage{*duration_seconds&*round:0}", "mandatory": true}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent/voice.json b/data/conf/samples/diamagent_mongo/voice.json old mode 100755 new mode 100644 similarity index 100% rename from data/conf/samples/diamsctpagent/voice.json rename to data/conf/samples/diamagent_mongo/voice.json diff --git a/data/conf/samples/diamagent_mysql/cgrates.json b/data/conf/samples/diamagent_mysql/cgrates.json new file mode 100644 index 000000000..dc4911a8d --- /dev/null +++ b/data/conf/samples/diamagent_mysql/cgrates.json @@ -0,0 +1,67 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, + "default_tenant": "cgrates.com", +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to +}, + +"stor_db": { + "db_password": "CGRateS.org", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "asr_template": "*asr", +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_mysql/data.json b/data/conf/samples/diamagent_mysql/data.json new file mode 100644 index 000000000..6b191ed7a --- /dev/null +++ b/data/conf/samples/diamagent_mysql/data.json @@ -0,0 +1,125 @@ + +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "data_init", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*initiate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_update_grp1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "_grp1"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*contant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + "continue": true, + }, + + { + "id": "data_update_grp2", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*constant", "value": "_grp2"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_terminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*terminate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginIDPrefix", "field_id": "OriginIDPrefix", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*handler", "handler_id": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets"}, + ], + }, + ] +} + +} diff --git a/data/conf/samples/diamagent_mysql/dryrun.json b/data/conf/samples/diamagent_mysql/dryrun.json new file mode 100644 index 000000000..ca076d017 --- /dev/null +++ b/data/conf/samples/diamagent_mysql/dryrun.json @@ -0,0 +1,74 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2002"}, + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "1"}, + {"tag": "CCTotalOctets1", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits1"}, + {"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + "continue": true, + }, + { + "id": "dryrun2", + "filters": ["*rsr::~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0](!^$)"], // make sure the CC-Total-Octets was populated in the previous processor + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "2","new_branch": true}, + {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql/message.json b/data/conf/samples/diamagent_mysql/message.json new file mode 100644 index 000000000..559fc5754 --- /dev/null +++ b/data/conf/samples/diamagent_mysql/message.json @@ -0,0 +1,37 @@ +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "message", + "filters": ["*string:~*vars.*cmd:CCR", "*prefix:~*req.Service-Context-Id:message", + "*string:~*req.CC-Request-Type:4"], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "sms"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql/simpa.json b/data/conf/samples/diamagent_mysql/simpa.json new file mode 100644 index 000000000..ddc025359 --- /dev/null +++ b/data/conf/samples/diamagent_mysql/simpa.json @@ -0,0 +1,28 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "simpa_event", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:simpa"], + "flags": ["*message", "*accounts", "*log"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*generic"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*value_exponent", "mandatory": true, + "value": "~*req.Requested-Service-Unit.CC-Money.Unit-Value.Value-Digits;~*req.Requested-Service-Unit.CC-Money.Unit-Value.Exponent"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql/tests.json b/data/conf/samples/diamagent_mysql/tests.json new file mode 100644 index 000000000..cd751c6b1 --- /dev/null +++ b/data/conf/samples/diamagent_mysql/tests.json @@ -0,0 +1,46 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "TestSessionDisconnect", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:testSessionDisconnect"], + "flags": ["*initiate", "*accounts","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*variable", + "value": "~*req.Origin-Host", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", + "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "DebitInterval", "field_id": "CGRDebitInterval", + "type": "*constant", "value": "1s"}, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", + "filters": ["*gte:~*cgrep.MaxUsage:0s"], + "type": "*variable", "value": "~*cgrep.MaxUsage{*duration_seconds&*round:0}", "mandatory": true}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql/voice.json b/data/conf/samples/diamagent_mysql/voice.json new file mode 100644 index 000000000..5f5bd32de --- /dev/null +++ b/data/conf/samples/diamagent_mysql/voice.json @@ -0,0 +1,103 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInit", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*initiate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceUpdate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*update", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceTerminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*cc_usage", "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagentmaxconn_internal/cgrates.json b/data/conf/samples/diamagentmaxconn_internal/cgrates.json new file mode 100755 index 000000000..1c10b412c --- /dev/null +++ b/data/conf/samples/diamagentmaxconn_internal/cgrates.json @@ -0,0 +1,77 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "concurrent_requests": 0, + "sessions_conns": ["*localhost"], + "request_processors": [ + { + "id": "maxconn", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[], + "continue": true, + }, + ], +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagentmaxconn/cgrates.json b/data/conf/samples/diamagentmaxconn_mongo/cgrates.json similarity index 100% rename from data/conf/samples/diamagentmaxconn/cgrates.json rename to data/conf/samples/diamagentmaxconn_mongo/cgrates.json diff --git a/data/conf/samples/diamagentmaxconn_mysql/cgrates.json b/data/conf/samples/diamagentmaxconn_mysql/cgrates.json new file mode 100755 index 000000000..fbda6c826 --- /dev/null +++ b/data/conf/samples/diamagentmaxconn_mysql/cgrates.json @@ -0,0 +1,77 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to +}, + +"stor_db": { + "db_password": "CGRateS.org", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "concurrent_requests": 0, + "sessions_conns": ["*localhost"], + "request_processors": [ + { + "id": "maxconn", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[], + "continue": true, + }, + ], +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamsctpagent_internal/cgrates.json b/data/conf/samples/diamsctpagent_internal/cgrates.json new file mode 100755 index 000000000..d90cf3204 --- /dev/null +++ b/data/conf/samples/diamsctpagent_internal/cgrates.json @@ -0,0 +1,69 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, + "default_tenant": "cgrates.com", +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "listen_net":"sctp", + "listen": "127.0.0.1:3869", // address where to listen for diameter requests + "sessions_conns": ["*localhost"], +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamsctpagent/data.json b/data/conf/samples/diamsctpagent_internal/data.json similarity index 100% rename from data/conf/samples/diamsctpagent/data.json rename to data/conf/samples/diamsctpagent_internal/data.json diff --git a/data/conf/samples/diamsctpagent_internal/dryrun.json b/data/conf/samples/diamsctpagent_internal/dryrun.json new file mode 100755 index 000000000..ca076d017 --- /dev/null +++ b/data/conf/samples/diamsctpagent_internal/dryrun.json @@ -0,0 +1,74 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2002"}, + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "1"}, + {"tag": "CCTotalOctets1", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits1"}, + {"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + "continue": true, + }, + { + "id": "dryrun2", + "filters": ["*rsr::~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0](!^$)"], // make sure the CC-Total-Octets was populated in the previous processor + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "2","new_branch": true}, + {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_internal/message.json b/data/conf/samples/diamsctpagent_internal/message.json new file mode 100755 index 000000000..559fc5754 --- /dev/null +++ b/data/conf/samples/diamsctpagent_internal/message.json @@ -0,0 +1,37 @@ +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "message", + "filters": ["*string:~*vars.*cmd:CCR", "*prefix:~*req.Service-Context-Id:message", + "*string:~*req.CC-Request-Type:4"], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "sms"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent/simpa.json b/data/conf/samples/diamsctpagent_internal/simpa.json similarity index 100% rename from data/conf/samples/diamsctpagent/simpa.json rename to data/conf/samples/diamsctpagent_internal/simpa.json diff --git a/data/conf/samples/diamsctpagent_internal/voice.json b/data/conf/samples/diamsctpagent_internal/voice.json new file mode 100755 index 000000000..5f5bd32de --- /dev/null +++ b/data/conf/samples/diamsctpagent_internal/voice.json @@ -0,0 +1,103 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInit", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*initiate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceUpdate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*update", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceTerminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*cc_usage", "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent/cgrates.json b/data/conf/samples/diamsctpagent_mongo/cgrates.json similarity index 100% rename from data/conf/samples/diamsctpagent/cgrates.json rename to data/conf/samples/diamsctpagent_mongo/cgrates.json diff --git a/data/conf/samples/diamsctpagent_mongo/data.json b/data/conf/samples/diamsctpagent_mongo/data.json new file mode 100755 index 000000000..44dd19bab --- /dev/null +++ b/data/conf/samples/diamsctpagent_mongo/data.json @@ -0,0 +1,125 @@ + +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "data_init", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*initiate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_update_grp1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "_grp1"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*contant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + "continue": true, + }, + + { + "id": "data_update_grp2", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*constant", "value": "_grp2"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_terminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*terminate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginIDPrefix", "field_id": "OriginIDPrefix", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*handler", "handler_id": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets"}, + ], + }, + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mongo/dryrun.json b/data/conf/samples/diamsctpagent_mongo/dryrun.json new file mode 100755 index 000000000..ca076d017 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mongo/dryrun.json @@ -0,0 +1,74 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2002"}, + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "1"}, + {"tag": "CCTotalOctets1", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits1"}, + {"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + "continue": true, + }, + { + "id": "dryrun2", + "filters": ["*rsr::~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0](!^$)"], // make sure the CC-Total-Octets was populated in the previous processor + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "2","new_branch": true}, + {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mongo/message.json b/data/conf/samples/diamsctpagent_mongo/message.json new file mode 100755 index 000000000..559fc5754 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mongo/message.json @@ -0,0 +1,37 @@ +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "message", + "filters": ["*string:~*vars.*cmd:CCR", "*prefix:~*req.Service-Context-Id:message", + "*string:~*req.CC-Request-Type:4"], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "sms"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mongo/simpa.json b/data/conf/samples/diamsctpagent_mongo/simpa.json new file mode 100755 index 000000000..bbb483603 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mongo/simpa.json @@ -0,0 +1,28 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "simpa_event", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:simpa"], + "flags": ["*message", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*generic"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*value_exponent", "mandatory": true, + "value": "~*req.Requested-Service-Unit.CC-Money.Unit-Value.Value-Digits;~*req.Requested-Service-Unit.CC-Money.Unit-Value.Exponent"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mongo/voice.json b/data/conf/samples/diamsctpagent_mongo/voice.json new file mode 100755 index 000000000..5f5bd32de --- /dev/null +++ b/data/conf/samples/diamsctpagent_mongo/voice.json @@ -0,0 +1,103 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInit", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*initiate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceUpdate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*update", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceTerminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*cc_usage", "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mysql/cgrates.json b/data/conf/samples/diamsctpagent_mysql/cgrates.json new file mode 100755 index 000000000..0d708fe86 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/cgrates.json @@ -0,0 +1,69 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, + "default_tenant": "cgrates.com", +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to +}, + +"stor_db": { + "db_password": "CGRateS.org", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "listen_net":"sctp", + "listen": "127.0.0.1:3869", // address where to listen for diameter requests + "sessions_conns": ["*localhost"], +}, + +"apier": { + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamsctpagent_mysql/data.json b/data/conf/samples/diamsctpagent_mysql/data.json new file mode 100755 index 000000000..44dd19bab --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/data.json @@ -0,0 +1,125 @@ + +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "data_init", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*initiate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_update_grp1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "_grp1"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*contant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + "continue": true, + }, + + { + "id": "data_update_grp2", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*update", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*constant", "value": "_grp2"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*constant", "value": "2048"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"}, + ], + "reply_fields": [ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + { + "id": "data_terminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:gprs"], + "flags": ["*terminate", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginIDPrefix", "field_id": "OriginIDPrefix", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*constant", "value": "data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*handler", "handler_id": "*sum", + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets"}, + ], + }, + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mysql/dryrun.json b/data/conf/samples/diamsctpagent_mysql/dryrun.json new file mode 100755 index 000000000..ca076d017 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/dryrun.json @@ -0,0 +1,74 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2002"}, + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "1"}, + {"tag": "CCTotalOctets1", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits1"}, + {"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + "continue": true, + }, + { + "id": "dryrun2", + "filters": ["*rsr::~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0](!^$)"], // make sure the CC-Total-Octets was populated in the previous processor + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "2","new_branch": true}, + {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mysql/message.json b/data/conf/samples/diamsctpagent_mysql/message.json new file mode 100755 index 000000000..559fc5754 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/message.json @@ -0,0 +1,37 @@ +{ + +"diameter_agent": { + "request_processors": [ + + { + "id": "message", + "filters": ["*string:~*vars.*cmd:CCR", "*prefix:~*req.Service-Context-Id:message", + "*string:~*req.CC-Request-Type:4"], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "sms"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mysql/simpa.json b/data/conf/samples/diamsctpagent_mysql/simpa.json new file mode 100755 index 000000000..bbb483603 --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/simpa.json @@ -0,0 +1,28 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "simpa_event", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:simpa"], + "flags": ["*message", "*accounts"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*generic"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "generic"}, + {"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*value_exponent", "mandatory": true, + "value": "~*req.Requested-Service-Unit.CC-Money.Unit-Value.Value-Digits;~*req.Requested-Service-Unit.CC-Money.Unit-Value.Exponent"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamsctpagent_mysql/voice.json b/data/conf/samples/diamsctpagent_mysql/voice.json new file mode 100755 index 000000000..5f5bd32de --- /dev/null +++ b/data/conf/samples/diamsctpagent_mysql/voice.json @@ -0,0 +1,103 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInit", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*initiate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceUpdate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*update", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + {"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "VoiceTerminate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3", + "*prefix:~*req.Service-Context-Id:voice"], + "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*cc_usage", "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"}, + {"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", + "value": "~*req.Used-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": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/radagent_internal/cgrates.json b/data/conf/samples/radagent_internal/cgrates.json new file mode 100644 index 000000000..50790d0fc --- /dev/null +++ b/data/conf/samples/radagent_internal/cgrates.json @@ -0,0 +1,160 @@ +{ +// CGRateS Configuration file +// + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + +"resources": { + "enabled": true, + "store_interval": "-1", +}, + +"attributes": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "resources_conns": ["*localhost"], + "chargers_conns": ["*internal"], + "debit_interval": "10s", +}, + +"radius_agent": { + "enabled": true, + "sessions_conns": ["*localhost"], + "request_processors": [ + { + "id": "KamailioAuth", + "filters": ["*string:~*vars.*radReqType:*radAuth"], + "flags": ["*auth", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", + "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "KamailioAccountingStart", + "filters": ["*string:~*req.Acct-Status-Type:Start"], + "flags": ["*initiate", "*attributes", "*resources", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + { + "id": "KamailioAccountingStop", + "filters": ["*string:~*req.Acct-Status-Type:Stop"], + "flags": ["*terminate", "*resources", "*accounts", "*cdrs"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", + "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + ], +}, + + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/radagent_internal_gob/cgrates.json b/data/conf/samples/radagent_internal_gob/cgrates.json new file mode 100644 index 000000000..af6a67e62 --- /dev/null +++ b/data/conf/samples/radagent_internal_gob/cgrates.json @@ -0,0 +1,168 @@ +{ +// CGRateS Configuration file +// + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + + + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + +"resources": { + "enabled": true, + "store_interval": "-1", +}, + +"attributes": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "resources_conns": ["conn1"], + "chargers_conns": ["*internal"], + "debit_interval": "10s", +}, + +"radius_agent": { + "enabled": true, + "sessions_conns": ["conn1"], + "request_processors": [ + { + "id": "KamailioAuth", + "filters": ["*string:~*vars.*radReqType:*radAuth"], + "flags": ["*auth", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", + "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "KamailioAccountingStart", + "filters": ["*string:~*req.Acct-Status-Type:Start"], + "flags": ["*initiate", "*attributes", "*resources", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + { + "id": "KamailioAccountingStop", + "filters": ["*string:~*req.Acct-Status-Type:Stop"], + "flags": ["*terminate", "*resources", "*accounts", "*cdrs"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", + "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + ], +}, + + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/radagent/cgrates.json b/data/conf/samples/radagent_mongo/cgrates.json similarity index 100% rename from data/conf/samples/radagent/cgrates.json rename to data/conf/samples/radagent_mongo/cgrates.json diff --git a/data/conf/samples/radagent_gob/cgrates.json b/data/conf/samples/radagent_mongo_gob/cgrates.json similarity index 100% rename from data/conf/samples/radagent_gob/cgrates.json rename to data/conf/samples/radagent_mongo_gob/cgrates.json diff --git a/data/conf/samples/radagent_mysql/cgrates.json b/data/conf/samples/radagent_mysql/cgrates.json new file mode 100644 index 000000000..540cbb331 --- /dev/null +++ b/data/conf/samples/radagent_mysql/cgrates.json @@ -0,0 +1,159 @@ +{ +// CGRateS Configuration file +// + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"data_db": { + "db_type": "redis", + "db_port": 6379, + "db_name": "10", +}, + +"stor_db": { // database used to store offline tariff plans and CDRs + "db_password": "CGRateS.org", // password to use when connecting to stordb +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + +"resources": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "resources_conns": ["*localhost"], + "chargers_conns": ["*internal"], + "debit_interval": "10s", +}, + +"radius_agent": { + "enabled": true, + "sessions_conns": ["*localhost"], + "request_processors": [ + { + "id": "KamailioAuth", + "filters": ["*string:~*vars.*radReqType:*radAuth"], + "flags": ["*auth", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", + "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "KamailioAccountingStart", + "filters": ["*string:~*req.Acct-Status-Type:Start"], + "flags": ["*initiate", "*attributes", "*resources", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + { + "id": "KamailioAccountingStop", + "filters": ["*string:~*req.Acct-Status-Type:Stop"], + "flags": ["*terminate", "*resources", "*accounts", "*cdrs"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", + "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + ], +}, + + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/radagent_mysql_gob/cgrates.json b/data/conf/samples/radagent_mysql_gob/cgrates.json new file mode 100644 index 000000000..bfe81aad1 --- /dev/null +++ b/data/conf/samples/radagent_mysql_gob/cgrates.json @@ -0,0 +1,166 @@ +{ +// CGRateS Configuration file +// + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + +"data_db": { + "db_type": "redis", + "db_port": 6379, + "db_name": "10", +}, + +"stor_db": { // database used to store offline tariff plans and CDRs + "db_password": "CGRateS.org", // password to use when connecting to stordb +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + +"resources": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "resources_conns": ["conn1"], + "chargers_conns": ["*internal"], + "debit_interval": "10s", +}, + +"radius_agent": { + "enabled": true, + "sessions_conns": ["conn1"], + "request_processors": [ + { + "id": "KamailioAuth", + "filters": ["*string:~*vars.*radReqType:*radAuth"], + "flags": ["*auth", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", + "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "KamailioAccountingStart", + "filters": ["*string:~*req.Acct-Status-Type:Start"], + "flags": ["*initiate", "*attributes", "*resources", "*accounts"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + { + "id": "KamailioAccountingStop", + "filters": ["*string:~*req.Acct-Status-Type:Stop"], + "flags": ["*terminate", "*resources", "*accounts", "*cdrs"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*prepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Subject", "field_id": "Subject", "type": "*variable", + "value": "~*req.User-Name", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", + "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"tag": "RemoteAddr" , "field_id": "RemoteAddr", "type": "*remote_host"}, + ], + "reply_fields":[], + }, + ], +}, + + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/integration_test.sh b/integration_test.sh index e1fc5c6bf..7bb2aec09 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -22,6 +22,9 @@ lds_internal=$? echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*internal' go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*internal gnr_internal=$? +echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*internal' +go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*internal +agts_internal=$? # SQL echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql @@ -41,6 +44,9 @@ lds_sql=$? echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*sql' go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*sql gnr_sql=$? +echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*sql' +go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*sql +agts_sql=$? # Mongo echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo @@ -60,6 +66,9 @@ lds_mongo=$? echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mongo' go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mongo gnr_mongo=$? +echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mongo' +go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mongo +agts_mongo=$? # Postgres echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres @@ -79,6 +88,10 @@ lds_postgres=$? echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*postgres' go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*postgres gnr_postgres=$? +echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*postgres' +go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*postgres +agts_postgres=$? + echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration' go test github.com/cgrates/cgrates/cdrc -tags=integration @@ -89,9 +102,7 @@ cfg=$? #All -echo 'go test github.com/cgrates/cgrates/agents -tags=integration' -go test github.com/cgrates/cgrates/agents -tags=integration -agts=$? + echo 'go test github.com/cgrates/cgrates/sessions -tags=integration' go test github.com/cgrates/cgrates/sessions -tags=integration smg=$?