datamodel

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package datamodel supports CPE datamodel and state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDataModel added in v0.2.1

func LoadDataModel(r io.Reader) (map[string]Parameter, error)

func LoadDataModelFile added in v0.2.9

func LoadDataModelFile(filePath string) (map[string]Parameter, error)

func NormalizeParameters added in v0.2.1

func NormalizeParameters(params map[string]Parameter)

NormalizeParameters will normalize all datamodel parameters.

Types

type DataModel

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

DataModel describes a stateful CPE datamodel.

func New added in v0.2.1

func New(state *State) *DataModel

func (*DataModel) AddEvent

func (dm *DataModel) AddEvent(evt string)

AddEvent adds a new event to be advertised during the next inform message.

func (*DataModel) AddObject

func (dm *DataModel) AddObject(name string) (int, error)

AddObject create a new object and returns the index if successful.

func (*DataModel) CanSetValue

func (dm *DataModel) CanSetValue(param Parameter) *rpc.FaultCode

CanSetValue returns a non-nil fault code if a value can't be set.

func (*DataModel) ClearEvents

func (dm *DataModel) ClearEvents()

ClearEvents removes all pending inform events.

func (*DataModel) CommandKey

func (dm *DataModel) CommandKey() string

CommandKey returns the current command key.

func (*DataModel) ConnectionRequestURL

func (dm *DataModel) ConnectionRequestURL() Parameter

ConnectionRequestURL returns the connection request URL.

func (*DataModel) DeleteObject

func (dm *DataModel) DeleteObject(name string)

DeleteObject deletes the given object.

func (*DataModel) DeviceID

func (dm *DataModel) DeviceID() DeviceID

DeviceID returns a DeviceID populated from the datamodel.

func (*DataModel) DownUntil

func (dm *DataModel) DownUntil() time.Time

DownUntil returns the time the CPE will stop pretending to be offline.

func (*DataModel) ForcedInformParameters added in v0.2.7

func (dm *DataModel) ForcedInformParameters() []string

ForcedInformParameters values that must be on every inform, according to the datamodel specifications.

TR-098: https://cwmp-data-models.broadband-forum.org/tr-098-1-2-0.html#forced-inform-parameters TR-181: https://cwmp-data-models.broadband-forum.org/tr-181-2-18-1-cwmp.html#forced-inform-parameters

func (*DataModel) GetAll

func (dm *DataModel) GetAll(path string) (params []Parameter, ok bool)

GetAll returns one or more parameters prefixed with the given path.

func (*DataModel) GetValue

func (dm *DataModel) GetValue(path string) (p Parameter, ok bool)

GetValue returns a parameter value with the given path and a boolean that is equal to true if a parameter exists.

func (*DataModel) GetValues added in v0.2.7

func (dm *DataModel) GetValues(paths ...string) (params []Parameter, ok bool)

GetValues returns all parameters in the given paths. If at least one requested parameter is missing ok will be set to false.

func (*DataModel) IncrRetryAttempts

func (dm *DataModel) IncrRetryAttempts()

IncrRetryAttempts increments the number of infrom attempts by one.

func (*DataModel) IsBootstrapped

func (dm *DataModel) IsBootstrapped() bool

IsBootstrapped returns true if CPE is had a successful bootstrap message exchange.

func (*DataModel) IsPeriodicInformParameter

func (dm *DataModel) IsPeriodicInformParameter(name string) bool

IsPeriodicInformParameter returns true if periodic inform is configured.

func (*DataModel) NotifyParams

func (dm *DataModel) NotifyParams() []string

NotifyParams returns a list of parameters that should be included in the next inform message. This will always include forced parameters.

func (*DataModel) ParameterNames

func (dm *DataModel) ParameterNames(path string, nextLevel bool) []Parameter

ParameterNames returns all subparameters in the given path. If nextLevel is set to true the list of parameters goes one level deeper. nolint:nestif

func (*DataModel) PendingEvents

func (dm *DataModel) PendingEvents() []string

PendingEvents returns all events to be advertised during the next inform message.

func (*DataModel) PeriodicInformEnabled

func (dm *DataModel) PeriodicInformEnabled() bool

PeriodicInformEnabled returns true if periodic inform is enabled.

