context

package
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

ProtocolConfigurationOptions

Index

Constants

View Source
const (
	MeasureInfoMNOP     = 0x10 // Measure Num of Pkts (MNOP)
	MeasureInfoMBQE     = 0x1  // Measure Before Qos Enforce(MQBE)
	MesureMethodVol     = "vol"
	MesureMethodTime    = "time"
	MeasurePeriodReport = 0x0100 // 0x10: PERIO
)
View Source
const DefaultNonGBR5QI = 9
View Source
const DefaultPrecedence uint32 = 255

Variables

View Source
var TeidGenerator *idgenerator.IDGenerator

Functions

func AllocateLocalSEID

func AllocateLocalSEID() uint64

func AllocateUPFID

func AllocateUPFID()

func BuildGSMPDUSessionEstablishmentAccept

func BuildGSMPDUSessionEstablishmentAccept(smContext *SMContext) ([]byte, error)

func BuildGSMPDUSessionEstablishmentReject

func BuildGSMPDUSessionEstablishmentReject(smContext *SMContext, cause uint8) ([]byte, error)

func BuildGSMPDUSessionModificationCommand

func BuildGSMPDUSessionModificationCommand(smContext *SMContext) ([]byte, error)

func BuildGSMPDUSessionModificationReject

func BuildGSMPDUSessionModificationReject(smContext *SMContext) ([]byte, error)

func BuildGSMPDUSessionReleaseCommand

func BuildGSMPDUSessionReleaseCommand(smContext *SMContext, cause uint8, isTriggeredByUE bool) ([]byte, error)

BuildGSMPDUSessionReleaseCommand makes a plain NAS message.

If isTriggeredByUE is true, the PTI field of the constructed NAS message is the value of smContext.Pti which is received from UE, otherwise it is 0. ref. 6.3.3.2 Network-requested PDU session release procedure initiation in TS24.501.

func BuildGSMPDUSessionReleaseReject

func BuildGSMPDUSessionReleaseReject(smContext *SMContext) ([]byte, error)

func BuildHandoverCommandTransfer

func BuildHandoverCommandTransfer(ctx *SMContext) ([]byte, error)

func BuildNASPacketFiltersFromFlowInformation

func BuildNASPacketFiltersFromFlowInformation(pfInfo *models.FlowInformation,
	smCtx *SMContext,
) ([]nasType.PacketFilter, error)

func BuildPDUSessionResourceModifyRequestTransfer

func BuildPDUSessionResourceModifyRequestTransfer(ctx *SMContext) ([]byte, error)

func BuildPDUSessionResourceReleaseCommandTransfer

func BuildPDUSessionResourceReleaseCommandTransfer(ctx *SMContext) (buf []byte, err error)

func BuildPDUSessionResourceSetupRequestTransfer

func BuildPDUSessionResourceSetupRequestTransfer(ctx *SMContext) ([]byte, error)

func BuildPathSwitchRequestAcknowledgeTransfer

func BuildPathSwitchRequestAcknowledgeTransfer(ctx *SMContext) ([]byte, error)

TS 38.413 9.3.4.9

func BuildPathSwitchRequestUnsuccessfulTransfer

func BuildPathSwitchRequestUnsuccessfulTransfer(causePresent int, causeValue aper.Enumerated) (buf []byte, err error)

func CheckUEHasPreConfig

func CheckUEHasPreConfig(supi string) (exist bool)

func GenerateChargingID

func GenerateChargingID() int32

func GenerateTEID

func GenerateTEID() (uint32, error)

func GetSMContextCount

func GetSMContextCount() uint64

func GetULCLGroupNameFromSUPI

func GetULCLGroupNameFromSUPI(supi string) string

func GetUpfIdFromUrrIdKey

func GetUpfIdFromUrrIdKey(urrIdKey string) string

func HandleHandoverRequestAcknowledgeTransfer

func HandleHandoverRequestAcknowledgeTransfer(b []byte, ctx *SMContext) error

func HandleHandoverRequiredTransfer

func HandleHandoverRequiredTransfer(b []byte, ctx *SMContext) error

func HandlePDUSessionResourceModifyResponseTransfer

func HandlePDUSessionResourceModifyResponseTransfer(b []byte, ctx *SMContext) error

func HandlePDUSessionResourceSetupResponseTransfer

func HandlePDUSessionResourceSetupResponseTransfer(b []byte, ctx *SMContext) error

func HandlePDUSessionResourceSetupUnsuccessfulTransfer

func HandlePDUSessionResourceSetupUnsuccessfulTransfer(b []byte, ctx *SMContext) error

func HandlePathSwitchRequestSetupFailedTransfer

func HandlePathSwitchRequestSetupFailedTransfer(b []byte, ctx *SMContext) error

func HandlePathSwitchRequestTransfer

func HandlePathSwitchRequestTransfer(b []byte, ctx *SMContext) error

func Init

func Init()

func InitSMFUERouting

func InitSMFUERouting(routingConfig *factory.RoutingConfig)

func InitSmfContext

func InitSmfContext(config *factory.Config)

func MeasureInformation

func MeasureInformation(isMeasurePkt, isMeasureBeforeQos bool) pfcpType.MeasurementInformation

func ReleaseTEID

func ReleaseTEID(teid uint32)

func RemoveSMContext

func RemoveSMContext(ref string)

*** add unit test ***//

func RemoveUPFNodeByNodeID

func RemoveUPFNodeByNodeID(nodeID pfcpType.NodeID) bool

*** add unit test ***//

func ResolveIP

func ResolveIP(host string) net.IP

func ResolveRef

func ResolveRef(id string, pduSessID int32) (string, error)

func SNssaiSmfInfo

func SNssaiSmfInfo() *[]models.SnssaiSmfInfoItem

func SetupSMFContext

func SetupSMFContext(config *factory.Config) error

Types

type AddingPSAState

type AddingPSAState int
const (
	ActivatingDataPath AddingPSAState = iota
	EstablishingNewPSA
	EstablishingULCL
	UpdatingPSA2DownLink
	UpdatingRANAndIUPFUpLink
	Finished
)

