rpc

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NSEnc  = "http://schemas.xmlsoap.org/soap/encoding/"
	NSEnv  = "http://schemas.xmlsoap.org/soap/envelope/"
	NSXSD  = "http://www.w3.org/2001/XMLSchema"
	NSXSI  = "http://www.w3.org/2001/XMLSchema-instance"
	NSCWMP = "urn:dslforum-org:cwmp-1-0"

	TypeXSDString  = "xsd:string"
	TypeXSDBoolean = "xsd:boolean"

	EventBootstrap                  = "0 BOOTSTRAP"
	EventBoot                       = "1 BOOT"
	EventPeriodic                   = "2 PERIODIC"
	EventScheduled                  = "3 SCHEDULED"
	EventValueChange                = "4 VALUE CHANGE"
	EventKicked                     = "5 KICKED"
	EventConnectionRequest          = "6 CONNECTION REQUEST"
	EventTransferComplete           = "7 TRANSFER COMPLETE"
	EventDiagnosticsComplete        = "8 DIAGNOSTICS COMPLETE"
	EventRequestDownload            = "9 REQUEST DOWNLOAD"
	EventAutonomousTransferComplete = "10 AUTONOMOUS TRANSFER COMPLETE"
	EventReboot                     = "M Reboot"
	EventScheduleInform             = "M ScheduleInform"
	EventDownload                   = "M Download"
	EventUpload                     = "M Upload"

	FileTypeFirmwareUpgradeImage    = "1 Firmware Upgrade Image"
	FileTypeWebContent              = "2 Web Content"
	FileTypeVendorConfigurationFile = "3 Vendor Configuration File"

	// AttributeNotificationOff indicates that the CPE need not inform the ACS
	// of a change to the specified parameter(s).
	AttributeNotificationOff AttributeNotification = 0
	// AttributeNotificationPassive indicates that whenever the specified
	// parameter value changes, the CPE MUST include the new value in the
	// ParameterList in the Inform message that is sent the next time a session
	// is established to the ACS. If the CPE has rebooted, or the URL of the ACS
	// has changed since the last session, the CPE MAY choose not to include the
	// list of changed parameters in the first session established with the new
	// ACS.
	AttributeNotificationPassive AttributeNotification = 1
	// AttributeNotificationActive indicates that whenever the specified
	// parameter value changes, the CPE MUST initiate a session to the ACS, and
	// include the new value in the ParameterList in the associated Inform
	// message.
	AttributeNotificationActive AttributeNotification = 2

	// MaxEnvelopes MUST be set to a value of 1 because this version of the
	// protocol supports only a single envelope per message, and on reception
	// its value MUST be ignored.
	MaxEnvelopes = 1

	// Download has completed and been applied.
	DownloadCompleted = 0
	// Download has not yet been completed and applied (for example, if the CPE
	// needs to reboot itself before it can perform the file download, or if the
	// CPE needs to reboot itself before it can apply the downloaded file).
	DownloadNotCompleted = 1
)

Variables

This section is empty.

Functions

func ArrayType

func ArrayType(typ string, size int) string

func SupportedMethods

func SupportedMethods() []string

Types

type AccessListEncoder

type AccessListEncoder struct {
	ArrayType string   `xml:"soapenc:arrayType,attr"`
	Values    []string `xml:"string"`
}

type AddObjectRequest

type AddObjectRequest struct {
	ObjectName   string
	ParameterKey string
}

func (AddObjectRequest) Debug

func (r AddObjectRequest) Debug()

type AddObjectResponseEncoder

type AddObjectResponseEncoder struct {
	InstanceNumber uint
	Status         int
}

type AttributeNotification

type AttributeNotification int

type AutonomousTransferCompleteRequestEncoder

type AutonomousTransferCompleteRequestEncoder struct {
	AnnounceURL    string
	TransferURL    string
	IsDownload     bool
	FileType       string
	FileSize       uint
	TargetFileName string
	Fault          any `xml:"FaultStruct,omitempty"`
	StartTime      string
	CompleteTime   string
}

type BodyDecoder

