diff --git a/internal/context/context.go b/internal/context/context.go index 3da5ecb4..154b997a 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -87,8 +87,10 @@ type SMFContext struct { } func GenerateChargingID() int32 { - if id, err := smfContext.ChargingIDGenerator.Allocate(); err == nil { - return int32(id) + if smfContext.ChargingIDGenerator != nil { + if id, err := smfContext.ChargingIDGenerator.Allocate(); err == nil { + return int32(id) + } } return 0 } diff --git a/internal/context/sm_context.go b/internal/context/sm_context.go index e520d1b8..62aee29e 100644 --- a/internal/context/sm_context.go +++ b/internal/context/sm_context.go @@ -324,7 +324,8 @@ func NewSMContext(id string, pduSessID int32) *SMContext { smContext.ChargingInfo = make(map[uint32]*ChargingInfo) smContext.ChargingID = GenerateChargingID() - if factory.SmfConfig.Configuration != nil { + if factory.SmfConfig != nil && + factory.SmfConfig.Configuration != nil { smContext.UrrReportTime = time.Duration(factory.SmfConfig.Configuration.UrrPeriod) * time.Second smContext.UrrReportThreshold = factory.SmfConfig.Configuration.UrrThreshold logger.CtxLog.Infof("UrrPeriod: %v", smContext.UrrReportTime) diff --git a/internal/context/sm_context_policy_test.go b/internal/context/sm_context_policy_test.go index a43d3f64..b688b8fd 100644 --- a/internal/context/sm_context_policy_test.go +++ b/internal/context/sm_context_policy_test.go @@ -671,6 +671,12 @@ func TestApplyPccRules(t *testing.T) { }, } smctx.SelectedSessionRuleID = "SessRuleId-1" + smctx.DnnConfiguration = models.DnnConfiguration{ + SessionAmbr: &models.Ambr{ + Uplink: "1 Gbps", + Downlink: "1 Gbps", + }, + } err := smctx.AllocUeIP() require.NoError(t, err) err = smctx.SelectDefaultDataPath()