Skip to content

Commit

Permalink
Feature/cfg update cmd (#105)
Browse files Browse the repository at this point in the history
* Add IE, universal time, in the configuration update command message:
* Add TimeZone field in the AMFContext.

* Fix bug: the format of time zone is wrong

* Modify BuildConfigurationUpdateCommand

* Update go module

* Modify the BuildConfigurationUpdateCommand and SendConfigurationUpdateCommand functions:
* Enhance the generality of the BuildConfigurationUpdateCommand function.
* Decouple the BuildConfigurationUpdateCommand from the SendConfigurationUpdateCommand, enabling finer customization of the Configuration Update Command message.
* Add T3555 timer for retransmission of CONFIGURATION UPDATE COMMAND message.
* Leave two TODOs in AmPolicyControlUpdateNotifyUpdateProcedure function.

* Modify coding style

* Stop T3555 timer in HandleConfigurationUpdateComplete function

* Modify BuildConfigurationUpdateCommand
* Reduce the number of parameters.
* AmPolicyControlUpdateNotifyUpdateProcedure keeps its original functionality with the configurationUpdateCommandFlags.

* Modify BuildConfigurationUpdateCommand
* Show some warning message while the required argument is nothing.
* Check the Configuration Update Command message if is valid.

* Modify SendConfigurationUpdateCommand
* Add ConfigurationUpdateCommandFlags parameter to control how to build the Configuration Update Command message.
* Determine whether to start the T3555 timer or not in the SendConfigurationUpdateCommand.

* Modify SendConfigurationUpdateCommand
* Add the missing return.

* Modify BuildConfigurationUpdateCommand and SendConfigurationUpdateCommand

* Fix bug: the original getTimeZone function was wrong
* Aggregate the same function into nasConvert.GetTimeZone

* Update go module

* Modify BuildConfigurationUpdateCommand
* Remove the parameter NetworkSlicingIndication

* Modify AmfUe structure
* Replace ConfigurationUpdateMessage by ConfigurationUpdateCommandFlags
* Modify HandleServiceRequest
  • Loading branch information
YouShengLiu authored Sep 12, 2023
1 parent 7de97a6 commit e4d31e8
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 147 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/davecgh/go-spew v1.1.1
github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582
github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e
github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828
github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f
github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 h1:IV9PXKo6MH62e7nngSqr+cwjuoffkouPMmyX3jHC9Ds=
github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4=
github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e h1:M2vWqCRQKa8hgJzbJkPrswFEe8lJoRTD/CmMwbJoW+Q=
github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU=
github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828 h1:/gIlzF8hacxWa6hsx+HQlw9F8yEorTvZvS1VR5Iwpjc=
github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU=
github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f h1:wgXjoknZ7JJoZ72J15g/f2/0DgdCpfcTg189lnhUPuY=
github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM3CGEBhZVxkGGJIkai5+Bvy2yHIMhb7Vx/k=
github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI=
Expand Down
79 changes: 59 additions & 20 deletions internal/context/amf_ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ type AmfUe struct {
/* Used for AMF relocation */
TargetAmfProfile *models.NfProfile
TargetAmfUri string
/* Ue Identity*/
PlmnId models.PlmnId
Suci string
Supi string
UnauthenticatedSupi bool
Gpsi string
Pei string
Tmsi int32 // 5G-Tmsi
Guti string
GroupID string
EBI int32
/* Ue Identity*/
/* Ue Identity */
PlmnId models.PlmnId
Suci string
Supi string
UnauthenticatedSupi bool
Gpsi string
Pei string
Tmsi int32 // 5G-Tmsi
Guti string
GroupID string
EBI int32
EventSubscriptionsInfo map[string]*AmfUeEventSubscription
/* User Location*/
/* User Location */
RatType models.RatType
Location models.UserLocation
Tai models.Tai
Expand Down Expand Up @@ -122,8 +121,7 @@ type AmfUe struct {
AmPolicyUri string
AmPolicyAssociation *models.PolicyAssociation
RequestTriggerLocationChange bool // true if AmPolicyAssociation.Trigger contains RequestTrigger_LOC_CH
ConfigurationUpdateMessage []byte
/* UeContextForHandover*/
/* UeContextForHandover */
HandoverNotifyUri string
/* N1N2Message */
N1N2MessageIDGenerator *idgenerator.IDGenerator
Expand All @@ -133,13 +131,14 @@ type AmfUe struct {
N1N2MessageSubscription sync.Map
/* Pdu Sesseion context */
SmContextList sync.Map // map[int32]*SmContext, pdu session id as key
/* Related Context*/
/* Related Context */
RanUe map[models.AccessType]*RanUe
/* other */
onGoing map[models.AccessType]*OnGoing
UeRadioCapability string // OCTET string
Capability5GMM nasType.Capability5GMM
ConfigurationUpdateIndication nasType.ConfigurationUpdateIndication
onGoing map[models.AccessType]*OnGoing
UeRadioCapability string // OCTET string
Capability5GMM nasType.Capability5GMM
ConfigurationUpdateIndication nasType.ConfigurationUpdateIndication
ConfigurationUpdateCommandFlags *ConfigurationUpdateCommandFlags
/* context related to Paging */
UeRadioCapabilityForPaging *UERadioCapabilityForPaging
InfoOnRecommendedCellsAndRanNodesForPaging *InfoOnRecommendedCellsAndRanNodesForPaging
Expand Down Expand Up @@ -183,6 +182,8 @@ type AmfUe struct {
T3522 *Timer
/* T3570 (for identity request) */
T3570 *Timer
/* T3555 (for configuration update command) */
T3555 *Timer
/* Ue Context Release Cause */
ReleaseCause map[models.AccessType]*CauseAll
/* T3502 (Assigned by AMF, and used by UE to initialize registration procedure) */
Expand Down Expand Up @@ -245,6 +246,22 @@ type NGRANCGI struct {
EUTRACGI *models.Ecgi
}

// TS 24.501 8.2.19
type ConfigurationUpdateCommandFlags struct {
NeedGUTI bool
NeedNITZ bool
NeedTaiList bool
NeedRejectNSSAI bool
NeedAllowedNSSAI bool
NeedSmsIndication bool
NeedMicoIndication bool
NeedLadnInformation bool
NeedServiceAreaList bool
NeedConfiguredNSSAI bool
NeedNetworkSlicingIndication bool
NeedOperatordefinedAccessCategoryDefinitions bool
}

func (ue *AmfUe) init() {
ue.servingAMF = GetSelf()
ue.State = make(map[models.AccessType]*fsm.State)
Expand Down Expand Up @@ -290,6 +307,8 @@ func (ue *AmfUe) Remove() {
ue.StopT3560()
ue.StopT3550()
ue.StopT3522()
ue.StopT3570()
ue.StopT3555()

for _, ranUe := range ue.RanUe {
if err := ranUe.Remove(); err != nil {
Expand Down Expand Up @@ -889,3 +908,23 @@ func (ue *AmfUe) StopT3522() {
ue.T3522.Stop()
ue.T3522 = nil // clear the timer
}

func (ue *AmfUe) StopT3570() {
if ue.T3570 == nil {
return
}

ue.GmmLog.Infof("Stop T3570 timer")
ue.T3570.Stop()
ue.T3570 = nil // clear the timer
}

func (ue *AmfUe) StopT3555() {
if ue.T3555 == nil {
return
}

ue.GmmLog.Infof("Stop T3555 timer")
ue.T3555.Stop()
ue.T3555 = nil // clear the timer
}
22 changes: 4 additions & 18 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/free5gc/amf/internal/logger"
"github.com/free5gc/amf/pkg/factory"
"github.com/free5gc/nas/nasConvert"
"github.com/free5gc/nas/security"
"github.com/free5gc/openapi"
"github.com/free5gc/openapi/models"
Expand Down Expand Up @@ -80,6 +81,7 @@ type AMFContext struct {
T3560Cfg factory.TimerValue
T3565Cfg factory.TimerValue
T3570Cfg factory.TimerValue
T3555Cfg factory.TimerValue
Locality string
}

Expand Down Expand Up @@ -130,7 +132,7 @@ func InitAmfContext(context *AMFContext) {
context.SecurityAlgorithm.CipheringOrder = getEncAlgOrder(security.CipheringOrder)
}
context.NetworkName = configuration.NetworkName
context.TimeZone = getTimeZone(time.Now())
context.TimeZone = nasConvert.GetTimeZone(time.Now())
context.T3502Value = configuration.T3502Value
context.T3512Value = configuration.T3512Value
context.Non3gppDeregTimerValue = configuration.Non3gppDeregTimerValue
Expand All @@ -140,26 +142,10 @@ func InitAmfContext(context *AMFContext) {
context.T3560Cfg = configuration.T3560
context.T3565Cfg = configuration.T3565
context.T3570Cfg = configuration.T3570
context.T3555Cfg = configuration.T3555
context.Locality = configuration.Locality
}

func getTimeZone(now time.Time) string {
timezone := ""
_, offset := now.Zone()
if offset < 0 {
timezone += "-"
offset = 0 - offset
} else {
timezone += "+"
}
timezone += fmt.Sprintf("%02d:%02d", offset/3600, (offset%3600)/60)
if now.IsDST() {
timezone += "+1"
}

return timezone
}

func getIntAlgOrder(integrityOrder []string) (intOrder []uint8) {
for _, intAlg := range integrityOrder {
switch intAlg {
Expand Down
4 changes: 4 additions & 0 deletions internal/gmm/common/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ func StopAll5GSMMTimers(ue *context.AmfUe) {
ue.T3570.Stop()
ue.T3570 = nil // clear the timer
}
if ue.T3555 != nil {
ue.T3555.Stop()
ue.T3555 = nil // clear the timer
}
}
17 changes: 11 additions & 6 deletions internal/gmm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,8 @@ func HandleConfigurationUpdateComplete(ue *context.AmfUe,
return fmt.Errorf("NAS message integrity check failed")
}

// TODO: Stop timer T3555 in TS 24.501 Figure 5.4.4.1.1 in handler
// Stop timer T3555 in TS 24.501 Figure 5.4.4.1.1 in handler
ue.StopT3555()
// TODO: Send acknowledgment by Nudm_SMD_Info_Service to UDM in handler
// import "github.com/free5gc/openapi/Nudm_SubscriberDataManagement" client.Info

Expand Down Expand Up @@ -1849,16 +1850,14 @@ func HandleServiceRequest(ue *context.AmfUe, anType models.AccessType,
}

// downlink signaling
if ue.ConfigurationUpdateMessage != nil {
if ue.ConfigurationUpdateCommandFlags != nil {
err := gmm_message.SendServiceAccept(ue, anType, cxtList,
pduStatusResult, reactivationResult, errPduSessionId, errCause)
if err != nil {
return err
}
mobilityRestrictionList := ngap_message.BuildIEMobilityRestrictionList(ue)
ngap_message.SendDownlinkNasTransport(ue.RanUe[models.AccessType__3_GPP_ACCESS],
ue.ConfigurationUpdateMessage, &mobilityRestrictionList)
ue.ConfigurationUpdateMessage = nil
gmm_message.SendConfigurationUpdateCommand(ue, anType, ue.ConfigurationUpdateCommandFlags)
ue.ConfigurationUpdateCommandFlags = nil
}
case nasMessage.ServiceTypeData:
if anType == models.AccessType__3_GPP_ACCESS {
Expand Down Expand Up @@ -2162,6 +2161,12 @@ func HandleRegistrationComplete(ue *context.AmfUe, accessType models.AccessType,
})
}

// Send NITZ information to UE
configurationUpdateCommandFlags := &context.ConfigurationUpdateCommandFlags{
NeedNITZ: true,
}
gmm_message.SendConfigurationUpdateCommand(ue, accessType, configurationUpdateCommandFlags)

// if registrationComplete.SORTransparentContainer != nil {
// TODO: if at regsitration procedure 14b, udm provide amf Steering of Roaming info & request an ack,
// AMF provides the UE's ack with Nudm_SDM_Info (SOR not supportted in this stage)
Expand Down
Loading

0 comments on commit e4d31e8

Please sign in to comment.