type BAR

type BAR struct {
	BARID uint8

	DownlinkDataNotificationDelay  pfcpType.DownlinkDataNotificationDelay
	SuggestedBufferingPacketsCount pfcpType.SuggestedBufferingPacketsCount

	State RuleState
}

Buffering Action Rule 7.5.2.6-1

type BPManager

type BPManager struct {
	BPStatus       BPStatus
	AddingPSAState AddingPSAState

	ActivatedPaths        []*DataPath
	ActivatingPath        *DataPath
	UpdatedBranchingPoint map[*UPF]int
	ULCL                  *UPF
}

func NewBPManager

func NewBPManager(supi string) (bpManager *BPManager)

func (*BPManager) FindULCL

func (bpMGR *BPManager) FindULCL(smContext *SMContext) error

func (*BPManager) SelectPSA2

func (bpMGR *BPManager) SelectPSA2(smContext *SMContext)

type BPStatus

type BPStatus int
const (
	UnInitialized BPStatus = iota
	AddingPSA
	AddPSASuccess
	InitializedSuccess
	InitializedFail
)

type ChargingInfo

type ChargingInfo struct {
	ChargingMethod         models.QuotaManagementIndicator
	VolumeLimitExpiryTimer *Timer
	EventLimitExpiryTimer  *Timer
	ChargingLevel          ChargingLevel
	RatingGroup            int32
	UpfId                  string
}

type ChargingLevel

type ChargingLevel uint8
const (
	PduSessionCharging ChargingLevel = iota
	FlowCharging
)

For a rating group that is pdu session charging level, all volume in a pdu session will be charged For a rating group that is flow charging level (or Rating group level (32.255)), only volume in a flow will be charged

type DLForwardingType

type DLForwardingType int
const (
	IndirectForwarding DLForwardingType = iota
	DirectForwarding
	NoForwarding
)

type DNS

type DNS struct {
	IPv4Addr net.IP
	IPv6Addr net.IP
}

type DataPath

type DataPath struct {
	PathID int64
	// meta data
	Activated         bool
	IsDefaultPath     bool
	GBRFlow           bool
	Destination       Destination
	HasBranchingPoint bool
	// Data Path Double Link List
	FirstDPNode *DataPathNode
}

func GenerateDataPath

func GenerateDataPath(upPath UPPath) *DataPath

func NewDataPath

func NewDataPath() *DataPath

func (*DataPath) ActivateTunnelAndPDR

func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence uint32)

func (*DataPath) AddChargingRules

func (p *DataPath) AddChargingRules(smContext *SMContext, chgLevel ChargingLevel, chgData *models.ChargingData)

func (*DataPath) AddForwardingParameters

func (p *DataPath) AddForwardingParameters(fwdPolicyID string, teid uint32)

func (*DataPath) AddQoS

func (p *DataPath) AddQoS(smContext *SMContext, qfi uint8, qos *models.QosData)

func (*DataPath) CopyFirstDPNode

func (dataPath *DataPath) CopyFirstDPNode() *DataPathNode

func (*DataPath) DeactivateTunnelAndPDR

func (dataPath *DataPath) DeactivateTunnelAndPDR(smContext *SMContext)

func (*DataPath) GetChargingUrr

func (p *DataPath) GetChargingUrr(smContext *SMContext) []*URR

func (*DataPath) RemovePDR

func (p *DataPath) RemovePDR()

func (*DataPath) String

func (dataPath *DataPath) String() string

func (*DataPath) UpdateFlowDescription

func (p *DataPath) UpdateFlowDescription(ulFlowDesc, dlFlowDesc string)

type DataPathNode

type DataPathNode struct {
	UPF *UPF

	UpLinkTunnel   *GTPTunnel
	DownLinkTunnel *GTPTunnel

	// InUse                bool
	IsBranchingPoint bool
}

func NewDataPathNode

func NewDataPathNode() *DataPathNode

func NewUEDataPathNode

func NewUEDataPathNode(name string) (node *DataPathNode, err error)

func (*DataPathNode) ActivateDownLinkTunnel

func (node *DataPathNode) ActivateDownLinkTunnel(smContext *SMContext) error

func (*DataPathNode) ActivateUpLinkTunnel

func (node *DataPathNode) ActivateUpLinkTunnel(smContext *SMContext) error

func (*DataPathNode) AddNext

func (node *DataPathNode) AddNext(next *DataPathNode)

func (*DataPathNode) AddPrev

func (node *DataPathNode) AddPrev(prev *DataPathNode)

func (*DataPathNode) DeactivateDownLinkTunnel

func (node *DataPathNode) DeactivateDownLinkTunnel(smContext *SMContext)

func (*DataPathNode) DeactivateUpLinkTunnel

func (node *DataPathNode) DeactivateUpLinkTunnel(smContext *SMContext)

func (*DataPathNode) GetNodeIP

func (node *DataPathNode) GetNodeIP() (ip string)

func (*DataPathNode) GetUPFID

func (node *DataPathNode) GetUPFID() (id string, err error)

func (*DataPathNode) GetUpLinkFAR

func (node *DataPathNode) GetUpLinkFAR() (far *FAR)

func (*DataPathNode) GetUpLinkPDR

func (node *DataPathNode) GetUpLinkPDR() (pdr *PDR)

func (*DataPathNode) IsANUPF

func (node *DataPathNode) IsANUPF() bool

func (*DataPathNode) IsAnchorUPF

func (node *DataPathNode) IsAnchorUPF() bool

func (*DataPathNode) Next

func (node *DataPathNode) Next() *DataPathNode

func (*DataPathNode) Prev

func (node *DataPathNode) Prev() *DataPathNode

type DataPathPool

type DataPathPool map[int64]*DataPath

func NewDataPathPool

func NewDataPathPool() DataPathPool

func (DataPathPool) GetDefaultPath

func (dataPathPool DataPathPool) GetDefaultPath() *DataPath

