From 799103d1dcc9da2706da85d881d82f3ee4b49d7f Mon Sep 17 00:00:00 2001 From: YuSheng Date: Wed, 17 Jul 2024 09:09:34 +0000 Subject: [PATCH] fix(TWIF): handling choice extensions The choice extensions have three different cases (refer to TS 38.413 R17) not only TNGF case. --- internal/context/ran_ue.go | 79 ++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/internal/context/ran_ue.go b/internal/context/ran_ue.go index 198cbce..18cda8a 100644 --- a/internal/context/ran_ue.go +++ b/internal/context/ran_ue.go @@ -255,32 +255,69 @@ func (ranUe *RanUe) UpdateLocation(userLocationInformation *ngapType.UserLocatio ranUe.AmfUe.Tai = *ranUe.Location.N3gaLocation.N3gppTai } case ngapType.UserLocationInformationPresentChoiceExtensions: - userLocationInformationExtIEsValue := userLocationInformation. - ChoiceExtensions.UserLocationInformationExtIEs.Value.UserLocationInformationTNGF - if ranUe.Location.N3gaLocation == nil { - ranUe.Location.N3gaLocation = new(models.N3gaLocation) - } + switch userLocationInformation.ChoiceExtensions.UserLocationInformationExtIEs.Id.Value { + case ngapType.ProtocolIEIDUserLocationInformationTNGF: + // TNGF + userLocationInformationExtIEsValue := userLocationInformation. + ChoiceExtensions.UserLocationInformationExtIEs.Value.UserLocationInformationTNGF + if ranUe.Location.N3gaLocation == nil { + ranUe.Location.N3gaLocation = new(models.N3gaLocation) + } - ip := userLocationInformationExtIEsValue.IPAddress - // port := userLocationInformationExtIEsValue.PortNumber + ip := userLocationInformationExtIEsValue.IPAddress + // port := userLocationInformationExtIEsValue.PortNumber - ipv4Addr, ipv6Addr := ngapConvert.IPAddressToString(ip) + ipv4Addr, ipv6Addr := ngapConvert.IPAddressToString(ip) - ranUe.Location.N3gaLocation.UeIpv4Addr = ipv4Addr - ranUe.Location.N3gaLocation.UeIpv6Addr = ipv6Addr - // ranUe.Location.N3gaLocation.PortNumber = ngapConvert.PortNumberToInt(port) - // N3GPP TAI is operator-specific - // TODO: define N3GPP TAI - ranUe.Location.N3gaLocation.N3gppTai = &models.Tai{ - PlmnId: amfSelf.SupportTaiLists[0].PlmnId, - Tac: amfSelf.SupportTaiLists[0].Tac, - } - ranUe.Tai = deepcopy.Copy(*ranUe.Location.N3gaLocation.N3gppTai).(models.Tai) + ranUe.Location.N3gaLocation.UeIpv4Addr = ipv4Addr + ranUe.Location.N3gaLocation.UeIpv6Addr = ipv6Addr + // ranUe.Location.N3gaLocation.PortNumber = ngapConvert.PortNumberToInt(port) + // N3GPP TAI is operator-specific + // TODO: define N3GPP TAI + ranUe.Location.N3gaLocation.N3gppTai = &models.Tai{ + PlmnId: amfSelf.SupportTaiLists[0].PlmnId, + Tac: amfSelf.SupportTaiLists[0].Tac, + } + ranUe.Tai = deepcopy.Copy(*ranUe.Location.N3gaLocation.N3gppTai).(models.Tai) - if ranUe.AmfUe != nil { - ranUe.AmfUe.Location = deepcopy.Copy(ranUe.Location).(models.UserLocation) - ranUe.AmfUe.Tai = *ranUe.Location.N3gaLocation.N3gppTai + if ranUe.AmfUe != nil { + ranUe.AmfUe.Location = deepcopy.Copy(ranUe.Location).(models.UserLocation) + ranUe.AmfUe.Tai = *ranUe.Location.N3gaLocation.N3gppTai + } + case ngapType.ProtocolIEIDUserLocationInformationTWIF: + // TWIF + userLocationInformationExtIEsValue := userLocationInformation. + ChoiceExtensions.UserLocationInformationExtIEs.Value.UserLocationInformationTWIF + + if ranUe.Location.N3gaLocation == nil { + ranUe.Location.N3gaLocation = new(models.N3gaLocation) + } + + ip := userLocationInformationExtIEsValue.IPAddress + // port := userLocationInformationExtIEsValue.PortNumber + + ipv4Addr, ipv6Addr := ngapConvert.IPAddressToString(ip) + + ranUe.Location.N3gaLocation.UeIpv4Addr = ipv4Addr + ranUe.Location.N3gaLocation.UeIpv6Addr = ipv6Addr + // ranUe.Location.N3gaLocation.PortNumber = ngapConvert.PortNumberToInt(port) + // N3GPP TAI is operator-specific + // TODO: define N3GPP TAI + ranUe.Location.N3gaLocation.N3gppTai = &models.Tai{ + PlmnId: amfSelf.SupportTaiLists[0].PlmnId, + Tac: amfSelf.SupportTaiLists[0].Tac, + } + ranUe.Tai = deepcopy.Copy(*ranUe.Location.N3gaLocation.N3gppTai).(models.Tai) + + if ranUe.AmfUe != nil { + ranUe.AmfUe.Location = deepcopy.Copy(ranUe.Location).(models.UserLocation) + ranUe.AmfUe.Tai = *ranUe.Location.N3gaLocation.N3gppTai + } + + case ngapType.ProtocolIEIDUserLocationInformationWAGF: + // W-AGF } + case ngapType.UserLocationInformationPresentNothing: } }