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
/
SubscriberDataManagement.go
173 lines (151 loc) · 5.56 KB
/
SubscriberDataManagement.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package amf_consumer
import (
"context"
"github.com/antihax/optional"
"free5gc/lib/Nudm_SubscriberDataManagement"
"free5gc/lib/openapi/common"
"free5gc/lib/openapi/models"
"free5gc/src/amf/amf_context"
)
func PutUpuAck(ue *amf_context.AmfUe, upuMacIue string) error {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
ackInfo := models.AcknowledgeInfo{
UpuMacIue: upuMacIue,
}
upuOpt := Nudm_SubscriberDataManagement.PutUpuAckParamOpts{
AcknowledgeInfo: optional.NewInterface(ackInfo),
}
_, err := client.ProvidingAcknowledgementOfUEParametersUpdateApi.PutUpuAck(context.Background(), ue.Supi, &upuOpt)
return err
}
func SDMGetAmData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
getAmDataParamOpt := Nudm_SubscriberDataManagement.GetAmDataParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
data, httpResp, localErr := client.AccessAndMobilitySubscriptionDataRetrievalApi.GetAmData(context.Background(), ue.Supi, &getAmDataParamOpt)
if localErr == nil {
ue.AccessAndMobilitySubscriptionData = &data
ue.Gpsi = data.Gpsis[0] // TODO: select GPSI
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(common.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = common.ReportError("server no response")
}
return
}
func SDMGetSmfSelectData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
paramOpt := Nudm_SubscriberDataManagement.GetSmfSelectDataParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
data, httpResp, localErr := client.SMFSelectionSubscriptionDataRetrievalApi.GetSmfSelectData(context.Background(), ue.Supi, ¶mOpt)
if localErr == nil {
ue.SmfSelectionData = &data
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(common.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = common.ReportError("server no response")
}
return
}
func SDMGetUeContextInSmfData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
data, httpResp, localErr := client.UEContextInSMFDataRetrievalApi.GetUeContextInSmfData(context.Background(), ue.Supi, nil)
if localErr == nil {
ue.UeContextInSmfData = &data
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(common.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = common.ReportError("server no response")
}
return
}
func SDMSubscribe(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
amfSelf := amf_context.AMF_Self()
sdmSubscription := models.SdmSubscription{
NfInstanceId: amfSelf.NfId,
PlmnId: &ue.PlmnId,
}
_, httpResp, localErr := client.SubscriptionCreationApi.Subscribe(context.Background(), ue.Supi, sdmSubscription)
if localErr == nil {
return
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(common.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = common.ReportError("server no response")
}
return
}
func SDMGetSliceSelectionSubscriptionData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
paramOpt := Nudm_SubscriberDataManagement.GetNssaiParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
nssai, httpResp, localErr := client.SliceSelectionSubscriptionDataRetrievalApi.GetNssai(context.Background(), ue.Supi, ¶mOpt)
if localErr == nil {
for _, defaultSnssai := range nssai.DefaultSingleNssais {
subscribedSnssai := models.SubscribedSnssai{
SubscribedSnssai: &models.Snssai{
Sst: defaultSnssai.Sst,
Sd: defaultSnssai.Sd,
},
DefaultIndication: true,
}
ue.SubscribedNssai = append(ue.SubscribedNssai, subscribedSnssai)
}
for _, snssai := range nssai.SingleNssais {
subscribedSnssai := models.SubscribedSnssai{
SubscribedSnssai: &models.Snssai{
Sst: snssai.Sst,
Sd: snssai.Sd,
},
DefaultIndication: false,
}
ue.SubscribedNssai = append(ue.SubscribedNssai, subscribedSnssai)
}
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(common.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = common.ReportError("server no response")
}
return
}