Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enable goconst linter and fix reported issues #180

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,13 @@ linters:
- staticcheck
- unused
- gosimple
# - structcheck
- ineffassign
- typecheck
# Additional
# - lll
- godox
#- gomnd
#- goconst
- goconst
# - gocognit
# - maligned
# - nestif
Expand Down
14 changes: 8 additions & 6 deletions consumer/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/omec-project/openapi/models"
)

const N2SMINFO_ID = "N2SmInfo"

func getServingSmfIndex(smfNum int) (servingSmfIndex int) {
servingSmfIndexStr := os.Getenv("SERVING_SMF_INDEX")
i, err := strconv.Atoi(servingSmfIndexStr)
Expand Down Expand Up @@ -302,7 +304,7 @@ func SendUpdateSmContextN2Info(
updateData := models.SmContextUpdateData{}
updateData.N2SmInfoType = n2SmType
updateData.N2SmInfo = new(models.RefToBinaryData)
updateData.N2SmInfo.ContentId = "N2SmInfo"
updateData.N2SmInfo.ContentId = N2SMINFO_ID
updateData.UeLocation = &ue.Location
return SendUpdateSmContextRequest(smContext, updateData, nil, N2SmInfo)
}
Expand All @@ -315,7 +317,7 @@ func SendUpdateSmContextXnHandover(
if n2SmType != "" {
updateData.N2SmInfoType = n2SmType
updateData.N2SmInfo = new(models.RefToBinaryData)
updateData.N2SmInfo.ContentId = "N2SmInfo"
updateData.N2SmInfo.ContentId = N2SMINFO_ID
}
updateData.ToBeSwitched = true
updateData.UeLocation = &ue.Location
Expand All @@ -337,7 +339,7 @@ func SendUpdateSmContextXnHandoverFailed(
if n2SmType != "" {
updateData.N2SmInfoType = n2SmType
updateData.N2SmInfo = new(models.RefToBinaryData)
updateData.N2SmInfo.ContentId = "N2SmInfo"
updateData.N2SmInfo.ContentId = N2SMINFO_ID
}
updateData.FailedToBeSwitched = true
return SendUpdateSmContextRequest(smContext, updateData, nil, N2SmInfo)
Expand All @@ -354,7 +356,7 @@ func SendUpdateSmContextN2HandoverPreparing(
if n2SmType != "" {
updateData.N2SmInfoType = n2SmType
updateData.N2SmInfo = new(models.RefToBinaryData)
updateData.N2SmInfo.ContentId = "N2SmInfo"
updateData.N2SmInfo.ContentId = N2SMINFO_ID
}
updateData.HoState = models.HoState_PREPARING
updateData.TargetId = targetId
Expand All @@ -373,7 +375,7 @@ func SendUpdateSmContextN2HandoverPrepared(
if n2SmType != "" {
updateData.N2SmInfoType = n2SmType
updateData.N2SmInfo = new(models.RefToBinaryData)
updateData.N2SmInfo.ContentId = "N2SmInfo"
updateData.N2SmInfo.ContentId = N2SMINFO_ID
}
updateData.HoState = models.HoState_PREPARED
return SendUpdateSmContextRequest(smContext, updateData, nil, N2SmInfo)
Expand Down Expand Up @@ -561,7 +563,7 @@ func buildReleaseSmContextRequest(
if n2Info != nil {
releaseData.N2SmInfoType = n2SmInfoType
releaseData.N2SmInfo = &models.RefToBinaryData{
ContentId: "n2SmInfo",
ContentId: N2SMINFO_ID,
}
}
// TODO: other param(ueLocation...)
Expand Down
31 changes: 19 additions & 12 deletions gmm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ import (
"github.com/omec-project/openapi/models"
)

const (
S_NSSAI_CONGESTION = "S-NSSAI_CONGESTION"
DNN_CONGESTION = "DNN_CONGESTION"
PRIORITIZED_SERVICES_ONLY = "PRIORITIZED_SERVICES_ONLY"
OUT_OF_LADN_SERVICE_AREA = "OUT_OF_LADN_SERVICE_AREA"
)

func HandleULNASTransport(ue *context.AmfUe, anType models.AccessType,
ulNasTransport *nasMessage.ULNASTransport,
) error {
Expand Down Expand Up @@ -846,11 +853,11 @@ func HandleMobilityAndPeriodicRegistrationUpdating(ue *context.AmfUe, anType mod
cause := nasMessage.Cause5GMMProtocolErrorUnspecified
if errResponse != nil {
switch errResponse.JsonData.Error.Cause {
case "OUT_OF_LADN_SERVICE_AREA":
case OUT_OF_LADN_SERVICE_AREA:
cause = nasMessage.Cause5GMMLADNNotAvailable
case "PRIORITIZED_SERVICES_ONLY":
case PRIORITIZED_SERVICES_ONLY:
cause = nasMessage.Cause5GMMRestrictedServiceArea
case "DNN_CONGESTION", "S-NSSAI_CONGESTION":
case DNN_CONGESTION, S_NSSAI_CONGESTION:
cause = nasMessage.Cause5GMMInsufficientUserPlaneResourcesForThePDUSession
}
}
Expand Down Expand Up @@ -962,11 +969,11 @@ func HandleMobilityAndPeriodicRegistrationUpdating(ue *context.AmfUe, anType mod
cause := nasMessage.Cause5GMMProtocolErrorUnspecified
if errRes != nil {
switch errRes.JsonData.Error.Cause {
case "OUT_OF_LADN_SERVICE_AREA":
case OUT_OF_LADN_SERVICE_AREA:
cause = nasMessage.Cause5GMMLADNNotAvailable
case "PRIORITIZED_SERVICES_ONLY":
case PRIORITIZED_SERVICES_ONLY:
cause = nasMessage.Cause5GMMRestrictedServiceArea
case "DNN_CONGESTION", "S-NSSAI_CONGESTION":
case DNN_CONGESTION, S_NSSAI_CONGESTION:
cause = nasMessage.Cause5GMMInsufficientUserPlaneResourcesForThePDUSession
}
}
Expand Down Expand Up @@ -1804,11 +1811,11 @@ func HandleServiceRequest(ue *context.AmfUe, anType models.AccessType,
cause := nasMessage.Cause5GMMProtocolErrorUnspecified
if errRes != nil {
switch errRes.JsonData.Error.Cause {
case "OUT_OF_LADN_SERVICE_AREA":
case OUT_OF_LADN_SERVICE_AREA:
cause = nasMessage.Cause5GMMLADNNotAvailable
case "PRIORITIZED_SERVICES_ONLY":
case PRIORITIZED_SERVICES_ONLY:
cause = nasMessage.Cause5GMMRestrictedServiceArea
case "DNN_CONGESTION", "S-NSSAI_CONGESTION":
case DNN_CONGESTION, S_NSSAI_CONGESTION:
cause = nasMessage.Cause5GMMInsufficientUserPlaneResourcesForThePDUSession
}
}
Expand Down Expand Up @@ -1903,11 +1910,11 @@ func HandleServiceRequest(ue *context.AmfUe, anType models.AccessType,
cause := nasMessage.Cause5GMMProtocolErrorUnspecified
if errRes != nil {
switch errRes.JsonData.Error.Cause {
case "OUT_OF_LADN_SERVICE_AREA":
case OUT_OF_LADN_SERVICE_AREA:
cause = nasMessage.Cause5GMMLADNNotAvailable
case "PRIORITIZED_SERVICES_ONLY":
case PRIORITIZED_SERVICES_ONLY:
cause = nasMessage.Cause5GMMRestrictedServiceArea
case "DNN_CONGESTION", "S-NSSAI_CONGESTION":
case DNN_CONGESTION, S_NSSAI_CONGESTION:
cause = nasMessage.Cause5GMMInsufficientUserPlaneResourcesForThePDUSession
}
}
Expand Down
10 changes: 6 additions & 4 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import (

type AMF struct{}

const IMSI_PREFIX = "imsi-"

var RocUpdateConfigChannel chan bool

type (
Expand Down Expand Up @@ -724,7 +726,7 @@ func (amf *AMF) SendNFProfileUpdateToNrf() {

func UeConfigSliceDeleteHandler(supi, sst, sd string, msg interface{}) {
amfSelf := context.AMF_Self()
ue, _ := amfSelf.AmfUeFindBySupi("imsi-" + supi)
ue, _ := amfSelf.AmfUeFindBySupi(IMSI_PREFIX + supi)

// Triggers for NwInitiatedDeRegistration
// - Only 1 Allowed Nssai is exist and its slice information matched
Expand Down Expand Up @@ -767,7 +769,7 @@ func UeConfigSliceDeleteHandler(supi, sst, sd string, msg interface{}) {

func UeConfigSliceAddHandler(supi, sst, sd string, msg interface{}) {
amfSelf := context.AMF_Self()
ue, _ := amfSelf.AmfUeFindBySupi("imsi-" + supi)
ue, _ := amfSelf.AmfUeFindBySupi(IMSI_PREFIX + supi)

ns := msg.(*protos.NetworkSlice)
var Nssai models.Snssai
Expand All @@ -794,7 +796,7 @@ func HandleImsiDeleteFromNetworkSlice(slice *protos.NetworkSlice) {

for _, supi := range slice.DeletedImsis {
amfSelf := context.AMF_Self()
ue, ok = amfSelf.AmfUeFindBySupi("imsi-" + supi)
ue, ok = amfSelf.AmfUeFindBySupi(IMSI_PREFIX + supi)
if !ok {
logger.CfgLog.Infof("the UE [%v] is not Registered with the 5G-Core", supi)
continue
Expand All @@ -819,7 +821,7 @@ func HandleImsiAddInNetworkSlice(slice *protos.NetworkSlice) {

for _, supi := range slice.AddUpdatedImsis {
amfSelf := context.AMF_Self()
ue, ok = amfSelf.AmfUeFindBySupi("imsi-" + supi)
ue, ok = amfSelf.AmfUeFindBySupi(IMSI_PREFIX + supi)
if !ok {
logger.CfgLog.Infof("the UE [%v] is not Registered with the 5G-Core", supi)
continue
Expand Down
Loading