func (DataPathPool) ResetDefaultPath

func (dataPathPool DataPathPool) ResetDefaultPath() error

type DefaultPathPool

type DefaultPathPool map[string]*DataPath // key: UPF name

type Destination

type Destination struct {
	DestinationIP   string
	DestinationPort string
	Url             string
}

type DnnUPFInfoItem

type DnnUPFInfoItem struct {
	Dnn             string
	DnaiList        []string
	PduSessionTypes []models.PduSessionType
	UeIPPools       []*UeIPPool
	StaticIPPools   []*UeIPPool
}

DnnUpfInfoItem presents UPF dnn information

func (*DnnUPFInfoItem) ContainsDNAI

func (d *DnnUPFInfoItem) ContainsDNAI(targetDnai string) bool

ContainsDNAI return true if the this dnn Info contains the specify DNAI

func (*DnnUPFInfoItem) ContainsIPPool

func (d *DnnUPFInfoItem) ContainsIPPool(ip net.IP) bool

ContainsIPPool returns true if the ip pool of this upf dnn info contains the `ip`

type EventExposureNotification

type EventExposureNotification struct {
	*models.NsmfEventExposureNotification

	Uri string
}

type FAR

type FAR struct {
	FARID uint32

	ApplyAction          pfcpType.ApplyAction
	ForwardingParameters *ForwardingParameters

	BAR   *BAR
	State RuleState
}

Forwarding Action Rule. 7.5.2.3-1

type FSEID

type FSEID struct {
	IP   net.IP
	SEID uint64
}

type ForwardingParameters

type ForwardingParameters struct {
	DestinationInterface pfcpType.DestinationInterface
	NetworkInstance      *pfcpType.NetworkInstance
	OuterHeaderCreation  *pfcpType.OuterHeaderCreation
	ForwardingPolicyID   string
	SendEndMarker        bool
}

Forwarding Parameters. 7.5.2.3-2

type GTPTunnel

type GTPTunnel struct {
	SrcEndPoint  *DataPathNode
	DestEndPoint *DataPathNode

	TEID uint32
	PDR  *PDR
}

GTPTunnel represents the GTP tunnel information

type NFContext

type NFContext interface {
	AuthorizationCheck(token string, serviceName models.ServiceName) error
}

type NFProfile

type NFProfile struct {
	NFServices       *[]models.NfService
	NFServiceVersion *[]models.NfServiceVersion
	SMFInfo          *models.SmfInfo
	PLMNList         *[]models.PlmnId
}

type NotifCallback

type NotifCallback func(uri string,
	notification *models.NsmfEventExposureNotification)

type PCCRule

type PCCRule struct {
	*models.PccRule
	QFI uint8
	// related Data
	Datapath *DataPath
}

PCCRule - Policy and Charging Rule

func NewPCCRule

func NewPCCRule(mPcc *models.PccRule) *PCCRule

NewPCCRule - create PCC rule from OpenAPI models

func (*PCCRule) AddDataPathForwardingParameters

func (r *PCCRule) AddDataPathForwardingParameters(c *SMContext,
	tgtRoute *models.RouteToLocation,
)

func (*PCCRule) BuildNasQoSRule

func (r *PCCRule) BuildNasQoSRule(smCtx *SMContext,
	opCode nasType.QoSRuleOperationCode,
) (*nasType.QoSRule, error)

func (*PCCRule) FlowDescription

func (r *PCCRule) FlowDescription() string

func (*PCCRule) IdentifyChargingLevel

func (r *PCCRule) IdentifyChargingLevel() (ChargingLevel, error)

func (*PCCRule) RefChgDataID

func (r *PCCRule) RefChgDataID() string

func (*PCCRule) RefQosDataID

func (r *PCCRule) RefQosDataID() string

func (*PCCRule) RefTcDataID

func (r *PCCRule) RefTcDataID() string

func (*PCCRule) SetQFI

func (r *PCCRule) SetQFI(qfi uint8)

func (*PCCRule) UpdateDataPathFlowDescription

func (r *PCCRule) UpdateDataPathFlowDescription(dlFlowDesc string) error

type PCSCF

type PCSCF struct {
	IPv4Addr net.IP
}

type PDI

type PDI struct {
	SourceInterface pfcpType.SourceInterface
	LocalFTeid      *pfcpType.FTEID
	NetworkInstance *pfcpType.NetworkInstance
	UEIPAddress     *pfcpType.UEIPAddress
	SDFFilter       *pfcpType.SDFFilter
	ApplicationID   string
}

Packet Detection. 7.5.2.2-2

type PDR

type PDR struct {
	PDRID uint16

	Precedence         uint32
	PDI                PDI
	OuterHeaderRemoval *pfcpType.OuterHeaderRemoval

	FAR *FAR
	URR []*URR
	QER []*QER

	State RuleState
}

Packet Detection Rule. Table 7.5.2.2-1

func (*PDR) AppendURRs

func (pdr *PDR) AppendURRs(urrs []*URR)

type PFCPSessionContext

type PFCPSessionContext struct {
	PDRs       map[uint16]*PDR
	NodeID     pfcpType.NodeID
	LocalSEID  uint64
	RemoteSEID uint64
}

func (*PFCPSessionContext) String

func (pfcpSessionContext *PFCPSessionContext) String() string

type PFCPSessionResponseStatus

type PFCPSessionResponseStatus int
const (
	SessionEstablishSuccess PFCPSessionResponseStatus = iota
	SessionEstablishFailed
	SessionUpdateSuccess
	SessionUpdateFailed
	SessionReleaseSuccess
	SessionReleaseFailed
)

func (PFCPSessionResponseStatus) String

func (pfcpSessionResponseStatus PFCPSessionResponseStatus) String() string

type ProtocolConfigurationOptions

type ProtocolConfigurationOptions struct {
	DNSIPv4Request     bool
	DNSIPv6Request     bool
	PCSCFIPv4Request   bool
	IPv4LinkMTURequest bool
}

type QER