type BodyDecoder struct {
	GetRPCMethods          *EmptyPayload
	SetParameterValues     *SetParameterValuesRequest
	GetParameterValues     *GetParameterValuesRequest
	GetParameterNames      *GetParameterNamesRequest
	SetParameterAttributes *SetParameterAttributesRequest
	GetParameterAttributes *GetParameterAttributesRequest
	AddObject              *AddObjectRequest
	DeleteObject           *DeleteObjectRequest
	Reboot                 *RebootRequest
	Download               *DownloadRequest
	Upload                 *UploadRequest
	FactoryReset           *EmptyPayload
	GetQueuedTransfers     *EmptyPayload
	GetAllQueuedTransfers  *EmptyPayload
	ScheduleInform         *ScheduleInformRequest
	SetVouchers            *SetVouchersRequest
	GetOptions             *GetOptionsRequest

	InformResponse                     *InformResponse
	TransferCompleteResponse           *EmptyPayload
	AutonomousTransferCompleteResponse *EmptyPayload
}

type BodyEncoder

type BodyEncoder struct {
	Inform                            *InformRequestEncoder                     `xml:"cwmp:Inform,omitempty"`
	GetRPCMethodsResponse             *GetRPCMethodsResponseEncoder             `xml:"cwmp:GetRPCMethodsResponse,omitempty"`
	SetParameterValuesResponse        *SetParameterValuesResponseEncoder        `xml:"cwmp:SetParameterValuesResponse,omitempty"`
	GetParameterValuesResponse        *GetParameterValuesResponseEncoder        `xml:"cwmp:GetParameterValuesResponse,omitempty"`
	GetParameterNamesResponse         *GetParameterNamesResponseEncoder         `xml:"cwmp:GetParameterNamesResponse,omitempty"`
	SetParameterAttributesResponse    *SetParameterAttributesResponseEncoder    `xml:"cwmp:SetParameterAttributesResponse,omitempty"`
	GetParameterAttributesResponse    *GetParameterAttributesResponseEncoder    `xml:"cwmp:GetParameterAttributesResponse,omitempty"`
	AddObjectResponse                 *AddObjectResponseEncoder                 `xml:"cwmp:AddObjectResponse,omitempty"`
	DeleteObjectResponse              *DeleteObjectResponseEncoder              `xml:"cwmp:DeleteObjectResponse,omitempty"`
	RebootResponse                    *RebootResponseEncoder                    `xml:"cwmp:RebootResponse,omitempty"`
	DownloadResponse                  *DownloadResponseEncoder                  `xml:"cwmp:DownloadResponse,omitempty"`
	FactoryResetResponse              *FactoryResetResponseEncoder              `xml:"cwmp:FactoryResetResponse,omitempty"`
	TransferCompleteRequest           *TransferCompleteRequestEncoder           `xml:"cwmp:TransferComplete,omitempty"`
	AutonomousTransferCompleteRequest *AutonomousTransferCompleteRequestEncoder `xml:"cwmp:AutonomousTransferComplete,omitempty"`
	Fault                             *FaultEncoder                             `xml:"soapenv:Fault,omitempty"`
}

type DeleteObjectRequest

type DeleteObjectRequest struct {
	ObjectName   string
	ParameterKey string
}

func (DeleteObjectRequest) Debug

func (r DeleteObjectRequest) Debug()

type DeleteObjectResponseEncoder

type DeleteObjectResponseEncoder struct {
	Status int
}

type DeviceID

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

type DownloadRequest

type DownloadRequest struct {
	CommandKey     string
	FileType       string
	URL            string
	Username       string
	Password       string
	FileSize       int
	TargetFileName string
	DelaySeconds   int
	SuccessURL     string
	FailureURL     string
}

func (DownloadRequest) Debug

func (r DownloadRequest) Debug()

type DownloadResponseEncoder

type DownloadResponseEncoder struct {
	Status       int
	StartTime    string
	CompleteTime string
}

type EmptyPayload

type EmptyPayload struct{}

type EnvelopeDecoder

type EnvelopeDecoder struct {
	XMLName xml.Name `xml:"Envelope"`
	Header  HeaderDecoder
	Body    BodyDecoder
}

