mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added disconnect_method config for diameter agent
This commit is contained in:
committed by
Dan Christian Bogos
parent
2a5a54127b
commit
d4fc68c86b
@@ -441,11 +441,29 @@ func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r
|
||||
utils.DiameterAgent, utils.ToJSON(args.EventStart)))
|
||||
return utils.ErrMandatoryIeMissing
|
||||
}
|
||||
msg, has := engine.Cache.Get(utils.CacheDiameterMessages, ssID.(string))
|
||||
originID := ssID.(string)
|
||||
switch da.cgrCfg.DiameterAgentCfg().DisconnectMethod {
|
||||
case utils.MetaASR:
|
||||
return da.sendASR(originID, reply)
|
||||
case utils.MetaRAR:
|
||||
return da.V1SendRAR(originID, reply)
|
||||
default:
|
||||
return fmt.Errorf("Unsupported request type <%s>", da.cgrCfg.DiameterAgentCfg().DisconnectMethod)
|
||||
}
|
||||
}
|
||||
|
||||
// V1GetActiveSessionIDs is part of the sessions.BiRPClient
|
||||
func (da *DiameterAgent) V1GetActiveSessionIDs(ignParam string,
|
||||
sessionIDs *[]*sessions.SessionID) error {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (da *DiameterAgent) sendASR(originID string, reply *string) (err error) {
|
||||
msg, has := engine.Cache.Get(utils.CacheDiameterMessages, originID)
|
||||
if !has {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<%s> cannot retrieve message from cache with OriginID: <%s>",
|
||||
utils.DiameterAgent, ssID))
|
||||
utils.DiameterAgent, originID))
|
||||
return utils.ErrMandatoryIeMissing
|
||||
}
|
||||
dmd := msg.(*diamMsgData)
|
||||
@@ -460,7 +478,7 @@ func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r
|
||||
if err = aReq.SetFields(da.cgrCfg.DiameterAgentCfg().Templates[da.cgrCfg.DiameterAgentCfg().ASRTemplate]); err != nil {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<%s> cannot disconnect session with OriginID: <%s>, err: %s",
|
||||
utils.DiameterAgent, ssID, err.Error()))
|
||||
utils.DiameterAgent, originID, err.Error()))
|
||||
return utils.ErrServerError
|
||||
}
|
||||
m := diam.NewRequest(dmd.m.Header.CommandCode,
|
||||
@@ -469,7 +487,7 @@ func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r
|
||||
da.cgrCfg.GeneralCfg().DefaultTimezone); err != nil {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<%s> cannot disconnect session with OriginID: <%s>, err: %s",
|
||||
utils.DiameterAgent, ssID, err.Error()))
|
||||
utils.DiameterAgent, originID, err.Error()))
|
||||
return utils.ErrServerError
|
||||
}
|
||||
if err = writeOnConn(dmd.c, m); err != nil {
|
||||
@@ -479,12 +497,6 @@ func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r
|
||||
return
|
||||
}
|
||||
|
||||
// V1GetActiveSessionIDs is part of the sessions.BiRPClient
|
||||
func (da *DiameterAgent) V1GetActiveSessionIDs(ignParam string,
|
||||
sessionIDs *[]*sessions.SessionID) error {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// V1SendRAR sends a rar meseage to diameter client
|
||||
func (da *DiameterAgent) V1SendRAR(originID string, reply *string) (err error) {
|
||||
if originID == "" {
|
||||
|
||||
@@ -415,7 +415,8 @@ const CGRATES_CFG_JSON = `
|
||||
"concurrent_requests": -1, // limit the number of active requests processed by the server <-1|0-n>
|
||||
"synced_conn_requests": false, // process one request at the time per connection
|
||||
"asr_template": "", // enable AbortSession message being sent to client on DisconnectSession
|
||||
"rar_template": "", // for building the RAR
|
||||
"rar_template": "", // template used to build the Re-Auth-Request
|
||||
"disconnect_method": "*asr", // the request to send to diameter on DisconnectSession <*asr|*rar>
|
||||
"templates":{ // default message templates
|
||||
"*err": [
|
||||
{"tag": "SessionId", "path": "*rep.Session-Id", "type": "*variable",
|
||||
|
||||
@@ -757,6 +757,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
|
||||
Synced_conn_requests: utils.BoolPointer(false),
|
||||
Asr_template: utils.StringPointer(""),
|
||||
Rar_template: utils.StringPointer(""),
|
||||
Disconnect_method: utils.StringPointer(utils.MetaASR),
|
||||
Templates: map[string][]*FcTemplateJsonCfg{
|
||||
utils.MetaErr: {
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ type DiameterAgentCfg struct {
|
||||
SyncedConnReqs bool
|
||||
ASRTemplate string
|
||||
RARTemplate string
|
||||
DisconnectMethod string
|
||||
Templates map[string][]*FCTemplate
|
||||
RequestProcessors []*RequestProcessor
|
||||
}
|
||||
@@ -89,6 +90,9 @@ func (da *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg, separa
|
||||
if jsnCfg.Rar_template != nil {
|
||||
da.RARTemplate = *jsnCfg.Rar_template
|
||||
}
|
||||
if jsnCfg.Disconnect_method != nil {
|
||||
da.DisconnectMethod = *jsnCfg.Disconnect_method
|
||||
}
|
||||
if jsnCfg.Templates != nil {
|
||||
if da.Templates == nil {
|
||||
da.Templates = make(map[string][]*FCTemplate)
|
||||
|
||||
@@ -314,6 +314,7 @@ type DiameterAgentJsonCfg struct {
|
||||
Synced_conn_requests *bool
|
||||
Asr_template *string
|
||||
Rar_template *string
|
||||
Disconnect_method *string
|
||||
Templates map[string][]*FcTemplateJsonCfg
|
||||
Request_processors *[]*ReqProcessorJsnCfg
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium
|
||||
DataDB/StorDB
|
||||
* [Migrator] Auto discover tenant from key instead of taking it from config
|
||||
* [Templates] Fixed missing "*" for strip and pading strategy
|
||||
* [DiameterAgent] Added RAR support
|
||||
|
||||
-- Alexandru Tripon <alexandru.tripon@itsyscom.com> Wed, 19 Feb 2020 13:25:52 +0200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user