type QER struct {
	QERID uint32

	QFI pfcpType.QFI

	GateStatus *pfcpType.GateStatus
	MBR        *pfcpType.MBR
	GBR        *pfcpType.GBR

	State RuleState
}

QoS Enhancement Rule

type QoSFlow

type QoSFlow struct {
	QFI        uint8
	QoSProfile *models.QosData
	State      QoSFlowState
}

func NewQoSFlow

func NewQoSFlow(qfi uint8, qosModel *models.QosData) *QoSFlow

func (*QoSFlow) BuildNasQoSDesc

func (q *QoSFlow) BuildNasQoSDesc(opCode nasType.QoSFlowOperationCode) (nasType.QoSFlowDesc, error)

func (*QoSFlow) BuildNgapQosFlowAddOrModifyRequestItem

func (q *QoSFlow) BuildNgapQosFlowAddOrModifyRequestItem() (ngapType.QosFlowAddOrModifyRequestItem, error)

func (*QoSFlow) BuildNgapQosFlowSetupRequestItem

func (q *QoSFlow) BuildNgapQosFlowSetupRequestItem() (ngapType.QosFlowSetupRequestItem, error)

func (*QoSFlow) Get5QI

func (q *QoSFlow) Get5QI() uint8

func (*QoSFlow) GetQFI

func (q *QoSFlow) GetQFI() uint8

func (*QoSFlow) GetQoSProfile

func (q *QoSFlow) GetQoSProfile() *models.QosData

func (*QoSFlow) IsGBRFlow

func (q *QoSFlow) IsGBRFlow() bool

type QoSFlowState

type QoSFlowState int
const (
	QoSFlowUnset QoSFlowState = iota
	QoSFlowSet
	QoSFlowToBeModify
)

type RequestType

type RequestType uint8
const (
	CHARGING_INIT RequestType = iota
	CHARGING_UPDATE
	CHARGING_RELEASE
)

For each charging event, it will have a corresponding charging request type, see 32.255 Table 5.2.1.4.1

type RuleState

type RuleState uint8
const (
	RULE_INITIAL RuleState = 0
	RULE_CREATE  RuleState = 1
	RULE_UPDATE  RuleState = 2
	RULE_REMOVE  RuleState = 3
	RULE_QUERY   RuleState = 4
)

type SMContext

type SMContext struct {
	*models.SmContextCreateData

	Ref string

	LocalSEID  uint64
	RemoteSEID uint64

	UnauthenticatedSupi bool

	Pei          string
	Identifier   string
	PDUSessionID int32

	LocalULTeid uint32
	LocalDLTeid uint32

	UpCnxState models.UpCnxState

	HoState models.HoState

	SelectionParam         *UPFSelectionParams
	PDUAddress             net.IP
	UseStaticIP            bool
	SelectedPDUSessionType uint8

	DnnConfiguration models.DnnConfiguration

	SMPolicyID string

	// Handover related
	DLForwardingType         DLForwardingType
	DLDirectForwardingTunnel *ngapType.UPTransportLayerInformation
	IndirectForwardingTunnel *DataPath

	// UP Security support TS 29.502 R16 6.1.6.2.39
	UpSecurity                                                     *models.UpSecurity
	MaximumDataRatePerUEForUserPlaneIntegrityProtectionForUpLink   models.MaxIntegrityProtectedDataRate
	MaximumDataRatePerUEForUserPlaneIntegrityProtectionForDownLink models.MaxIntegrityProtectedDataRate
	// SMF verified UP security result of Xn-handover TS 33.501 6.6.1
	UpSecurityFromPathSwitchRequestSameAsLocalStored bool

	// Client
	CommunicationClientApiPrefix string

	AMFProfile         models.NfProfile
	SelectedPCFProfile models.NfProfile
	SelectedCHFProfile models.NfProfile
	SmStatusNotifyUri  string

	Tunnel      *UPTunnel
	SelectedUPF *UPNode
	BPManager   *BPManager
	// NodeID(string form) to PFCP Session Context
	PFCPContext                         map[string]*PFCPSessionContext
	PDUSessionRelease_DUE_TO_DUP_PDU_ID bool

	DNNInfo *SnssaiSmfDnnInfo

	// SM Policy related
	PCCRules            map[string]*PCCRule
	SessionRules        map[string]*SessionRule
	TrafficControlDatas map[string]*TrafficControlData
	ChargingData        map[string]*models.ChargingData
	QosDatas            map[string]*models.QosData

	UpPathChgEarlyNotification map[string]*EventExposureNotification // Key: Uri+NotifId
	UpPathChgLateNotification  map[string]*EventExposureNotification // Key: Uri+NotifId
	DataPathToBeRemoved        map[int64]*DataPath                   // Key: pathID

	SelectedSessionRuleID string

	// QoS
	QoSRuleIDGenerator      *idgenerator.IDGenerator
	PacketFilterIDGenerator *idgenerator.IDGenerator
	QFIGenerator            *idgenerator.IDGenerator
	PCCRuleIDToQoSRuleID    map[string]uint8

	PacketFilterIDToNASPFID map[string]uint8
	AMBRQerMap              map[uuid.UUID]uint32
	QerUpfMap               map[string]uint32
	AdditonalQosFlows       map[uint8]*QoSFlow // Key: qfi

	// URR
	UrrIDGenerator     *idgenerator.IDGenerator
	UrrIdMap           map[UrrType]uint32
	UrrUpfMap          map[string]*URR
	UrrReportTime      time.Duration
	UrrReportThreshold uint64
	// Cache the usage reports, sent from UPF
	// Those information will be included in CDR.
	UrrReports []UsageReport

	// Charging Related
	ChargingDataRef string
	// Each PDU session has a unique charging id
	ChargingID    int32
	RequestedUnit int32
	// key = urrid
	// All urr can map to a rating group
	// However, a rating group may map to more than one urr
	// e.g. In UL CL case, the rating group for recoreding PDU Session volume may map to two URR
	//		one is for PSA 1, the other is for PSA 2.
	ChargingInfo map[uint32]*ChargingInfo
	// NAS
	Pti                     uint8
	EstAcceptCause5gSMValue uint8

	// PCO Related
	ProtocolConfigurationOptions *ProtocolConfigurationOptions

	UeCmRegistered bool

	// Loggers
	Log *logrus.Entry

	// 5GSM Timers
	// T3591 is PDU SESSION MODIFICATION COMMAND timer
	T3591 *Timer
	// T3592 is PDU SESSION RELEASE COMMAND timer
	T3592 *Timer

	// lock
	SMLock sync.Mutex
	// contains filtered or unexported fields
}

