Skip to content

Commit fb23ab1

Browse files
jeffjeff
authored andcommitted
fix: golangci-lint for ngap/handler.go, processor/ue_context.go
1 parent 003b729 commit fb23ab1

2 files changed

Lines changed: 136 additions & 134 deletions

File tree

internal/ngap/handler.go

Lines changed: 134 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,155 +1708,156 @@ func handleHandoverRequiredMain(ran *context.AmfRan,
17081708
return
17091709
// TODO: Send to T-AMF
17101710
// Described in (23.502 4.9.1.3.2) step 3.Namf_Communication_CreateUEContext Request
1711-
var ueContextCreateData models.UeContextCreateData
1712-
ueContextCreateData.UeContext.Supi = amfUe.Supi
1713-
ueContextCreateData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi
1714-
ueContextCreateData.UeContext.UdmGroupId = amfUe.UdmGroupId
1715-
ueContextCreateData.UeContext.AusfGroupId = amfUe.AusfGroupId
1716-
ueContextCreateData.UeContext.RestrictedPrimaryRatList[0] = amfUe.RatType
1717-
1718-
ueContextCreateData.TargetId.RanNodeId = &targetRanNodeId
1719-
ueContextCreateData.TargetId.Tai = &amfUe.Tai
1720-
1721-
ueContextCreateData.PduSessionList = make([]models.N2SmInformation, 0)
1722-
for _, pDUSessionResourceHoItem := range pDUSessionResourceListHORqd.List {
1723-
pduSessionID := int32(pDUSessionResourceHoItem.PDUSessionID.Value)
1724-
smContext, okSmContextFindByPDUSessionID := amfUe.SmContextFindByPDUSessionID(pduSessionID)
1725-
if !okSmContextFindByPDUSessionID {
1726-
sourceUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID)
1727-
// TODO: Check if doing error handling here
1728-
continue
1711+
/*
1712+
var ueContextCreateData models.UeContextCreateData
1713+
ueContextCreateData.UeContext.Supi = amfUe.Supi
1714+
ueContextCreateData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi
1715+
ueContextCreateData.UeContext.UdmGroupId = amfUe.UdmGroupId
1716+
ueContextCreateData.UeContext.AusfGroupId = amfUe.AusfGroupId
1717+
ueContextCreateData.UeContext.RestrictedPrimaryRatList[0] = amfUe.RatType
1718+
1719+
ueContextCreateData.TargetId.RanNodeId = &targetRanNodeId
1720+
ueContextCreateData.TargetId.Tai = &amfUe.Tai
1721+
1722+
ueContextCreateData.PduSessionList = make([]models.N2SmInformation, 0)
1723+
for _, pDUSessionResourceHoItem := range pDUSessionResourceListHORqd.List {
1724+
pduSessionID := int32(pDUSessionResourceHoItem.PDUSessionID.Value)
1725+
smContext, okSmContextFindByPDUSessionID := amfUe.SmContextFindByPDUSessionID(pduSessionID)
1726+
if !okSmContextFindByPDUSessionID {
1727+
sourceUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID)
1728+
// TODO: Check if doing error handling here
1729+
continue
1730+
}
1731+
snssai := smContext.Snssai()
1732+
ueContextCreateData.PduSessionList = append(ueContextCreateData.PduSessionList, models.N2SmInformation{
1733+
PduSessionId: pduSessionID,
1734+
SNssai: &snssai,
1735+
})
17291736
}
1730-
snssai := smContext.Snssai()
1731-
ueContextCreateData.PduSessionList = append(ueContextCreateData.PduSessionList, models.N2SmInformation{
1732-
PduSessionId: pduSessionID,
1733-
SNssai: &snssai,
1734-
})
1735-
}
17361737
1737-
ueContextCreateData.SourceToTargetData.NgapIeType = models.AmfCommunicationNgapIeType_HANDOVER_REQUIRED
1738-
ueContextCreateData.SourceToTargetData.NgapData.ContentId = "N2SmInfo"
1738+
ueContextCreateData.SourceToTargetData.NgapIeType = models.AmfCommunicationNgapIeType_HANDOVER_REQUIRED
1739+
ueContextCreateData.SourceToTargetData.NgapData.ContentId = "N2SmInfo"
17391740
1740-
ueContextCreateData.N2NotifyUri = ""
1741-
ueContextCreatedData, targetToSourceTransparentContainer,
1742-
problemDetails, err := consumer.GetConsumer().CreateUEContextRequest(amfUe, ueContextCreateData)
1741+
ueContextCreateData.N2NotifyUri = ""
1742+
ueContextCreatedData, targetToSourceTransparentContainer,
1743+
problemDetails, err := consumer.GetConsumer().CreateUEContextRequest(amfUe, ueContextCreateData)
17431744
1744-
if problemDetails != nil {
1745-
// get UeContextCreateError (HANDOVER FAILURE) from target AMF.
1746-
// Send Handover Preparation Failure to source RAN (described in TS 38.413 8.4.1.3).
1747-
sourceUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]")
1748-
cause = &ngapType.Cause{
1749-
Present: ngapType.CausePresentRadioNetwork,
1750-
RadioNetwork: &ngapType.CauseRadioNetwork{
1751-
Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem,
1752-
},
1753-
}
1754-
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1755-
return
1756-
} else if err != nil {
1757-
// error occurred in S-AMF.
1758-
sourceUe.Log.Errorf("CreateUEContextRequest Error in source AMF: %s", err.Error())
1759-
cause = &ngapType.Cause{
1760-
Present: ngapType.CausePresentRadioNetwork,
1761-
RadioNetwork: &ngapType.CauseRadioNetwork{
1762-
Value: ngapType.CauseRadioNetworkPresentUnspecified,
1763-
},
1764-
}
1765-
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1766-
} else {
1767-
// Get UeContextCreatedData from T-AMF.
1768-
// Send HandoverCommand to S-RAN.
1769-
var pduSessionResourceHandoverList ngapType.PDUSessionResourceHandoverList
1770-
var pduSessionResourceToReleaseList ngapType.PDUSessionResourceToReleaseListHOCmd
1771-
1772-
for _, N2SmInfo := range ueContextCreatedData.PduSessionList {
1773-
var item ngapType.PDUSessionResourceHandoverItem
1774-
item.PDUSessionID.Value = int64(N2SmInfo.PduSessionId)
1775-
}
1776-
1777-
ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList,
1778-
*targetToSourceTransparentContainer, nil)
1779-
/*
1780-
// describe in 23.502 4.9.1.3.2 step11
1781-
if pDUSessionResourceAdmittedList != nil {
1782-
targetUe.Log.Infof("Send HandoverRequestAcknowledgeTransfer to SMF")
1783-
for _, item := range pDUSessionResourceAdmittedList.List { /*
1745+
if problemDetails != nil {
1746+
// get UeContextCreateError (HANDOVER FAILURE) from target AMF.
1747+
// Send Handover Preparation Failure to source RAN (described in TS 38.413 8.4.1.3).
1748+
sourceUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]")
1749+
cause = &ngapType.Cause{
1750+
Present: ngapType.CausePresentRadioNetwork,
1751+
RadioNetwork: &ngapType.CauseRadioNetwork{
1752+
Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem,
1753+
},
1754+
}
1755+
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1756+
return
1757+
} else if err != nil {
1758+
// error occurred in S-AMF.
1759+
sourceUe.Log.Errorf("CreateUEContextRequest Error in source AMF: %s", err.Error())
1760+
cause = &ngapType.Cause{
1761+
Present: ngapType.CausePresentRadioNetwork,
1762+
RadioNetwork: &ngapType.CauseRadioNetwork{
1763+
Value: ngapType.CauseRadioNetworkPresentUnspecified,
1764+
},
1765+
}
1766+
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1767+
} else {
1768+
// Get UeContextCreatedData from T-AMF.
1769+
// Send HandoverCommand to S-RAN.
1770+
var pduSessionResourceHandoverList ngapType.PDUSessionResourceHandoverList
1771+
var pduSessionResourceToReleaseList ngapType.PDUSessionResourceToReleaseListHOCmd
1772+
1773+
for _, N2SmInfo := range ueContextCreatedData.PduSessionList {
1774+
var item ngapType.PDUSessionResourceHandoverItem
1775+
item.PDUSessionID.Value = int64(N2SmInfo.PduSessionId)
1776+
}
1777+
1778+
ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList,
1779+
*targetToSourceTransparentContainer, nil)
1780+
/*
1781+
// describe in 23.502 4.9.1.3.2 step11
1782+
if pDUSessionResourceAdmittedList != nil {
1783+
targetUe.Log.Infof("Send HandoverRequestAcknowledgeTransfer to SMF")
1784+
for _, item := range pDUSessionResourceAdmittedList.List { /*
1785+
pduSessionID := int32(item.PDUSessionID.Value)
1786+
transfer := item.HandoverRequestAcknowledgeTransfer
1787+
smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID)
1788+
if !ok {
1789+
targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID)
1790+
// TODO: Check if doing error handling here
1791+
continue
1792+
}
1793+
resp, errResponse, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe,
1794+
smContext, models.N2SmInfoType_HANDOVER_REQ_ACK, transfer)
1795+
if err != nil {
1796+
targetUe.Log.Errorf("Send HandoverRequestAcknowledgeTransfer error: %v", err)
1797+
}
1798+
if problemDetails != nil {
1799+
targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause)
1800+
}
1801+
if resp != nil && resp.BinaryDataN2SmInformation != nil {
1802+
handoverItem := ngapType.PDUSessionResourceHandoverItem{}
1803+
handoverItem.PDUSessionID = item.PDUSessionID
1804+
handoverItem.HandoverCommandTransfer = resp.BinaryDataN2SmInformation
1805+
pduSessionResourceHandoverList.List = append(pduSessionResourceHandoverList.List, handoverItem)
1806+
targetUe.SuccessPduSessionId = append(targetUe.SuccessPduSessionId, pduSessionID)
1807+
}
1808+
if errResponse != nil && errResponse.BinaryDataN2SmInformation != nil {
1809+
releaseItem := ngapType.PDUSessionResourceToReleaseItemHOCmd{}
1810+
releaseItem.PDUSessionID = item.PDUSessionID
1811+
releaseItem.HandoverPreparationUnsuccessfulTransfer = errResponse.BinaryDataN2SmInformation
1812+
pduSessionResourceToReleaseList.List = append(pduSessionResourceToReleaseList.List, releaseItem)
1813+
}
1814+
}
1815+
}
1816+
1817+
if pDUSessionResourceFailedToSetupListHOAck != nil {
1818+
targetUe.Log.Infof("Send HandoverResourceAllocationUnsuccessfulTransfer to SMF")
1819+
for _, item := range pDUSessionResourceFailedToSetupListHOAck.List {
17841820
pduSessionID := int32(item.PDUSessionID.Value)
1785-
transfer := item.HandoverRequestAcknowledgeTransfer
1821+
transfer := item.HandoverResourceAllocationUnsuccessfulTransfer
17861822
smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID)
17871823
if !ok {
17881824
targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID)
17891825
// TODO: Check if doing error handling here
17901826
continue
17911827
}
1792-
resp, errResponse, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe,
1793-
smContext, models.N2SmInfoType_HANDOVER_REQ_ACK, transfer)
1794-
if err != nil {
1795-
targetUe.Log.Errorf("Send HandoverRequestAcknowledgeTransfer error: %v", err)
1796-
}
1797-
if problemDetails != nil {
1798-
targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause)
1799-
}
1800-
if resp != nil && resp.BinaryDataN2SmInformation != nil {
1801-
handoverItem := ngapType.PDUSessionResourceHandoverItem{}
1802-
handoverItem.PDUSessionID = item.PDUSessionID
1803-
handoverItem.HandoverCommandTransfer = resp.BinaryDataN2SmInformation
1804-
pduSessionResourceHandoverList.List = append(pduSessionResourceHandoverList.List, handoverItem)
1805-
targetUe.SuccessPduSessionId = append(targetUe.SuccessPduSessionId, pduSessionID)
1806-
}
1807-
if errResponse != nil && errResponse.BinaryDataN2SmInformation != nil {
1808-
releaseItem := ngapType.PDUSessionResourceToReleaseItemHOCmd{}
1809-
releaseItem.PDUSessionID = item.PDUSessionID
1810-
releaseItem.HandoverPreparationUnsuccessfulTransfer = errResponse.BinaryDataN2SmInformation
1811-
pduSessionResourceToReleaseList.List = append(pduSessionResourceToReleaseList.List, releaseItem)
1812-
}
1813-
}
1814-
}
1815-
1816-
if pDUSessionResourceFailedToSetupListHOAck != nil {
1817-
targetUe.Log.Infof("Send HandoverResourceAllocationUnsuccessfulTransfer to SMF")
1818-
for _, item := range pDUSessionResourceFailedToSetupListHOAck.List {
1819-
pduSessionID := int32(item.PDUSessionID.Value)
1820-
transfer := item.HandoverResourceAllocationUnsuccessfulTransfer
1821-
smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID)
1822-
if !ok {
1823-
targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID)
1824-
// TODO: Check if doing error handling here
1825-
continue
1826-
}
1827-
_, _, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, smContext,
1828-
models.N2SmInfoType_HANDOVER_RES_ALLOC_FAIL, transfer)
1829-
if err != nil {
1830-
targetUe.Log.Errorf("Send HandoverResourceAllocationUnsuccessfulTransfer error: %v", err)
1831-
}
1832-
if problemDetails != nil {
1833-
targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause)
1828+
_, _, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, smContext,
1829+
models.N2SmInfoType_HANDOVER_RES_ALLOC_FAIL, transfer)
1830+
if err != nil {
1831+
targetUe.Log.Errorf("Send HandoverResourceAllocationUnsuccessfulTransfer error: %v", err)
1832+
}
1833+
if problemDetails != nil {
1834+
targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause)
1835+
}
18341836
}
18351837
}
1836-
}
18371838
1838-
sourceUe := targetUe.SourceUe
1839-
if sourceUe == nil {
1840-
// TODO: Send Namf_Communication_CreateUEContext Response to S-AMF
1841-
ran.Log.Error("handover between different Ue has not been implement yet")
1842-
} else {
1843-
ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId)
1844-
ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId)
1845-
if len(pduSessionResourceHandoverList.List) == 0 {
1846-
targetUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]")
1847-
cause := &ngapType.Cause{
1848-
Present: ngapType.CausePresentRadioNetwork,
1849-
RadioNetwork: &ngapType.CauseRadioNetwork{
1850-
Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem,
1851-
},
1839+
sourceUe := targetUe.SourceUe
1840+
if sourceUe == nil {
1841+
// TODO: Send Namf_Communication_CreateUEContext Response to S-AMF
1842+
ran.Log.Error("handover between different Ue has not been implement yet")
1843+
} else {
1844+
ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId)
1845+
ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId)
1846+
if len(pduSessionResourceHandoverList.List) == 0 {
1847+
targetUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]")
1848+
cause := &ngapType.Cause{
1849+
Present: ngapType.CausePresentRadioNetwork,
1850+
RadioNetwork: &ngapType.CauseRadioNetwork{
1851+
Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem,
1852+
},
1853+
}
1854+
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1855+
return
18521856
}
1853-
ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil)
1854-
return
1857+
ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList,
1858+
*targetToSourceTransparentContainer, nil)
18551859
}
1856-
ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList,
1857-
*targetToSourceTransparentContainer, nil)
1858-
} */
1859-
}
1860+
} */
18601861
} else {
18611862
// Handover in same AMF
18621863
sourceUe.HandOverType.Value = handoverType.Value

internal/sbi/processor/ue_context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func (p *Processor) CreateUEContextProcedure(ueContextID string, createUeContext
9595
logger.CommLog.Infof("pointer of AmPolicyAssociation: %p", ue.AmPolicyAssociation)
9696
ue.AmPolicyAssociation.ServAreaRes = new(models.ServiceAreaRestriction)
9797
logger.CommLog.Infof("pointer of ServAreaRes: %p", ue.AmPolicyAssociation.ServAreaRes)
98-
ue.AmPolicyAssociation.ServAreaRes.RestrictionType = ueContextCreateData.UeContext.ServiceAreaRestriction.RestrictionType
98+
ue.AmPolicyAssociation.ServAreaRes.RestrictionType =
99+
ueContextCreateData.UeContext.ServiceAreaRestriction.RestrictionType
99100
ue.AmPolicyAssociation.ServAreaRes.Areas = append(ue.AmPolicyAssociation.ServAreaRes.Areas,
100101
ueContextCreateData.UeContext.ServiceAreaRestriction.Areas[0])
101102
ue.UnauthenticatedSupi = ueContextCreateData.UeContext.SupiUnauthInd

0 commit comments

Comments
 (0)