gy

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

CreditControl constants and structs to be used in sending/receiving messages

GyClient is a client to send Credit Control Request messages over diameter And receive Credit Control Answer messages in response

Index

Constants

View Source
const (
	OCSAddrEnv              = "OCS_ADDR"
	GyNetworkEnv            = "GY_NETWORK"
	GyDiamHostEnv           = "GY_DIAM_HOST"
	GyDiamRealmEnv          = "GY_DIAM_REALM"
	GyDiamProductEnv        = "GY_DIAM_PRODUCT"
	GyInitMethodEnv         = "GY_INIT_METHOD"
	GyLocalAddr             = "GY_LOCAL_ADDR"
	OCSHostEnv              = "OCS_HOST"
	OCSRealmEnv             = "OCS_REALM"
	OCSApnOverwriteEnv      = "OCS_APN_OVERWRITE"
	OCSServiceIdentifierEnv = "OCS_SERVICE_IDENTIFIER_OVERWRITE"
	DisableDestHostEnv      = "DISABLE_DEST_HOST"
	OverwriteDestHostEnv    = "GY_OVERWRITE_DEST_HOST"
	UseGyForAuthOnlyEnv     = "USE_GY_FOR_AUTH_ONLY"
	GySupportedVendorIDsEnv = "GY_SUPPORTED_VENDOR_IDS"
	GyServiceContextIdEnv   = "GY_SERVICE_CONTEXT_ID"

	GyInitMethodFlag         = "gy_init_method"
	OCSApnOverwriteFlag      = "ocs_apn_overwrite"
	OCSServiceIdentifierFlag = "ocs_service_identifier_overwrite"
)

OCS Environment Variables

View Source
const (
	// 3GPP TS 29.274 RAT Types (for Gy)
	RAT_TYPE_WLAN   = "\x03"
	RAT_TYPE_EUTRAN = "\x06"
)
View Source
const (
	RetryCount = 2
)

Variables

This section is empty.

Functions

func GetGyClientConfiguration

func GetGyClientConfiguration() []*diameter.DiameterClientConfig

GetGyClientConfiguration returns the client diameter configuration

func GetOCSConfiguration

func GetOCSConfiguration() []*diameter.DiameterServerConfig

TODO: refactor those functions to make it more simple GetOCSConfiguration returns the server configuration for the set OCS

func GetRATType

func GetRATType(prt protos.RATType) string

Types

type CCADiameterMessage

type CCADiameterMessage struct {
	SessionID     string                 `avp:"Session-Id"`
	RequestNumber uint32                 `avp:"CC-Request-Number"`
	ResultCode    uint32                 `avp:"Result-Code"`
	OriginHost    string                 `avp:"Origin-Host"`
	RequestType   uint32                 `avp:"CC-Request-Type"`
	CreditControl []*MSCCDiameterMessage `avp:"Multiple-Services-Credit-Control"`
}

type ChargingReAuthAnswer

type ChargingReAuthAnswer struct {
	SessionID  string `avp:"Session-Id"`
	ResultCode uint32 `avp:"Result-Code"`
}

ReAuthAnswer is a diameter answer sent back to the OCS after a credit update is initiated

type ChargingReAuthHandler

type ChargingReAuthHandler func(request *ChargingReAuthRequest) *ChargingReAuthAnswer

ReAuthHandler defines a function that responds to a RAR message with an RAA

func GetGyReAuthHandler

func GetGyReAuthHandler(cloudRegistry service_registry.GatewayRegistry) ChargingReAuthHandler

GetGyReAuthHandler returns the default handler for RAR messages by relaying them to the gateway, where session proxy will initiate a credit update and respond with an RAA

type ChargingReAuthRequest

type ChargingReAuthRequest struct {
	SessionID         string  `avp:"Session-Id"`
	RatingGroup       *uint32 `avp:"Rating-Group"`
	ServiceIdentifier *uint32 `avp:"Service-Identifier"`
}

ReAuthRequest is a diameter request received from the OCS to initiate a credit update

type CreditClient

type CreditClient interface {
	SendCreditControlRequest(
		server *diameter.DiameterServerConfig,
		done chan interface{},
		request *CreditControlRequest,
	) error
	IgnoreAnswer(request *CreditControlRequest)
	EnableConnections() error
	DisableConnections(period time.Duration)
}

type CreditControlAnswer

type CreditControlAnswer struct {
	ResultCode    uint32
	SessionID     string
	RequestNumber uint32
	OriginHost    string
	Credits       []*ReceivedCredits
}

func GetAnswer

func GetAnswer(done <-chan interface{}) *CreditControlAnswer

GetAnswer returns a *CreditControlAnswer from the given interface channel

type CreditControlRequest

type CreditControlRequest struct {
	SessionID     string
	Type          credit_control.CreditRequestType
	IMSI          string
	RequestNumber uint32
	UeIPV4        string
	SpgwIPV4      string
	Apn           string
	Imei          string
	PlmnID        string
	GcID          string
	UserLocation  []byte
	Msisdn        []byte
	Qos           *QosRequestInfo
	Credits       []*UsedCredits
	RatType       string
	TgppCtx       *protos.TgppContext
}

func (*CreditControlRequest) FromCreditUsageUpdate

func (request *CreditControlRequest) FromCreditUsageUpdate(update *protos.CreditUsageUpdate) *CreditControlRequest

type FinalUnitAction

type FinalUnitAction uint8
const (
	Terminate      FinalUnitAction = 0x0
	Redirect       FinalUnitAction = 0x1
	RestrictAccess FinalUnitAction = 0x2
)