func GetSMContextById

func GetSMContextById(id string, pduSessID int32) *SMContext

func GetSMContextByRef

func GetSMContextByRef(ref string) *SMContext

*** add unit test ***//

func GetSMContextBySEID

func GetSMContextBySEID(seid uint64) *SMContext

*** add unit test ***//

func NewSMContext

func NewSMContext(id string, pduSessID int32) *SMContext

func (*SMContext) AddQosFlow

func (c *SMContext) AddQosFlow(qfi uint8, qos *models.QosData)

func (*SMContext) AllocUeIP

func (c *SMContext) AllocUeIP() error

func (*SMContext) AllocateLocalSEIDForDataPath

func (smContext *SMContext) AllocateLocalSEIDForDataPath(dataPath *DataPath)

func (*SMContext) AllocateLocalSEIDForUPPath

func (smContext *SMContext) AllocateLocalSEIDForUPPath(path UPPath)

func (*SMContext) ApplyPccRules

func (c *SMContext) ApplyPccRules(
	decision *models.SmPolicyDecision,
) error

func (*SMContext) ApplySessionRules

func (c *SMContext) ApplySessionRules(
	decision *models.SmPolicyDecision,
) error

func (*SMContext) AssignQFI

func (smContext *SMContext) AssignQFI(qosId string) uint8

func (*SMContext) BuildCreatedData

func (smContext *SMContext) BuildCreatedData() *models.SmContextCreatedData

func (*SMContext) BuildUpPathChgEventExposureNotification

func (c *SMContext) BuildUpPathChgEventExposureNotification(
	chgEvent *models.UpPathChgEvent,
	srcRoute, tgtRoute *models.RouteToLocation,
)

func (*SMContext) CheckState

func (smContext *SMContext) CheckState(state SMContextState) bool

func (*SMContext) CreatePccRuleDataPath

func (c *SMContext) CreatePccRuleDataPath(pccRule *PCCRule,
	tcData *TrafficControlData, qosData *models.QosData,
	chgData *models.ChargingData,
) error

func (*SMContext) GenerateUrrId

func (smContext *SMContext) GenerateUrrId()

func (*SMContext) GetNodeIDByLocalSEID

func (smContext *SMContext) GetNodeIDByLocalSEID(seid uint64) pfcpType.NodeID

func (*SMContext) HandleReports

func (smContext *SMContext) HandleReports(
	usageReportRequest []*pfcp.UsageReportPFCPSessionReportRequest,
	usageReportModification []*pfcp.UsageReportPFCPSessionModificationResponse,
	usageReportDeletion []*pfcp.UsageReportPFCPSessionDeletionResponse,
	nodeId pfcpType.NodeID, reportTpye models.TriggerType,
)

func (*SMContext) IsAllowedPDUSessionType

func (smContext *SMContext) IsAllowedPDUSessionType(requestedPDUSessionType uint8) error

func (*SMContext) PDUAddressToNAS

func (smContext *SMContext) PDUAddressToNAS() ([12]byte, uint8)

func (*SMContext) PostRemoveDataPath

func (c *SMContext) PostRemoveDataPath()

Remove data path after receiving PFCP rsp

func (*SMContext) PreRemoveDataPath

func (c *SMContext) PreRemoveDataPath(dp *DataPath)

Set data path PDR to REMOVE beofre sending PFCP req

func (*SMContext) PutPDRtoPFCPSession

func (smContext *SMContext) PutPDRtoPFCPSession(nodeID pfcpType.NodeID, pdr *PDR) error

func (*SMContext) RemovePDRfromPFCPSession

func (smContext *SMContext) RemovePDRfromPFCPSession(nodeID pfcpType.NodeID, pdr *PDR)

func (*SMContext) RemoveQFI

func (smContext *SMContext) RemoveQFI(qosId string)

func (*SMContext) RemoveQosFlow

func (c *SMContext) RemoveQosFlow(qfi uint8)

func (*SMContext) SelectDefaultDataPath

func (c *SMContext) SelectDefaultDataPath() error

This function create a data path to be default data path.

func (*SMContext) SelectedSessionRule

func (c *SMContext) SelectedSessionRule() *SessionRule

SelectedSessionRule - return the SMF selected session rule for this SM Context

func (*SMContext) SendUpPathChgNotification

func (c *SMContext) SendUpPathChgNotification(chgType string, notifCb NotifCallback)

func (*SMContext) SetState

func (smContext *SMContext) SetState(state SMContextState)

func (*SMContext) State

func (smContext *SMContext) State() SMContextState

func (*SMContext) StopT3591

func (smContext *SMContext) StopT3591()

func (*SMContext) StopT3592

func (smContext *SMContext) StopT3592()

type SMContextState

type SMContextState uint32
const (
	InActive SMContextState = iota
	ActivePending
	Active
	InActivePending
	ModificationPending
	PFCPModification
)

func (SMContextState) String

func (smContextState SMContextState) String() string

type SMFContext