func Decode

func Decode(b []byte) (*EnvelopeDecoder, error)

type EnvelopeEncoder

type EnvelopeEncoder struct {
	XMLName      xml.Name `xml:"soapenv:Envelope"`
	XMLSpaceEnv  string   `xml:"xmlns:soapenv,attr"`
	XMLSpaceEnc  string   `xml:"xmlns:soapenc,attr"`
	XMLSpaceXSD  string   `xml:"xmlns:xsd,attr"`
	XMLSpaceXSI  string   `xml:"xmlns:xsi,attr"`
	XMLSpaceCWMP string   `xml:"xmlns:cwmp,attr"`

	Header HeaderEncoder `xml:"soapenv:Header"`
	Body   BodyEncoder   `xml:"soapenv:Body"`
}

func NewEnvelope

func NewEnvelope(id string) EnvelopeEncoder

func (EnvelopeEncoder) Encode

func (ee EnvelopeEncoder) Encode() ([]byte, error)

func (EnvelopeEncoder) EncodePretty

func (ee EnvelopeEncoder) EncodePretty() ([]byte, error)

func (EnvelopeEncoder) Method

func (ee EnvelopeEncoder) Method() string

func (EnvelopeEncoder) WithFault

func (ee EnvelopeEncoder) WithFault(fault FaultCode) EnvelopeEncoder

func (EnvelopeEncoder) WithFaultMsg added in v0.1.3

func (ee EnvelopeEncoder) WithFaultMsg(fault FaultCode, msg string) EnvelopeEncoder

type EventEncoder

type EventEncoder struct {
	ArrayType string        `xml:"soapenc:arrayType,attr"`
	Events    []EventStruct `xml:"EventStruct"`
}

type EventStruct

type EventStruct struct {
	EventCode  string
	CommandKey string
}

type FactoryResetResponseEncoder

type FactoryResetResponseEncoder struct{}

type FaultCode

type FaultCode int
const (
	FaultMethodNotSupported FaultCode = 9000
	FaultRequestDenied      FaultCode = 9001
	FaultInternalError      FaultCode = 9002
	FaultInvalidArguments   FaultCode = 9003
	// When used in association with SetParameterValues, this must not be used
	// to indicate parameters in error.
	FaultResourcesExceeded FaultCode = 9004
	// Associated with SetParameterValues, GetParameterValues,
	// GetParameterNames, SetParameterAttributes, GetParameterAttributes,
	// AddObject, and DeleteObject.
	FaultInvalidParameterName FaultCode = 9005
	// Associated with SetParameterValues.
	FaultInvalidParameterType FaultCode = 9006
	// Associated with SetParameterValues.
	FaultInvalidParameterValue FaultCode = 9007
	// Attempt to set a non-writable parameter. Associated with
	// SetParameterValues.
	FaultNonWritableParameter FaultCode = 9008
	// Associated with SetParameterAttributes method.
	FaultNotificationRequestRejected FaultCode = 9009
	// Associated with Download, TransferComplete, or AutonomousTransferComplete
	// methods.
	FaultDownloadFailure FaultCode = 9010
	// Associated with Upload, TransferComplete, or AutonomousTransferComplete
	// methods.
	FaultUploadFailure FaultCode = 9011
	// File transfer server authentication failure. Associated with Upload,
	// Download, TransferComplete, or AutonomousTransferComplete methods.
	FaultFileTransferAuthenticationFailure FaultCode = 9012
	// Unsupported protocol for file transfer. Associated with Upload and
	// Download methods.
	FaultFileTransferUnsupportedProtocol FaultCode = 9013
	// Unable to join multicast group. Associated with Download,
	// TransferComplete, or AutonomousTransferComplete methods.
	FaultDownloadFailureJoinMulticastGroup FaultCode = 9014
	// Unable to contact file server. Associated with Download,
	// TransferComplete, or AutonomousTransferComplete methods.
	FaultDownloadFailureContactFileServer FaultCode = 9015
	// Unable to access file. Associated with Download, TransferComplete, or
	// AutonomousTransferComplete methods.
	FaultDownloadFailureAccessFile FaultCode = 9016
	// Unable to complete download. Associated with Download, TransferComplete,
	// or AutonomousTransferComplete methods.
	FaultDownloadFailureCompleteDownload FaultCode = 9017
	// Associated with Download, TransferComplete, or
	// AutonomousTransferComplete methods.
	FaultDownloadFailureFileCorrupted FaultCode = 9018
	// file authentication failure. Associated with Download, TransferComplete,
	// or AutonomousTransferComplete methods.
	FaultDownloadFailureAuthenticationFailure FaultCode = 9019

	FaultACSMethodNotSupported FaultCode = 8000
	FaultACSRequestDenied      FaultCode = 8001
	FaultACSInternalError      FaultCode = 8002
	FaultACSInvalidArguments   FaultCode = 8003
	FaultACSResoucesExceeded   FaultCode = 8004
	FaultACSRetryRequest       FaultCode = 8005
)

