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

SDCORE-444 SMF should support plmn id configuration in helm chart #72

Merged
merged 3 commits into from
Sep 25, 2021
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
6 changes: 6 additions & 0 deletions config/smfcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ configuration:
ipv6: 2001:4860:4860::8888
ueSubnet: 60.60.0.0/16 # should be CIDR type
mtu: 1400
plmnId:
mcc: "111"
mnc: "222"
- sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information)
sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: "112233" # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
Expand All @@ -43,6 +46,9 @@ configuration:
ipv6: 2001:4860:4860::8888
ueSubnet: 60.61.0.0/16 # should be CIDR type
mtu: 1400
plmnId:
mcc: "333"
mnc: "444"
pfcp: # the IP address of N4 interface on this SMF (PFCP)
addr: smf
userplane_information: # list of userplane information
Expand Down
3 changes: 3 additions & 0 deletions consumer/nnrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func SendNFRegistration() error {
NfServices: smf_context.NFServices,
SmfInfo: smf_context.SmfInfo,
SNssais: &sNssais,
PlmnList: smf_context.SmfPlmnConfig(),
UpadhyayaAnkur marked this conversation as resolved.
Show resolved Hide resolved
AllowedPlmns: smf_context.SmfPlmnConfig(),
}

var rep models.NfProfile
var res *http.Response
var err error
Expand Down
7 changes: 4 additions & 3 deletions context/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func (c *SMFContext) insertSmfNssaiInfo(snssaiInfoConfig *factory.SnssaiInfoItem
Sd: snssaiInfoConfig.SNssai.Sd,
}

//PLMN ID
snssaiInfo.PlmnId = snssaiInfoConfig.PlmnId

//DNN Info
snssaiInfo.DnnInfos = make(map[string]*SnssaiSmfDnnInfo)

for _, dnnInfoConfig := range snssaiInfoConfig.DnnInfos {
Expand All @@ -54,9 +58,6 @@ func (c *SMFContext) insertSmfNssaiInfo(snssaiInfoConfig *factory.SnssaiInfoItem
}
c.SnssaiInfos = append(c.SnssaiInfos, snssaiInfo)

//TODO: Update to other SMF structure also required
//check init config code

return nil
}

Expand Down
34 changes: 30 additions & 4 deletions context/nf_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ package context

import (
"fmt"
"strconv"
"time"

"github.com/free5gc/openapi/models"
"github.com/free5gc/smf/factory"
"github.com/free5gc/smf/logger"
)

var NFServices *[]models.NfService
Expand All @@ -19,6 +21,10 @@ var NfServiceVersion *[]models.NfServiceVersion

var SmfInfo *models.SmfInfo

type SmfSnssaiPlmnIdInfo map[string]models.PlmnId

var SmfPlmnInfo SmfSnssaiPlmnIdInfo

func SetupNFProfile(config *factory.Config) {
// Set time
nfSetupTime := time.Now()
Expand All @@ -32,6 +38,11 @@ func SetupNFProfile(config *factory.Config) {
},
}

// set smfInfo/PlmnInfo
SmfInfo = &models.SmfInfo{
SNssaiSmfInfoList: SNssaiSmfInfo(),
}

// set NFServices
NFServices = new([]models.NfService)
for _, serviceName := range config.Configuration.ServiceNameList {
Expand All @@ -42,25 +53,40 @@ func SetupNFProfile(config *factory.Config) {
Scheme: models.UriScheme_HTTPS,
NfServiceStatus: models.NfServiceStatus_REGISTERED,
ApiPrefix: fmt.Sprintf("%s://%s:%d", SMF_Self().URIScheme, SMF_Self().RegisterIPv4, SMF_Self().SBIPort),
AllowedPlmns: SmfPlmnConfig(),
UpadhyayaAnkur marked this conversation as resolved.
Show resolved Hide resolved
})
}
}

// set smfInfo
SmfInfo = &models.SmfInfo{
SNssaiSmfInfoList: SNssaiSmfInfo(),
func SmfPlmnConfig() *[]models.PlmnId {
plmns := make([]models.PlmnId, 0)
for _, plmn := range SmfPlmnInfo {
plmns = append(plmns, plmn)
}

if len(plmns) > 0 {
logger.CfgLog.Debugf("plmnId configured [%v] ", plmns)
return &plmns
}
return nil
}

func SNssaiSmfInfo() *[]models.SnssaiSmfInfoItem {
snssaiInfo := make([]models.SnssaiSmfInfoItem, 0)
SmfPlmnInfo = make(SmfSnssaiPlmnIdInfo)
for _, snssai := range smfContext.SnssaiInfos {
var snssaiInfoModel models.SnssaiSmfInfoItem
snssaiInfoModel.SNssai = &models.Snssai{
Sst: snssai.Snssai.Sst,
Sd: snssai.Snssai.Sd,
}
dnnModelList := make([]models.DnnSmfInfoItem, 0)

//Plmn Info
if snssai.PlmnId.Mcc != "" && snssai.PlmnId.Mnc != "" {
SmfPlmnInfo[strconv.Itoa(int(snssai.Snssai.Sst))+snssai.Snssai.Sd] = snssai.PlmnId
}

dnnModelList := make([]models.DnnSmfInfoItem, 0)
for dnn := range snssai.DnnInfos {
dnnModelList = append(dnnModelList, models.DnnSmfInfoItem{
Dnn: dnn,
Expand Down
9 changes: 7 additions & 2 deletions context/snssai_dnn_smf_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@

package context

import "net"
import (
"net"

"github.com/free5gc/openapi/models"
)

// SnssaiSmfInfo records the SMF S-NSSAI related information
type SnssaiSmfInfo struct {
Snssai SNssai
DnnInfos map[string]*SnssaiSmfDnnInfo
PlmnId models.PlmnId
}

// SnssaiSmfDnnInfo records the SMF per S-NSSAI DNN information
type SnssaiSmfDnnInfo struct {
DNS DNS
UeIPAllocator *IPAllocator
MTU uint16
MTU uint16
}

type DNS struct {
Expand Down
7 changes: 7 additions & 0 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type Configuration struct {
type SnssaiInfoItem struct {
SNssai *models.Snssai `yaml:"sNssai"`
DnnInfos []SnssaiDnnInfoItem `yaml:"dnnInfos"`
PlmnId models.PlmnId `yaml:"plmnId"`
}

type SnssaiDnnInfoItem struct {
Expand Down Expand Up @@ -261,6 +262,12 @@ func (c *Configuration) parseRocConfig(rsp *protos.NetworkSliceResponse) error {
sNssai.Sst = int32(numSst)
sNssaiInfoItem.SNssai = &sNssai

//Add PLMN Id Info
if ns.Site.Plmn != nil {
sNssaiInfoItem.PlmnId.Mcc = ns.Site.Plmn.Mcc
sNssaiInfoItem.PlmnId.Mnc = ns.Site.Plmn.Mnc
}

//Populate enterprise name
c.EnterpriseList[ns.Nssai.Sst+ns.Nssai.Sd] = ns.Name

Expand Down