func (*DataModel) PeriodicInformInterval

func (dm *DataModel) PeriodicInformInterval() time.Duration

PeriodicInformInterval returns the value of periodic inform interval.

func (*DataModel) PeriodicInformTime

func (dm *DataModel) PeriodicInformTime() time.Time

PeriodicInformTime returns the value of periodic inform time.

func (*DataModel) Reset added in v0.2.1

func (dm *DataModel) Reset()

func (*DataModel) ResetRetryAttempts

func (dm *DataModel) ResetRetryAttempts()

ResetRetryAttempts resets the number of infrom attempts to zero.

func (*DataModel) RetryAttempts

func (dm *DataModel) RetryAttempts() uint32

RetryAttempts returns the number of currently take attepts to inform.

func (*DataModel) SaveState

func (dm *DataModel) SaveState(stateFile string) error

SaveState saves the state to the given file.

func (*DataModel) SetBootstrapped

func (dm *DataModel) SetBootstrapped(b bool)

SetBootstrapped assigns the bootstrap flag to the given value.

func (*DataModel) SetCommandKey

func (dm *DataModel) SetCommandKey(ck string)

SetCommandKey sets the command key value.

func (*DataModel) SetConnectionRequestURL

func (dm *DataModel) SetConnectionRequestURL(val string)

SetConnectionRequestURL sets connection request URL to the given value.

func (*DataModel) SetDownUntil

func (dm *DataModel) SetDownUntil(du time.Time)

SetDownUntil sets the time until the CPE should pretend to be offline.

func (*DataModel) SetFirmwareVersion

func (dm *DataModel) SetFirmwareVersion(ver string)

SetFirmwareVersion sets the new firmware version value.

func (*DataModel) SetParameterAttribute

func (dm *DataModel) SetParameterAttribute(name string, notif int, notifChange bool, acl []string, aclChange bool)

SetParameterAttribute changes parameter value attributes.

func (*DataModel) SetParameterKey

func (dm *DataModel) SetParameterKey(val string)

SetParameterKey sets parameter key to the given value.

func (*DataModel) SetPeriodicInformInterval

func (dm *DataModel) SetPeriodicInformInterval(sec int64)

SetPeriodicInformInterval sets periodic inform interval to the given value.

func (*DataModel) SetPeriodicInformTime

func (dm *DataModel) SetPeriodicInformTime(ts time.Time)

SetPeriodicInformTime sets periodic inform time to the given value.

func (*DataModel) SetSerialNumber

func (dm *DataModel) SetSerialNumber(val string)

SetSerialNumber sets serial number to the given value.

func (*DataModel) SetUptime added in v0.2.0

func (dm *DataModel) SetUptime(dur time.Duration)

func (*DataModel) SetValue

func (dm *DataModel) SetValue(path, val string)

SetValue sets the value of a given parameter.

func (*DataModel) SetValues

func (dm *DataModel) SetValues(params []Parameter)

SetValues saves multiple parameter values.

func (*DataModel) Version added in v0.2.9

func (dm *DataModel) Version() string

type DeviceID

type DeviceID struct {
	Manufacturer string
	OUI          string
	ProductClass string
	SerialNumber string
}

DeviceID contains basic CPE info.

type Parameter

type Parameter struct {
	Path         string
	Object       bool
	Writable     bool
	Type         string
	Value        string
	Notification rpc.AttributeNotification
	ACL          []string
}

Parameter describes a datamodel paremeter.

func (Parameter) Encode

func (p Parameter) Encode() rpc.ParameterValueEncoder

Encode converts a parameter into RPC ParameterValue structure.

func (*Parameter) Normalize added in v0.2.0

func (p *Parameter) Normalize()

Normalize attempts to normalize parameter type and value in order to make it fully compliant with SOAP data types spec.

type State added in v0.2.1

type State struct {
	Bootstrapped bool
	Changes      map[string]Parameter
	Deleted      map[string]struct{}
	// contains filtered or unexported fields
}

func LoadState added in v0.2.1

func LoadState(filePath string) (*State, error)

func (*State) WithDefaults added in v0.2.1

func (s *State) WithDefaults(dm map[string]Parameter) *State

Jump to

Keyboard shortcuts

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