func (FaultCode) Ptr

func (f FaultCode) Ptr() *FaultCode

func (FaultCode) String

func (i FaultCode) String() string

type FaultDetailEncoder

type FaultDetailEncoder struct {
	Fault FaultStruct `xml:"cwmp:Fault"`
}

type FaultEncoder

type FaultEncoder struct {
	FaultCode   string             `xml:"faultcode"`
	FaultString string             `xml:"faultstring"`
	Detail      FaultDetailEncoder `xml:"detail"`
}

func NewFaultResponse

func NewFaultResponse(code FaultCode, str string) *FaultEncoder

type FaultStruct

type FaultStruct struct {
	FaultCode               FaultCode
	FaultString             string
	SetParameterValuesFault []SetParameterValuesFault
}

type GetOptionsRequest

type GetOptionsRequest struct {
	OptionName string
}

type GetParameterAttributesRequest

type GetParameterAttributesRequest struct {
	ParameterNames ParameterNames
}

func (GetParameterAttributesRequest) Debug

type GetParameterAttributesResponseEncoder

type GetParameterAttributesResponseEncoder struct {
	ParameterList ParameterAttributeStructEncoder
}

type GetParameterNamesRequest

type GetParameterNamesRequest struct {
	ParameterPath string
	NextLevel     bool
}

func (GetParameterNamesRequest) Debug

func (r GetParameterNamesRequest) Debug()

type GetParameterNamesResponseEncoder

type GetParameterNamesResponseEncoder struct {
	ParameterList ParameterInfoEncoder
}

type GetParameterValuesRequest

type GetParameterValuesRequest struct {
	ParameterNames ParameterNames
}

func (GetParameterValuesRequest) Debug

func (r GetParameterValuesRequest) Debug()

type GetParameterValuesResponseEncoder

type GetParameterValuesResponseEncoder struct {
	ParameterList ParameterListEncoder
}

type GetRPCMethodsResponseEncoder

type GetRPCMethodsResponseEncoder struct {
	MethodList MethodListEncoder
}

type HeaderDecoder

type HeaderDecoder struct {
	ID IDDecoder
}

type HeaderEncoder

type HeaderEncoder struct {
	ID IDEncoder `xml:"cwmp:ID"`
}

type IDDecoder

type IDDecoder struct {
	MustUnderstand int    `xml:"mustUnderstand,attr"`
	Value          string `xml:",chardata"`
}

type IDEncoder

type IDEncoder struct {
	MustUnderstand int    `xml:"soapenv:mustUnderstand,attr"`
	Value          string `xml:",chardata"`
}

type InformRequestEncoder

type InformRequestEncoder struct {
	DeviceId      DeviceID
	Event         EventEncoder
	MaxEnvelopes  int
	CurrentTime   string
	RetryCount    int
	ParameterList ParameterListEncoder
}

type InformResponse

type InformResponse struct {
	MaxEnvelopes int
}

type MethodListEncoder

type MethodListEncoder struct {
	ArrayType string   `xml:"soapenc:arrayType,attr"`
	Methods   []string `xml:"string"`
}

type NoFaultStruct

