Skip to content

Commit

Permalink
Modify missing consumers
Browse files Browse the repository at this point in the history
Co-authored-by: ming-hsien <w2bc8860@gmail.com>
Co-authored-by: ian60509 <ian.60509@gmail.com>
  • Loading branch information
3 people committed Jan 26, 2024
1 parent cbcd8a4 commit fbd6deb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
9 changes: 7 additions & 2 deletions internal/pfcp/handler/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handler

import (
"context"
"fmt"

"github.com/free5gc/openapi/models"
Expand Down Expand Up @@ -173,9 +172,15 @@ func HandlePfcpSessionReportRequest(msg *pfcpUdp.Message) {
},
}

ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
logger.PfcpLog.Warnf("Get NAMF_COMM context failed: %s", err)
return
}

rspData, _, err := smContext.CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
if err != nil {
logger.PfcpLog.Warnf("Send N1N2Transfer failed: %s", err)
}
Expand Down
16 changes: 12 additions & 4 deletions internal/sbi/consumer/ue_context_management.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package consumer

import (
"context"

"github.com/pkg/errors"

"github.com/free5gc/openapi"
Expand Down Expand Up @@ -42,7 +40,12 @@ func UeCmRegistration(smCtx *smf_context.SMContext) (
" PduSessionId:", registrationData.PduSessionId, " SNssai:", registrationData.SingleNssai,
" Dnn:", registrationData.Dnn, " PlmnId:", registrationData.PlmnId)

_, httpResp, localErr := client.SMFRegistrationApi.SmfRegistrationsPduSessionId(context.Background(),
ctx, pd, err := smf_context.GetSelf().GetTokenCtx("nudm-uecm", models.NfType_UDM)
if err != nil {
return pd, err
}

_, httpResp, localErr := client.SMFRegistrationApi.SmfRegistrationsPduSessionId(ctx,
smCtx.Supi, smCtx.PduSessionId, registrationData)
defer func() {
if httpResp != nil {
Expand Down Expand Up @@ -78,7 +81,12 @@ func UeCmDeregistration(smCtx *smf_context.SMContext) (*models.ProblemDetails, e
configuration.SetBasePath(uecmUri)
client := Nudm_UEContextManagement.NewAPIClient(configuration)

httpResp, localErr := client.SMFDeregistrationApi.Deregistration(context.Background(),
ctx, pd, err := smf_context.GetSelf().GetTokenCtx("nudm-uecm", models.NfType_UDM)
if err != nil {
return pd, err
}

httpResp, localErr := client.SMFDeregistrationApi.Deregistration(ctx,
smCtx.Supi, smCtx.PduSessionId)
defer func() {
if httpResp != nil {
Expand Down
17 changes: 14 additions & 3 deletions internal/sbi/producer/datapath.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package producer

import (
"context"
"fmt"

"github.com/free5gc/nas/nasMessage"
Expand Down Expand Up @@ -239,10 +238,16 @@ func sendPDUSessionEstablishmentReject(
},
}

ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
logger.PduSessLog.Warnf("Get NAMF_COMM context failed: %s", err)
return
}

rspData, rsp, err := smContext.
CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
defer func() {
if rsp != nil {
if resCloseErr := rsp.Body.Close(); resCloseErr != nil {
Expand Down Expand Up @@ -301,10 +306,16 @@ func sendPDUSessionEstablishmentAccept(
},
}

ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
logger.PduSessLog.Warnf("Get NAMF_COMM context failed: %s", err)
return
}

rspData, rsp, err := smContext.
CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
defer func() {
if rsp != nil {
if resCloseErr := rsp.Body.Close(); resCloseErr != nil {
Expand Down
25 changes: 21 additions & 4 deletions internal/sbi/producer/pdu_session.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package producer

import (
"context"
"encoding/hex"
"errors"
"net"
Expand Down Expand Up @@ -101,9 +100,15 @@ func HandlePDUSessionSMContextCreate(isDone <-chan struct{},

SubscriberDataManagementClient := smf_context.GetSelf().SubscriberDataManagementClient

ctx, _, oauthErr := smf_context.GetSelf().GetTokenCtx("nudm-sdm", models.NfType_UDM)
if oauthErr != nil {
smContext.Log.Errorf("Get Token Context Error[%v]", oauthErr)
return nil
}

if sessSubData, rsp, err := SubscriberDataManagementClient.
SessionManagementSubscriptionDataRetrievalApi.
GetSmData(context.Background(), smContext.Supi, smDataParams); err != nil {
GetSmData(ctx, smContext.Supi, smDataParams); err != nil {
smContext.Log.Errorln("Get SessionManagementSubscriptionData error:", err)
} else {
defer func() {
Expand Down Expand Up @@ -1093,12 +1098,18 @@ func sendGSMPDUSessionReleaseCommand(smContext *smf_context.SMContext, nasPdu []
// Start T3592
t3592 := factory.SmfConfig.Configuration.T3592
if t3592.Enable {
ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
smContext.Log.Warnf("Get namf-comm token failed: %+v", err)
return
}

smContext.T3592 = smf_context.NewTimer(t3592.ExpireTime, t3592.MaxRetryTimes, func(expireTimes int32) {
smContext.SMLock.Lock()
rspData, rsp, err := smContext.
CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
if err != nil {
smContext.Log.Warnf("Send N1N2Transfer for GSMPDUSessionReleaseCommand failed: %s", err)
}
Expand Down Expand Up @@ -1138,13 +1149,19 @@ func sendGSMPDUSessionModificationCommand(smContext *smf_context.SMContext, nasP
// Start T3591
t3591 := factory.SmfConfig.Configuration.T3591
if t3591.Enable {
ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
smContext.Log.Warnf("Get namf-comm token failed: %+v", err)
return
}

smContext.T3591 = smf_context.NewTimer(t3591.ExpireTime, t3591.MaxRetryTimes, func(expireTimes int32) {
smContext.SMLock.Lock()
defer smContext.SMLock.Unlock()
rspData, rsp, err := smContext.
CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
if err != nil {
smContext.Log.Warnf("Send N1N2Transfer for GSMPDUSessionModificationCommand failed: %s", err)
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/association/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,14 @@ func requestAMFToReleasePDUResources(smContext *smf_context.SMContext) (sendNoti
}
}

ctx, _, err := smf_context.GetSelf().GetTokenCtx("namf-comm", models.NfType_AMF)
if err != nil {
return false, false
}

rspData, res, err := smContext.CommunicationClient.
N1N2MessageCollectionDocumentApi.
N1N2MessageTransfer(context.Background(), smContext.Supi, n1n2Request)
N1N2MessageTransfer(ctx, smContext.Supi, n1n2Request)
if err != nil {
logger.MainLog.Warnf("Send N1N2Transfer failed: %+v", err)
}
Expand Down

0 comments on commit fbd6deb

Please sign in to comment.