mock_ocs

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DiameterCreditLimitReached = 4012

Variables

This section is empty.

Functions

func GetAVP

func GetAVP(message *ccrMessage, AVPToFind string) (interface{}, error)

TODO: Remove this when not needed anymore (use findAVP from diam library) Searches on ccr message for an specific AVP message based on the avp tag on ccr type (ie "Session-Id") It returns on the first match it finds.

Types

type CreditBucket

type CreditBucket struct {
	Unit   protos.CreditInfo_UnitType
	Volume *protos.Octets
}

type GyAnswer

type GyAnswer struct {
	*protos.GyCreditControlAnswer
}

type GyExpectation

type GyExpectation struct {
	*protos.GyCreditControlExpectation
}

Here we wrap the protobuf definitions to easily define instance methods

func (GyExpectation) DoesMatch

func (e GyExpectation) DoesMatch(message interface{}) error

func (GyExpectation) GetAnswer

func (e GyExpectation) GetAnswer() interface{}

type OCSConfig

type OCSConfig struct {
	MaxUsageOctets  *protos.Octets
	MaxUsageTime    uint32
	ValidityTime    uint32
	ServerConfig    *diameter.DiameterServerConfig
	GyInitMethod    gy.InitMethod
	UseMockDriver   bool
	RedirectAddress string
	FinalUnitAction protos.FinalUnitAction
}

type OCSDiamServer

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

OCSDiamServer wraps an OCS storing subscriber accounts and their credit

func NewOCSDiamServer

func NewOCSDiamServer(
	diameterSettings *diameter.DiameterClientConfig,
	ocsConfig *OCSConfig,
) *OCSDiamServer

NewOCSDiamServer initializes an OCS with an empty account map Input: *sm.Settings containing the diameter related parameters

*TestOCSConfig containing the server address, and standard OCS settings
	like how many bytes to allocate to users

Output: a new OCSDiamServer

func (*OCSDiamServer) AbortSession

AbortSession call for a subscriber Initiate a Abort session request and provide the response

func (*OCSDiamServer) AssertExpectations

func (srv *OCSDiamServer) AssertExpectations(_ context.Context, void *orcprotos.Void) (*protos.GyCreditControlResult, error)

func (*OCSDiamServer) ClearSubscribers

func (srv *OCSDiamServer) ClearSubscribers(_ context.Context, void *orcprotos.Void) (*orcprotos.Void, error)

Reset eliminates all the accounts allocated for the system.

func (*OCSDiamServer) ConfigServer

func (srv *OCSDiamServer) ConfigServer(
	_ context.Context,
	config *protos.ServerConfiguration,
) (*orcprotos.Void, error)

ConfigServer is an GRPC procedure which configure the server to respond to requests. It will be called from the gateway

func (*OCSDiamServer) CreateAccount

func (srv *OCSDiamServer) CreateAccount(
	_ context.Context,
	subscriberID *lteprotos.SubscriberID,
) (*orcprotos.Void, error)

NewAccount adds a subscriber to the OCS to be tracked Input: string containing the subscriber IMSI (can be in any form)

func (*OCSDiamServer) GetCredits

func (srv *OCSDiamServer) GetCredits(
	_ context.Context,
	subscriberID *lteprotos.SubscriberID,
) (*protos.CreditInfos, error)

GetCredits returns all the credits allocated for an account Input: string IMSI for the account Output: map[uint32]*CreditBucket a map of charging key to credit bucket

error if account could not be found

func (*OCSDiamServer) GetLastAVPreceived

func (srv *OCSDiamServer) GetLastAVPreceived() (*diam.Message, error)

GetLastAVPreceived gets the last message in diam format received Message gets overwriten every time a new CCR is sent

func (*OCSDiamServer) ReAuth

ReAuth initiates a reauth call for a subscriber and optional rating group. It waits for any answer from the OCS

func (*OCSDiamServer) Reset

func (srv *OCSDiamServer) Reset(
	_ context.Context,
	req *orcprotos.Void,
) (*orcprotos.Void, error)

Reset is an GRPC procedure which resets the server to its default state. It will be called from the gateway.

func (*OCSDiamServer) SetCredit

func (srv *OCSDiamServer) SetCredit(
	_ context.Context,
	creditInfo *protos.CreditInfo,
) (*orcprotos.Void, error)

SetCredit sets or overrides the prepaid credit allocated for an account Input: string IMSI for the account

	  uint32 charging key to add credit to
	  uint64 volume (in any units) to set this bucket to
    UnitType dictating which unit the volume represents

Output: error if account could not be found

func (*OCSDiamServer) SetExpectations

func (*OCSDiamServer) SetOCSSettings

func (srv *OCSDiamServer) SetOCSSettings(
	_ context.Context,
	ocsConfig *protos.OCSConfig,
) (*orcprotos.Void, error)

SetOCSSettings changes the standard OCS return values. All parameters are optional, and this only sets the non-nil ones. Input: *uint32 optional maximum bytes to return in a CCA

*uint32 optional maximum time to return in a CCA
*uint32 optional credit validity time to return in a CCA

func (*OCSDiamServer) Start

func (srv *OCSDiamServer) Start(lis net.Listener) error

Start begins the server and blocks, listening to the network Output: error if the server could not be started

func (*OCSDiamServer) StartListener

func (srv *OCSDiamServer) StartListener() (net.Listener, error)

type SubscriberAccount

type SubscriberAccount struct {
	ChargingCredit map[uint32]*CreditBucket // map of charging key to credit bucket
	CurrentState   *SubscriberSessionState
}

type SubscriberSessionState

type SubscriberSessionState struct {
	SessionID  string
	Connection diam.Conn
}

Jump to

Keyboard shortcuts

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