type NoFaultStruct struct {
	Status int `xml:",chardata"`
}

type ParameterAttribute

type ParameterAttribute struct {
	Name               string
	NotificationChange bool
	Notification       int
	AccessListChange   bool
	AccessList         []string
}

type ParameterAttributeStruct

type ParameterAttributeStruct struct {
	Name         string
	Notification AttributeNotification
	AccessList   AccessListEncoder
}

type ParameterAttributeStructEncoder

type ParameterAttributeStructEncoder struct {
	ArrayType           string                     `xml:"soapenc:arrayType,attr"`
	ParameterAttributes []ParameterAttributeStruct `xml:"ParameterAttributeStruct"`
}

type ParameterInfoEncoder

type ParameterInfoEncoder struct {
	ArrayType  string                `xml:"soapenc:arrayType,attr"`
	Parameters []ParameterInfoStruct `xml:"ParameterInfoStruct"`
}

type ParameterInfoStruct

type ParameterInfoStruct struct {
	Name     string
	Writable bool
}

type ParameterListEncoder

type ParameterListEncoder struct {
	ArrayType       string                  `xml:"soapenc:arrayType,attr"`
	ParameterValues []ParameterValueEncoder `xml:"ParameterValueStruct"`
}

type ParameterNames

type ParameterNames struct {
	ArrayType string   `xml:"arrayType,attr"`
	Names     []string `xml:"string"`
}

type ParameterValueDecoder

type ParameterValueDecoder struct {
	Name  string
	Value struct {
		Type  string `xml:"type,attr"`
		Value string `xml:",chardata"`
	}
}

type ParameterValueEncoder

type ParameterValueEncoder struct {
	Name  string
	Value ValueEncoder
}

type RebootRequest

type RebootRequest struct {
	CommandKey string
}

type RebootResponseEncoder

type RebootResponseEncoder struct{}

type ScheduleInformRequest

type ScheduleInformRequest struct {
	DelaySeconds int64
	CommandKey   string
}

type SetParameterAttributesRequest

type SetParameterAttributesRequest struct {
	ParameterList struct {
		ArrayType           string                         `xml:"arrayType,attr"`
		ParameterAttributes []SetParameterAttributesStruct `xml:"SetParameterAttributesStruct"`
	}
}

func (SetParameterAttributesRequest) Debug

type SetParameterAttributesResponseEncoder

type SetParameterAttributesResponseEncoder struct{}

type SetParameterAttributesStruct

type SetParameterAttributesStruct struct {
	Name               string
	NotificationChange bool
	Notification       AttributeNotification
	AccessListChange   bool
	AccessList         struct {
		ArrayType string   `xml:"arrayType,attr"`
		Values    []string `xml:"string"`
	}
}

type SetParameterValuesFault

type SetParameterValuesFault struct {
	ParameterName string
	FaultCode     FaultCode
	FaultString   string
}

type SetParameterValuesRequest

type SetParameterValuesRequest struct {
	ParameterList struct {
		ArrayType       string                  `xml:"arrayType,attr"`
		ParameterValues []ParameterValueDecoder `xml:"ParameterValueStruct"`
	}
	ParameterKey string
}

func (SetParameterValuesRequest) Debug

func (r SetParameterValuesRequest) Debug()

type SetParameterValuesResponseEncoder

type SetParameterValuesResponseEncoder struct {
	Status int
}

type SetVouchersRequest

type SetVouchersRequest struct {
	VoucherList struct {
		ArrayType string   `xml:"arrayType,attr"`
		Values    []string `xml:"base64"`
	}
}

type TransferCompleteRequestEncoder

type TransferCompleteRequestEncoder struct {
	CommandKey   string
	Fault        any `xml:"FaultStruct,omitempty"`
	StartTime    string
	CompleteTime string
}

type UploadRequest

type UploadRequest struct {
	CommandKey string
}

func (UploadRequest) Debug

func (r UploadRequest) Debug()

type ValueEncoder

type ValueEncoder struct {
	Type  string `xml:"xsi:type,attr"`
	Value string `xml:",chardata"`
}

Jump to

Keyboard shortcuts

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