Added integration tests for birpc codec

This commit is contained in:
Trial97
2021-02-18 17:19:27 +02:00
committed by Dan Christian Bogos
parent 3afe8fc6a6
commit 9cef3b28f4
71 changed files with 9628 additions and 188 deletions

View File

@@ -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)
},
}
}

View File

@@ -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:

View File

@@ -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)
},
}
}

View File

@@ -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 {

View File

@@ -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)
},
}
}

View File

@@ -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()))
}
}

View File

@@ -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)
},
}
}

View File

@@ -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()

View File

@@ -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()))
}
}

View File

@@ -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
}

View File

@@ -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},

View File

@@ -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))
}
}

View File

@@ -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()
}

View File

@@ -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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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: <mysql|postgres>
"db_port": 27017, // the port to reach the stordb
"db_name": "datadb",
"db_password": "",
},
"stor_db": {
"db_type": "mongo", // stor database type to use: <mysql|postgres>
"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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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: <mysql|postgres>
"db_port": 27017, // the port to reach the stordb
"db_name": "datadb",
"db_password": "",
},
"stor_db": {
"db_type": "mongo", // stor database type to use: <mysql|postgres>
"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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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: <redis|mongo>
"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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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: <redis|mongo>
"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"],
},
}

View File

@@ -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"
},
],
},
]
}
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
},
],
},
],
},
}

View File

@@ -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"
},
],
},
],
},
}

View File

@@ -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
}
]
}
]
}
}

View File

@@ -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 {

4
go.mod
View File

@@ -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

2
go.sum
View File

@@ -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=

View File

@@ -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)
},
}
}