From 9cef3b28f4129183855de6d46803cf5fc2ffb863 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 18 Feb 2021 17:19:27 +0200 Subject: [PATCH] Added integration tests for birpc codec --- agents/astagent.go | 24 +- agents/diam_it_test.go | 20 + agents/diamagent.go | 33 +- agents/dnsagent.go | 10 +- agents/fsagent.go | 21 +- agents/httpagent.go | 12 +- agents/kamagent.go | 21 +- agents/kamevent.go | 6 +- agents/radagent.go | 12 +- agents/sipagent.go | 88 +--- apier/v1/config_it_test.go | 3 + cores/server.go | 12 +- cores/server_it_test.go | 9 +- .../diamagent_internal_gobbirpc/cgrates.json | 77 ++++ .../diamagent_internal_gobbirpc/data.json | 377 +++++++++++++++ .../diamagent_internal_gobbirpc/dryrun.json | 200 ++++++++ .../diamagent_internal_gobbirpc/message.json | 91 ++++ .../diamagent_internal_gobbirpc/mms.json | 91 ++++ .../diamagent_internal_gobbirpc/simpa.json | 66 +++ .../diamagent_internal_gobbirpc/tests.json | 116 +++++ .../diamagent_internal_gobbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ .../diamagent_internal_jsonbirpc/cgrates.json | 76 +++ .../diamagent_internal_jsonbirpc/data.json | 377 +++++++++++++++ .../diamagent_internal_jsonbirpc/dryrun.json | 200 ++++++++ .../diamagent_internal_jsonbirpc/message.json | 91 ++++ .../diamagent_internal_jsonbirpc/mms.json | 91 ++++ .../diamagent_internal_jsonbirpc/simpa.json | 66 +++ .../diamagent_internal_jsonbirpc/tests.json | 116 +++++ .../diamagent_internal_jsonbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ .../diamagent_mongo_gobbirpc/cgrates.json | 82 ++++ .../diamagent_mongo_gobbirpc/data.json | 377 +++++++++++++++ .../diamagent_mongo_gobbirpc/dryrun.json | 200 ++++++++ .../diamagent_mongo_gobbirpc/message.json | 91 ++++ .../samples/diamagent_mongo_gobbirpc/mms.json | 91 ++++ .../diamagent_mongo_gobbirpc/simpa.json | 66 +++ .../diamagent_mongo_gobbirpc/tests.json | 116 +++++ .../diamagent_mongo_gobbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ .../diamagent_mongo_jsonbirpc/cgrates.json | 81 ++++ .../diamagent_mongo_jsonbirpc/data.json | 377 +++++++++++++++ .../diamagent_mongo_jsonbirpc/dryrun.json | 200 ++++++++ .../diamagent_mongo_jsonbirpc/message.json | 91 ++++ .../diamagent_mongo_jsonbirpc/mms.json | 91 ++++ .../diamagent_mongo_jsonbirpc/simpa.json | 66 +++ .../diamagent_mongo_jsonbirpc/tests.json | 116 +++++ .../diamagent_mongo_jsonbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ .../diamagent_mysql_gobbirpc/cgrates.json | 78 ++++ .../diamagent_mysql_gobbirpc/data.json | 377 +++++++++++++++ .../diamagent_mysql_gobbirpc/dryrun.json | 200 ++++++++ .../diamagent_mysql_gobbirpc/message.json | 91 ++++ .../samples/diamagent_mysql_gobbirpc/mms.json | 91 ++++ .../diamagent_mysql_gobbirpc/simpa.json | 66 +++ .../diamagent_mysql_gobbirpc/tests.json | 116 +++++ .../diamagent_mysql_gobbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ .../diamagent_mysql_jsonbirpc/cgrates.json | 77 ++++ .../diamagent_mysql_jsonbirpc/data.json | 377 +++++++++++++++ .../diamagent_mysql_jsonbirpc/dryrun.json | 200 ++++++++ .../diamagent_mysql_jsonbirpc/message.json | 91 ++++ .../diamagent_mysql_jsonbirpc/mms.json | 91 ++++ .../diamagent_mysql_jsonbirpc/simpa.json | 66 +++ .../diamagent_mysql_jsonbirpc/tests.json | 116 +++++ .../diamagent_mysql_jsonbirpc/voice.json | 434 ++++++++++++++++++ .../wrong_template.json | 103 +++++ engine/connmanager.go | 4 +- go.mod | 4 +- go.sum | 2 + sessions/sessions.go | 196 ++++++-- 71 files changed, 9628 insertions(+), 188 deletions(-) create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/data.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/message.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/mms.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/tests.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/voice.json create mode 100644 data/conf/samples/diamagent_internal_gobbirpc/wrong_template.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/data.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/message.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/mms.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/tests.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/voice.json create mode 100644 data/conf/samples/diamagent_internal_jsonbirpc/wrong_template.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/data.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/message.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/mms.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/tests.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/voice.json create mode 100644 data/conf/samples/diamagent_mongo_gobbirpc/wrong_template.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/data.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/message.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/mms.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/tests.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/voice.json create mode 100644 data/conf/samples/diamagent_mongo_jsonbirpc/wrong_template.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/data.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/message.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/mms.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/tests.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/voice.json create mode 100644 data/conf/samples/diamagent_mysql_gobbirpc/wrong_template.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/cgrates.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/data.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/dryrun.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/message.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/mms.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/simpa.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/tests.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/voice.json create mode 100644 data/conf/samples/diamagent_mysql_jsonbirpc/wrong_template.json diff --git a/agents/astagent.go b/agents/astagent.go index 246ebfee9..33847904d 100644 --- a/agents/astagent.go +++ b/agents/astagent.go @@ -27,6 +27,7 @@ import ( "sync" "time" + "github.com/cenkalti/rpc2" "github.com/cgrates/aringo" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" @@ -386,8 +387,7 @@ func (sma *AsteriskAgent) BiRPCv1DisconnectSession(clnt rpcclient.ClientConnecto } // BiRPCv1GetActiveSessionIDs is internal method to get all active sessions in asterisk -func (sma *AsteriskAgent) BiRPCv1GetActiveSessionIDs(clnt rpcclient.ClientConnector, ignParam string, - sessionIDs *[]*sessions.SessionID) error { +func (sma *AsteriskAgent) BiRPCv1GetActiveSessionIDs(clnt rpcclient.ClientConnector, ignParam string, sessionIDs *[]*sessions.SessionID) error { return sma.V1GetActiveSessionIDs(ignParam, sessionIDs) } @@ -410,10 +410,20 @@ func (sma *AsteriskAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, // Handlers is used to implement the rpcclient.BiRPCConector interface func (sma *AsteriskAgent) Handlers() map[string]interface{} { return map[string]interface{}{ - utils.SessionSv1DisconnectSession: sma.BiRPCv1DisconnectSession, - utils.SessionSv1GetActiveSessionIDs: sma.BiRPCv1GetActiveSessionIDs, - utils.SessionSv1ReAuthorize: sma.BiRPCv1ReAuthorize, - utils.SessionSv1DisconnectPeer: sma.BiRPCv1DisconnectPeer, - utils.SessionSv1WarnDisconnect: sma.BiRPCv1WarnDisconnect, + utils.SessionSv1DisconnectSession: func(clnt *rpc2.Client, args utils.AttrDisconnectSession, rply *string) error { + return sma.BiRPCv1DisconnectSession(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessionIDs: func(clnt *rpc2.Client, args string, rply *[]*sessions.SessionID) error { + return sma.BiRPCv1GetActiveSessionIDs(clnt, args, rply) + }, + utils.SessionSv1ReAuthorize: func(clnt *rpc2.Client, args string, rply *string) (err error) { + return sma.BiRPCv1ReAuthorize(clnt, args, rply) + }, + utils.SessionSv1DisconnectPeer: func(clnt *rpc2.Client, args *utils.DPRArgs, rply *string) (err error) { + return sma.BiRPCv1DisconnectPeer(clnt, args, rply) + }, + utils.SessionSv1WarnDisconnect: func(clnt *rpc2.Client, args map[string]interface{}, rply *string) (err error) { + return sma.BiRPCv1WarnDisconnect(clnt, args, rply) + }, } } diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index 4e35686a5..c5d2eaee8 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -19,6 +19,7 @@ package agents import ( "flag" + "fmt" "net/rpc" "os/exec" "path" @@ -132,6 +133,25 @@ func TestDiamItSctp(t *testing.T) { } } +func TestDiamItBiRPC(t *testing.T) { + switch *dbType { + case utils.MetaInternal: + diamConfigDIR = "diamagent_internal_%sbirpc" + case utils.MetaMySQL: + diamConfigDIR = "diamagent_mysql_%sbirpc" + case utils.MetaMongo: + diamConfigDIR = "diamagent_mongo_%sbirpc" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + diamConfigDIR = fmt.Sprintf(diamConfigDIR, strings.TrimPrefix(*encoding, utils.Meta)) + for _, stest := range sTestsDiam { + t.Run(diamConfigDIR, stest) + } +} + func TestDiamItMaxConn(t *testing.T) { switch *dbType { case utils.MetaInternal: diff --git a/agents/diamagent.go b/agents/diamagent.go index 9bdd8d1ac..8b997d6bf 100644 --- a/agents/diamagent.go +++ b/agents/diamagent.go @@ -26,6 +26,7 @@ import ( "sync" "time" + "github.com/cenkalti/rpc2" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/sessions" @@ -368,6 +369,7 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1AuthorizeReply) err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1AuthorizeEvent, authArgs, rply) + rply.SetMaxUsageNeeded(authArgs.GetMaxUsage) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -385,6 +387,7 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1InitSessionReply) err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1InitiateSession, initArgs, rply) + rply.SetMaxUsageNeeded(initArgs.InitSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -395,6 +398,7 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, reqProcessor.Flags.Has(utils.MetaAccounts), cgrEv, reqProcessor.Flags.Has(utils.MetaFD)) rply := new(sessions.V1UpdateSessionReply) + rply.SetMaxUsageNeeded(updateArgs.UpdateSession) err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1UpdateSession, updateArgs, rply) if err = agReq.setCGRReply(rply, err); err != nil { @@ -409,9 +413,9 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, reqProcessor.Flags.GetBool(utils.MetaStats), reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs), cgrEv, reqProcessor.Flags.Has(utils.MetaFD)) - rply := utils.StringPointer("") + var rply string err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1TerminateSession, - terminateArgs, rply) + terminateArgs, &rply) if err = agReq.setCGRReply(nil, err); err != nil { return } @@ -440,6 +444,7 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, } else if msgArgs.Debit { cgrEv.Event[utils.Usage] = rply.MaxUsage // make sure the CDR reflects the debit } + rply.SetMaxUsageNeeded(msgArgs.Debit) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -465,9 +470,9 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, // separate request so we can capture the Terminate/Event also here if reqProcessor.Flags.GetBool(utils.MetaCDRs) && !reqProcessor.Flags.Has(utils.MetaDryRun) { - rplyCDRs := utils.StringPointer("") + var rplyCDRs string if err = da.connMgr.Call(da.cgrCfg.DiameterAgentCfg().SessionSConns, da, utils.SessionSv1ProcessCDR, - cgrEv, rplyCDRs); err != nil { + cgrEv, &rplyCDRs); err != nil { agReq.CGRReply.Set(utils.PathItems{{Field: utils.Error}}, utils.NewNMData(err.Error())) } } @@ -780,10 +785,20 @@ func (da *DiameterAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, a // Handlers is used to implement the rpcclient.BiRPCConector interface func (da *DiameterAgent) Handlers() map[string]interface{} { return map[string]interface{}{ - utils.SessionSv1DisconnectSession: da.BiRPCv1DisconnectSession, - utils.SessionSv1GetActiveSessionIDs: da.BiRPCv1GetActiveSessionIDs, - utils.SessionSv1ReAuthorize: da.BiRPCv1ReAuthorize, - utils.SessionSv1DisconnectPeer: da.BiRPCv1DisconnectPeer, - utils.SessionSv1WarnDisconnect: da.BiRPCv1WarnDisconnect, + utils.SessionSv1DisconnectSession: func(clnt *rpc2.Client, args utils.AttrDisconnectSession, rply *string) error { + return da.BiRPCv1DisconnectSession(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessionIDs: func(clnt *rpc2.Client, args string, rply *[]*sessions.SessionID) error { + return da.BiRPCv1GetActiveSessionIDs(clnt, args, rply) + }, + utils.SessionSv1ReAuthorize: func(clnt *rpc2.Client, args string, rply *string) (err error) { + return da.BiRPCv1ReAuthorize(clnt, args, rply) + }, + utils.SessionSv1DisconnectPeer: func(clnt *rpc2.Client, args *utils.DPRArgs, rply *string) (err error) { + return da.BiRPCv1DisconnectPeer(clnt, args, rply) + }, + utils.SessionSv1WarnDisconnect: func(clnt *rpc2.Client, args map[string]interface{}, rply *string) (err error) { + return da.BiRPCv1WarnDisconnect(clnt, args, rply) + }, } } diff --git a/agents/dnsagent.go b/agents/dnsagent.go index c889b7945..3c7625b4e 100644 --- a/agents/dnsagent.go +++ b/agents/dnsagent.go @@ -230,6 +230,7 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1AuthorizeEvent, authArgs, rply) + rply.SetMaxUsageNeeded(authArgs.GetMaxUsage) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -248,6 +249,7 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1InitiateSession, initArgs, rply) + rply.SetMaxUsageNeeded(initArgs.InitSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -261,6 +263,7 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1UpdateSession, updateArgs, rply) + rply.SetMaxUsageNeeded(updateArgs.UpdateSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -273,10 +276,10 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, reqProcessor.Flags.GetBool(utils.MetaStats), reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs), cgrEv, reqProcessor.Flags.Has(utils.MetaFD)) - rply := utils.StringPointer("") + var rply string err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1TerminateSession, - terminateArgs, rply) + terminateArgs, &rply) if err = agReq.setCGRReply(nil, err); err != nil { return } @@ -305,6 +308,7 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, } else if evArgs.Debit { cgrEv.Event[utils.Usage] = rply.MaxUsage // make sure the CDR reflects the debit } + rply.SetMaxUsageNeeded(evArgs.Debit) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -331,7 +335,7 @@ func (da *DNSAgent) processRequest(reqProcessor *config.RequestProcessor, // separate request so we can capture the Terminate/Event also here if reqProcessor.Flags.GetBool(utils.MetaCDRs) && !reqProcessor.Flags.Has(utils.MetaDryRun) { - rplyCDRs := utils.StringPointer("") + var rplyCDRs string if err = da.connMgr.Call(da.cgrCfg.DNSAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessCDR, cgrEv, &rplyCDRs); err != nil { diff --git a/agents/fsagent.go b/agents/fsagent.go index cbc142527..a17edf307 100644 --- a/agents/fsagent.go +++ b/agents/fsagent.go @@ -24,6 +24,7 @@ import ( "strings" "time" + "github.com/cenkalti/rpc2" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/sessions" @@ -516,10 +517,20 @@ func (fsa *FSsessions) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, arg // Handlers is used to implement the rpcclient.BiRPCConector interface func (fsa *FSsessions) Handlers() map[string]interface{} { return map[string]interface{}{ - utils.SessionSv1DisconnectSession: fsa.BiRPCv1DisconnectSession, - utils.SessionSv1GetActiveSessionIDs: fsa.BiRPCv1GetActiveSessionIDs, - utils.SessionSv1ReAuthorize: fsa.BiRPCv1ReAuthorize, - utils.SessionSv1DisconnectPeer: fsa.BiRPCv1DisconnectPeer, - utils.SessionSv1WarnDisconnect: fsa.BiRPCv1WarnDisconnect, + utils.SessionSv1DisconnectSession: func(clnt *rpc2.Client, args utils.AttrDisconnectSession, rply *string) error { + return fsa.BiRPCv1DisconnectSession(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessionIDs: func(clnt *rpc2.Client, args string, rply *[]*sessions.SessionID) error { + return fsa.BiRPCv1GetActiveSessionIDs(clnt, args, rply) + }, + utils.SessionSv1ReAuthorize: func(clnt *rpc2.Client, args string, rply *string) (err error) { + return fsa.BiRPCv1ReAuthorize(clnt, args, rply) + }, + utils.SessionSv1DisconnectPeer: func(clnt *rpc2.Client, args *utils.DPRArgs, rply *string) (err error) { + return fsa.BiRPCv1DisconnectPeer(clnt, args, rply) + }, + utils.SessionSv1WarnDisconnect: func(clnt *rpc2.Client, args map[string]interface{}, rply *string) (err error) { + return fsa.BiRPCv1WarnDisconnect(clnt, args, rply) + }, } } diff --git a/agents/httpagent.go b/agents/httpagent.go index 2d70a8c6c..0755405b8 100644 --- a/agents/httpagent.go +++ b/agents/httpagent.go @@ -166,6 +166,7 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1AuthorizeReply) err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1AuthorizeEvent, authArgs, rply) + rply.SetMaxUsageNeeded(authArgs.GetMaxUsage) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -183,6 +184,7 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1InitSessionReply) err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1InitiateSession, initArgs, rply) + rply.SetMaxUsageNeeded(initArgs.InitSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -195,6 +197,7 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1UpdateSessionReply) err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1UpdateSession, updateArgs, rply) + rply.SetMaxUsageNeeded(updateArgs.UpdateSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -207,9 +210,9 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, reqProcessor.Flags.GetBool(utils.MetaStats), reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs), cgrEv, reqProcessor.Flags.Has(utils.MetaFD)) - rply := utils.StringPointer("") + var rply string err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1TerminateSession, - terminateArgs, rply) + terminateArgs, &rply) if err = agReq.setCGRReply(nil, err); err != nil { return } @@ -237,6 +240,7 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, } else if evArgs.Debit { cgrEv.Event[utils.Usage] = rply.MaxUsage // make sure the CDR reflects the debit } + rply.SetMaxUsageNeeded(evArgs.Debit) if err = agReq.setCGRReply(nil, err); err != nil { return } @@ -262,9 +266,9 @@ func (ha *HTTPAgent) processRequest(reqProcessor *config.RequestProcessor, // separate request so we can capture the Terminate/Event also here if reqProcessor.Flags.GetBool(utils.MetaCDRs) && !reqProcessor.Flags.Has(utils.MetaDryRun) { - rplyCDRs := utils.StringPointer("") + var rplyCDRs string if err = ha.connMgr.Call(ha.sessionConns, nil, utils.SessionSv1ProcessCDR, - cgrEv, rplyCDRs); err != nil { + cgrEv, &rplyCDRs); err != nil { agReq.CGRReply.Set(utils.PathItems{{Field: utils.Error}}, utils.NewNMData(err.Error())) } } diff --git a/agents/kamagent.go b/agents/kamagent.go index 31aa17e66..349c85827 100644 --- a/agents/kamagent.go +++ b/agents/kamagent.go @@ -26,6 +26,7 @@ import ( "strings" "time" + "github.com/cenkalti/rpc2" "github.com/cgrates/cgrates/engine" "github.com/cgrates/rpcclient" @@ -480,10 +481,20 @@ func (ka *KamailioAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, a // Handlers is used to implement the rpcclient.BiRPCConector interface func (ka *KamailioAgent) Handlers() map[string]interface{} { return map[string]interface{}{ - utils.SessionSv1DisconnectSession: ka.BiRPCv1DisconnectSession, - utils.SessionSv1GetActiveSessionIDs: ka.BiRPCv1GetActiveSessionIDs, - utils.SessionSv1ReAuthorize: ka.BiRPCv1ReAuthorize, - utils.SessionSv1DisconnectPeer: ka.BiRPCv1DisconnectPeer, - utils.SessionSv1WarnDisconnect: ka.BiRPCv1WarnDisconnect, + utils.SessionSv1DisconnectSession: func(clnt *rpc2.Client, args utils.AttrDisconnectSession, rply *string) error { + return ka.BiRPCv1DisconnectSession(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessionIDs: func(clnt *rpc2.Client, args string, rply *[]*sessions.SessionID) error { + return ka.BiRPCv1GetActiveSessionIDs(clnt, args, rply) + }, + utils.SessionSv1ReAuthorize: func(clnt *rpc2.Client, args string, rply *string) (err error) { + return ka.BiRPCv1ReAuthorize(clnt, args, rply) + }, + utils.SessionSv1DisconnectPeer: func(clnt *rpc2.Client, args *utils.DPRArgs, rply *string) (err error) { + return ka.BiRPCv1DisconnectPeer(clnt, args, rply) + }, + utils.SessionSv1WarnDisconnect: func(clnt *rpc2.Client, args map[string]interface{}, rply *string) (err error) { + return ka.BiRPCv1WarnDisconnect(clnt, args, rply) + }, } } diff --git a/agents/kamevent.go b/agents/kamevent.go index a89cf060a..22861c073 100644 --- a/agents/kamevent.go +++ b/agents/kamevent.go @@ -239,7 +239,11 @@ func (kev KamEvent) AsKamAuthReply(authArgs *sessions.V1AuthorizeArgs, kar.ResourceAllocation = *authReply.ResourceAllocation } if authArgs.GetMaxUsage { - kar.MaxUsage = int(utils.Round(authReply.MaxUsage.Seconds(), 0, utils.MetaRoundingMiddle)) + if authReply.MaxUsage != nil { + kar.MaxUsage = int(utils.Round(authReply.MaxUsage.Seconds(), 0, utils.MetaRoundingMiddle)) + } else { + kar.MaxUsage = 0 + } } if authArgs.GetRoutes && authReply.Routes != nil { kar.Routes = authReply.Routes.Digest() diff --git a/agents/radagent.go b/agents/radagent.go index e5b06b9e4..4f8c398ca 100644 --- a/agents/radagent.go +++ b/agents/radagent.go @@ -224,6 +224,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R rply := new(sessions.V1AuthorizeReply) err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1AuthorizeEvent, authArgs, rply) + rply.SetMaxUsageNeeded(authArgs.GetMaxUsage) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -241,6 +242,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R rply := new(sessions.V1InitSessionReply) err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1InitiateSession, initArgs, rply) + rply.SetMaxUsageNeeded(initArgs.InitSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -253,6 +255,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R rply := new(sessions.V1UpdateSessionReply) err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1UpdateSession, updateArgs, rply) + rply.SetMaxUsageNeeded(updateArgs.UpdateSession) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -265,9 +268,9 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R reqProcessor.Flags.GetBool(utils.MetaStats), reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs), cgrEv, reqProcessor.Flags.Has(utils.MetaFD)) - rply := utils.StringPointer("") + var rply string err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1TerminateSession, - terminateArgs, rply) + terminateArgs, &rply) if err = agReq.setCGRReply(nil, err); err != nil { return } @@ -294,6 +297,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R } else if evArgs.Debit { cgrEv.Event[utils.Usage] = rply.MaxUsage // make sure the CDR reflects the debit } + rply.SetMaxUsageNeeded(evArgs.Debit) if err = agReq.setCGRReply(rply, err); err != nil { return } @@ -324,9 +328,9 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R } // separate request so we can capture the Terminate/Event also here if reqProcessor.Flags.GetBool(utils.MetaCDRs) { - rplyCDRs := utils.StringPointer("") + var rplyCDRs string if err = ra.connMgr.Call(ra.cgrCfg.RadiusAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessCDR, - cgrEv, rplyCDRs); err != nil { + cgrEv, &rplyCDRs); err != nil { agReq.CGRReply.Set(utils.PathItems{{Field: utils.Error}}, utils.NewNMData(err.Error())) } } diff --git a/agents/sipagent.go b/agents/sipagent.go index cfb8faaab..5ced80911 100644 --- a/agents/sipagent.go +++ b/agents/sipagent.go @@ -434,83 +434,10 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor, rply := new(sessions.V1AuthorizeReply) err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1AuthorizeEvent, authArgs, rply) + rply.SetMaxUsageNeeded(authArgs.GetMaxUsage) if err = agReq.setCGRReply(rply, err); err != nil { return } - // case utils.MetaInitiate: - // initArgs := sessions.NewV1InitSessionArgs( - // reqProcessor.Flags.GetBool(utils.MetaAttributes), - // reqProcessor.Flags.ParamsSlice(utils.MetaAttributes,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaThresholds), - // reqProcessor.Flags.ParamsSlice(utils.MetaThresholds,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaStats), - // reqProcessor.Flags.ParamsSlice(utils.MetaStats,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaResources), - // reqProcessor.Flags.Has(utils.MetaAccounts), - // cgrEv, reqProcessor.Flags.Has(utils.MetaFD), - // opts) - // rply := new(sessions.V1InitSessionReply) - // err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1InitiateSession, - // initArgs, rply) - // if err = agReq.setCGRReply(rply, err); err != nil { - // return - // } - // case utils.MetaUpdate: - // updateArgs := sessions.NewV1UpdateSessionArgs( - // reqProcessor.Flags.GetBool(utils.MetaAttributes), - // reqProcessor.Flags.ParamsSlice(utils.MetaAttributes,utils.MetaIDs), - // reqProcessor.Flags.Has(utils.MetaAccounts), - // cgrEv, reqProcessor.Flags.Has(utils.MetaFD), - // opts) - // rply := new(sessions.V1UpdateSessionReply) - // err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1UpdateSession, - // updateArgs, rply) - // if err = agReq.setCGRReply(rply, err); err != nil { - // return - // } - // case utils.MetaTerminate: - // terminateArgs := sessions.NewV1TerminateSessionArgs( - // reqProcessor.Flags.Has(utils.MetaAccounts), - // reqProcessor.Flags.GetBool(utils.MetaResources), - // reqProcessor.Flags.GetBool(utils.MetaThresholds), - // reqProcessor.Flags.ParamsSlice(utils.MetaThresholds,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaStats), - // reqProcessor.Flags.ParamsSlice(utils.MetaStats,utils.MetaIDs), - // cgrEv, reqProcessor.Flags.Has(utils.MetaFD), - // opts) - // rply := utils.StringPointer("") - // err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1TerminateSession, - // terminateArgs, rply) - // if err = agReq.setCGRReply(nil, err); err != nil { - // return - // } - // case utils.MetaMessage: - // evArgs := sessions.NewV1ProcessMessageArgs( - // reqProcessor.Flags.GetBool(utils.MetaAttributes), - // reqProcessor.Flags.ParamsSlice(utils.MetaAttributes,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaThresholds), - // reqProcessor.Flags.ParamsSlice(utils.MetaThresholds,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaStats), - // reqProcessor.Flags.ParamsSlice(utils.MetaStats,utils.MetaIDs), - // reqProcessor.Flags.GetBool(utils.MetaResources), - // reqProcessor.Flags.Has(utils.MetaAccounts), - // reqProcessor.Flags.GetBool(utils.MetaRoutes), - // reqProcessor.Flags.Has(utils.MetaRoutesIgnoreErrors), - // reqProcessor.Flags.Has(utils.MetaRoutesEventCost), - // cgrEv, cgrArgs, // reqProcessor.Flags.Has(utils.MetaFD), - // reqProcessor.Flags.ParamValue(utils.MetaRoutesMaxCost), - // opts) - // rply := new(sessions.V1ProcessMessageReply) - // err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessMessage, - // evArgs, rply) - // if utils.ErrHasPrefix(err, utils.RalsErrorPrfx) { - // cgrEv.Event[utils.Usage] = 0 // avoid further debits - // } else if evArgs.Debit { - // cgrEv.Event[utils.Usage] = rply.MaxUsage // make sure the CDR reflects the debit - // } - // if err = agReq.setCGRReply(nil, err); err != nil { - // return - // } case utils.MetaEvent: evArgs := &sessions.V1ProcessEventArgs{ Flags: reqProcessor.Flags.SliceFlags(), @@ -529,20 +456,7 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor, if err = agReq.setCGRReply(rply, err); err != nil { return } - // case utils.MetaCDRs: // allow CDR processing } - // separate request so we can capture the Terminate/Event also here - // if reqProcessor.Flags.GetBool(utils.MetaCDRs) && - // !reqProcessor.Flags.Has(utils.MetaDryRun) { - // rplyCDRs := utils.StringPointer("") - // if err = sa.connMgr.Call(sa.cfg.SIPAgentCfg().SessionSConns, nil, utils.SessionSv1ProcessCDR, - // &utils.CGREventWithOpts{ - // CGREvent: cgrEv, - // Opts: opts, - // }, rplyCDRs); err != nil { - // agReq.CGRReply.Set(utils.PathItems{{Field: utils.Error}}, utils.NewNMData(err.Error())) - // } - // } if err := agReq.SetFields(reqProcessor.ReplyFields); err != nil { return false, err } diff --git a/apier/v1/config_it_test.go b/apier/v1/config_it_test.go index da88261d5..235869347 100644 --- a/apier/v1/config_it_test.go +++ b/apier/v1/config_it_test.go @@ -146,6 +146,7 @@ func testConfigSSetConfigSessionS(t *testing.T) { "client_protocol": 1., "debit_interval": "0", "listen_bijson": "127.0.0.1:2014", + "listen_bigob": "", "session_ttl": "0", "session_indexes": []interface{}{utils.OriginID}, "attributes_conns": []interface{}{utils.MetaLocalHost}, @@ -180,6 +181,7 @@ func testConfigSSetConfigSessionS(t *testing.T) { exp = map[string]interface{}{ "enabled": true, "listen_bijson": "127.0.0.1:2014", + "listen_bigob": "", "chargers_conns": []string{utils.MetaInternal}, "rals_conns": []string{utils.MetaInternal}, "resources_conns": []string{utils.MetaLocalHost}, @@ -226,6 +228,7 @@ func testConfigSv1GetJSONSectionWithoutTenant(t *testing.T) { exp := map[string]interface{}{ "enabled": true, "listen_bijson": "127.0.0.1:2014", + "listen_bigob": "", "chargers_conns": []interface{}{utils.MetaInternal}, "rals_conns": []interface{}{utils.MetaInternal}, "resources_conns": []interface{}{utils.MetaLocalHost}, diff --git a/cores/server.go b/cores/server.go index 2d7f85941..f22d6213c 100644 --- a/cores/server.go +++ b/cores/server.go @@ -262,14 +262,14 @@ func (s *Server) ServeBiRPC(addrJSON, addrGOB string, onConn func(*rpc2.Client), s.birpcSrv.OnDisconnect(onDis) if addrJSON != utils.EmptyString { var ljson net.Listener - if ljson, err = s.listenBiRPC(addrJSON, utils.JSONCaps, jsonrpc2.NewJSONCodec); err != nil { + if ljson, err = s.listenBiRPC(s.birpcSrv, addrJSON, utils.JSONCaps, jsonrpc2.NewJSONCodec); err != nil { return } defer ljson.Close() } if addrGOB != utils.EmptyString { var lgob net.Listener - if lgob, err = s.listenBiRPC(addrGOB, utils.GOBCaps, rpc2.NewGobCodec); err != nil { + if lgob, err = s.listenBiRPC(s.birpcSrv, addrGOB, utils.GOBCaps, rpc2.NewGobCodec); err != nil { return } defer lgob.Close() @@ -278,17 +278,17 @@ func (s *Server) ServeBiRPC(addrJSON, addrGOB string, onConn func(*rpc2.Client), return } -func (s *Server) listenBiRPC(addr, codecName string, newCodec func(io.ReadWriteCloser) rpc2.Codec) (lBiRPC net.Listener, err error) { +func (s *Server) listenBiRPC(srv *rpc2.Server, addr, codecName string, newCodec func(io.ReadWriteCloser) rpc2.Codec) (lBiRPC net.Listener, err error) { if lBiRPC, err = net.Listen(utils.TCP, addr); err != nil { log.Printf("ServeBi%s listen error: %s \n", codecName, err) return } utils.Logger.Info(fmt.Sprintf("Starting CGRateS Bi%s server at <%s>", codecName, addr)) - go s.acceptBiRPC(lBiRPC, codecName, newCodec) + go s.acceptBiRPC(srv, lBiRPC, codecName, newCodec) return } -func (s *Server) acceptBiRPC(l net.Listener, codecName string, newCodec func(io.ReadWriteCloser) rpc2.Codec) { +func (s *Server) acceptBiRPC(srv *rpc2.Server, l net.Listener, codecName string, newCodec func(io.ReadWriteCloser) rpc2.Codec) { for { conn, err := l.Accept() if err != nil { @@ -299,7 +299,7 @@ func (s *Server) acceptBiRPC(l net.Listener, codecName string, newCodec func(io. utils.Logger.Crit(fmt.Sprintf("Stoped Bi%s server beacause %s", codecName, err)) return // stop if we get Accept error } - go s.birpcSrv.ServeCodec(newCodec(conn)) + go srv.ServeCodec(newCodec(conn)) } } diff --git a/cores/server_it_test.go b/cores/server_it_test.go index 9440cf1fd..40c213ff9 100644 --- a/cores/server_it_test.go +++ b/cores/server_it_test.go @@ -69,6 +69,9 @@ var ( testServeBiJSON, testServeBiJSONEmptyBiRPCServer, testServeBiJSONInvalidPort, + testServeBiGoB, + testServeBiGoBEmptyBiRPCServer, + testServeBiGoBInvalidPort, testServeGOBTLS, testServeJSONTls, testServeCodecTLSErr, @@ -396,7 +399,7 @@ func testServeBiGoB(t *testing.T) { sessions := sessions2.NewSessionS(cfgDflt, dm, nil) go func() { - if err := server.ServeBiRPC("", ":93434", sessions.OnBiJSONConnect, sessions.OnBiJSONDisconnect); err != nil { + if err := server.ServeBiRPC("", ":9343", sessions.OnBiJSONConnect, sessions.OnBiJSONDisconnect); err != nil { t.Error(err) } }() @@ -756,7 +759,7 @@ func testAcceptBiRPC(t *testing.T) { l := &mockListener{ p1: p1, } - go server.acceptBiRPC(l, utils.JSONCaps, jsonrpc2.NewJSONCodec) + go server.acceptBiRPC(server.birpcSrv, l, utils.JSONCaps, jsonrpc2.NewJSONCodec) rpc := jsonrpc.NewClient(p2) var reply string expected := "rpc2: can't find method AttributeSv1.Ping" @@ -784,7 +787,7 @@ func testAcceptBiRPCError(t *testing.T) { //it will contain "use of closed network connection" l := new(mockListenError) - go server.acceptBiRPC(l, utils.JSONCaps, jsonrpc2.NewJSONCodec) + go server.acceptBiRPC(server.birpcSrv, l, utils.JSONCaps, jsonrpc2.NewJSONCodec) runtime.Gosched() } diff --git a/data/conf/samples/diamagent_internal_gobbirpc/cgrates.json b/data/conf/samples/diamagent_internal_gobbirpc/cgrates.json new file mode 100644 index 000000000..3cd89a507 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/cgrates.json @@ -0,0 +1,77 @@ +{ +// 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 +}, + +"rpc_conns": { + "*gobbirpc": { + "conns": [{"address": "127.0.0.1:2015", "transport":"*birpc_gob"}], + }, +}, + +"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, + "listen_bigob": "127.0.0.1:2015", + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "sessions_conns": ["*gobbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_internal_gobbirpc/data.json b/data/conf/samples/diamagent_internal_gobbirpc/data.json new file mode 100644 index 000000000..9066f4254 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_internal_gobbirpc/dryrun.json b/data/conf/samples/diamagent_internal_gobbirpc/dryrun.json new file mode 100644 index 000000000..2323e3f42 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_gobbirpc/message.json b/data/conf/samples/diamagent_internal_gobbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_gobbirpc/mms.json b/data/conf/samples/diamagent_internal_gobbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_gobbirpc/simpa.json b/data/conf/samples/diamagent_internal_gobbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_internal_gobbirpc/tests.json b/data/conf/samples/diamagent_internal_gobbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_internal_gobbirpc/voice.json b/data/conf/samples/diamagent_internal_gobbirpc/voice.json new file mode 100644 index 000000000..1c7201894 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes", "*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_gobbirpc/wrong_template.json b/data/conf/samples/diamagent_internal_gobbirpc/wrong_template.json new file mode 100644 index 000000000..8fd1b6cd7 --- /dev/null +++ b/data/conf/samples/diamagent_internal_gobbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/cgrates.json b/data/conf/samples/diamagent_internal_jsonbirpc/cgrates.json new file mode 100644 index 000000000..272752d22 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/cgrates.json @@ -0,0 +1,76 @@ +{ +// 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 +}, + +"rpc_conns": { + "*jsonbirpc": { + "conns": [{"address": "127.0.0.1:2014", "transport":"*birpc_json"}], + }, +}, + +"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, + "sessions_conns": ["*jsonbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/data.json b/data/conf/samples/diamagent_internal_jsonbirpc/data.json new file mode 100644 index 000000000..9066f4254 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_internal_jsonbirpc/dryrun.json b/data/conf/samples/diamagent_internal_jsonbirpc/dryrun.json new file mode 100644 index 000000000..2323e3f42 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/message.json b/data/conf/samples/diamagent_internal_jsonbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/mms.json b/data/conf/samples/diamagent_internal_jsonbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/simpa.json b/data/conf/samples/diamagent_internal_jsonbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_internal_jsonbirpc/tests.json b/data/conf/samples/diamagent_internal_jsonbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_internal_jsonbirpc/voice.json b/data/conf/samples/diamagent_internal_jsonbirpc/voice.json new file mode 100644 index 000000000..1c7201894 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes", "*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_internal_jsonbirpc/wrong_template.json b/data/conf/samples/diamagent_internal_jsonbirpc/wrong_template.json new file mode 100644 index 000000000..8fd1b6cd7 --- /dev/null +++ b/data/conf/samples/diamagent_internal_jsonbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/cgrates.json b/data/conf/samples/diamagent_mongo_gobbirpc/cgrates.json new file mode 100644 index 000000000..b7d639b7e --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/cgrates.json @@ -0,0 +1,82 @@ +{ +// 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": "mongo", // stor database type to use: + "db_port": 27017, // the port to reach the stordb + "db_name": "datadb", + "db_password": "", +}, + +"stor_db": { + "db_type": "mongo", // stor database type to use: + "db_port": 27017, // the port to reach the stordb + "db_name": "stordb", + "db_password": "", +}, + +"rpc_conns": { + "*gobbirpc": { + "conns": [{"address": "127.0.0.1:2015", "transport":"*birpc_gob"}], + }, +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "listen_bigob": "127.0.0.1:2015", + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "sessions_conns": ["*gobbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/data.json b/data/conf/samples/diamagent_mongo_gobbirpc/data.json new file mode 100644 index 000000000..9066f4254 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_mongo_gobbirpc/dryrun.json b/data/conf/samples/diamagent_mongo_gobbirpc/dryrun.json new file mode 100644 index 000000000..2323e3f42 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/message.json b/data/conf/samples/diamagent_mongo_gobbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/mms.json b/data/conf/samples/diamagent_mongo_gobbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/simpa.json b/data/conf/samples/diamagent_mongo_gobbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_gobbirpc/tests.json b/data/conf/samples/diamagent_mongo_gobbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_mongo_gobbirpc/voice.json b/data/conf/samples/diamagent_mongo_gobbirpc/voice.json new file mode 100644 index 000000000..1110de3cf --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_gobbirpc/wrong_template.json b/data/conf/samples/diamagent_mongo_gobbirpc/wrong_template.json new file mode 100644 index 000000000..391411dd3 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_gobbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/cgrates.json b/data/conf/samples/diamagent_mongo_jsonbirpc/cgrates.json new file mode 100644 index 000000000..ed770a342 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/cgrates.json @@ -0,0 +1,81 @@ +{ +// 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": "mongo", // stor database type to use: + "db_port": 27017, // the port to reach the stordb + "db_name": "datadb", + "db_password": "", +}, + +"stor_db": { + "db_type": "mongo", // stor database type to use: + "db_port": 27017, // the port to reach the stordb + "db_name": "stordb", + "db_password": "", +}, + +"rpc_conns": { + "*jsonbirpc": { + "conns": [{"address": "127.0.0.1:2014", "transport":"*birpc_json"}], + }, +}, + +"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, + "sessions_conns": ["*jsonbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/data.json b/data/conf/samples/diamagent_mongo_jsonbirpc/data.json new file mode 100644 index 000000000..9066f4254 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_mongo_jsonbirpc/dryrun.json b/data/conf/samples/diamagent_mongo_jsonbirpc/dryrun.json new file mode 100644 index 000000000..2323e3f42 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/message.json b/data/conf/samples/diamagent_mongo_jsonbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/mms.json b/data/conf/samples/diamagent_mongo_jsonbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/simpa.json b/data/conf/samples/diamagent_mongo_jsonbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_jsonbirpc/tests.json b/data/conf/samples/diamagent_mongo_jsonbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_mongo_jsonbirpc/voice.json b/data/conf/samples/diamagent_mongo_jsonbirpc/voice.json new file mode 100644 index 000000000..1110de3cf --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mongo_jsonbirpc/wrong_template.json b/data/conf/samples/diamagent_mongo_jsonbirpc/wrong_template.json new file mode 100644 index 000000000..391411dd3 --- /dev/null +++ b/data/conf/samples/diamagent_mongo_jsonbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/cgrates.json b/data/conf/samples/diamagent_mysql_gobbirpc/cgrates.json new file mode 100644 index 000000000..e38008e3a --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/cgrates.json @@ -0,0 +1,78 @@ +{ +// 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", +}, + +"rpc_conns": { + "*gobbirpc": { + "conns": [{"address": "127.0.0.1:2015", "transport":"*birpc_gob"}], + }, +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, +}, + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "listen_bigob": "127.0.0.1:2015", + "attributes_conns": ["*localhost"], + "chargers_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], +}, + +"diameter_agent": { + "enabled": true, + "sessions_conns": ["*gobbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/data.json b/data/conf/samples/diamagent_mysql_gobbirpc/data.json new file mode 100644 index 000000000..59e80982d --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*composed", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*composed", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_gobbirpc/dryrun.json b/data/conf/samples/diamagent_mysql_gobbirpc/dryrun.json new file mode 100644 index 000000000..6b384af11 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/message.json b/data/conf/samples/diamagent_mysql_gobbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/mms.json b/data/conf/samples/diamagent_mysql_gobbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/simpa.json b/data/conf/samples/diamagent_mysql_gobbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_gobbirpc/tests.json b/data/conf/samples/diamagent_mysql_gobbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_gobbirpc/voice.json b/data/conf/samples/diamagent_mysql_gobbirpc/voice.json new file mode 100644 index 000000000..1c7201894 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes", "*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_gobbirpc/wrong_template.json b/data/conf/samples/diamagent_mysql_gobbirpc/wrong_template.json new file mode 100644 index 000000000..8fd1b6cd7 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_gobbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/cgrates.json b/data/conf/samples/diamagent_mysql_jsonbirpc/cgrates.json new file mode 100644 index 000000000..acf9ef17f --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/cgrates.json @@ -0,0 +1,77 @@ +{ +// 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", +}, + +"rpc_conns": { + "*jsonbirpc": { + "conns": [{"address": "127.0.0.1:2014", "transport":"*birpc_json"}], + }, +}, + +"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, + "sessions_conns": ["*jsonbirpc"], + "asr_template": "*asr", + "rar_template": "*rar", + "forced_disconnect": "*asr", // the request to send to diameter on DisconnectSession <*none|*asr|*rar> +}, + +"apiers": { + "enabled": true, + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/data.json b/data/conf/samples/diamagent_mysql_jsonbirpc/data.json new file mode 100644 index 000000000..59e80982d --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/data.json @@ -0,0 +1,377 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + ], + "reply_fields": [ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*composed", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*composed", + "value": "_grp1" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*contant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": 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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "InitialOriginID", + "path": "*cgreq.InitialOriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*constant", + "value": "_grp2" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*constant", + "value": "2048" + }, + { + "tag": "LastUsed", + "path": "*cgreq.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": ["*notempty:~*cgrep.Error:"], + "path": "*rep.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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*data" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginIDPrefix", + "path": "*cgreq.OriginIDPrefix", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*constant", + "value": "data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.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_jsonbirpc/dryrun.json b/data/conf/samples/diamagent_mysql_jsonbirpc/dryrun.json new file mode 100644 index 000000000..6b384af11 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/dryrun.json @@ -0,0 +1,200 @@ +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "dryrun1", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.Service-Context-Id:TestDiamItDryRun" + ], + "flags": ["*dryrun","*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent", + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "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", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2002" + }, + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", + "value": "1" + }, + { + "tag": "CCTotalOctets1", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", + "value": "~*cgreq.UsedUnits1" + }, + { + "tag": "GrantedUsage", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*sum", + "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, + ], + }, + { + "id": "dryrun2", + "filters": ["*notempty:~*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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "Val1", + "path": "*cgreq.Val1", + "type": "*constant", + "value": "1" + }, + { + "tag": "Val2", + "path": "*cgreq.Val2", + "type": "*constant", + "value": "2" + }, + { + "tag": "Val3", + "path": "*cgreq.Val3", + "type": "*constant", + "value": "3" + }, + { + "tag": "OptionalField", + "path":"*cgreq.OptionalField", + "type":"*variable", + "value":"~*req.Inexistent" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "UsedUnits1", + "path": "*cgreq.UsedUnits1", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]" + }, + { + "tag": "UsedUnits2", + "path": "*cgreq.UsedUnits2", + "type": "*variable", + "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]" + }, + ], + "reply_fields":[ + { + "tag": "RatingGroup", + "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", + "type": "*group", + "value": "2", + "new_branch": true + }, + { + "tag": "CCTotalOctets2", + "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*group", + "value": "~*cgreq.UsedUnits2" + }, + ], + }, + + ], +}, + +} diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/message.json b/data/conf/samples/diamagent_mysql_jsonbirpc/message.json new file mode 100644 index 000000000..784707957 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/message.json @@ -0,0 +1,91 @@ +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/mms.json b/data/conf/samples/diamagent_mysql_jsonbirpc/mms.json new file mode 100644 index 000000000..4ec65e707 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/mms.json @@ -0,0 +1,91 @@ +{ + + "diameter_agent": { + "request_processors": [ + + { + "id": "mms", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*prefix:~*req.Service-Context-Id:mms", + "*string:~*req.CC-Request-Type:4" + ], + "flags": ["*message", "*accounts", "*cdrs","*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*mms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "mms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + ], + }, + + ], + }, + + } \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/simpa.json b/data/conf/samples/diamagent_mysql_jsonbirpc/simpa.json new file mode 100644 index 000000000..7c46da38a --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/simpa.json @@ -0,0 +1,66 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*generic" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "generic" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.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_jsonbirpc/tests.json b/data/conf/samples/diamagent_mysql_jsonbirpc/tests.json new file mode 100644 index 000000000..40fa2cded --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/tests.json @@ -0,0 +1,116 @@ + +{ + +"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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*variable", + "value": "~*req.Origin-Host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + { + "tag": "Subject", + "path": "*cgreq.Subject", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", + "mandatory": true + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "DebitInterval", + "path": "*opts.*sessionsDebitInterval", + "type": "*constant", + "value": "1s" + }, + ], + "reply_fields":[ + { + "tag": "CCATemplate", + "type": "*template", + "value": "*cca" + }, + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "GrantedUnits", + "path": "*rep.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_jsonbirpc/voice.json b/data/conf/samples/diamagent_mysql_jsonbirpc/voice.json new file mode 100644 index 000000000..1c7201894 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/voice.json @@ -0,0 +1,434 @@ + +{ + +"diameter_agent": { + "request_processors": [ + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInit", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice" + ], + "flags": ["*initiate", "*accounts", "*attributes", "*continue"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceTerminateEmulate", + "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"], + "flags": ["*terminate", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"}, + {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", + "value": "0s", "mandatory": true}, + {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true} + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true}, + {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"}, + ], + }, + { + "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "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", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*cc_usage", + "mandatory": true, + "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m" + }, + { + "tag": "LastUsed", + "path": "*cgreq.LastUsed", + "type": "*variable", + "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/diamagent_mysql_jsonbirpc/wrong_template.json b/data/conf/samples/diamagent_mysql_jsonbirpc/wrong_template.json new file mode 100644 index 000000000..8fd1b6cd7 --- /dev/null +++ b/data/conf/samples/diamagent_mysql_jsonbirpc/wrong_template.json @@ -0,0 +1,103 @@ +{ + + +"diameter_agent": { + "request_processors": [ + { // this request proccessor is only used to test that an error message + // is sent if one is raised when proccesing the request + "id": "ErrorProcessing", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:4", + "*prefix:~*req.Service-Context-Id:error" + ], + "flags": ["*event", "*accounts"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*sms" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "sms" + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*prepaid" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*variable", + "mandatory": true, + "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "mandatory": true, + "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data" + }, + { + "tag": "SetupTime", + "path": "*cgreq.SetupTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time", + "mandatory": true + }, + ], + "reply_fields":[ + {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, + { + "tag": "GrantedUnitsError", + "path": "*rep.Granted-Service-Unit.CC-Total", // this should return a error because it expect an unsigned integer + "type": "*constant", "blocker": true, + "value": "-10" + }, + { + "tag": "ResultCode","path": "*rep.Result-Code", + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], + "type": "*constant", "value": "4012", + "blocker": true + }, + { + "tag": "ResultCode", "path": "*rep.Result-Code", + "filters": ["*notempty:~*cgrep.Error:"], + "type": "*constant", "value": "5030", + "blocker": true + } + ] + } + + ] +} + +} \ No newline at end of file diff --git a/engine/connmanager.go b/engine/connmanager.go index c54762072..ecf180148 100644 --- a/engine/connmanager.go +++ b/engine/connmanager.go @@ -107,9 +107,7 @@ func (cM *ConnManager) getConn(connID string, biRPCClient rpcclient.BiRPCConecto } if biRPCClient != nil { for _, c := range connCfg.Conns { - if c.Transport == rpcclient.BiRPCGOB || - c.Transport == rpcclient.BiRPCJSON || - c.Address == rpcclient.BiRPCInternal { + if c.Address == rpcclient.BiRPCInternal { // register only on internal var rply string if err = conn.Call(utils.SessionSv1RegisterInternalBiJSONConn, connID, &rply); err != nil { diff --git a/go.mod b/go.mod index 277c5e608..c01bc044b 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 // replace github.com/cgrates/radigo => ../radigo -replace github.com/cgrates/rpcclient => ../rpcclient +// replace github.com/cgrates/rpcclient => ../rpcclient require ( cloud.google.com/go v0.75.0 // indirect @@ -22,7 +22,7 @@ require ( github.com/cgrates/kamevapi v0.0.0-20191001125829-7dbc3ad58817 github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca github.com/cgrates/radigo v0.0.0-20201113143731-162035428d72 - github.com/cgrates/rpcclient v0.0.0-00010101000000-000000000000 + github.com/cgrates/rpcclient v0.0.0-20210218104959-cc39fa26221e github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e github.com/cgrates/ugocodec v0.0.0-20201023092048-df93d0123f60 github.com/creack/pty v1.1.11 diff --git a/go.sum b/go.sum index 3cf7e7a27..fd12f4b71 100644 --- a/go.sum +++ b/go.sum @@ -103,6 +103,8 @@ github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca h1:Ejj4m0Ccl8dMMVn github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca/go.mod h1:q7c996DUu8OrJRnewVSQzM+y/bRcxZAHoo+zCD8bFBo= github.com/cgrates/radigo v0.0.0-20201113143731-162035428d72 h1:cTAWQEbab3gKkDSeaxkTaoiP/cNFx+7/kC96wYckk3g= github.com/cgrates/radigo v0.0.0-20201113143731-162035428d72/go.mod h1:3IDSbfIqU5VsYKjrwa3HhuAK1jlI65wa1coHetoaN20= +github.com/cgrates/rpcclient v0.0.0-20210218104959-cc39fa26221e h1:OhIDLqNfNx9n64DAZhqIsJsWh8KXrZmvpwUg3WDmPww= +github.com/cgrates/rpcclient v0.0.0-20210218104959-cc39fa26221e/go.mod h1:1lZpAp/cwSuf9Kt+ZSd3hgCt/7E1z3dx5GwkdlgKBTI= github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e h1:izFjZB83/XRXInc+gMIssUxdbleGsGIuGCPj2u7RQo0= github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e/go.mod h1:0f2+3dq5Iiv3VlcuY83VPJ0QzqRlzDG1Cr8okogQE3g= github.com/cgrates/ugocodec v0.0.0-20201023092048-df93d0123f60 h1:TQDg+HGB17LU8FitLiLvYazYSy62GQ1lO3lGKI3xUrU= diff --git a/sessions/sessions.go b/sessions/sessions.go index b6ebdee75..b74d12efc 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1888,12 +1888,23 @@ func (args *V1AuthorizeArgs) ParseFlags(flags string) { // V1AuthorizeReply are options available in auth reply type V1AuthorizeReply struct { - Attributes *engine.AttrSProcessEventReply - ResourceAllocation *string - MaxUsage *time.Duration - Routes *engine.SortedRoutes - ThresholdIDs *[]string - StatQueueIDs *[]string + Attributes *engine.AttrSProcessEventReply `json:",omitempty"` + ResourceAllocation *string `json:",omitempty"` + MaxUsage *time.Duration `json:",omitempty"` + Routes *engine.SortedRoutes `json:",omitempty"` + ThresholdIDs *[]string `json:",omitempty"` + StatQueueIDs *[]string `json:",omitempty"` + + needsMaxUsage bool // for gob encoding only +} + +// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper +// only used for gob encoding +func (v1AuthReply *V1AuthorizeReply) SetMaxUsageNeeded(getMaxUsage bool) { + if v1AuthReply == nil { + return + } + v1AuthReply.needsMaxUsage = getMaxUsage } // AsNavigableMap is part of engine.NavigableMapper interface @@ -1914,7 +1925,10 @@ func (v1AuthReply *V1AuthorizeReply) AsNavigableMap() utils.NavigableMap2 { } if v1AuthReply.MaxUsage != nil { cgrReply[utils.CapMaxUsage] = utils.NewNMData(*v1AuthReply.MaxUsage) + } else if v1AuthReply.needsMaxUsage { + cgrReply[utils.CapMaxUsage] = utils.NewNMData(0) } + if v1AuthReply.Routes != nil { cgrReply[utils.CapRoutes] = v1AuthReply.Routes.AsNavigableMap() } @@ -2160,11 +2174,22 @@ func (args *V1InitSessionArgs) ParseFlags(flags string) { // V1InitSessionReply are options for initialization reply type V1InitSessionReply struct { - Attributes *engine.AttrSProcessEventReply - ResourceAllocation *string - MaxUsage *time.Duration - ThresholdIDs *[]string - StatQueueIDs *[]string + Attributes *engine.AttrSProcessEventReply `json:",omitempty"` + ResourceAllocation *string `json:",omitempty"` + MaxUsage *time.Duration `json:",omitempty"` + ThresholdIDs *[]string `json:",omitempty"` + StatQueueIDs *[]string `json:",omitempty"` + + needsMaxUsage bool // for gob encoding only +} + +// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper +// only used for gob encoding +func (v1Rply *V1InitSessionReply) SetMaxUsageNeeded(getMaxUsage bool) { + if v1Rply == nil { + return + } + v1Rply.needsMaxUsage = getMaxUsage } // AsNavigableMap is part of engine.NavigableMapper interface @@ -2185,6 +2210,8 @@ func (v1Rply *V1InitSessionReply) AsNavigableMap() utils.NavigableMap2 { } if v1Rply.MaxUsage != nil { cgrReply[utils.CapMaxUsage] = utils.NewNMData(*v1Rply.MaxUsage) + } else if v1Rply.needsMaxUsage { + cgrReply[utils.CapMaxUsage] = utils.NewNMData(0) } if v1Rply.ThresholdIDs != nil { @@ -2403,8 +2430,19 @@ type V1UpdateSessionArgs struct { // V1UpdateSessionReply contains options for session update reply type V1UpdateSessionReply struct { - Attributes *engine.AttrSProcessEventReply - MaxUsage *time.Duration + Attributes *engine.AttrSProcessEventReply `json:",omitempty"` + MaxUsage *time.Duration `json:",omitempty"` + + needsMaxUsage bool // for gob encoding only +} + +// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper +// only used for gob encoding +func (v1Rply *V1UpdateSessionReply) SetMaxUsageNeeded(getMaxUsage bool) { + if v1Rply == nil { + return + } + v1Rply.needsMaxUsage = getMaxUsage } // AsNavigableMap is part of engine.NavigableMapper interface @@ -2422,6 +2460,8 @@ func (v1Rply *V1UpdateSessionReply) AsNavigableMap() utils.NavigableMap2 { } if v1Rply.MaxUsage != nil { cgrReply[utils.CapMaxUsage] = utils.NewNMData(*v1Rply.MaxUsage) + } else if v1Rply.needsMaxUsage { + cgrReply[utils.CapMaxUsage] = utils.NewNMData(0) } return cgrReply } @@ -2819,12 +2859,23 @@ func (args *V1ProcessMessageArgs) ParseFlags(flags string) { // V1ProcessMessageReply is the reply for the ProcessMessage API type V1ProcessMessageReply struct { - MaxUsage *time.Duration - ResourceAllocation *string - Attributes *engine.AttrSProcessEventReply - Routes *engine.SortedRoutes - ThresholdIDs *[]string - StatQueueIDs *[]string + MaxUsage *time.Duration `json:",omitempty"` + ResourceAllocation *string `json:",omitempty"` + Attributes *engine.AttrSProcessEventReply `json:",omitempty"` + Routes *engine.SortedRoutes `json:",omitempty"` + ThresholdIDs *[]string `json:",omitempty"` + StatQueueIDs *[]string `json:",omitempty"` + + needsMaxUsage bool // for gob encoding only +} + +// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper +// only used for gob encoding +func (v1Rply *V1ProcessMessageReply) SetMaxUsageNeeded(getMaxUsage bool) { + if v1Rply == nil { + return + } + v1Rply.needsMaxUsage = getMaxUsage } // AsNavigableMap is part of engine.NavigableMapper interface @@ -2832,6 +2883,8 @@ func (v1Rply *V1ProcessMessageReply) AsNavigableMap() utils.NavigableMap2 { cgrReply := make(utils.NavigableMap2) if v1Rply.MaxUsage != nil { cgrReply[utils.CapMaxUsage] = utils.NewNMData(*v1Rply.MaxUsage) + } else if v1Rply.needsMaxUsage { + cgrReply[utils.CapMaxUsage] = utils.NewNMData(0) } if v1Rply.ResourceAllocation != nil { cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation) @@ -4066,35 +4119,80 @@ func (sS *SessionS) BiRPCv1STIRIdentity(clnt rpcclient.ClientConnector, // Handlers bidirectional methods following func (sS *SessionS) Handlers() map[string]interface{} { return map[string]interface{}{ - utils.SessionSv1GetActiveSessions: sS.BiRPCv1GetActiveSessions, - utils.SessionSv1GetActiveSessionsCount: sS.BiRPCv1GetActiveSessionsCount, - utils.SessionSv1GetPassiveSessions: sS.BiRPCv1GetPassiveSessions, - utils.SessionSv1GetPassiveSessionsCount: sS.BiRPCv1GetPassiveSessionsCount, - - utils.SessionSv1AuthorizeEvent: sS.BiRPCv1AuthorizeEvent, - utils.SessionSv1AuthorizeEventWithDigest: sS.BiRPCv1AuthorizeEventWithDigest, - utils.SessionSv1InitiateSession: sS.BiRPCv1InitiateSession, - utils.SessionSv1InitiateSessionWithDigest: sS.BiRPCv1InitiateSessionWithDigest, - utils.SessionSv1UpdateSession: sS.BiRPCv1UpdateSession, - utils.SessionSv1SyncSessions: sS.BiRPCv1SyncSessions, - utils.SessionSv1TerminateSession: sS.BiRPCv1TerminateSession, - utils.SessionSv1ProcessCDR: sS.BiRPCv1ProcessCDR, - utils.SessionSv1ProcessMessage: sS.BiRPCv1ProcessMessage, - utils.SessionSv1ProcessEvent: sS.BiRPCv1ProcessEvent, - utils.SessionSv1GetCost: sS.BiRPCv1GetCost, - - utils.SessionSv1ForceDisconnect: sS.BiRPCv1ForceDisconnect, - utils.SessionSv1RegisterInternalBiJSONConn: sS.BiRPCv1RegisterInternalBiJSONConn, - - utils.SessionSv1ReplicateSessions: sS.BiRPCv1ReplicateSessions, - utils.SessionSv1SetPassiveSession: sS.BiRPCv1SetPassiveSession, - utils.SessionSv1ActivateSessions: sS.BiRPCv1ActivateSessions, - utils.SessionSv1DeactivateSessions: sS.BiRPCv1DeactivateSessions, - - utils.SessionSv1ReAuthorize: sS.BiRPCv1ReAuthorize, - utils.SessionSv1DisconnectPeer: sS.BiRPCv1DisconnectPeer, - - utils.SessionSv1STIRAuthenticate: sS.BiRPCv1STIRAuthenticate, - utils.SessionSv1STIRIdentity: sS.BiRPCv1STIRIdentity, + utils.SessionSv1AuthorizeEvent: func(clnt *rpc2.Client, args *V1AuthorizeArgs, rply *V1AuthorizeReply) (err error) { + return sS.BiRPCv1AuthorizeEvent(clnt, args, rply) + }, + utils.SessionSv1AuthorizeEventWithDigest: func(clnt *rpc2.Client, args *V1AuthorizeArgs, rply *V1AuthorizeReplyWithDigest) (err error) { + return sS.BiRPCv1AuthorizeEventWithDigest(clnt, args, rply) + }, + utils.SessionSv1InitiateSession: func(clnt *rpc2.Client, args *V1InitSessionArgs, rply *V1InitSessionReply) (err error) { + return sS.BiRPCv1InitiateSession(clnt, args, rply) + }, + utils.SessionSv1InitiateSessionWithDigest: func(clnt *rpc2.Client, args *V1InitSessionArgs, rply *V1InitReplyWithDigest) (err error) { + return sS.BiRPCv1InitiateSessionWithDigest(clnt, args, rply) + }, + utils.SessionSv1UpdateSession: func(clnt *rpc2.Client, args *V1UpdateSessionArgs, rply *V1UpdateSessionReply) (err error) { + return sS.BiRPCv1UpdateSession(clnt, args, rply) + }, + utils.SessionSv1SyncSessions: func(clnt *rpc2.Client, args *utils.TenantWithOpts, rply *string) (err error) { + return sS.BiRPCv1SyncSessions(clnt, args, rply) + }, + utils.SessionSv1TerminateSession: func(clnt *rpc2.Client, args *V1TerminateSessionArgs, rply *string) (err error) { + return sS.BiRPCv1TerminateSession(clnt, args, rply) + }, + utils.SessionSv1ProcessCDR: func(clnt *rpc2.Client, args *utils.CGREvent, rply *string) (err error) { + return sS.BiRPCv1ProcessCDR(clnt, args, rply) + }, + utils.SessionSv1ProcessMessage: func(clnt *rpc2.Client, args *V1ProcessMessageArgs, rply *V1ProcessMessageReply) (err error) { + return sS.BiRPCv1ProcessMessage(clnt, args, rply) + }, + utils.SessionSv1ProcessEvent: func(clnt *rpc2.Client, args *V1ProcessEventArgs, rply *V1ProcessEventReply) (err error) { + return sS.BiRPCv1ProcessEvent(clnt, args, rply) + }, + utils.SessionSv1GetCost: func(clnt *rpc2.Client, args *V1ProcessEventArgs, rply *V1GetCostReply) (err error) { + return sS.BiRPCv1GetCost(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessions: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *[]*ExternalSession) (err error) { + return sS.BiRPCv1GetActiveSessions(clnt, args, rply) + }, + utils.SessionSv1GetActiveSessionsCount: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *int) (err error) { + return sS.BiRPCv1GetActiveSessionsCount(clnt, args, rply) + }, + utils.SessionSv1GetPassiveSessions: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *[]*ExternalSession) (err error) { + return sS.BiRPCv1GetPassiveSessions(clnt, args, rply) + }, + utils.SessionSv1GetPassiveSessionsCount: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *int) (err error) { + return sS.BiRPCv1GetPassiveSessionsCount(clnt, args, rply) + }, + utils.SessionSv1ForceDisconnect: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *string) (err error) { + return sS.BiRPCv1ForceDisconnect(clnt, args, rply) + }, + utils.SessionSv1RegisterInternalBiJSONConn: func(clnt *rpc2.Client, args string, rply *string) (err error) { + return sS.BiRPCv1RegisterInternalBiJSONConn(clnt, args, rply) + }, + utils.SessionSv1ReplicateSessions: func(clnt *rpc2.Client, args ArgsReplicateSessions, rply *string) (err error) { + return sS.BiRPCv1ReplicateSessions(clnt, args, rply) + }, + utils.SessionSv1SetPassiveSession: func(clnt *rpc2.Client, args *Session, rply *string) (err error) { + return sS.BiRPCv1SetPassiveSession(clnt, args, rply) + }, + utils.SessionSv1ActivateSessions: func(clnt *rpc2.Client, args *utils.SessionIDsWithArgsDispatcher, rply *string) (err error) { + return sS.BiRPCv1ActivateSessions(clnt, args, rply) + }, + utils.SessionSv1DeactivateSessions: func(clnt *rpc2.Client, args *utils.SessionIDsWithArgsDispatcher, rply *string) (err error) { + return sS.BiRPCv1DeactivateSessions(clnt, args, rply) + }, + utils.SessionSv1ReAuthorize: func(clnt *rpc2.Client, args *utils.SessionFilter, rply *string) (err error) { + return sS.BiRPCv1ReAuthorize(clnt, args, rply) + }, + utils.SessionSv1DisconnectPeer: func(clnt *rpc2.Client, args *utils.DPRArgs, rply *string) (err error) { + return sS.BiRPCv1DisconnectPeer(clnt, args, rply) + }, + utils.SessionSv1STIRAuthenticate: func(clnt *rpc2.Client, args *V1STIRAuthenticateArgs, rply *string) (err error) { + return sS.BiRPCv1STIRAuthenticate(clnt, args, rply) + }, + utils.SessionSv1STIRIdentity: func(clnt *rpc2.Client, args *V1STIRIdentityArgs, rply *string) (err error) { + return sS.BiRPCv1STIRIdentity(clnt, args, rply) + }, } }