diff --git a/internal/context/gsm_build.go b/internal/context/gsm_build.go index 44e9396..fb56534 100644 --- a/internal/context/gsm_build.go +++ b/internal/context/gsm_build.go @@ -38,7 +38,7 @@ func BuildGSMPDUSessionEstablishmentAccept(smContext *SMContext) ([]byte, error) qoSRules := nasType.QoSRules{ { - Identifier: 0x01, + Identifier: smContext.defRuleID, DQR: true, Operation: nasType.OperationCodeCreateNewQoSRule, Precedence: 255, diff --git a/internal/context/sm_context.go b/internal/context/sm_context.go index c97c8f1..9a115d7 100644 --- a/internal/context/sm_context.go +++ b/internal/context/sm_context.go @@ -182,6 +182,7 @@ type SMContext struct { SelectedSessionRuleID string // QoS + defRuleID uint8 QoSRuleIDGenerator *idgenerator.IDGenerator PacketFilterIDGenerator *idgenerator.IDGenerator QFIGenerator *idgenerator.IDGenerator @@ -299,6 +300,12 @@ func NewSMContext(id string, pduSessID int32) *SMContext { smContext.Tunnel = NewUPTunnel() smContext.QoSRuleIDGenerator = idgenerator.NewGenerator(1, 255) + if defRuleID, err := smContext.QoSRuleIDGenerator.Allocate(); err != nil { + logger.CtxLog.Warnln("Create Default QoS rule error ", err) + } else { + smContext.defRuleID = uint8(defRuleID) + } + smContext.PacketFilterIDGenerator = idgenerator.NewGenerator(1, 255) smContext.QFIGenerator = idgenerator.NewGenerator(2, 63) // 1 always reserve for default Qos smContext.PCCRuleIDToQoSRuleID = make(map[string]uint8)