This repository has been archived by the owner on Apr 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
nsselection_for_pdu_session.go
123 lines (104 loc) · 3.55 KB
/
nsselection_for_pdu_session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* NSSF NS Selection
*
* NSSF Network Slice Selection Service
*/
package nssf_producer
import (
"fmt"
"math/rand"
"net/http"
. "free5gc/lib/openapi/models"
. "free5gc/src/nssf/plugin"
"free5gc/src/nssf/util"
)
func selectNsiInformation(nsiInformationList []NsiInformation) NsiInformation {
// TODO: Algorithm to select Network Slice Instance
// Take roaming indication into consideration
// Randomly select a Network Slice Instance
idx := rand.Intn(len(nsiInformationList))
return nsiInformationList[idx]
}
// Network slice selection for PDU session
// The function is executed when the IE, `slice-info-for-pdu-session`, is provided in query parameters
func nsselectionForPduSession(p NsselectionQueryParameter,
a *AuthorizedNetworkSliceInfo,
d *ProblemDetails) (status int) {
if p.HomePlmnId != nil {
// Check whether UE's Home PLMN is supported when UE is a roamer
if !util.CheckSupportedHplmn(*p.HomePlmnId) {
a.RejectedNssaiInPlmn = append(a.RejectedNssaiInPlmn, *p.SliceInfoRequestForPduSession.SNssai)
status = http.StatusOK
return
}
}
if p.Tai != nil {
// Check whether UE's current TA is supported when UE provides TAI
if !util.CheckSupportedTa(*p.Tai) {
a.RejectedNssaiInTa = append(a.RejectedNssaiInTa, *p.SliceInfoRequestForPduSession.SNssai)
status = http.StatusOK
return
}
}
if p.Tai != nil && !util.CheckSupportedSnssaiInPlmn(*p.SliceInfoRequestForPduSession.SNssai, *p.Tai.PlmnId) {
// Return ProblemDetails indicating S-NSSAI is not supported
// TODO: Based on TS 23.501 V15.2.0, if the Requested NSSAI includes an S-NSSAI that is not valid in the
// Serving PLMN, the NSSF may derive the Configured NSSAI for Serving PLMN
*d = ProblemDetails{
Title: util.UNSUPPORTED_RESOURCE,
Status: http.StatusForbidden,
Detail: "S-NSSAI in Requested NSSAI is not supported in PLMN",
Cause: "SNSSAI_NOT_SUPPORTED",
}
status = http.StatusForbidden
return
}
if p.HomePlmnId != nil {
if p.SliceInfoRequestForPduSession.RoamingIndication == RoamingIndication_NON_ROAMING {
problemDetail := "`home-plmn-id` is provided, which contradicts `roamingIndication`:'NON_ROAMING'"
*d = ProblemDetails{
Title: util.INVALID_REQUEST,
Status: http.StatusBadRequest,
Detail: problemDetail,
InvalidParams: []InvalidParam{
{
Param: "home-plmn-id",
Reason: problemDetail,
},
},
}
status = http.StatusBadRequest
return
}
} else {
if p.SliceInfoRequestForPduSession.RoamingIndication != RoamingIndication_NON_ROAMING {
problemDetail := fmt.Sprintf("`home-plmn-id` is not provided, which contradicts `roamingIndication`:'%s'",
string(p.SliceInfoRequestForPduSession.RoamingIndication))
*d = ProblemDetails{
Title: util.INVALID_REQUEST,
Status: http.StatusBadRequest,
Detail: problemDetail,
InvalidParams: []InvalidParam{
{
Param: "home-plmn-id",
Reason: problemDetail,
},
},
}
status = http.StatusBadRequest
return
}
}
if p.Tai != nil && !util.CheckSupportedSnssaiInTa(*p.SliceInfoRequestForPduSession.SNssai, *p.Tai) {
// Requested S-NSSAI does not supported in UE's current TA
// Add it to Rejected NSSAI in TA
a.RejectedNssaiInTa = append(a.RejectedNssaiInTa, *p.SliceInfoRequestForPduSession.SNssai)
status = http.StatusOK
return
}
nsiInformationList := util.GetNsiInformationListFromConfig(*p.SliceInfoRequestForPduSession.SNssai)
nsiInformation := selectNsiInformation(nsiInformationList)
a.NsiInformation = new(NsiInformation)
*a.NsiInformation = nsiInformation
return http.StatusOK
}