type SMFContext struct {
	Name         string
	NfInstanceID string

	URIScheme    models.UriScheme
	BindingIPv4  string
	RegisterIPv4 string
	SBIPort      int

	// N4 interface-related
	CPNodeID     pfcpType.NodeID
	ExternalAddr string
	ListenAddr   string

	UDMProfile models.NfProfile
	NfProfile  NFProfile

	Key    string
	PEM    string
	KeyLog string

	SnssaiInfos []*SnssaiSmfInfo

	NrfUri                 string
	NrfCertPem             string
	Locality               string
	AssocFailAlertInterval time.Duration
	AssocFailRetryInterval time.Duration
	OAuth2Required         bool

	UserPlaneInformation  *UserPlaneInformation
	Ctx                   context.Context
	PFCPCancelFunc        context.CancelFunc
	PfcpHeartbeatInterval time.Duration

	// Now only "IPv4" supported
	// TODO: support "IPv6", "IPv4v6", "Ethernet"
	SupportedPDUSessionType string

	// *** For ULCL *** //
	ULCLSupport         bool
	ULCLGroups          map[string][]string
	UEPreConfigPathPool map[string]*UEPreConfigPaths
	UEDefaultPathPool   map[string]*UEDefaultPaths
	LocalSEIDCount      uint64

	// Each pdu session should have a unique charging id
	ChargingIDGenerator *idgenerator.IDGenerator
}

func GetSelf

func GetSelf() *SMFContext

func (*SMFContext) AuthorizationCheck

func (c *SMFContext) AuthorizationCheck(token string, serviceName models.ServiceName) error

func (*SMFContext) ExternalIP

func (s *SMFContext) ExternalIP() net.IP

func (*SMFContext) GetTokenCtx

func (c *SMFContext) GetTokenCtx(serviceName models.ServiceName, targetNF models.NfType) (
	context.Context, *models.ProblemDetails, error,
)

func (*SMFContext) ListenIP

func (s *SMFContext) ListenIP() net.IP

func (*SMFContext) SetupNFProfile

func (c *SMFContext) SetupNFProfile(nfProfileconfig *factory.Config)

type SNssai

type SNssai struct {
	Sst int32
	Sd  string
}

func (*SNssai) Equal

func (s *SNssai) Equal(target *SNssai) bool

Equal return true if two S-NSSAI is equal

func (*SNssai) EqualModelsSnssai

func (s *SNssai) EqualModelsSnssai(target *models.Snssai) bool

type SessionRule

type SessionRule struct {
	*models.SessionRule
	DefQosQFI uint8
}

SessionRule - A session rule consists of policy information elements associated with PDU session.

func NewSessionRule

func NewSessionRule(model *models.SessionRule) *SessionRule

NewSessionRule - create session rule from OpenAPI models

type SnssaiSmfDnnInfo

type SnssaiSmfDnnInfo struct {
	DNS   DNS
	PCSCF PCSCF
}

SnssaiSmfDnnInfo records the SMF per S-NSSAI DNN information

func RetrieveDnnInformation

func RetrieveDnnInformation(snssai *models.Snssai, dnn string) *SnssaiSmfDnnInfo

RetrieveDnnInformation gets the corresponding dnn info from S-NSSAI and DNN

type SnssaiSmfInfo

type SnssaiSmfInfo struct {
	Snssai   SNssai
	DnnInfos map[string]*SnssaiSmfDnnInfo
}

SnssaiSmfInfo records the SMF S-NSSAI related information

type SnssaiUPFInfo

type SnssaiUPFInfo struct {
	SNssai  *SNssai
	DnnList []*DnnUPFInfoItem
}

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer can be used for retransmission, it will manage retry times automatically

func NewTimer

func NewTimer(d time.Duration, maxRetryTimes int,
	expiredFunc func(expireTimes int32),
	cancelFunc func(),
) *Timer

NewTimer will return a Timer struct and create a goroutine. Then it calls expiredFunc every time interval d until the user call Stop(). the number of expire event is be recorded when the timer is active. When the number of expire event is > maxRetryTimes, then the timer will call cancelFunc and turns off itself. Whether expiredFunc pass a parameter expireTimes to tell the user that the current expireTimes.

func (*Timer) ExpireTimes

func (t *Timer) ExpireTimes() int32

ExpireTimes return the current expire times of the timer

func (*Timer) MaxRetryTimes

func (t *Timer) MaxRetryTimes() int32

MaxRetryTimes return the max retry times of the timer

func (*Timer) Stop

func (t *Timer) Stop()

Stop turns off the timer, after Stop, no more timeout event will be triggered. User should call Stop() only once otherwise it may hang on writing to done channel

type TrafficControlData

type TrafficControlData struct {
	*models.TrafficControlData
}

TrafficControlData - Traffic control data defines how traffic data flows associated with a rule are treated (e.g. blocked, redirected).

func NewTrafficControlData

func NewTrafficControlData(model *models.TrafficControlData) *TrafficControlData

NewTrafficControlData - create the traffic control data from OpenAPI model

type UEDefaultPaths

type UEDefaultPaths struct {
	AnchorUPFs      []string // list of UPF name
	DefaultPathPool DefaultPathPool
}

func GetUEDefaultPathPool

func GetUEDefaultPathPool(groupName string) *UEDefaultPaths

func NewUEDefaultPaths

func NewUEDefaultPaths(upi *UserPlaneInformation, topology []factory.UPLink) (*UEDefaultPaths, error)

func (*UEDefaultPaths) GetDefaultPath

func (dfp *UEDefaultPaths) GetDefaultPath(upfName string) *DataPath

func (*UEDefaultPaths) SelectUPFAndAllocUEIPForULCL

func (dfp *UEDefaultPaths) SelectUPFAndAllocUEIPForULCL(upi *UserPlaneInformation,
	selection *UPFSelectionParams,
) (string, net.IP, bool)

type UEPreConfigPaths

type UEPreConfigPaths struct {
	DataPathPool    DataPathPool
	PathIDGenerator *idgenerator.IDGenerator
}

func GetUEPreConfigPaths

func GetUEPreConfigPaths(supi string, upfName string) *UEPreConfigPaths

func NewUEPreConfigPaths

func NewUEPreConfigPaths(paths []factory.SpecificPath) (*UEPreConfigPaths, error)

type UPF

