shynuu / free5gc-cli

An interactive CLI for free5gc
Apache License 2.0
20 stars 14 forks source link

Update to latest version of free5GC v3.0.5 #5

Open shynuu opened 3 years ago

IgorLashin commented 1 year ago

Hi, Thank you for this tool. I have one question. I want to add new IE. For example, RAT-Information IE in NGSetupRequest. I added following lines in files:

/free5gc-cli/lib/ngap/ngapType/ProtocolExtensionField.go

type SupportedTAItemExtIEs struct {
        Id             ProtocolExtensionID
        Criticality    Criticality
        ExtensionValue SupportedTAItemExtIEsExtensionValue `aper:"openType,referenceFieldName:Id"`
}

const (
        SupportedTAItemExtIEsPresentNothing int = iota /* No components present */
        SupportedTAItemExtIEsPresentRATInformation
)

type SupportedTAItemExtIEsExtensionValue struct {
        Present int
        RATInformation   *RATInformation  `aper:"referenceFieldValue:179"`
}

/free5gc-cli/lib/ngap/ngapType/ProtocolExtensionID.go

package ngapType

// Need to import "free5gc-cli/lib/aper" if it uses "aper"

type ProtocolExtensionID struct {
        ExtensionValue int64 `aper:"valueLB:0,valueUB:65535"`
}

const ProtocolExtensionIDRATInformation int64 = 179

Created for test file /free5gc-cli/lib/ngap/ngapType/RATInformation.go

package ngapType

import "free5gc-cli/lib/aper"

// Need to import "free5gc-cli/lib/aper" if it uses "aper"

const (
        RATInformationPresentnRMEO  aper.Enumerated = 0
        RATInformationPresentnRLEO  aper.Enumerated = 1
)

type RATInformation struct {
        Value aper.Enumerated `aper:"valueExt,valueLB:0,valueUB:1"`
}

And described this new IE in file /free5gc-cli/module/gnb/api/ngapTestpacket/ngap.go

//RATInformation
        is := ngapType.SupportedTAItemExtIEs{}
        is.Id.ExtensionValue = ngapType.ProtocolExtensionIDRATInformation
        is.Criticality.Value = ngapType.CriticalityPresentReject
        is.ExtensionValue.Present = ngapType.SupportedTAItemExtIEsPresentRATInformation
        is.ExtensionValue.RATInformation = new(ngapType.RATInformation)
        ratinformation := is.ExtensionValue.RATInformation
        ratinformation.Value = ngapType.RATInformationPresentnRLEO

RATInformation must include in IEExtensions in file /free5gc-cli/lib/ngap/ngapType/SupportedTAItem.go

package ngapType

// Need to import "free5gc-cli/lib/aper" if it uses "aper"

type SupportedTAItem struct {
        TAC               TAC
        BroadcastPLMNList BroadcastPLMNList
        IEExtensions      *ProtocolExtensionContainerSupportedTAItemExtIEs `aper:"optional"`
}

I did the above steps but the field RATInformation is not getting inserted into the package NGSetupRequest. Build created without errors. Could you help me with this problem? Maybe I'm doing something wrong or the current code does not provide for adding new IE in packets. Thank you in advance :-)