type FinalUnitIndication

type FinalUnitIndication struct {
	Action         FinalUnitAction `avp:"Final-Unit-Action"`
	RedirectServer RedirectServer  `avp:"Redirect-Server"`
}

type GyClient

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

GyClient holds the relevant state for sending and receiving diameter calls over Gy

func NewConnectedGyClient

func NewConnectedGyClient(
	diamClient *diameter.Client,
	serverCfg *diameter.DiameterServerConfig,
	reAuthHandler ChargingReAuthHandler,
	cloudRegistry service_registry.GatewayRegistry,
	globalConfig *GyGlobalConfig,
) *GyClient

NewGyClient constructs a new GyClient with the magma diameter settings

func NewGyClient

func NewGyClient(
	clientCfg *diameter.DiameterClientConfig,
	serverCfg *diameter.DiameterServerConfig,
	reAuthHandler ChargingReAuthHandler,
	cloudRegistry service_registry.GatewayRegistry,
	globalConfig *GyGlobalConfig,
) *GyClient

NewGyClient constructs a new GyClient with the magma diameter settings

func (*GyClient) DisableConnections

func (gyClient *GyClient) DisableConnections(period time.Duration)

func (*GyClient) EnableConnections

func (gyClient *GyClient) EnableConnections() error

func (*GyClient) IgnoreAnswer

func (gyClient *GyClient) IgnoreAnswer(request *CreditControlRequest)

IgnoreAnswers removes tracked requests in the request manager to ensure the request mapping does not leak. For example, if 10 requests are sent out, and 2 time out given the user's timeout duration, then those 2 requests should be ignored so that they don't leak

func (*GyClient) SendCreditControlRequest

func (gyClient *GyClient) SendCreditControlRequest(
	server *diameter.DiameterServerConfig,
	done chan interface{},
	request *CreditControlRequest,
) error

SendCreditControlRequest sends a Credit Control Request to the given connection. Multiple requests can be sent in a row without waiting for the answer Example use:

	client := NewGyClient()
 done :=  make(chan *CreditControlAnswer, 1)
	client.SendCreditControlRequest(server, done, requests)
	answer := <- done

Input: DiameterServerConfig containing info about where to send messages

	chan<- *CreditControlAnswer to send answers to
  CreditControlRequest containing the request to send

Output: error if server connection failed

type GyGlobalConfig

type GyGlobalConfig struct {
	OCSOverwriteApn      string
	OCSServiceIdentifier string
	DisableGy            bool
}

func GetGyGlobalConfig

func GetGyGlobalConfig() *GyGlobalConfig

type InitMethod

type InitMethod uint8

InitMethod describes the type of ways sessions can be initialized through the Gy interface

const (
	// 1 CCR-Init per session, multiple CCR-Updates to get initial credit
	PerSessionInit InitMethod = 1
	// CCR-Init per charging key
	PerKeyInit InitMethod = 2
)

InitMethod enum values

func GetInitMethod

func GetInitMethod() InitMethod

GetInitMethod returns the init method for this gy client based on the flags or environment variables

type MSCCDiameterMessage

type MSCCDiameterMessage struct {
	ResultCode          uint32                            `avp:"Result-Code"`
	GrantedServiceUnit  credit_control.GrantedServiceUnit `avp:"Granted-Service-Unit"`
	ValidityTime        uint32                            `avp:"Validity-Time"`
	FinalUnitIndication *FinalUnitIndication              `avp:"Final-Unit-Indication"`
	RatingGroup         uint32                            `avp:"Rating-Group"`
	ServiceIdentifier   *uint32                           `avp:"Service-Identifier"`
}

type QosRequestInfo

type QosRequestInfo struct {
	ApnAggMaxBitRateUL uint32
	ApnAggMaxBitRateDL uint32
}

type ReceivedCredits

type ReceivedCredits struct {
	ResultCode        uint32
	RatingGroup       uint32
	ServiceIdentifier *uint32
	GrantedUnits      *credit_control.GrantedServiceUnit
	ValidityTime      uint32
	IsFinal           bool
	FinalAction       FinalUnitAction // unused if IsFinal is false
	RedirectServer    RedirectServer
}

type RedirectAddressType

type RedirectAddressType uint8
const (
	IPV4Address RedirectAddressType = iota
	IPV6Address
	URL
	SIPURI
)

type RedirectServer

type RedirectServer struct {
	RedirectAddressType   RedirectAddressType `avp:"Redirect-Address-Type"`
	RedirectServerAddress string              `avp:"Redirect-Server-Address"`
}

func (*RedirectServer) ToProto

func (redirectServer *RedirectServer) ToProto() *protos.RedirectServer

type UsedCredits

type UsedCredits struct {
	RatingGroup       uint32
	ServiceIdentifier *uint32
	InputOctets       uint64
	OutputOctets      uint64
	TotalOctets       uint64
	Type              UsedCreditsType
}

func (*UsedCredits) FromCreditUsage

func (credits *UsedCredits) FromCreditUsage(usage *protos.CreditUsage) *UsedCredits

type UsedCreditsType

type UsedCreditsType int32
const (
	THRESHOLD UsedCreditsType = iota
	QHT
	FINAL                  // FINAL - UE disconnected, flow not in use
	QUOTA_EXHAUSTED        // UE hit credit limit
	VALIDITY_TIMER_EXPIRED // Credit expired
	OTHER_QUOTA_TYPE
	RATING_CONDITION_CHANGE
	FORCED_REAUTHORISATION
	POOL_EXHAUSTED
)

Jump to

Keyboard shortcuts

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