type UPF struct {
	NodeID            pfcpType.NodeID
	Addr              string
	UPIPInfo          pfcpType.UserPlaneIPResourceInformation
	UPFStatus         UPFStatus
	RecoveryTimeStamp time.Time

	Ctx        context.Context
	CancelFunc context.CancelFunc

	SNssaiInfos  []*SnssaiUPFInfo
	N3Interfaces []*UPFInterfaceInfo
	N9Interfaces []*UPFInterfaceInfo
	// contains filtered or unexported fields
}

func GetUpfById

func GetUpfById(uuid string) *UPF

func NewUPF

func NewUPF(nodeID *pfcpType.NodeID, ifaces []*factory.InterfaceUpfInfoItem) (upf *UPF)

*** add unit test ***// NewUPF returns a new UPF context in SMF

func RetrieveUPFNodeByNodeID

func RetrieveUPFNodeByNodeID(nodeID pfcpType.NodeID) *UPF

*** add unit test ***//

func SelectUPFByDnn

func SelectUPFByDnn(dnn string) *UPF

func (*UPF) AddBAR

func (upf *UPF) AddBAR() (*BAR, error)

func (*UPF) AddFAR

func (upf *UPF) AddFAR() (*FAR, error)

func (*UPF) AddPDR

func (upf *UPF) AddPDR() (*PDR, error)

func (*UPF) AddQER

func (upf *UPF) AddQER() (*QER, error)

func (*UPF) AddURR

func (upf *UPF) AddURR(urrId uint32, opts ...UrrOpt) (*URR, error)

func (*UPF) GetInterface

func (upf *UPF) GetInterface(interfaceType models.UpInterfaceType, dnn string) *UPFInterfaceInfo

*** add unit test ***// GetInterface return the UPFInterfaceInfo that match input cond

func (*UPF) GetQERById

func (upf *UPF) GetQERById(qerId uint32) *QER

func (*UPF) GetUPFID

func (upf *UPF) GetUPFID() string

func (*UPF) GetUPFIP

func (upf *UPF) GetUPFIP() string

func (*UPF) GetUUID

func (upf *UPF) GetUUID() uuid.UUID

func (*UPF) PFCPAddr

func (upf *UPF) PFCPAddr() *net.UDPAddr

func (*UPF) ProcEachSMContext

func (upf *UPF) ProcEachSMContext(procFunc func(*SMContext))

func (*UPF) RemoveBAR

func (upf *UPF) RemoveBAR(bar *BAR) (err error)

*** add unit test ***//

func (*UPF) RemoveFAR

func (upf *UPF) RemoveFAR(far *FAR) (err error)

*** add unit test ***//

func (*UPF) RemovePDR

func (upf *UPF) RemovePDR(pdr *PDR) (err error)

*** add unit test ***//

func (*UPF) RemoveQER

func (upf *UPF) RemoveQER(qer *QER) (err error)

*** add unit test ***//

func (*UPF) UUID

func (upf *UPF) UUID() string

UUID return this UPF UUID (allocate by SMF in this time) Maybe allocate by UPF in future

type UPFInterfaceInfo

type UPFInterfaceInfo struct {
	NetworkInstances      []string
	IPv4EndPointAddresses []net.IP
	IPv6EndPointAddresses []net.IP
	EndpointFQDN          string
}

UPFInterfaceInfo store the UPF interface information

func NewUPFInterfaceInfo

func NewUPFInterfaceInfo(i *factory.InterfaceUpfInfoItem) *UPFInterfaceInfo

NewUPFInterfaceInfo parse the InterfaceUpfInfoItem to generate UPFInterfaceInfo

func (*UPFInterfaceInfo) IP

func (i *UPFInterfaceInfo) IP(pduSessType uint8) (net.IP, error)

*** add unit test ***// IP returns the IP of the user plane IP information of the pduSessType

type UPFSelectionParams

type UPFSelectionParams struct {
	Dnn        string
	SNssai     *SNssai
	Dnai       string
	PDUAddress net.IP
}

UPFSelectionParams ... parameters for upf selection

func (*UPFSelectionParams) String

func (upfSelectionParams *UPFSelectionParams) String() string

type UPFStatus

type UPFStatus int
const (
	NotAssociated          UPFStatus = 0
	AssociatedSettingUp    UPFStatus = 1
	AssociatedSetUpSuccess UPFStatus = 2
)

type UPNode

type UPNode struct {
	Name   string
	Type   UPNodeType
	NodeID pfcpType.NodeID
	ANIP   net.IP
	Dnn    string
	Links  []*UPNode
	UPF    *UPF
}

UPNode represent the user plane node topology

func (*UPNode) MatchedSelection

func (u *UPNode) MatchedSelection(selection *UPFSelectionParams) bool

type UPNodeType

type UPNodeType string
const (
	UPNODE_UPF UPNodeType = "UPF"
	UPNODE_AN  UPNodeType = "AN"
)

type UPPath

type UPPath []*UPNode

UPPath represent User Plane Sequence of this path

type UPTunnel

type UPTunnel struct {
	PathIDGenerator *idgenerator.IDGenerator
	DataPathPool    DataPathPool
	ANInformation   struct {
		IPAddress net.IP
		TEID      uint32
	}
}

func NewUPTunnel

func NewUPTunnel() (tunnel *UPTunnel)

func (*UPTunnel) AddDataPath

func (t *UPTunnel) AddDataPath(dataPath *DataPath)

*** add unit test ***//

func (*UPTunnel) RemoveDataPath

func (t *UPTunnel) RemoveDataPath(pathID int64)

func (*UPTunnel) UpdateANInformation

func (t *UPTunnel) UpdateANInformation(ip net.IP, teid uint32)

type URR

type URR struct {
	URRID                  uint32
	MeasureMethod          string // vol or time
	ReportingTrigger       pfcpType.ReportingTriggers
	MeasurementPeriod      time.Duration
	QuotaValidityTime      time.Time
	MeasurementInformation pfcpType.MeasurementInformation
	VolumeThreshold        uint64
	VolumeQuota            uint64
	State                  RuleState
}

Usage Report Rule

type UeIPPool

