Skip to content
Draft
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
12 changes: 12 additions & 0 deletions context/amf_ran.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ func (ran *AmfRan) ConvertGnbIdToRanId(gnbId string) (ranNodeId *models.GlobalRa
return ranId
}

func (ran *AmfRan) ConvertN3iwfIdToRanId(n3iwfId string) (ranNodeId *models.GlobalRanNodeId) {
ranId := &models.GlobalRanNodeId{}
val := strings.Split(n3iwfId, ":")
if len(val) != 3 {
return nil
}
ranId.PlmnId = &models.PlmnId{Mcc: val[0], Mnc: val[1]}
ranId.N3IwfId = val[2]
ran.RanPresent = RanPresentN3IwfId
return ranId
}

func (ran *AmfRan) RanID() string {
switch ran.RanPresent {
case RanPresentGNbId:
Expand Down
12 changes: 10 additions & 2 deletions nas/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func HandleNAS(ctx ctxt.Context, ue *context.RanUe, procedureCode int64, nasPdu
rsp.AmfId = os.Getenv("HOSTNAME")
/* TODO for this release setting pod ip to simplify logic in sctplb */
rsp.RedirectId = id.PodIp
rsp.GnbId = ue.Ran.GnbId
if ue.Ran.RanPresent == context.RanPresentN3IwfId {
rsp.N3IwfId = ue.Ran.GnbId
} else {
rsp.GnbId = ue.Ran.GnbId
}
rsp.Msg = ue.SctplbMsg
if ue.AmfUe != nil {
ue.AmfUe.Remove()
Expand All @@ -72,7 +76,11 @@ func HandleNAS(ctx ctxt.Context, ue *context.RanUe, procedureCode int64, nasPdu
// we dont call this function when AMF restarts. So we
// need to set the AnType from stored Information.
if amfSelf.EnableSctpLb {
ue.Ran.AnType = models.AccessType__3_GPP_ACCESS
if ue.Ran.RanPresent == context.RanPresentN3IwfId {
ue.Ran.AnType = models.AccessType_NON_3_GPP_ACCESS
} else {
ue.Ran.AnType = models.AccessType__3_GPP_ACCESS
}
}
ue.AmfUe.AttachRanUe(ue)

Expand Down
17 changes: 16 additions & 1 deletion ngap/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/omec-project/amf/protos/sdcoreAmfServer"
"github.com/omec-project/ngap"
"github.com/omec-project/ngap/ngapType"
"github.com/omec-project/openapi/models"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Expand All @@ -43,6 +44,16 @@ func DispatchLb(ctx ctxt.Context, sctplbMsg *sdcoreAmfServer.SctplbMessage, Amf2
ran.Amf2RanMsgChan = Amf2RanMsgChan
logger.NgapLog.Infof("dispatchLb, Create new Amf RAN", sctplbMsg.GnbId)
}
} else if sctplbMsg.N3IwfId != "" {
var ok bool
ran, ok = amfSelf.AmfRanFindByGnbId(sctplbMsg.N3IwfId)
if !ok {
logger.NgapLog.Infof("create a new NG connection for N3IWF: %s", sctplbMsg.N3IwfId)
ran = amfSelf.NewAmfRanId(sctplbMsg.N3IwfId)
ran.RanId = ran.ConvertN3iwfIdToRanId(sctplbMsg.N3IwfId)
ran.AnType = models.AccessType_NON_3_GPP_ACCESS
ran.Amf2RanMsgChan = Amf2RanMsgChan
Comment thread
andybavier marked this conversation as resolved.
}
} else if sctplbMsg.GnbIpAddr != "" {
logger.NgapLog.Infoln("GnbIpAddress received but no GnbId")
ran = &context.AmfRan{}
Expand Down Expand Up @@ -84,7 +95,11 @@ func DispatchLb(ctx ctxt.Context, sctplbMsg *sdcoreAmfServer.SctplbMessage, Amf2
/* TODO set only pod name, for this release setting pod ip to simplify logic in sctplb */
logger.NgapLog.Infof("dispatchLb, amfNgapId: %v is not for this amf instance, redirect to amf instance: %v %v", ngapId.Value, id.PodName, id.PodIp)
rsp.RedirectId = id.PodIp
rsp.GnbId = ran.GnbId
if ran.RanPresent == context.RanPresentN3IwfId {
rsp.N3IwfId = ran.GnbId
} else {
rsp.GnbId = ran.GnbId
}
rsp.Msg = make([]byte, len(sctplbMsg.Msg))
copy(rsp.Msg, sctplbMsg.Msg)
ran.Amf2RanMsgChan = Amf2RanMsgChan
Expand Down
6 changes: 5 additions & 1 deletion ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,11 @@ func HandleInitialUEMessage(ctx ctxt.Context, ran *context.AmfRan, message *ngap
rsp.AmfId = os.Getenv("HOSTNAME")
/* TODO for this release setting pod ip to simplify logic in sctplb */
rsp.RedirectId = id.PodIp
rsp.GnbId = ran.GnbId
if ran.RanPresent == context.RanPresentN3IwfId {
rsp.N3IwfId = ran.GnbId
} else {
rsp.GnbId = ran.GnbId
}
rsp.Msg = sctplbMsg.Msg
if ranUe != nil && ranUe.AmfUe != nil {
ranUe.AmfUe.Remove()
Expand Down
6 changes: 5 additions & 1 deletion ngap/message/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func SendToRan(ran *context.AmfRan, packet []byte) {
msg.Msgtype = sdcoreAmfServer.MsgType_AMF_MSG
msg.AmfId = os.Getenv("HOSTNAME")
msg.GnbIpAddr = ran.GnbIp
msg.GnbId = ran.GnbId
if ran.RanPresent == context.RanPresentN3IwfId {
msg.N3IwfId = ran.GnbId
} else {
msg.GnbId = ran.GnbId
}
ran.Amf2RanMsgChan <- msg
} else {
if ran.Conn == nil {
Expand Down
Loading
Loading