type UeIPPool struct {
	// contains filtered or unexported fields
}

UeIPPool represent IPv4 address pool for UE

func NewUEIPPool

func NewUEIPPool(factoryPool *factory.UEIPPool) *UeIPPool

func (*UeIPPool) Allocate

func (ueIPPool *UeIPPool) Allocate(request net.IP) net.IP

func (*UeIPPool) Exclude

func (ueIPPool *UeIPPool) Exclude(excludePool *UeIPPool) error

func (*UeIPPool) Pool

func (u *UeIPPool) Pool() *pool.LazyReusePool

func (*UeIPPool) Release

func (ueIPPool *UeIPPool) Release(addr net.IP)

type UrrOpt

type UrrOpt func(urr *URR)

func NewMeasureInformation

func NewMeasureInformation(isMeasurePkt, isMeasureBeforeQos bool) UrrOpt

func NewMeasurementPeriod

func NewMeasurementPeriod(time time.Duration) UrrOpt

func NewVolumeQuota

func NewVolumeQuota(quota uint64) UrrOpt

func NewVolumeThreshold

func NewVolumeThreshold(threshold uint64) UrrOpt

func SetStartOfSDFTrigger

func SetStartOfSDFTrigger() UrrOpt

type UrrType

type UrrType int
const (
	N3N6_MBQE_URR UrrType = iota
	N3N6_MAQE_URR
	N3N9_MBQE_URR
	N3N9_MAQE_URR
	N9N6_MBQE_URR
	N9N6_MAQE_URR
	NOT_FOUND_URR
)

Reserved URR report for ID = 0 ~ 6

func (UrrType) Direct

func (t UrrType) Direct() string

func (UrrType) IsBeforeQos

func (t UrrType) IsBeforeQos() bool

func (UrrType) String

func (t UrrType) String() string

type UsageReport

type UsageReport struct {
	UrrId uint32
	UpfId string

	TotalVolume    uint64
	UplinkVolume   uint64
	DownlinkVolume uint64

	TotalPktNum    uint64
	UplinkPktNum   uint64
	DownlinkPktNum uint64

	ReportTpye models.TriggerType
}

type UserPlaneInformation

type UserPlaneInformation struct {
	Mu                        sync.RWMutex // protect UPF and topology structure
	UPNodes                   map[string]*UPNode
	UPFs                      map[string]*UPNode
	AccessNetwork             map[string]*UPNode
	UPFIPToName               map[string]string
	UPFsID                    map[string]string               // name to id
	UPFsIPtoID                map[string]string               // ip->id table, for speed optimization
	DefaultUserPlanePath      map[string][]*UPNode            // DNN to Default Path
	DefaultUserPlanePathToUPF map[string]map[string][]*UPNode // DNN and UPF to Default Path
}

UserPlaneInformation store userplane topology

func GetUserPlaneInformation

func GetUserPlaneInformation() *UserPlaneInformation

func NewUserPlaneInformation

func NewUserPlaneInformation(upTopology *factory.UserPlaneInformation) *UserPlaneInformation

NewUserPlaneInformation process the configuration then returns a new instance of UserPlaneInformation

func (*UserPlaneInformation) ExistDefaultPath

func (upi *UserPlaneInformation) ExistDefaultPath(dnn string) bool

func (*UserPlaneInformation) GenerateDefaultPath

func (upi *UserPlaneInformation) GenerateDefaultPath(selection *UPFSelectionParams) bool

func (*UserPlaneInformation) GenerateDefaultPathToUPF

func (upi *UserPlaneInformation) GenerateDefaultPathToUPF(selection *UPFSelectionParams, destination *UPNode) bool

func (*UserPlaneInformation) GetDefaultUserPlanePathByDNN

func (upi *UserPlaneInformation) GetDefaultUserPlanePathByDNN(selection *UPFSelectionParams) (path UPPath)

func (*UserPlaneInformation) GetDefaultUserPlanePathByDNNAndUPF

func (upi *UserPlaneInformation) GetDefaultUserPlanePathByDNNAndUPF(selection *UPFSelectionParams,
	upf *UPNode,
) (path UPPath)

func (*UserPlaneInformation) GetUPFIDByIP

func (upi *UserPlaneInformation) GetUPFIDByIP(ip string) string

func (*UserPlaneInformation) GetUPFNameByIp

func (upi *UserPlaneInformation) GetUPFNameByIp(ip string) string

func (*UserPlaneInformation) GetUPFNodeByIP

func (upi *UserPlaneInformation) GetUPFNodeByIP(ip string) *UPNode

func (*UserPlaneInformation) GetUPFNodeIDByName

func (upi *UserPlaneInformation) GetUPFNodeIDByName(name string) pfcpType.NodeID

func (*UserPlaneInformation) LinksFromConfiguration

func (upi *UserPlaneInformation) LinksFromConfiguration(upTopology *factory.UserPlaneInformation)

func (*UserPlaneInformation) LinksToConfiguration

func (upi *UserPlaneInformation) LinksToConfiguration() []*factory.UPLink

func (*UserPlaneInformation) ReleaseUEIP

func (upi *UserPlaneInformation) ReleaseUEIP(upf *UPNode, addr net.IP, static bool)

func (*UserPlaneInformation) SelectUPFAndAllocUEIP

func (upi *UserPlaneInformation) SelectUPFAndAllocUEIP(selection *UPFSelectionParams) (*UPNode, net.IP, bool)

SelectUPFAndAllocUEIP will return anchor UPF, allocated UE IP and use/not use static IP

func (*UserPlaneInformation) UpNodeDelete

func (upi *UserPlaneInformation) UpNodeDelete(upNodeName string)

func (*UserPlaneInformation) UpNodesFromConfiguration

func (upi *UserPlaneInformation) UpNodesFromConfiguration(upTopology *factory.UserPlaneInformation)

func (*UserPlaneInformation) UpNodesToConfiguration

func (upi *UserPlaneInformation) UpNodesToConfiguration() map[string]*factory.UPNode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL